Permalink
Browse files

create symbols from the auto zone, allowing associative references to…

… work without emitting warnings/errors

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4073 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent e32abeb commit 171f9c2a8aa28a3ec57030fbcc2a8ec9ff7cbbc7 @lrz lrz committed May 11, 2010
Showing with 10 additions and 4 deletions.
  1. +6 −0 spec/macruby/core/symbol_spec.rb
  2. +4 −4 symbol.c
@@ -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
View
@@ -32,11 +32,10 @@ typedef struct {
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 @@ void
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.

0 comments on commit 171f9c2

Please sign in to comment.