Mercurial > MadButterfly
annotate tools/gen_v8_binding.m4 @ 668:916dc9723086
Fix issue of return value of code generated
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 04 Aug 2010 22:07:13 +0800 |
parents | 08fd45d119c9 |
children | eeea1b593a2f |
rev | line source |
---|---|
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
1 dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
2 dnl Developers should provide SET, WRAP, UNWRAP, and THROW C macros. |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
3 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 changequote(`[', `]')dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 include([foreach.m4])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 divert([-1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 define([UNQUOTE], [$*]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 define([QUOTE], [[[$*]]]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 define([COUNT],[ifelse([$*],[],0,[$#])]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 define([IMPORT],[define([$1],[$2$1(]$[]@[)])]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
16 define([EXPAND], [$1]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
17 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 define([PROJ_PREFIX], [xnjsmb_]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 define([START_ACCESSOR], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 divert([-1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 define([INT], [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) { |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
25 Handle<Object> self = info.This(); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
26 STRUCT_TYPE *data; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
27 |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
28 data = (STRUCT_TYPE *)UNWRAP(self); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 return Integer::New(data->$][1); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 static void |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 Local<Value> value, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 const AccessorInfo &info) { |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 Handle<Object> self = info.This(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 STRUCT_TYPE *data; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 data = (STRUCT_TYPE *)UNWRAP(self); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 data->$][1 = value->Int32Value(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 ]) |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
43 define([NUMBER], [ |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
44 static Handle<Value> |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
45 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) { |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
46 Handle<Object> self = info.This(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
47 STRUCT_TYPE *data; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
48 |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
49 data = (STRUCT_TYPE *)UNWRAP(self); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
50 return Number::New(data->$][1); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
51 } |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
52 |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
53 static void |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
54 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property, |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
55 Local<Value> value, |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
56 const AccessorInfo &info) { |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
57 Handle<Object> self = info.This(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
58 STRUCT_TYPE *data; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
59 |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
60 data = (STRUCT_TYPE *)UNWRAP(self); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
61 data->$][1 = value->NumberValue(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
62 } |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
63 ]) |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 define([OBJ], [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
65 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
66 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) { |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
67 Handle<Object> self = info.This(); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
68 STRUCT_TYPE *data; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
69 |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
70 data = (STRUCT_TYPE *)UNWRAP(self); |
657
32d0eef1ee46
Force type-casting for member variables.
Thinker K.F. Li <thinker@branda.to>
parents:
651
diff
changeset
|
71 return ]PROJ_PREFIX[$][2_new(($][3 *)data->$][1); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
72 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
73 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
74 static void |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
75 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
76 Local<Value> value, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
77 const AccessorInfo &info) { |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
78 Handle<Object> self = info.This(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
79 Handle<Object> obj; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
80 $][3 *v; |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
81 STRUCT_TYPE *data; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
82 |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
83 data = (STRUCT_TYPE *)UNWRAP(self); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
84 obj = value->ToObject(); |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
85 v = ($][3 *)UNWRAP(obj); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
86 data->$][1 = v; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
87 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
88 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
89 define([STR], [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
90 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
91 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) { |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
92 Handle<Object> self = info.This(); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
93 STRUCT_TYPE *data; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
94 |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
95 data = (STRUCT_TYPE *)UNWRAP(self); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
96 return String::New(data->$][1); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
97 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
98 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
99 static void |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
100 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
101 Local<Value> value, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
102 const AccessorInfo &info) { |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
103 Handle<Object> self = info.This(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
104 STRUCT_TYPE *data; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
105 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
106 data = (STRUCT_TYPE *)UNWRAP(self); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
107 String::Utf8Value utf8(value->ToString()); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
108 free(data->$][1); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
109 data->$][1 = strdup(*utf8); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
110 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
111 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
112 divert([])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
113 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
114 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
115 define([STOP_ACCESSOR], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
116 divert([-1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
117 undefine([INT]) |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
118 undefine([NUMBER]) |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
119 undefine([OBJ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
120 undefine([STR]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
121 divert([])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
122 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
123 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
124 define([SET_ACCESSSOR], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
125 define([INT], [$][1])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
126 define([NUMBER], [$][1])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
127 define([OBJ], [$][1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
128 define([STR], [$][1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
129 inst_temp->SetAccessor(String::New("$1"), |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
130 PROJ_PREFIX[]STRUCT_NAME[]_get_[]$1, |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
131 PROJ_PREFIX[]STRUCT_NAME[]_set_[]$1); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
132 undefine([INT])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
133 undefine([NUMBER])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
134 undefine([OBJ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
135 undefine([STR])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
136 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
137 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
138 define([START_METHOD_ARG_VAR], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
139 define([INT], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
140 int arg_$][1; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
141 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
142 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
143 double arg_$][1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
144 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
145 define([OBJ], [dnl |
663
974d98233eab
Fix mis-using of arguments of OBJ() argument type
Thinker K.F. Li <thinker@branda.to>
parents:
660
diff
changeset
|
146 $][3 *arg_$][1; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
147 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
148 define([STR], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
149 char *arg_$][1; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
150 ])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
151 define([FUNC], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
152 Handle<Function> arg_$][1; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
153 ])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
154 define([SELF], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
155 define([ERR], [])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
156 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
157 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
158 define([START_METHOD_ARG_TYPE_CHK], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
159 define([INT], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
160 !args[[i++]]->IsInt32()])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
161 define([NUMBER], [ || |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
162 !args[[i++]]->IsNumber()])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
163 define([OBJ], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
164 !args[[i++]]->IsObject()])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
165 define([STR], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
166 !args[[i++]]->IsString()])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
167 define([FUNC], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
168 !args[[i++]]->IsFunction()])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
169 define([SELF], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
170 define([ERR], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
171 ]) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
172 |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
173 define([START_TYPE_CHK], [dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
174 define([INT], [$1->IsInt32()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
175 define([NUMBER], [$1->IsNumber()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
176 define([OBJ], [$1->IsObject()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
177 define([STR], [$1->IsString()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
178 define([FUNC], [$1->IsFunction()])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
179 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
180 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
181 define([START_METHOD_ARG_ASSIGN], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
182 define([INT], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
183 arg_$][1 = args[[i++]]->Int32Value(); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
184 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
185 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
186 arg_$][1 = args[[i++]]->NumberValue(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
187 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
188 define([OBJ], [dnl |
663
974d98233eab
Fix mis-using of arguments of OBJ() argument type
Thinker K.F. Li <thinker@branda.to>
parents:
660
diff
changeset
|
189 arg_$][1 = ($][3 *)UNWRAP(args[[i++]]->ToObject()); |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
190 ])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
191 define([STR], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
192 arg_$][1 = strdup(*String::Utf8Value(args[[i++]]->ToString())); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
193 ])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
194 define([FUNC], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
195 arg_$][1 = args[[i++]].As<Function>(); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
196 ])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
197 define([SELF], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
198 define([ERR], [])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
199 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
200 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
201 define([START_VALUE_ASSIGN], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
202 define([INT], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
203 $1 = $2->Int32Value(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
204 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
205 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
206 $1 = $2->NumberValue(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
207 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
208 define([OBJ], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
209 $1 = ($][2 *)UNWRAP($2->ToObject()); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
210 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
211 define([STR], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
212 $1 = strdup(*String::Utf8Value($2->ToString())); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
213 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
214 define([FUNC], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
215 $1 = $2.As<Function>(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
216 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
217 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
218 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
219 define([START_METHOD_ARG_PASS], [dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
220 define([INT], [arg_$][1])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
221 define([NUMBER], [arg_$][1])dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
222 define([OBJ], [arg_$][1])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
223 define([STR], [arg_$][1])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
224 define([FUNC], [arg_$][1])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
225 define([SELF], [self])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
226 define([ERR], [&_err])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
227 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
228 |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
229 define([START_METHOD_RET_VAL], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
230 define([INT], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
231 int _ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
232 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
233 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
234 double _ret; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
235 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
236 define([OBJ], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
237 $][2 *_ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
238 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
239 define([STR], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
240 char *_ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
241 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
242 define([FUNC], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
243 Handle<Function> _ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
244 ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
245 ]) |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
246 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
247 define([START_VAR], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
248 define([INT], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
249 int $1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
250 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
251 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
252 double $1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
253 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
254 define([OBJ], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
255 $][2 *$1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
256 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
257 define([STR], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
258 char *$1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
259 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
260 define([FUNC], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
261 Handle<Function> $1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
262 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
263 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
264 |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
265 define([START_METHOD_RET_ASSIGN], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
266 define([INT], [_ret = (int)])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
267 define([NUMBER], [_ret = (double)])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
268 define([OBJ], [_ret = ($][2 *)])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
269 define([STR], [_ret = (char *)])dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
270 define([FUNC], [_ret = ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
271 ]) |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
272 |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
273 define([START_METHOD_RET], [dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
274 define([INT], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
275 _ret_val = Integer::New(_ret); |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
276 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
277 define([NUMBER], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
278 _ret_val = Number::New(_ret); |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
279 ])dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
280 define([OBJ], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
281 _ret_val = PROJ_PREFIX[]$][1[]_new(_ret); |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
282 ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
283 define([STR], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
284 _ret_val = String::New(_ret); |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
285 ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
286 define([FUNC], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
287 _rt_val = _ret; |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
288 ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
289 ]) |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
290 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
291 define([STOP_METHOD_ARG], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
292 undefine([INT])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
293 undefine([NUMBER])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
294 undefine([OBJ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
295 undefine([STR])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
296 undefine([FUNC])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
297 undefine([SELF])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
298 undefine([ERR])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
299 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
300 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
301 define([START_METHOD], [dnl |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
302 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
303 dnl METHOD(name, func, arguments, cnt, ret_type, options) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
304 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
305 define([METHOD], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
306 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
307 ifelse($][6, [], [], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
308 foreach([ITER], ]$][6[, [EXPAND([define]ITER)])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
309 ])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
310 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
311 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
312 PROJ_PREFIX[]STRUCT_NAME[]_$][1(const Arguments &args) { |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
313 int i; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
314 int argc = args.Length(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
315 Handle<Object> self = args.This(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
316 STRUCT_TYPE *_self = (STRUCT_TYPE *)UNWRAP(self); |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
317 const char *_err = NULL; |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
318 foreach([ITER], $][3, [START_METHOD_ARG_VAR[]ITER[]STOP_METHOD_ARG])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
319 START_METHOD_RET_VAL[]$][5[]STOP_METHOD_ARG |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
320 Handle<Value> _ret_val; |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
321 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
322 if(argc != $][4) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
323 THROW("Invalid number of arguments (!=$][4)"); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
324 i = 0; |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
325 if(0[]dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
326 foreach([ITER], $][3, [START_METHOD_ARG_TYPE_CHK[]ITER[]STOP_METHOD_ARG])) |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
327 THROW("Invalid argument type"); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
328 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
329 i = 0; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
330 foreach([ITER], $][3, [START_METHOD_ARG_ASSIGN[]ITER[]STOP_METHOD_ARG])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
331 |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
332 START_METHOD_RET_ASSIGN[]$][5[]STOP_METHOD_ARG[]$][2(_self[]foreach([ITER], $][3, [START_METHOD_ARG_PASS[], ITER[]STOP_METHOD_ARG])); |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
333 if(_err) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
334 THROW(_err); |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
335 START_METHOD_RET[]$][5[]STOP_METHOD_ARG[]dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
336 ifelse($][5, [], [ |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
337 return Null(); |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
338 ], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
339 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
340 dnl Modify returned object |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
341 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
342 ifdef([MOD], [ |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
343 MOD[](self, _ret_val); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
344 ])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
345 return _ret_val; |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
346 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
347 } |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
348 ifelse($][6, [], [], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
349 foreach([ITER], ]$][6[, [EXPAND([undefine]ITER)])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
350 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
351 ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
352 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
353 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
354 define([STOP_METHOD], [undefine([METHOD])]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
355 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
356 define([SET_METHOD], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
357 define([METHOD], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
358 SET(proto_temp, "$][1", |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
359 FunctionTemplate::New(PROJ_PREFIX[]STRUCT_NAME[]_$][1)); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
360 ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
361 $1[]dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
362 undefine([METHOD])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
363 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
364 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
365 define([DEF_GET_INDEX], [ |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
366 static Handle<Value> |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
367 PROJ_PREFIX[]STRUCT_NAME[]_get_index(uint32_t index, const AccessorInfo &info) { |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
368 Handle<Object> self = info.This(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
369 STRUCT_TYPE *obj = (STRUCT_TYPE *)UNWRAP(self); |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
370 const char *_err = NULL; |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
371 START_METHOD_RET_VAL[]$2[]STOP_METHOD_ARG[]dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
372 Handle<Value> _ret_val; |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
373 |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
374 _ret = $1(obj, self, index, &_err); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
375 if(_err) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
376 THROW(_err); |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
377 START_METHOD_RET[]$2[]STOP_METHOD_ARG[]dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
378 return _ret_val; |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
379 } |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
380 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
381 |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
382 define([DEF_SET_INDEX], [ |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
383 static Handle<Value> |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
384 PROJ_PREFIX[]STRUCT_NAME[]_set_index(uint32_t index, Local<Value> value, |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
385 const AccessorInfo &info) { |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
386 Handle<Object> self = info.This(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
387 STRUCT_TYPE *obj = (STRUCT_TYPE *)UNWRAP(self); |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
388 const char *_err = NULL; |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
389 START_VAR([in_value])[]$2[]STOP_METHOD_ARG[]dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
390 START_METHOD_RET_VAL[]$2[]STOP_METHOD_ARG[]dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
391 Handle<Value> _ret_val; |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
392 |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
393 if(START_TYPE_CHK(value)[]![]$2[]STOP_METHOD_ARG) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
394 THROW("Invalid value type"); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
395 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
396 START_VALUE_ASSIGN(in_value, value)[]$2[]STOP_METHOD_ARG[]dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
397 _ret = $1(obj, self, index, in_value, &_err); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
398 if(_err) THROW(_err); |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
399 START_METHOD_RET[]$2[]STOP_METHOD_ARG[]dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
400 return _ret_val; |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
401 } |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
402 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
403 |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
404 define([INSTALL_INDEX_FUNCTIONS],[dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
405 define([FIRST], [$][1])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
406 ifdef([GET_INDEX], [ifdef([SET_INDEX], [dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
407 inst_temp->SetIndexedPropertyHandler(PROJ_PREFIX[]STRUCT_NAME[]_get_index, |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
408 PROJ_PREFIX[]STRUCT_NAME[]_set_index); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
409 ], [dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
410 inst_temp->SetIndexedPropertyHandler(PROJ_PREFIX[]STRUCT_NAME[]_get_index); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
411 ])])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
412 undefine([FIRST])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
413 ]) |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
414 |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
415 define([CTOR_INTERNAL], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
416 int argc = args.Length(); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
417 Handle<Object> self = args.This(); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
418 $4 *obj; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
419 foreach([ITER], $2, [START_METHOD_ARG_VAR[]ITER[]STOP_METHOD_ARG])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
420 int i; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
421 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
422 if(argc != $3) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
423 THROW("Invalid number of arguments (!=$][4)"); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
424 i = 0; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
425 if(0]dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
426 [foreach([ITER], $2, [START_METHOD_ARG_TYPE_CHK[]ITER[]STOP_METHOD_ARG])) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
427 THROW("Invalid argument type"); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
428 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
429 i = 0; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
430 foreach([ITER], $2, [START_METHOD_ARG_ASSIGN[]ITER[]STOP_METHOD_ARG])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
431 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
432 define([SEP], [])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
433 obj = ($4 *)$1(foreach([ITER], $2, [START_METHOD_ARG_PASS[]SEP[]ITER[]STOP_METHOD_ARG[]define([SEP], [, ])]));[]undefine([SEP]) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
434 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
435 WRAP(self, obj); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
436 ]) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
437 |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
438 dnl |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
439 dnl STRUCT(struct_name, struct_type, member_vars, methods, options) |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
440 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
441 define([STRUCT], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
442 define([STRUCT_NAME], [$1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
443 define([STRUCT_TYPE], [$2])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
444 dnl |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
445 ifelse([$5], [], [], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
446 foreach([ITER], $5, [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
447 EXPAND([define]ITER)[]dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
448 ])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
449 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
450 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
451 [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
452 /* ************************************************** |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
453 * STRUCT: $1 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
454 * Generated by gen_v8_binding.m4 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
455 */ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
456 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
457 ]PROJ_PREFIX[$1(const Arguments &args) { |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
458 ]ifdef([CTOR], [EXPAND([CTOR_INTERNAL](EXPAND([UNQUOTE]CTOR), [$2]))])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
459 return Null(); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
460 [} |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
461 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
462 static Persistent<FunctionTemplate> ]PROJ_PREFIX[$1][_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
463 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
464 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
465 ]PROJ_PREFIX[$1][_new($2 *data) { |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
466 Handle<Object> obj; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
467 Handle<Function> func; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
468 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
469 func = ]PROJ_PREFIX[$1][_temp->GetFunction(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
470 obj = func->NewInstance(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
471 WRAP(obj, data); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
472 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
473 return obj; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
474 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
475 ]dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
476 foreach([ITER], ($3), [START_ACCESSOR ITER STOP_ACCESSOR])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
477 foreach([ITER], ($4), [START_METHOD ITER STOP_METHOD])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
478 ifdef([GET_INDEX], [EXPAND([DEF_GET_INDEX]GET_INDEX)])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
479 ifdef([SET_INDEX], [EXPAND([DEF_SET_INDEX]SET_INDEX)])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
480 [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
481 static void |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
482 ]PROJ_PREFIX[$1][_init(void) { |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
483 Handle<FunctionTemplate> func_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
484 Handle<ObjectTemplate> inst_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
485 Handle<ObjectTemplate> proto_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
486 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
487 func_temp = FunctionTemplate::New(]PROJ_PREFIX[$1); |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
488 func_temp->SetClassName(String::New("]STRUCT_NAME[")); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
489 inst_temp = func_temp->InstanceTemplate(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
490 inst_temp->SetInternalFieldCount(1); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
491 ] |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
492 foreach([ITER], ($3), [SET_ACCESSSOR(ITER)])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
493 INSTALL_INDEX_FUNCTIONS[]dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
494 |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
495 proto_temp = func_temp->PrototypeTemplate(); |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
496 foreach([ITER], ($4), [SET_METHOD(ITER)])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
497 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
498 PROJ_PREFIX[$1][_temp = Persistent<FunctionTemplate>::New(func_temp); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
499 }]dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
500 dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
501 ifelse([$5], [], [], [foreach([ITER], $5, [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
502 define([DUMMY], [undefine]ITER)dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
503 DUMMY[]dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
504 undefine([DUMMY])])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
505 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
506 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
507 ]) |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
508 |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
509 dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
510 dnl FUNCTION(func_name, real_func, arguments, arguement_count, |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
511 dnl return_type, options) |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
512 dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
513 define([FUNCTION], [dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
514 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
515 ifelse($6, [], [], [dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
516 foreach([ITER], $6, [EXPAND([define]ITER)])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
517 ])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
518 dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
519 /* ************************************************** |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
520 * [FUNCTION]: $1 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
521 * Generated by gen_v8_binding.m4 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
522 */ |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
523 static Handle<Value> |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
524 PROJ_PREFIX[]$1(const Arguments &args) { |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
525 int argc = args.Length(); |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
526 int i; |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
527 const char *_err = NULL; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
528 foreach([ITER], ($3), [START_METHOD_ARG_VAR[]ITER[]STOP_METHOD_ARG])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
529 START_METHOD_RET_VAL[]$5[]STOP_METHOD_ARG[]dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
530 Handle<Value> _ret_val; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
531 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
532 if(argc != $4) |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
533 THROW("Invalid number of arguments (!=$][4)"); |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
534 i = 0; |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
535 if(0]dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
536 [foreach([ITER], ($3), [START_METHOD_ARG_TYPE_CHK[]ITER[]STOP_METHOD_ARG])) |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
537 THROW("Invalid argument type"); |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
538 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
539 i = 0; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
540 foreach([ITER], ($3), [START_METHOD_ARG_ASSIGN[]ITER[]STOP_METHOD_ARG])dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
541 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
542 define([SEP], [])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
543 START_METHOD_RET_ASSIGN[]$5[]STOP_METHOD_ARG[]$2(foreach([ITER], ($3), [START_METHOD_ARG_PASS[]SEP[]ITER[]STOP_METHOD_ARG[]define([SEP], [, ])]));[]undefine([SEP]) |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
544 if(_err) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
545 THROW(_err); |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
546 START_METHOD_RET[]$][5[]STOP_METHOD_ARG[]dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
547 ifelse($][5, [], [ |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
548 return Null(); |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
549 ], [dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
550 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
551 dnl Modify returned object |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
552 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
553 ifdef([MOD], [ |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
554 MOD[](self, _ret_val); |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
555 ])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
556 return _ret_val; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
557 ])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
558 } |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
559 static Persistent<FunctionTemplate> PROJ_PREFIX[]$1[]_temp; |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
560 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
561 static void |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
562 PROJ_PREFIX[]$1[]_init(void) { |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
563 Handle<FunctionTemplate> func_temp; |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
564 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
565 func_temp = FunctionTemplate::New(PROJ_PREFIX[]$1); |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
566 PROJ_PREFIX[]$1[]_temp = Persistent<FunctionTemplate>::New(func_temp); |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
567 } |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
568 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
569 ifelse($6, [], [], [dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
570 foreach([ITER], $6, [EXPAND([undefine]ITER)])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
571 ])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
572 dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
573 ]) |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
574 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
575 divert([])dnl |