public
Rubygem
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
Search Repo:
removing gc thing by object id
tenderlove (author)
Mon Jul 21 14:08:55 -0700 2008
commit  a84310caa88e754d6b6e73cf9d310073892eb4d0
tree    ad720ad22b2f730500de919493bc78d990f797de
parent  eb003e58b22a30591c9b2ed0eedc172ee837ae25
...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
103
104
105
...
89
90
91
 
 
 
 
 
 
 
92
93
94
 
95
96
97
98
0
@@ -89,17 +89,10 @@ initialize_native(VALUE self, VALUE rb_runtime, VALUE UNUSED(options))
0
 //// INFRASTRUCTURE BELOW HERE ////////////////////////////////////////////
0
 ///////////////////////////////////////////////////////////////////////////
0
 
0
-static void deallocate(JohnsonContext* context)
0
-{
0
- JS_SetContextPrivate(context->js, 0);
0
- JS_DestroyContext(context->js);
0
- free(context);
0
-}
0
-
0
 static VALUE allocate(VALUE klass)
0
 {
0
   JohnsonContext* context = calloc(1, sizeof(JohnsonContext));
0
- return Data_Wrap_Struct(klass, 0, deallocate, context);
0
+ return Data_Wrap_Struct(klass, 0, 0, context);
0
 }
0
 
0
 void init_Johnson_SpiderMonkey_Context(VALUE spidermonkey)
...
550
551
552
553
 
554
555
556
 
 
557
558
559
...
550
551
552
 
553
554
 
 
555
556
557
558
559
0
@@ -550,10 +550,10 @@ static void finalize(JSContext* js_context, JSObject* obj)
0
 
0
     // remove the proxy OID from the id map
0
     JS_HashTableRemove(runtime->rbids, (void *)self);
0
-
0
+
0
     // free up the ruby value for GC
0
- call_ruby_from_js(runtime, NULL, ruby_runtime, rb_intern("remove_gcthing"), 1, self);
0
- }
0
+ rb_funcall(ruby_runtime, rb_intern("remove_gcthing"), 1, rb_obj_id(self));
0
+ }
0
 }
0
 
0
 JSBool make_js_land_proxy(JohnsonRuntime* runtime, VALUE value, jsval* retval)
...
17
18
19
20
21
 
 
22
23
24
...
17
18
19
 
 
20
21
22
23
24
0
@@ -17,8 +17,8 @@ module Johnson #:nodoc:
0
       end
0
       
0
       # called from js_land_proxy.c:finalize
0
- def remove_gcthing(thing)
0
- @gcthings.delete(thing.object_id)
0
+ def remove_gcthing(object_id)
0
+ @gcthings.delete(object_id) if @gcthings
0
       end
0
 
0
 

Comments

    No one has commented yet.