Skip to content

Commit

Permalink
create symbols from the auto zone, allowing associative references to…
Browse files Browse the repository at this point in the history
… 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
lrz committed May 11, 2010
1 parent e32abeb commit 171f9c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions spec/macruby/core/symbol_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
it "should return self on -copy" do it "should return self on -copy" do
:sym.copy.__id__.should == :sym.__id__ :sym.copy.__id__.should == :sym.__id__
end 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 end
8 changes: 4 additions & 4 deletions symbol.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ typedef struct {
static rb_sym_t * static rb_sym_t *
sym_alloc(VALUE str, ID id) 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); assert(rb_cSymbol != 0);
sym->klass = rb_cSymbol; sym->klass = rb_cSymbol;
GC_RETAIN(str); // never released GC_WB(&sym->str, str);
sym->str = str;
sym->id = id; sym->id = id;
return sym; return sym;
} }
Expand Down Expand Up @@ -243,7 +242,8 @@ void
Init_PreSymbol(void) Init_PreSymbol(void)
{ {
sym_id = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); sym_id = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
id_str = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); id_str = CFDictionaryCreateMutable(NULL, 0, NULL,
&kCFTypeDictionaryValueCallBacks);
last_id = 1000; last_id = 1000;


// Pre-register parser symbols. // Pre-register parser symbols.
Expand Down

0 comments on commit 171f9c2

Please sign in to comment.