Mercurial > MadButterfly
annotate nodejs/paints.cc @ 684:b346e4699e55
Add more comment for JS binding
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 07 Aug 2010 19:33:42 +0800 |
parents | 714cd6470bd9 |
children | da12923a789a |
rev | line source |
---|---|
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #include <v8.h> |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 extern "C" { |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include "mb.h" |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #include "mbfly_njs.h" |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 using namespace v8; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
11 #ifndef ASSERT |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
12 #define ASSERT(x) |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
13 #endif |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
15 /*! \defgroup xnjsmb_paints JS binding for paints |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
16 * \ingroup xnjsmb |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
17 * |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
18 * @{ |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
19 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
21 /*! \brief Fill a shape with the paint. |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
22 */ |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
23 static Handle<Value> |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
24 xnjsmb_paint_fill(const Arguments &args) { |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
25 int argc = args.Length(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
26 Handle<Object> self = args.This(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
27 Handle<Object> sh_obj; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
28 Handle<Object> rt; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
29 Handle<Value> rt_val; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
30 paint_t *paint; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
31 shape_t *sh; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
32 redraw_man_t *rdman; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
33 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
34 if(argc != 1) |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
35 THROW("Invalid number of arguments (!= 1)"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
36 if(!args[0]->IsObject()) |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
37 THROW("Invalid argument type (shape)"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
38 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
39 paint = (paint_t *)UNWRAP(self); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
40 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
41 sh_obj = args[0]->ToObject(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
42 sh = (shape_t *)UNWRAP(sh_obj); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
43 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
44 rt_val = GET(self, "mbrt"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
45 rt = rt_val->ToObject(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
46 rdman = xnjsmb_rt_rdman(rt); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
47 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
48 rdman_paint_fill(rdman, paint, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
49 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
50 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
51 rdman_shape_changed(rdman, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
52 |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
53 return Null(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
54 } |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
55 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
56 /*! \brief Stroke a shape with the paint. |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
57 */ |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
58 static Handle<Value> |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
59 xnjsmb_paint_stroke(const Arguments &args) { |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
60 int argc = args.Length(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
61 Handle<Object> self = args.This(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
62 Handle<Object> sh_obj; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
63 Handle<Object> rt; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
64 Handle<Value> rt_val, sh_val; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
65 paint_t *paint; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
66 shape_t *sh; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
67 redraw_man_t *rdman; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
68 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
69 if(argc != 1) |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
70 THROW("Invalid number of arguments (!= 1)"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
71 if(!args[0]->IsObject()) |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
72 THROW("Invalid argument type (shape)"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
73 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
74 paint = (paint_t *)UNWRAP(self); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
75 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
76 sh_val = args[0]; |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
77 sh_obj = sh_val->ToObject(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
78 sh = (shape_t *)UNWRAP(sh_obj); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
79 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
80 rt_val = GET(self, "mbrt"); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
81 rt = rt_val->ToObject(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
82 rdman = xnjsmb_rt_rdman(rt); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
83 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
84 rdman_paint_stroke(rdman, paint, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
85 |
576
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
86 if(sh_get_coord(sh)) |
5a68e2bcea17
Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
570
diff
changeset
|
87 rdman_shape_changed(rdman, sh); |
570
49e79253b6d3
Functions of setting/getting stroke width of a shape
Thinker K.F. Li <thinker@branda.to>
parents:
569
diff
changeset
|
88 |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
89 return Null(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
90 } |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
91 |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
92 /*! \brief Constructor of color paint_color_t object for Javascript. |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
93 */ |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
94 static Handle<Value> |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
95 xnjsmb_paint_color(const Arguments &args) { |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
96 int argc = args.Length(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
97 Handle<Object> self = args.This(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
98 Handle<Object> rt; |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
99 redraw_man_t *rdman; |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
100 paint_t *paint; |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
101 float r, g, b, a; |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
102 |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
103 if(argc != 5) |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
104 THROW("Invalid number of arguments (!= 5)"); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
105 if(!args[0]->IsObject() || !args[1]->IsNumber() || |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
106 !args[2]->IsNumber() || !args[3]->IsNumber() || |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
107 !args[4]->IsNumber()) |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
108 THROW("Invalid argument type"); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
109 |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
110 rt = args[0]->ToObject(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
111 r = args[1]->ToNumber()->Value(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
112 g = args[2]->ToNumber()->Value(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
113 b = args[3]->ToNumber()->Value(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
114 a = args[4]->ToNumber()->Value(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
115 |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
116 rdman = xnjsmb_rt_rdman(rt); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
117 paint = rdman_paint_color_new(rdman, r, g, b, a); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
118 ASSERT(sh != NULL); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
119 |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
120 WRAP(self, paint); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
121 SET(self, "mbrt", rt); |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
122 |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
123 return Null(); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
124 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
125 |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
126 static Persistent<FunctionTemplate> xnjsmb_paint_temp; |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
127 static Persistent<FunctionTemplate> xnjsmb_paint_color_temp; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
128 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
129 /*! \brief Create and return a paint_color object. |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
130 */ |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
131 static Handle<Value> |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
132 xnjsmb_paint_color_new(const Arguments &args) { |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
133 HandleScope scope; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
134 Handle<Object> rt = args.This(); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
135 Handle<Object> paint_color_obj; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
136 Handle<Function> paint_color_func; |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
137 Handle<Value> pc_args[5]; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
138 int argc; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
139 int i; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
140 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
141 argc = args.Length(); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
142 if(argc != 4) |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
143 THROW("Invalid number of arguments (r, g, b, a)"); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
144 for(i = 0; i < 4; i++) |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
145 if(!args[i]->IsNumber()) |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
146 THROW("Invalid argument type"); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
147 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
148 pc_args[0] = rt; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
149 pc_args[1] = args[0]; // r |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
150 pc_args[2] = args[1]; // g |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
151 pc_args[3] = args[2]; // b |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
152 pc_args[4] = args[3]; // a |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
153 paint_color_func = xnjsmb_paint_color_temp->GetFunction(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
154 paint_color_obj = paint_color_func->NewInstance(5, pc_args); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
155 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
156 scope.Close(paint_color_obj); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
157 return paint_color_obj; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
158 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
159 |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
160 static Persistent<FunctionTemplate> xnjsmb_paint_color_new_temp; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
161 |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
162 /*! \brief Constructor of paint_image_t objects for Javascript. |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
163 */ |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
164 static Handle<Value> |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
165 xnjsmb_paint_image(const Arguments &args) { |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
166 int argc = args.Length(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
167 Handle<Object> rt; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
168 Handle<Object> self = args.This(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
169 Handle<Object> img_obj; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
170 redraw_man_t *rdman; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
171 mb_img_data_t *img; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
172 paint_t *paint; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
173 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
174 if(argc != 2) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
175 THROW("Invalid number of arguments (!= 2)"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
176 if(!args[0]->IsObject() || !args[1]->IsObject()) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
177 THROW("Invalid argument type"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
178 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
179 rt = args[0]->ToObject(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
180 img_obj = args[1]->ToObject(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
181 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
182 rdman = xnjsmb_rt_rdman(rt); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
183 img = (mb_img_data_t *)UNWRAP(img_obj); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
184 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
185 paint = rdman_paint_image_new(rdman, img); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
186 ASSERT(paint != NULL); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
187 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
188 WRAP(self, paint); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
189 SET(self, "mbrt", rt); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
190 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
191 return Null(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
192 } |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
193 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
194 static Persistent<FunctionTemplate> xnjsmb_paint_image_temp; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
195 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
196 /*! \brief Create and return a paint_image object. |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
197 */ |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
198 static Handle<Value> |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
199 xnjsmb_paint_image_new(const Arguments &args) { |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
200 int argc = args.Length(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
201 HandleScope scope; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
202 Handle<Object> rt = args.This(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
203 Handle<Object> paint_image_obj; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
204 Handle<Value> pi_args[2]; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
205 Handle<Function> paint_image_func; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
206 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
207 if(argc != 1) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
208 THROW("Invalid number of arguments (!= 2)"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
209 if(!args[0]->IsObject()) |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
210 THROW("Invalid argument type"); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
211 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
212 pi_args[0] = rt; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
213 pi_args[1] = args[0]; // image |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
214 paint_image_func = xnjsmb_paint_image_temp->GetFunction(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
215 paint_image_obj = paint_image_func->NewInstance(2, pi_args); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
216 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
217 scope.Close(paint_image_obj); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
218 return paint_image_obj; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
219 } |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
220 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
221 static Persistent<FunctionTemplate> xnjsmb_paint_image_new_temp; |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
222 |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
223 /*! \brief Create templates for paint types. |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
224 * |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
225 * This function is only called one time for every execution. |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
226 */ |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
227 static void |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
228 xnjsmb_init_paints(void) { |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
229 Handle<FunctionTemplate> temp, meth; |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
230 Handle<ObjectTemplate> inst_temp; |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
231 Handle<ObjectTemplate> proto_temp; |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
232 |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
233 /* |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
234 * Base type of paint types. |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
235 */ |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
236 temp = FunctionTemplate::New(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
237 xnjsmb_paint_temp = Persistent<FunctionTemplate>::New(temp); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
238 xnjsmb_paint_temp->SetClassName(String::New("paint")); |
569
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
239 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
240 meth = FunctionTemplate::New(xnjsmb_paint_fill); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
241 proto_temp = xnjsmb_paint_temp->PrototypeTemplate(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
242 SET(proto_temp, "fill", meth); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
243 |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
244 meth = FunctionTemplate::New(xnjsmb_paint_stroke); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
245 proto_temp = xnjsmb_paint_temp->PrototypeTemplate(); |
f87a368e847a
Functions of stroke and fill a shape
Thinker K.F. Li <thinker@branda.to>
parents:
568
diff
changeset
|
246 SET(proto_temp, "stroke", meth); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
247 |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
248 /* |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
249 * Paint color |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
250 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
251 temp = FunctionTemplate::New(xnjsmb_paint_color); |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
252 xnjsmb_paint_color_temp = Persistent<FunctionTemplate>::New(temp); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
253 xnjsmb_paint_color_temp->SetClassName(String::New("paint_color")); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
254 xnjsmb_paint_color_temp->Inherit(xnjsmb_paint_temp); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
255 |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
256 inst_temp = xnjsmb_paint_color_temp->InstanceTemplate(); |
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
257 inst_temp->SetInternalFieldCount(1); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
258 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
259 temp = FunctionTemplate::New(xnjsmb_paint_color_new); |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
260 xnjsmb_paint_color_new_temp = Persistent<FunctionTemplate>::New(temp); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
261 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
262 /* |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
263 * Paint image |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
264 */ |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
265 temp = FunctionTemplate::New(xnjsmb_paint_image); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
266 xnjsmb_paint_image_temp = Persistent<FunctionTemplate>::New(temp); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
267 xnjsmb_paint_image_temp->SetClassName(String::New("paint_image")); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
268 xnjsmb_paint_image_temp->Inherit(xnjsmb_paint_temp); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
269 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
270 inst_temp = xnjsmb_paint_image_temp->InstanceTemplate(); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
271 inst_temp->SetInternalFieldCount(1); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
272 |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
273 temp = FunctionTemplate::New(xnjsmb_paint_image_new); |
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
274 xnjsmb_paint_image_new_temp = Persistent<FunctionTemplate>::New(temp); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
275 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
276 |
637
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
277 /*! \brief Initialize paints for mbfly. |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
278 * |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
279 * This function is called by init() in mbfly_njs.cc when the module |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
280 * being loaded. |
714cd6470bd9
Doc on xnjsmb_paints_init_mb_rt_temp()
Thinker K.F. Li <thinker@branda.to>
parents:
636
diff
changeset
|
281 */ |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
282 void xnjsmb_paints_init_mb_rt_temp(Handle<FunctionTemplate> rt_temp) { |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
283 static int init_flag = 0; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
284 Handle<ObjectTemplate> rt_proto_temp; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
285 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
286 if(!init_flag) { |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
287 xnjsmb_init_paints(); |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
288 init_flag = 1; |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
289 } |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
290 |
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
291 rt_proto_temp = rt_temp->PrototypeTemplate(); |
568
d796e6b8b97e
Real initialize a paint_color_t object for paint_color JS obj
Thinker K.F. Li <thinker@branda.to>
parents:
567
diff
changeset
|
292 SET(rt_proto_temp, "paint_color_new", xnjsmb_paint_color_new_temp); |
636
cc39cf3f623c
paint_image_t for nodejs.
Thinker K.F. Li <thinker@branda.to>
parents:
576
diff
changeset
|
293 SET(rt_proto_temp, "paint_image_new", xnjsmb_paint_image_new_temp); |
567
a12c3448afb6
Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
294 } |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
295 |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
637
diff
changeset
|
296 /* @} */ |