From 7567345876e063a9d65d259dcc86516a43be090c Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 27 Sep 2005 22:57:53 +0000 Subject: * lib/yaml/basenode.rb (YAML::BaseNode::match_segment): fix typo. [ruby-dev:27237], [ruby-core:05854] * lib/yaml/tag.rb (Module#yaml_as): suppress warnings. * lib/yaml/types.rb (YAML::PrivateType, YAML::DomainType): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++++++ ext/syck/rubyext.c | 3 ++ lib/yaml/basenode.rb | 4 +-- lib/yaml/tag.rb | 9 ++++-- lib/yaml/types.rb | 79 ++++++++++++++++++++++++++++------------------------ 5 files changed, 63 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74b57fc06b..00b9309d51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Sep 28 07:56:52 2005 Nobuyoshi Nakada + + * lib/yaml/basenode.rb (YAML::BaseNode::match_segment): fix typo. + [ruby-dev:27237], [ruby-core:05854] + + * lib/yaml/tag.rb (Module#yaml_as): suppress warnings. + + * lib/yaml/types.rb (YAML::PrivateType, YAML::DomainType): ditto. + Wed Sep 28 03:23:35 2005 NAKAMURA Usaku * rubysig.h: fixed build problem with --enable-pthread on platforms diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index 2be6217d2d..e3b07775c9 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -76,6 +76,9 @@ SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *)); void rb_syck_output_handler _((SyckEmitter *, char *, long)); void rb_syck_emitter_handler _((SyckEmitter *, st_data_t)); int syck_parser_assign_io _((SyckParser *, VALUE)); +VALUE syck_scalar_alloc _((VALUE class)); +VALUE syck_seq_alloc _((VALUE class)); +VALUE syck_map_alloc _((VALUE class)); struct parser_xtra { VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */ diff --git a/lib/yaml/basenode.rb b/lib/yaml/basenode.rb index 7072b1dcd6..d24f6172e9 100644 --- a/lib/yaml/basenode.rb +++ b/lib/yaml/basenode.rb @@ -148,7 +148,7 @@ module YAML if pred case pred when /^\.=/ - pred = $' + pred = $' # ' match_nodes.reject! { |n| n.last.value != pred } @@ -187,7 +187,7 @@ module YAML v = @value.detect { |k,v| k.transform == key.first } v[1] if v elsif Array === @value - @value.[]( *k ) + @value.[]( *key ) end end diff --git a/lib/yaml/tag.rb b/lib/yaml/tag.rb index 0e25e1f85a..e51677230f 100644 --- a/lib/yaml/tag.rb +++ b/lib/yaml/tag.rb @@ -55,13 +55,14 @@ class Module # :nodoc: all # in YAML. See YAML::tag_class for detailed information on typing and # taguris. def yaml_as( tag, sc = true ) - class_eval <<-"end;" - attr_accessor :taguri + verbose, $VERBOSE = $VERBOSE, nil + class_eval <<-"end;", __FILE__, __LINE__+1 + attr_writer :taguri def taguri if respond_to? :to_yaml_type YAML::tagurize( to_yaml_type[1..-1] ) else - return @taguri if @taguri + return @taguri if defined?(@taguri) and @taguri tag = #{ tag.dump } if self.class.yaml_tag_subclasses? and self.class != YAML::tagged_classes[tag] tag = "\#{ tag }:\#{ self.class.yaml_tag_class_name }" @@ -72,6 +73,8 @@ class Module # :nodoc: all def self.yaml_tag_subclasses?; #{ sc ? 'true' : 'false' }; end end; YAML::tag_class tag, self + ensure + $VERBOSE = verbose end # Transforms the subclass name into a name suitable for display # in a subclassed tag. diff --git a/lib/yaml/types.rb b/lib/yaml/types.rb index c890f22bfa..05113f216d 100644 --- a/lib/yaml/types.rb +++ b/lib/yaml/types.rb @@ -1,45 +1,52 @@ +# -*- mode: ruby; ruby-indent-level: 4 -*- vim: sw=4 # # Classes required by the full core typeset # module YAML - # - # Default private type - # - class PrivateType + # + # Default private type + # + class PrivateType def self.tag_subclasses?; false; end - attr_accessor :type_id, :value - def initialize( type, val ) - @type_id = type; @value = val + attr_accessor :type_id, :value + verbose, $VERBOSE = $VERBOSE, nil + def initialize( type, val ) + @type_id = type; @value = val @value.taguri = "x-private:#{ @type_id }" - end - def to_yaml( opts = {} ) + end + def to_yaml( opts = {} ) @value.to_yaml( opts ) - end - end + end + ensure + $VERBOSE = verbose + end # # Default domain type # class DomainType def self.tag_subclasses?; false; end - attr_accessor :domain, :type_id, :value - def initialize( domain, type, val ) - @domain = domain; @type_id = type; @value = val + attr_accessor :domain, :type_id, :value + verbose, $VERBOSE = $VERBOSE, nil + def initialize( domain, type, val ) + @domain = domain; @type_id = type; @value = val @value.taguri = "tag:#{ @domain }:#{ @type_id }" - end - def to_yaml( opts = {} ) + end + def to_yaml( opts = {} ) @value.to_yaml( opts ) - end - end + end + ensure + $VERBOSE = verbose + end # # Unresolved objects # class Object def self.tag_subclasses?; false; end - def to_yaml( opts = {} ) + def to_yaml( opts = {} ) YAML::quick_emit( object_id, opts ) do |out| out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map| @ivars.each do |k,v| @@ -47,31 +54,31 @@ module YAML end end end - end - end + end + end - # - # YAML Hash class to support comments and defaults - # - class SpecialHash < ::Hash - attr_accessor :default + # + # YAML Hash class to support comments and defaults + # + class SpecialHash < ::Hash + attr_accessor :default def inspect self.default.to_s end - def to_s - self.default.to_s - end - def update( h ) - if YAML::SpecialHash === h - @default = h.default if h.default - end - super( h ) - end + def to_s + self.default.to_s + end + def update( h ) + if YAML::SpecialHash === h + @default = h.default if h.default + end + super( h ) + end def to_yaml( opts = {} ) opts[:DefaultKey] = self.default super( opts ) end - end + end # # Builtin collection: !omap -- cgit v1.2.3