comparison 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
comparison
equal deleted inserted replaced
679:799c852b9065 680:a588eefd3f04
13 #ifndef ASSERT 13 #ifndef ASSERT
14 #define ASSERT(x) 14 #define ASSERT(x)
15 #endif 15 #endif
16 16
17 using namespace v8; 17 using namespace v8;
18
19 static void
20 xnjsmb_coord_mod(Handle<Object> self, coord_t *coord) {
21 Persistent<Object> *self_hdl;
22 subject_t *subject;
23 Handle<Value> subject_o;
24
25 /* Keep associated js object in property store for retrieving,
26 * later, without create new js object.
27 */
28 self_hdl = new Persistent<Object>(self);
29 mb_prop_set(&coord->obj.props, PROP_JSOBJ, self_hdl);
30
31 subject = coord->mouse_event;
32 subject_o = export_xnjsmb_auto_subject_new(subject);
33 SET(self, "mouse_event", subject_o);
34 }
18 35
19 static float 36 static float
20 coord_get_index(coord_t *coord, Handle<Object> self, int idx, 37 coord_get_index(coord_t *coord, Handle<Object> self, int idx,
21 const char **err) { 38 const char **err) {
22 if(idx < 0 || idx >= 6) { 39 if(idx < 0 || idx >= 6) {