From 17f705e8cd357158916481eb2a8f13e0f91f2299 Mon Sep 17 00:00:00 2001 From: why Date: Tue, 13 May 2003 22:29:52 +0000 Subject: * lib/yaml/rubytypes.rb, lib/yaml/types.rb: using Object#object_id rather than deprecated Object#id. * ext/token.c: changed ASCII escapes to octal notation. * ext/Setup*: added entries for static linking of Syck extension. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/yaml/rubytypes.rb | 18 +++++++++++------- lib/yaml/types.rb | 12 ++++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'lib/yaml') diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index 3d4992a29f..1a9c4ef67a 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -2,6 +2,10 @@ require 'date' # # Type conversions # + +# Ruby 1.6.x Object#object_id +class Object; alias_method :object_id, :id; end unless Object.respond_to? :object_id + class Object def is_complex_yaml? true @@ -13,7 +17,7 @@ class Object instance_variables.sort end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| out.map( self.to_yaml_type ) { |map| to_yaml_properties.each { |m| map.add( m[1..-1], instance_eval( m ) ) @@ -44,7 +48,7 @@ class Hash end def to_yaml( opts = {} ) opts[:DocType] = self.class if Hash === opts - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| hash_type = to_yaml_type if not out.options[:ExplicitTypes] and hash_type == "!map" hash_type = "" @@ -106,7 +110,7 @@ module YAML true end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| out.seq( "!ruby/flexhash" ) { |seq| self.each { |v| if v[1] @@ -145,7 +149,7 @@ class Struct true end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| # # Basic struct is passed as a YAML map # @@ -204,7 +208,7 @@ class Array end def to_yaml( opts = {} ) opts[:DocType] = self.class if Hash === opts - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| array_type = to_yaml_type if not out.options[:ExplicitTypes] and array_type == "!seq" array_type = "" @@ -252,7 +256,7 @@ class String complex = true end end - YAML::quick_emit( complex ? self.id : nil, opts ) { |out| + YAML::quick_emit( complex ? self.object_id : nil, opts ) { |out| if complex if self.is_binary_data? out.binary_base64( self ) @@ -299,7 +303,7 @@ class Symbol def to_yaml( opts = {} ) YAML::quick_emit( nil, opts ) { |out| out << "!ruby/sym " - self.id2name.to_yaml( :Emitter => out ) + self.object_id2name.to_yaml( :Emitter => out ) } end end diff --git a/lib/yaml/types.rb b/lib/yaml/types.rb index 7602c436e7..b34c38fe71 100644 --- a/lib/yaml/types.rb +++ b/lib/yaml/types.rb @@ -1,6 +1,10 @@ # # Classes required by the full core typeset # + +# Ruby 1.6.x Object#object_id +class Object; alias_method :object_id, :id; end unless Object.respond_to? :object_id + module YAML # @@ -12,7 +16,7 @@ module YAML @type_id = type; @value = val end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| out << " !!#{@type_id}" value.to_yaml( :Emitter => out ) } @@ -35,7 +39,7 @@ module YAML "#{dom}/#{@type_id}" end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| out << " !#{to_yaml_type} " value.to_yaml( :Emitter => out ) } @@ -95,7 +99,7 @@ module YAML true end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| out.seq( "!omap" ) { |seq| self.each { |v| seq.add( Hash[ *v ] ) @@ -146,7 +150,7 @@ module YAML true end def to_yaml( opts = {} ) - YAML::quick_emit( self.id, opts ) { |out| + YAML::quick_emit( self.object_id, opts ) { |out| out.seq( "!pairs" ) { |seq| self.each { |v| seq.add( Hash[ *v ] ) -- cgit v1.2.3