[macruby-changes] [4073] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue May 11 16:43:02 PDT 2010


Revision: 4073
          http://trac.macosforge.org/projects/ruby/changeset/4073
Author:   lsansonetti at apple.com
Date:     2010-05-11 16:43:00 -0700 (Tue, 11 May 2010)
Log Message:
-----------
create symbols from the auto zone, allowing associative references to work without emitting warnings/errors

Modified Paths:
--------------
    MacRuby/trunk/spec/macruby/core/symbol_spec.rb
    MacRuby/trunk/symbol.c

Modified: MacRuby/trunk/spec/macruby/core/symbol_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/symbol_spec.rb	2010-05-11 23:42:23 UTC (rev 4072)
+++ MacRuby/trunk/spec/macruby/core/symbol_spec.rb	2010-05-11 23:43:00 UTC (rev 4073)
@@ -13,4 +13,10 @@
   it "should return self on -copy" do
     :sym.copy.__id__.should == :sym.__id__
   end
+
+  it "can have instance variables attached to it" do
+    s = :foo
+    s.instance_variable_set(:@omg, 42)
+    s.instance_variable_get(:@omg).should == 42
+  end
 end

Modified: MacRuby/trunk/symbol.c
===================================================================
--- MacRuby/trunk/symbol.c	2010-05-11 23:42:23 UTC (rev 4072)
+++ MacRuby/trunk/symbol.c	2010-05-11 23:43:00 UTC (rev 4073)
@@ -32,11 +32,10 @@
 static rb_sym_t *
 sym_alloc(VALUE str, ID id)
 {
-    rb_sym_t *sym = (rb_sym_t *)malloc(sizeof(rb_sym_t));
+    rb_sym_t *sym = (rb_sym_t *)xmalloc(sizeof(rb_sym_t));
     assert(rb_cSymbol != 0);
     sym->klass = rb_cSymbol;
-    GC_RETAIN(str); // never released
-    sym->str = str;
+    GC_WB(&sym->str, str);
     sym->id = id;
     return sym;
 }
@@ -243,7 +242,8 @@
 Init_PreSymbol(void)
 {
     sym_id = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
-    id_str = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
+    id_str = CFDictionaryCreateMutable(NULL, 0, NULL,
+	    &kCFTypeDictionaryValueCallBacks);
     last_id = 1000;
 
     // Pre-register parser symbols.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100511/9464eb89/attachment.html>


More information about the macruby-changes mailing list