Mercurial > MadButterfly
annotate tools/gen_v8_binding.m4 @ 674:5c8387fd123e
Support user defined accessors on binding generated
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 06 Aug 2010 00:50:40 +0800 |
parents | f0b4fbcd1c51 |
children | efa666d118e5 |
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 ]) |
674
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
112 dnl |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
113 dnl ACCESSOR(name, getter, setter) |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
114 dnl |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
115 define([ACCESSOR], [ |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
116 static Handle<Value> |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
117 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) { |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
118 Handle<Object> self = info.This(); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
119 Handle<Value> _ret; |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
120 STRUCT_TYPE *data; |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
121 const char *err = NULL; |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
122 |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
123 data = (STRUCT_TYPE *)UNWRAP(self); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
124 _ret = $][2(self, data, &err); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
125 if(err) |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
126 THROW(err); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
127 return _ret; |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
128 } |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
129 |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
130 static void |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
131 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property, |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
132 Local<Value> value, |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
133 const AccessorInfo &info) { |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
134 Handle<Object> self = info.This(); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
135 STRUCT_TYPE *data; |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
136 const char *err = NULL; |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
137 |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
138 data = (STRUCT_TYPE *)UNWRAP(self); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
139 $][3(self, data, value, &err); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
140 if(err) |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
141 THROW_noret(err); |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
142 } |
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
143 ]) |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
144 divert([])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
145 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
146 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
147 define([STOP_ACCESSOR], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
148 divert([-1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
149 undefine([INT]) |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
150 undefine([NUMBER]) |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
151 undefine([OBJ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
152 undefine([STR]) |
674
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
153 undefine([ACCESSOR]) |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
154 divert([])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
155 ]) |
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 define([SET_ACCESSSOR], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
158 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
|
159 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
|
160 define([OBJ], [$][1])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
161 define([STR], [$][1])dnl |
674
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
162 define([ACCESSOR], [$][1])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 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
|
167 undefine([NUMBER])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
168 undefine([OBJ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
169 undefine([STR])dnl |
674
5c8387fd123e
Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents:
670
diff
changeset
|
170 undefine([ACCESSOR])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
171 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
172 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
173 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
|
174 define([INT], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
175 int arg_$][1; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
176 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
177 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
178 double arg_$][1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
179 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
180 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
|
181 $][3 *arg_$][1; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
182 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
183 define([STR], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
184 char *arg_$][1; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
185 ])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
186 define([FUNC], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
187 Handle<Function> arg_$][1; |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
188 ])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
189 define([SELF], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
190 define([ERR], [])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
191 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
192 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
193 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
|
194 define([INT], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
195 !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
|
196 define([NUMBER], [ || |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
197 !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
|
198 define([OBJ], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
199 !args[[i++]]->IsObject()])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
200 define([STR], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
201 !args[[i++]]->IsString()])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
202 define([FUNC], [ || |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
203 !args[[i++]]->IsFunction()])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
204 define([SELF], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
205 define([ERR], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
206 ]) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
207 |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
208 define([START_TYPE_CHK], [dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
209 define([INT], [$1->IsInt32()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
210 define([NUMBER], [$1->IsNumber()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
211 define([OBJ], [$1->IsObject()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
212 define([STR], [$1->IsString()])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
213 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
|
214 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
215 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
216 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
|
217 define([INT], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
218 arg_$][1 = args[[i++]]->Int32Value(); |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
219 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
220 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
221 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
|
222 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
223 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
|
224 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
|
225 ])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
226 define([STR], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
227 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
|
228 ])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
229 define([FUNC], [dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
230 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
|
231 ])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
232 define([SELF], [])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
233 define([ERR], [])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
234 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
235 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
236 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
|
237 define([INT], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
238 $1 = $2->Int32Value(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
239 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
240 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
241 $1 = $2->NumberValue(); |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
242 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
243 define([OBJ], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
244 $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
|
245 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
246 define([STR], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
247 $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
|
248 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
249 define([FUNC], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
250 $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
|
251 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
252 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
253 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
254 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
|
255 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
|
256 define([NUMBER], [arg_$][1])dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
257 define([OBJ], [arg_$][1])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
258 define([STR], [arg_$][1])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
259 define([FUNC], [arg_$][1])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
260 define([SELF], [self])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
261 define([ERR], [&_err])dnl |
670
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
262 define([VAL], [&_err])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
263 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
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_VAL], [dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
266 define([INT], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
267 int _ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
268 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
269 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
270 double _ret; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
271 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
272 define([OBJ], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
273 $][2 *_ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
274 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
275 define([STR], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
276 char *_ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
277 ])dnl |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
278 define([FUNC], [dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
279 Handle<Function> _ret; |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
280 ])dnl |
670
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
281 define([VAL], [dnl |
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
282 Handle<Value> _ret; |
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
283 ])dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
284 ]) |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
285 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
286 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
|
287 define([INT], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
288 int $1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
289 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
290 define([NUMBER], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
291 double $1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
292 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
293 define([OBJ], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
294 $][2 *$1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
295 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
296 define([STR], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
297 char *$1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
298 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
299 define([FUNC], [dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
300 Handle<Function> $1; |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
301 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
302 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
303 |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 define([OBJ], [_ret = ($][2 *)])dnl |
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
308 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
|
309 define([FUNC], [_ret = ])dnl |
670
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
310 define([VAL], [_ret = ])dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
311 ]) |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
312 |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
313 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
|
314 define([INT], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
315 _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
|
316 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
317 define([NUMBER], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
318 _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
|
319 ])dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
320 define([OBJ], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
321 _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
|
322 ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
323 define([STR], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
324 _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
|
325 ])dnl |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
326 define([FUNC], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
327 _rt_val = _ret; |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
328 ])dnl |
670
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
329 define([VAL], [ |
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
330 _rt_val = _ret; |
f0b4fbcd1c51
Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents:
669
diff
changeset
|
331 ])dnl |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
332 ]) |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
333 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
334 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
|
335 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
|
336 undefine([NUMBER])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
337 undefine([OBJ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
338 undefine([STR])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
339 undefine([FUNC])dnl |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
340 undefine([SELF])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
341 undefine([ERR])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
342 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
343 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
344 define([START_METHOD], [dnl |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
345 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
346 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
|
347 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
348 define([METHOD], [ |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
349 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
350 ifelse($][6, [], [], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
351 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
|
352 ])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
353 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
354 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
355 PROJ_PREFIX[]STRUCT_NAME[]_$][1(const Arguments &args) { |
669
eeea1b593a2f
Add handle scope for function and method generated
Thinker K.F. Li <thinker@branda.to>
parents:
668
diff
changeset
|
356 HandleScope scope; |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
357 int i; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
358 int argc = args.Length(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
359 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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
366 if(argc != $][4) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
367 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
|
368 i = 0; |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
369 if(0[]dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
370 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
|
371 THROW("Invalid argument type"); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
372 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
373 i = 0; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
374 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
|
375 |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
376 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
|
377 if(_err) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
378 THROW(_err); |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
379 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
|
380 ifelse($][5, [], [ |
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
381 return Null(); |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
382 ], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
383 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
384 dnl Modify returned object |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
385 dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
386 ifdef([MOD], [ |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
387 MOD[](self, _ret_val); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
388 ])dnl |
669
eeea1b593a2f
Add handle scope for function and method generated
Thinker K.F. Li <thinker@branda.to>
parents:
668
diff
changeset
|
389 scope.Close(_ret_val); |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
390 return _ret_val; |
649
2030e5d9f7f7
Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
648
diff
changeset
|
391 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
392 } |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
393 ifelse($][6, [], [], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
394 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
|
395 ])dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
396 ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
397 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
398 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
399 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
|
400 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
401 define([SET_METHOD], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
402 define([METHOD], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
403 SET(proto_temp, "$][1", |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
404 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
|
405 ])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
406 $1[]dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
407 undefine([METHOD])dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
408 ]) |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
409 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
410 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
|
411 static Handle<Value> |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
412 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
|
413 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
|
414 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
|
415 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
|
416 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
|
417 Handle<Value> _ret_val; |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
418 |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
419 _ret = $1(obj, self, index, &_err); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
420 if(_err) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
421 THROW(_err); |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
422 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
|
423 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
|
424 } |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
425 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
426 |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
427 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
|
428 static Handle<Value> |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
429 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
|
430 const AccessorInfo &info) { |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
438 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
|
439 THROW("Invalid value type"); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
440 |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
441 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
|
442 _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
|
443 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
|
444 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
|
445 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
|
446 } |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
447 ]) |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
448 |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
449 define([INSTALL_INDEX_FUNCTIONS],[dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
450 define([FIRST], [$][1])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
451 ifdef([GET_INDEX], [ifdef([SET_INDEX], [dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
452 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
|
453 PROJ_PREFIX[]STRUCT_NAME[]_set_index); |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
454 ], [dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
455 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
|
456 ])])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
457 undefine([FIRST])dnl |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
458 ]) |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
459 |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
460 define([CTOR_INTERNAL], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
461 int argc = args.Length(); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
462 Handle<Object> self = args.This(); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
463 $4 *obj; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
464 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
|
465 int i; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
466 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
467 if(argc != $3) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
468 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
|
469 i = 0; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
470 if(0]dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
471 [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
|
472 THROW("Invalid argument type"); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
473 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
474 i = 0; |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
475 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
|
476 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
477 define([SEP], [])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
478 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
|
479 |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
480 WRAP(self, obj); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
481 ]) |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
482 |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
483 dnl |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
484 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
|
485 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
486 define([STRUCT], [dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
487 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
|
488 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
|
489 dnl |
664
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
490 ifelse([$5], [], [], [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
491 foreach([ITER], $5, [dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
492 EXPAND([define]ITER)[]dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
493 ])dnl |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
494 ])dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
495 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
496 [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
497 /* ************************************************** |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
498 * STRUCT: $1 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
499 * 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
|
500 */ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
501 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
502 ]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
|
503 ]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
|
504 return Null(); |
08fd45d119c9
Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents:
663
diff
changeset
|
505 [} |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
506 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
507 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
|
508 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
509 static Handle<Value> |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
510 ]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
|
511 Handle<Object> obj; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
512 Handle<Function> func; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
513 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
514 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
|
515 obj = func->NewInstance(); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
516 WRAP(obj, data); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
517 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
518 return obj; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
519 } |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
520 ]dnl |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
521 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
|
522 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
|
523 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
|
524 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
|
525 [ |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
526 static void |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
527 ]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
|
528 Handle<FunctionTemplate> func_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
529 Handle<ObjectTemplate> inst_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
530 Handle<ObjectTemplate> proto_temp; |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
531 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
532 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
|
533 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
|
534 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
|
535 inst_temp->SetInternalFieldCount(1); |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
536 ] |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
537 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
|
538 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
|
539 |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
540 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
|
541 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
|
542 |
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
543 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
|
544 }]dnl |
659
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
545 dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
546 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
|
547 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
|
548 DUMMY[]dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
549 undefine([DUMMY])])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
550 ])dnl |
d4aa1cce0af7
Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents:
657
diff
changeset
|
551 dnl |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
552 ]) |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
553 |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
554 dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
555 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
|
556 dnl return_type, options) |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
557 dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
558 define([FUNCTION], [dnl |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
559 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
560 ifelse($6, [], [], [dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
561 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
|
562 ])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
563 dnl |
650
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 * [FUNCTION]: $1 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
566 * Generated by gen_v8_binding.m4 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
567 */ |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
568 static Handle<Value> |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
569 PROJ_PREFIX[]$1(const Arguments &args) { |
669
eeea1b593a2f
Add handle scope for function and method generated
Thinker K.F. Li <thinker@branda.to>
parents:
668
diff
changeset
|
570 HandleScope scope; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
571 int argc = args.Length(); |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
572 int i; |
660
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
573 const char *_err = NULL; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
574 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
|
575 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
|
576 Handle<Value> _ret_val; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
577 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
578 if(argc != $4) |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
579 THROW("Invalid number of arguments (!=$][4)"); |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
580 i = 0; |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
581 if(0]dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
582 [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
|
583 THROW("Invalid argument type"); |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
584 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
585 i = 0; |
651
aa52883534fc
Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents:
650
diff
changeset
|
586 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
|
587 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
588 define([SEP], [])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
589 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
|
590 if(_err) |
dde4e3cc9529
Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents:
659
diff
changeset
|
591 THROW(_err); |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
592 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
|
593 ifelse($][5, [], [ |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
594 return Null(); |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
595 ], [dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
596 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
597 dnl Modify returned object |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
598 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
599 ifdef([MOD], [ |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
600 MOD[](self, _ret_val); |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
601 ])dnl |
669
eeea1b593a2f
Add handle scope for function and method generated
Thinker K.F. Li <thinker@branda.to>
parents:
668
diff
changeset
|
602 scope.Close(_ret_val); |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
603 return _ret_val; |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
604 ])dnl |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
605 } |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
606 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
|
607 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
608 static void |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
609 PROJ_PREFIX[]$1[]_init(void) { |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
610 Handle<FunctionTemplate> func_temp; |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
611 |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
612 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
|
613 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
|
614 } |
668
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
615 dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
616 ifelse($6, [], [], [dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
617 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
|
618 ])dnl |
916dc9723086
Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents:
664
diff
changeset
|
619 dnl |
650
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
620 ]) |
123e7eeff10c
Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents:
649
diff
changeset
|
621 |
648
e13dbfd37eab
JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
622 divert([])dnl |