* ext/syck/lib/syck/types.rb: use toplevel Syck.

for the case someone define Syck::Syck (or YAML::Syck).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-09-07 22:37:34 +00:00
parent 4fe51cb330
commit 7dc427f7ed
2 changed files with 13 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Thu Sep 8 07:36:36 2011 NARUSE, Yui <naruse@ruby-lang.org>
* ext/syck/lib/syck/types.rb: use toplevel Syck.
for the case someone define Syck::Syck (or YAML::Syck).
Thu Sep 8 07:33:12 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Sep 8 07:33:12 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (id2ref): unmarked object is already dead while lazy * gc.c (id2ref): unmarked object is already dead while lazy

View File

@ -45,7 +45,7 @@ module Syck
class Object class Object
def self.tag_subclasses?; false; end def self.tag_subclasses?; false; end
def to_yaml( opts = {} ) def to_yaml( opts = {} )
Syck.quick_emit( self, opts ) do |out| ::Syck.quick_emit( self, opts ) do |out|
out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map| out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map|
@ivars.each do |k,v| @ivars.each do |k,v|
map.add( k, v ) map.add( k, v )
@ -67,7 +67,7 @@ module Syck
self.default.to_s self.default.to_s
end end
def update( h ) def update( h )
if Syck::SpecialHash === h if ::Syck::SpecialHash === h
@default = h.default if h.default @default = h.default if h.default
end end
super( h ) super( h )
@ -89,11 +89,11 @@ module Syck
if Hash === v if Hash === v
concat( v.to_a ) # Convert the map to a sequence concat( v.to_a ) # Convert the map to a sequence
else else
raise Syck::Error, "Invalid !omap entry: " + val.inspect raise ::Syck::Error, "Invalid !omap entry: " + val.inspect
end end
end end
else else
raise Syck::Error, "Invalid !omap: " + val.inspect raise ::Syck::Error, "Invalid !omap: " + val.inspect
end end
self self
end end
@ -123,7 +123,7 @@ module Syck
true true
end end
def to_yaml( opts = {} ) def to_yaml( opts = {} )
Syck.quick_emit( self, opts ) do |out| ::Syck.quick_emit( self, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq| out.seq( taguri, to_yaml_style ) do |seq|
self.each do |v| self.each do |v|
seq.add( Hash[ *v ] ) seq.add( Hash[ *v ] )
@ -144,11 +144,11 @@ module Syck
if Hash === v if Hash === v
concat( v.to_a ) # Convert the map to a sequence concat( v.to_a ) # Convert the map to a sequence
else else
raise Syck::Error, "Invalid !pairs entry: " + val.inspect raise ::Syck::Error, "Invalid !pairs entry: " + val.inspect
end end
end end
else else
raise Syck::Error, "Invalid !pairs: " + val.inspect raise ::Syck::Error, "Invalid !pairs: " + val.inspect
end end
self self
end end
@ -173,7 +173,7 @@ module Syck
true true
end end
def to_yaml( opts = {} ) def to_yaml( opts = {} )
Syck.quick_emit( self, opts ) do |out| ::Syck.quick_emit( self, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq| out.seq( taguri, to_yaml_style ) do |seq|
self.each do |v| self.each do |v|
seq.add( Hash[ *v ] ) seq.add( Hash[ *v ] )