Mercurial > MadButterfly
comparison nodejs/coord.cc @ 566:6639d386db78 Android_Skia
Function of add a shape to a coord in Javascript.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 08 Jun 2010 09:08:23 +0800 |
parents | bc207070e3d5 |
children | 90c7726bc953 |
comparison
equal
deleted
inserted
replaced
565:c0bc60448913 | 566:6639d386db78 |
---|---|
59 rdman_coord_changed(rdman, coord); | 59 rdman_coord_changed(rdman, coord); |
60 | 60 |
61 return value; | 61 return value; |
62 } | 62 } |
63 | 63 |
64 /*! \brief Callback functio to add a shape to a coord in Javascript. | |
65 * | |
66 * coord.add_shape(shape) | |
67 */ | |
68 static Handle<Value> | |
69 xnjsmb_coord_add_shape(const Arguments &args) { | |
70 int argc = args.Length(); | |
71 Handle<Object> self = args.This(); | |
72 Handle<Object> shape_obj; | |
73 Handle<Object> rt_obj; | |
74 Handle<Value> rt_val; | |
75 redraw_man_t *rdman; | |
76 coord_t *coord; | |
77 shape_t *sh; | |
78 int r; | |
79 | |
80 if(argc != 1) | |
81 THROW("Invalid number of arguments (!= 1)"); | |
82 | |
83 shape_obj = args[0]->ToObject(); | |
84 sh = (shape_t *)UNWRAP(shape_obj); | |
85 ASSERT(sh != NULL); | |
86 | |
87 coord = (coord_t *)UNWRAP(self); | |
88 ASSERT(coord != NULL); | |
89 | |
90 rt_val = GET(self, "mbrt"); | |
91 rt_obj = rt_val->ToObject(); | |
92 rdman = xnjsmb_rt_rdman(rt_obj); | |
93 | |
94 r = rdman_add_shape(rdman, sh, coord); | |
95 if(r != 0) | |
96 THROW("Unknown error"); | |
97 | |
98 return Null(); | |
99 } | |
100 | |
64 static Persistent<ObjectTemplate> coord_obj_temp; | 101 static Persistent<ObjectTemplate> coord_obj_temp; |
65 | 102 |
66 static void | 103 static void |
67 xnjsmb_init_temp(void) { | 104 xnjsmb_init_temp(void) { |
105 Handle<FunctionTemplate> add_shape_temp; | |
106 | |
68 coord_obj_temp = Persistent<ObjectTemplate>::New(ObjectTemplate::New()); | 107 coord_obj_temp = Persistent<ObjectTemplate>::New(ObjectTemplate::New()); |
69 coord_obj_temp->SetIndexedPropertyHandler(xnjsmb_coord_get_index, | 108 coord_obj_temp->SetIndexedPropertyHandler(xnjsmb_coord_get_index, |
70 xnjsmb_coord_set_index); | 109 xnjsmb_coord_set_index); |
71 coord_obj_temp->SetInternalFieldCount(1); | 110 coord_obj_temp->SetInternalFieldCount(1); |
111 | |
112 add_shape_temp = FunctionTemplate::New(xnjsmb_coord_add_shape); | |
113 SET(coord_obj_temp, "add_shape", add_shape_temp); | |
72 } | 114 } |
73 | 115 |
74 /*! \brief Create and initialize a Javascript object for a coord. | 116 /*! \brief Create and initialize a Javascript object for a coord. |
75 */ | 117 */ |
76 static Handle<Object> | 118 static Handle<Object> |