Mercurial > MadButterfly
diff nodejs/shapes.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 | 7685c57e29d0 |
line wrap: on
line diff
--- a/nodejs/shapes.cc Fri Aug 06 00:50:40 2010 +0800 +++ b/nodejs/shapes.cc Fri Aug 06 00:56:26 2010 +0800 @@ -125,6 +125,7 @@ redraw_man_t *rdman; Handle<Object> self = args.This(); // path object Handle<Object> rt; + Persistent<Object> *self_hdl; char *dstr; int argc; @@ -145,7 +146,11 @@ WRAP(self, sh); SET(self, "mbrt", rt); - mb_prop_set(&sh->obj.props, PROP_JSOBJ, *self); + /* Keep associated js object in property store for retrieving, + * later, without create new js object. + */ + self_hdl = new Persistent<Object>(self); + mb_prop_set(&sh->obj.props, PROP_JSOBJ, self_hdl); return Null(); } @@ -212,6 +217,7 @@ int argc = args.Length(); Handle<Object> self = args.This(); Handle<Object> rt; + Persistent<Object> *self_hdl; float x, y; char *data; redraw_man_t *rdman; @@ -236,7 +242,11 @@ WRAP(self, stext); SET(self, "mbrt", rt); - mb_prop_set(&stext->obj.props, PROP_JSOBJ, *self); + /* Keep associated js object in property store for retrieving, + * later, without create new js object. + */ + self_hdl = new Persistent<Object>(self); + mb_prop_set(&stext->obj.props, PROP_JSOBJ, self_hdl); return Null(); } @@ -349,6 +359,7 @@ int argc = args.Length(); Handle<Object> self = args.This(); Handle<Object> rt; + Persistent<Object> *self_hdl; float x, y; float w, h; redraw_man_t *rdman; @@ -372,7 +383,11 @@ WRAP(self, img); SET(self, "mbrt", rt); - mb_prop_set(&img->obj.props, PROP_JSOBJ, *self); + /* Keep associated js object in property store for retrieving, + * later, without create new js object. + */ + self_hdl = new Persistent<Object>(self); + mb_prop_set(&img->obj.props, PROP_JSOBJ, self_hdl); return Null(); }