Mercurial > MadButterfly
annotate nodejs/shapes.cc @ 570:49e79253b6d3 Android_Skia
Functions of setting/getting stroke width of a shape
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 09 Jun 2010 15:10:29 +0800 |
parents | f87a368e847a |
children | a2faee809514 |
rev | line source |
---|---|
564 | 1 #include <v8.h> |
2 #include "mbfly_njs.h" | |
3 | |
4 extern "C" { | |
5 #include <mb.h> | |
6 } | |
7 | |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
8 #ifndef ASSERT |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
9 #define ASSERT(x) |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
10 #endif |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
11 |
564 | 12 using namespace v8; |
13 | |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
14 /*! \defgroup shape_temp Templates for shape and derivations. |
564 | 15 * |
16 * @{ | |
17 */ | |
18 static Persistent<FunctionTemplate> xnjsmb_shape_temp; | |
19 | |
20 static Handle<Value> | |
21 xnjsmb_shape_show(const Arguments &args) { | |
22 shape_t *sh; | |
23 Handle<Object> self; | |
24 | |
25 self = args.This(); | |
26 sh = (shape_t *)UNWRAP(self); | |
27 sh_show(sh); | |
28 | |
29 return Null(); | |
30 } | |
31 | |
32 static Handle<Value> | |
33 xnjsmb_shape_hide(const Arguments &args) { | |
34 shape_t *sh; | |
35 Handle<Object> self; | |
36 | |
37 self = args.This(); | |
38 sh = (shape_t *)UNWRAP(self); | |
39 sh_hide(sh); | |
40 | |
41 return Null(); | |
42 } | |
43 | |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
44 /*! \brief Get stroke width of a shape. |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
45 */ |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
46 static Handle<Value> |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
47 xnjsmb_shape_stroke_width_getter(Local<String> property, |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
48 const AccessorInfo &info) { |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
49 Handle<Object> self = info.This(); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
50 shape_t *sh; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
51 float w; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
52 Handle<Value> w_val; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
53 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
54 sh = (shape_t *)UNWRAP(self); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
55 w = sh_get_stroke_width(sh); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
56 w_val = Number::New(w); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
57 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
58 return w_val; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
59 } |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
60 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
61 /*! \brief Set stroke width of a shape. |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
62 */ |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
63 static void |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
64 xnjsmb_shape_stroke_width_setter(Local<String> property, |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
65 Local<Value> value, |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
66 const AccessorInfo &info) { |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
67 Handle<Object> self = info.This(); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
68 Handle<Object> rt; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
69 shape_t *sh; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
70 redraw_man_t *rdman; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
71 float w; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
72 Handle<Number> w_num; |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
73 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
74 sh = (shape_t *)UNWRAP(self); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
75 w_num = value->ToNumber(); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
76 w = w_num->Value(); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
77 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
78 sh_set_stroke_width(sh, w); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
79 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
80 /* |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
81 * Mark changed. |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
82 */ |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
83 rt = GET(self, "mbrt")->ToObject(); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
84 ASSERT(rt != NULL); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
85 rdman = xnjsmb_rt_rdman(rt); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
86 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
87 rdman_shape_changed(rdman, sh); |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
88 } |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
89 |
564 | 90 static void |
91 xnjsmb_init_shape_temp(void) { | |
92 Handle<FunctionTemplate> temp; | |
93 Handle<ObjectTemplate> proto_temp; | |
94 Handle<FunctionTemplate> method_temp; | |
95 | |
96 temp = FunctionTemplate::New(); | |
97 temp->SetClassName(String::New("shape")); | |
98 xnjsmb_shape_temp = Persistent<FunctionTemplate>::New(temp); | |
99 proto_temp = temp->PrototypeTemplate(); | |
100 | |
101 method_temp = FunctionTemplate::New(xnjsmb_shape_show); | |
102 SET(proto_temp, "show", method_temp); | |
103 method_temp = FunctionTemplate::New(xnjsmb_shape_hide); | |
104 SET(proto_temp, "hide", method_temp); | |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
105 |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
106 proto_temp->SetAccessor(String::New("stroke_width"), |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
107 xnjsmb_shape_stroke_width_getter, |
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
108 xnjsmb_shape_stroke_width_setter); |
564 | 109 } |
110 | |
111 /* @} */ | |
112 | |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
113 /*! \defgroup path_temp Templates for path objects. |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
114 * |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
115 * @{ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
116 */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
117 static Persistent<FunctionTemplate> xnjsmb_path_temp; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
118 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
119 /*! \brief Callback of constructor of path objects for Javascript. |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
120 */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
121 static Handle<Value> |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
122 xnjsmb_shape_path(const Arguments &args) { |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
123 shape_t *sh; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
124 redraw_man_t *rdman; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
125 Handle<Object> self = args.This(); // path object |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
126 Handle<Object> rt; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
127 char *dstr; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
128 int argc; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
129 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
130 argc = args.Length(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
131 if(argc != 2) |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
132 THROW("Invalid number of arugments (!= 1)"); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
133 if(!args[0]->IsString()) |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
134 THROW("Invalid argument type (should be a string)"); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
135 if(!args[1]->IsObject()) |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
136 THROW("Invalid argument type (should be an object)"); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
137 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
138 String::Utf8Value dutf8(args[0]->ToString()); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
139 dstr = *dutf8; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
140 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
141 rt = args[1]->ToObject(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
142 rdman = xnjsmb_rt_rdman(rt); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
143 sh = rdman_shape_path_new(rdman, dstr); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
144 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
145 WRAP(self, sh); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
565
diff
changeset
|
146 SET(self, "mbrt", rt); |
565
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
147 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
148 return Null(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
149 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
150 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
151 /*! \brief Initial function template for constructor of path objects. |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
152 */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
153 static void |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
154 xnjsmb_init_path_temp(void) { |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
155 Handle<FunctionTemplate> temp; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
156 Handle<ObjectTemplate> inst_temp; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
157 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
158 temp = FunctionTemplate::New(xnjsmb_shape_path); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
159 temp->Inherit(xnjsmb_shape_temp); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
160 temp->SetClassName(String::New("path")); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
161 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
162 inst_temp = temp->InstanceTemplate(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
163 inst_temp->SetInternalFieldCount(1); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
164 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
165 xnjsmb_path_temp = Persistent<FunctionTemplate>::New(temp); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
166 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
167 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
168 /*! \brief Callback function of mb_rt.path_new(). |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
169 */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
170 static Handle<Value> |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
171 xnjsmb_shape_path_new(const Arguments &args) { |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
172 HandleScope scope; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
173 Handle<Object> self = args.This(); // runtime object |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
174 Handle<Object> path_obj; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
175 Handle<Value> path_args[2]; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
176 int argc; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
177 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
178 argc = args.Length(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
179 if(argc != 1) |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
180 THROW("Invalid number of arugments (!= 1)"); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
181 if(!args[0]->IsString()) |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
182 THROW("Invalid argument type (shoud be a string)"); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
183 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
184 path_args[0] = args[0]; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
185 path_args[1] = self; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
186 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
187 path_obj = xnjsmb_path_temp->GetFunction()->NewInstance(2, path_args); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
188 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
189 scope.Close(path_obj); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
190 return path_obj; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
191 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
192 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
193 /* @} */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
194 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
195 /*! \brief Set properties of template of mb_rt. |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
196 */ |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
197 void |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
198 xnjsmb_shapes_init_mb_rt_temp(Handle<FunctionTemplate> rt_temp) { |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
199 Handle<FunctionTemplate> path_new_temp; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
200 Handle<ObjectTemplate> rt_proto_temp; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
201 static int temp_init_flag = 0; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
202 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
203 if(temp_init_flag == 0) { |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
204 xnjsmb_init_shape_temp(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
205 xnjsmb_init_path_temp(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
206 temp_init_flag = 1; |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
207 } |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
208 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
209 rt_proto_temp = rt_temp->PrototypeTemplate(); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
210 |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
211 path_new_temp = FunctionTemplate::New(xnjsmb_shape_path_new); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
212 SET(rt_proto_temp, "path_new", path_new_temp); |
c0bc60448913
Constructor for path objects in Javascript domain
Thinker K.F. Li <thinker@branda.to>
parents:
564
diff
changeset
|
213 } |