changeset 671:fc29a343ce7c

Track JS object with property store of objects
author Thinker K.F. Li <thinker@branda.to>
date Thu, 05 Aug 2010 17:43:33 +0800
parents f0b4fbcd1c51
children cbad519226d4
files include/mb_prop.h nodejs/mbfly_njs.cc nodejs/observer.cc nodejs/shapes.cc
diffstat 4 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_prop.h	Thu Aug 05 17:42:36 2010 +0800
+++ b/include/mb_prop.h	Thu Aug 05 17:43:33 2010 +0800
@@ -32,6 +32,7 @@
     PROP_DUMMY,
     PROP_MEVT_OB_CNT,
     PROP_MEVT_OBSERVER,
+    PROP_JSOBJ,
     PROP_LAST
 };
 
--- a/nodejs/mbfly_njs.cc	Thu Aug 05 17:42:36 2010 +0800
+++ b/nodejs/mbfly_njs.cc	Thu Aug 05 17:43:33 2010 +0800
@@ -28,8 +28,11 @@
 static void
 xnjsmb_coord_mod(Handle<Object> mbrt, Handle<Value> ret) {
     Handle<Object> ret_obj = ret->ToObject();
+    coord_t *coord;
 
     SET(ret_obj, "mbrt", mbrt);
+    coord = (coord_t *)UNWRAP(ret_obj);
+    mb_prop_set(&coord->obj.props, PROP_JSOBJ, *ret_obj);
 }
 
 #define xnjsmb_auto_coord_new export_xnjsmb_auto_coord_new
--- a/nodejs/observer.cc	Thu Aug 05 17:42:36 2010 +0800
+++ b/nodejs/observer.cc	Thu Aug 05 17:43:33 2010 +0800
@@ -62,4 +62,7 @@
 
 void
 xnjsmb_observer_init(void) {
+    xnjsmb_auto_observer_init();
+    xnjsmb_auto_subject_init();
+    xnjsmb_auto_event_init();
 }
--- a/nodejs/shapes.cc	Thu Aug 05 17:42:36 2010 +0800
+++ b/nodejs/shapes.cc	Thu Aug 05 17:43:33 2010 +0800
@@ -145,6 +145,7 @@
 
     WRAP(self, sh);
     SET(self, "mbrt", rt);
+    mb_prop_set(&sh->obj.props, PROP_JSOBJ, *self);
 
     return Null();
 }
@@ -235,6 +236,7 @@
 
     WRAP(self, stext);
     SET(self, "mbrt", rt);
+    mb_prop_set(&stext->obj.props, PROP_JSOBJ, *self);
 
     return Null();
 }
@@ -370,6 +372,7 @@
 
     WRAP(self, img);
     SET(self, "mbrt", rt);
+    mb_prop_set(&img->obj.props, PROP_JSOBJ, *self);
 
     return Null();
 }