[macruby-changes] [2541] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 10 16:11:55 PDT 2009


Revision: 2541
          http://trac.macosforge.org/projects/ruby/changeset/2541
Author:   lsansonetti at apple.com
Date:     2009-09-10 16:11:55 -0700 (Thu, 10 Sep 2009)
Log Message:
-----------
fixed yaml deserialization of booleans

Modified Paths:
--------------
    MacRuby/trunk/TODO
    MacRuby/trunk/ext/libyaml/rubyext.c
    MacRuby/trunk/lib/rubygems.rb
    MacRuby/trunk/lib/yaml/rubytypes.rb

Modified: MacRuby/trunk/TODO
===================================================================
--- MacRuby/trunk/TODO	2009-09-10 22:33:02 UTC (rev 2540)
+++ MacRuby/trunk/TODO	2009-09-10 23:11:55 UTC (rev 2541)
@@ -5,7 +5,7 @@
 [ ] backtracing / symbolication
 [/] rubygems should work (modulo C extensions)
   [ ] fix version numbers
-  [ ] fix YAML deserialization of booleans
+  [X] fix YAML deserialization of booleans
   [ ] fix ~/.gemrc
   [X] `source --add http://gems.github.com' crashes (outside gdb)
   [ ] `install rest-client' prints a lot of debug code

Modified: MacRuby/trunk/ext/libyaml/rubyext.c
===================================================================
--- MacRuby/trunk/ext/libyaml/rubyext.c	2009-09-10 22:33:02 UTC (rev 2540)
+++ MacRuby/trunk/ext/libyaml/rubyext.c	2009-09-10 23:11:55 UTC (rev 2541)
@@ -358,6 +358,12 @@
 	    // TODO use rb_str_to_inum
 	    tag = "tag:yaml.org,2002:int";
 	}
+	else if (strcmp(val, "true") == 0) {
+	    tag = "tag:yaml.org,2002:true";
+	}
+	else if (strcmp(val, "false") == 0) {
+	    tag = "tag:yaml.org,2002:false";
+	}
 	else {
 	    tag = "tag:yaml.org,2002:str";
 	}
@@ -381,7 +387,7 @@
     VALUE arr = rb_ary_new();
 
     VALUE node;
-    while (node = get_node(parser)) {
+    while ((node = get_node(parser)) != Qundef) {
 	rb_ary_push(arr, node);
     }
     return interpret_value(parser, arr, handler, false);
@@ -395,8 +401,11 @@
     VALUE hash = rb_hash_new();
 
     VALUE key_node;
-    while (key_node = get_node(parser)) {
+    while ((key_node = get_node(parser)) != Qundef) {
 	VALUE value_node = get_node(parser);
+	if (value_node == Qundef) {
+	    value_node = Qnil;
+	}
 	rb_hash_aset(hash, key_node, value_node);
     }
     return interpret_value(parser, hash, handler, false);
@@ -413,7 +422,7 @@
 	case YAML_MAPPING_END_EVENT:
 	case YAML_SEQUENCE_END_EVENT:
 	case YAML_STREAM_END_EVENT:
-	    return 0ull;
+	    return Qundef;
 
 	case YAML_MAPPING_START_EVENT:
 	    node = handle_mapping(parser);
@@ -429,7 +438,7 @@
 
 	case YAML_ALIAS_EVENT:
 	    rb_warn("ignoring alias");
-	    node = Qnil;
+	    node = Qundef;
 	    break;
 
 	default:
@@ -457,7 +466,7 @@
     }
 
     root = get_node(parser);
-    if (root == 0) {
+    if (root == Qundef) {
 	root = Qnil;
     }
 
@@ -507,7 +516,8 @@
     if ((strcmp(tag, "tag:yaml.org,2002:int") == 0) ||
 	    (strcmp(tag, "tag:yaml.org,2002:float") == 0) ||
 	    (strcmp(tag, "tag:ruby.yaml.org,2002:symbol") == 0) ||
-	    (strcmp(tag, "tag:yaml.org,2002:bool") == 0) ||
+	    (strcmp(tag, "tag:yaml.org,2002:true") == 0) ||
+	    (strcmp(tag, "tag:yaml.org,2002:false") == 0) ||
 	    (strcmp(tag, "tag:yaml.org,2002:null") == 0) ||
 	    (strcmp(tag, "tag:yaml.org,2002:str") == 0) ||
 	    (strcmp(tag, YAML_DEFAULT_SEQUENCE_TAG) == 0) ||

Modified: MacRuby/trunk/lib/rubygems.rb
===================================================================
--- MacRuby/trunk/lib/rubygems.rb	2009-09-10 22:33:02 UTC (rev 2540)
+++ MacRuby/trunk/lib/rubygems.rb	2009-09-10 23:11:55 UTC (rev 2541)
@@ -882,8 +882,8 @@
 
 require 'rubygems/config_file'
 
-if RUBY_VERSION < '1.9' then
+#if RUBY_VERSION < '1.9' then
   require 'rubygems/custom_require'
-end
+#end
 
 Gem.clear_paths

Modified: MacRuby/trunk/lib/yaml/rubytypes.rb
===================================================================
--- MacRuby/trunk/lib/yaml/rubytypes.rb	2009-09-10 22:33:02 UTC (rev 2540)
+++ MacRuby/trunk/lib/yaml/rubytypes.rb	2009-09-10 23:11:55 UTC (rev 2541)
@@ -235,7 +235,7 @@
 end
 
 class TrueClass
-  yaml_as "tag:yaml.org,2002:bool"
+  yaml_as "tag:yaml.org,2002:true"
   
   def self.yaml_new(val); true; end
   
@@ -247,7 +247,7 @@
 end
 
 class FalseClass
-  yaml_as "tag:yaml.org,2002:bool"
+  yaml_as "tag:yaml.org,2002:false"
   
   def self.yaml_new(val); false; end
   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090910/de25779f/attachment.html>


More information about the macruby-changes mailing list