Mercurial > MadButterfly
diff nodejs/coord.cc @ 680:a588eefd3f04
Refactor to xnjsmb_coord_mod().
Move code of initializing attributes of JS coord objects to
xnjsmb_coord_mod().
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 06 Aug 2010 22:56:58 +0800 |
parents | 7315c6e953c3 |
children | b346e4699e55 |
line wrap: on
line diff
--- a/nodejs/coord.cc Fri Aug 06 19:31:37 2010 +0800 +++ b/nodejs/coord.cc Fri Aug 06 22:56:58 2010 +0800 @@ -16,6 +16,23 @@ using namespace v8; +static void +xnjsmb_coord_mod(Handle<Object> self, coord_t *coord) { + Persistent<Object> *self_hdl; + subject_t *subject; + Handle<Value> subject_o; + + /* Keep associated js object in property store for retrieving, + * later, without create new js object. + */ + self_hdl = new Persistent<Object>(self); + mb_prop_set(&coord->obj.props, PROP_JSOBJ, self_hdl); + + subject = coord->mouse_event; + subject_o = export_xnjsmb_auto_subject_new(subject); + SET(self, "mouse_event", subject_o); +} + static float coord_get_index(coord_t *coord, Handle<Object> self, int idx, const char **err) {