diff nodejs/mbfly_njs.cc @ 675:c643af2095c5

Keep and retrieve respective js object to/from property store
author Thinker K.F. Li <thinker@branda.to>
date Fri, 06 Aug 2010 00:56:26 +0800
parents fc29a343ce7c
children f264b50c469c
line wrap: on
line diff
--- a/nodejs/mbfly_njs.cc	Fri Aug 06 00:50:40 2010 +0800
+++ b/nodejs/mbfly_njs.cc	Fri Aug 06 00:56:26 2010 +0800
@@ -28,11 +28,16 @@
 static void
 xnjsmb_coord_mod(Handle<Object> mbrt, Handle<Value> ret) {
     Handle<Object> ret_obj = ret->ToObject();
+    Persistent<Object> *ret_obj_hdl;
     coord_t *coord;
 
     SET(ret_obj, "mbrt", mbrt);
     coord = (coord_t *)UNWRAP(ret_obj);
-    mb_prop_set(&coord->obj.props, PROP_JSOBJ, *ret_obj);
+    /* Keep associated js object in property store for retrieving,
+     * later, without create new js object.
+     */
+    ret_obj_hdl = new Persistent<Object>(ret_obj);
+    mb_prop_set(&coord->obj.props, PROP_JSOBJ, ret_obj_hdl);
 }
 
 #define xnjsmb_auto_coord_new export_xnjsmb_auto_coord_new