annotate tools/gen_v8_binding.m4 @ 719:1b6856fda760

Collect mbnames and mapping to object through mb_rt.mbnames
author Thinker K.F. Li <thinker@branda.to>
date Sun, 15 Aug 2010 01:41:10 +0800
parents 4a38e571cfce
children 00a8c8a9e157
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
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
12 define([VARFRAME], [dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
13 pushdef([_FRAME_VARS], [])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
14 ])
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
15
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
16 define([UNVARFRAME], [dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
17 EXPAND(_FRAME_VARS)dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
18 popdef([_FRAME_VARS])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
19 ])
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
20
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
21 define([fdefine], [dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
22 pushdef([$1], [$2])dnl
678
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
23 define([_FRAME_VARS], QUOTE(_FRAME_VARS[popdef([$1])]))dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
24 ])
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
25
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 define([COUNT],[ifelse([$*],[],0,[$#])])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 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
29
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
30 define([EXPAND], [$1])
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
31
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 define([PROJ_PREFIX], [xnjsmb_])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 define([START_ACCESSOR], [dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 divert([-1])dnl
678
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
36 VARFRAME[]dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
37 fdefine([INT], [
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 static Handle<Value>
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 ]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
40 Handle<Object> self = info.This();
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
41 STRUCT_TYPE *data;
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
42
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
43 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
44 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
45 }
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 static void
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 ]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
49 Local<Value> value,
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 const AccessorInfo &info) {
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 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
52 STRUCT_TYPE *data;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 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
55 data->$][1 = value->Int32Value();
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 }
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 ])
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
58 fdefine([NUMBER], [
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
59 static Handle<Value>
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
60 ]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
61 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
62 STRUCT_TYPE *data;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
63
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
64 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
65 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
66 }
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
67
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
68 static void
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
69 ]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
70 Local<Value> value,
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
71 const AccessorInfo &info) {
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
72 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
73 STRUCT_TYPE *data;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
74
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
75 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
76 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
77 }
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
78 ])
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
79 fdefine([OBJ], [
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 static Handle<Value>
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
81 ]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
82 Handle<Object> self = info.This();
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
83 STRUCT_TYPE *data;
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
84
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
85 data = (STRUCT_TYPE *)UNWRAP(self);
657
32d0eef1ee46 Force type-casting for member variables.
Thinker K.F. Li <thinker@branda.to>
parents: 651
diff changeset
86 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
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 static void
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90 ]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
91 Local<Value> value,
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
92 const AccessorInfo &info) {
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
93 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
94 Handle<Object> obj;
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
95 $][3 *v;
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
96 STRUCT_TYPE *data;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
97
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
98 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
99 obj = value->ToObject();
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
100 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
101 data->$][1 = v;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
102 }
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
103 ])
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
104 fdefine([ARRAY], [
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
105 static Handle<Value>
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
106 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) {
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
107 Handle<Object> self = info.This();
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
108 STRUCT_TYPE *data;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
109
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
110 data = (STRUCT_TYPE *)UNWRAP(self);
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
111 return data->$][1;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
112 }
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
113
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
114 static void
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
115 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property,
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
116 Local<Value> value,
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
117 const AccessorInfo &info) {
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
118 Handle<Object> self = info.This();
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
119 Handle<Object> obj;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
120 STRUCT_TYPE *data;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
121
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
122 data = (STRUCT_TYPE *)UNWRAP(self);
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
123 data->$][1 = value;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
124 }
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
125 ])
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
126 fdefine([STR], [
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
127 static Handle<Value>
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
128 ]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
129 Handle<Object> self = info.This();
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
130 STRUCT_TYPE *data;
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
131
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
132 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
133 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
134 }
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
135
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
136 static void
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
137 ]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
138 Local<Value> value,
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
139 const AccessorInfo &info) {
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
140 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
141 STRUCT_TYPE *data;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
142
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
143 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
144 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
145 free(data->$][1);
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
146 data->$][1 = strdup(*utf8);
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
147 }
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
148 ])
674
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
149 dnl
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
150 dnl ACCESSOR(name, getter, setter)
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
151 dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
152 fdefine([ACCESSOR], [
674
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
153 static Handle<Value>
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
154 ]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
155 Handle<Object> self = info.This();
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
156 Handle<Value> _ret;
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
157 STRUCT_TYPE *data;
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
158 const char *err = NULL;
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
159
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
160 data = (STRUCT_TYPE *)UNWRAP(self);
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
161 _ret = $][2(self, data, &err);
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
162 if(err)
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
163 THROW(err);
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
164 return _ret;
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
165 }
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
166
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
167 static void
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
168 ]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
169 Local<Value> value,
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
170 const AccessorInfo &info) {
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
171 Handle<Object> self = info.This();
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
172 STRUCT_TYPE *data;
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
173 const char *err = NULL;
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
174
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
175 data = (STRUCT_TYPE *)UNWRAP(self);
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
176 $][3(self, data, value, &err);
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
177 if(err)
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
178 THROW_noret(err);
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
179 }
5c8387fd123e Support user defined accessors on binding generated
Thinker K.F. Li <thinker@branda.to>
parents: 670
diff changeset
180 ])
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
181 divert([])dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
182 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
183
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
184 define([STOP_ACCESSOR], [dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
185 divert([-1])dnl
678
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
186 UNVARFRAME[]dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
187 divert([])dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
188 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
189
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
190 define([SET_ACCESSSOR], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
191 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
192 fdefine([INT], [$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
193 fdefine([NUMBER], [$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
194 fdefine([OBJ], [$][1])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
195 fdefine([ARRAY], [$][1])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
196 fdefine([STR], [$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
197 fdefine([ACCESSOR], [$][1])dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
198 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
199 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
200 PROJ_PREFIX[]STRUCT_NAME[]_set_[]$1);
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
201 UNVARFRAME[]dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
202 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
203
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
204 define([START_METHOD_ARG_VAR], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
205 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
206 fdefine([INT], [dnl
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
207 int arg_$][1;
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
208 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
209 fdefine([NUMBER], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
210 double arg_$][1;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
211 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
212 fdefine([OBJ], [dnl
663
974d98233eab Fix mis-using of arguments of OBJ() argument type
Thinker K.F. Li <thinker@branda.to>
parents: 660
diff changeset
213 $][3 *arg_$][1;
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
214 ])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
215 fdefine([ARRAY], [dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
216 Handle<Value> arg_$][1;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
217 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
218 fdefine([STR], [dnl
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
219 char *arg_$][1;
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
220 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
221 fdefine([FUNC], [dnl
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
222 Handle<Function> arg_$][1;
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
223 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
224 fdefine([SELF], [])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
225 fdefine([ERR], [])dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
226 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
227
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
228 define([START_METHOD_ARG_TYPE_CHK], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
229 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
230 fdefine([INT], [ ||
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
231 !args[[i++]]->IsInt32()])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
232 fdefine([NUMBER], [ ||
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
233 !args[[i++]]->IsNumber()])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
234 fdefine([OBJ], [ ||
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
235 !args[[i++]]->IsObject()])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
236 fdefine([ARRAY], [ ||
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
237 !args[[i++]]->IsArray()])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
238 fdefine([STR], [ ||
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
239 !args[[i++]]->IsString()])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
240 fdefine([FUNC], [ ||
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
241 !args[[i++]]->IsFunction()])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
242 fdefine([SELF], [])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
243 fdefine([ERR], [])dnl
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
244 ])
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
245
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
246 define([START_TYPE_CHK], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
247 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
248 fdefine([INT], [$1->IsInt32()])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
249 fdefine([NUMBER], [$1->IsNumber()])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
250 fdefine([OBJ], [$1->IsObject()])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
251 fdefine([ARRAY], [$1->IsArray()])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
252 fdefine([STR], [$1->IsString()])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
253 fdefine([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
254 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
255
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
256 define([START_METHOD_ARG_ASSIGN], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
257 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
258 fdefine([INT], [dnl
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
259 arg_$][1 = args[[i++]]->Int32Value();
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
260 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
261 fdefine([NUMBER], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
262 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
263 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
264 fdefine([OBJ], [dnl
663
974d98233eab Fix mis-using of arguments of OBJ() argument type
Thinker K.F. Li <thinker@branda.to>
parents: 660
diff changeset
265 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
266 ])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
267 fdefine([ARRAY], [dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
268 arg_$][1 = args[[i++]];
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
269 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
270 fdefine([STR], [dnl
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
271 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
272 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
273 fdefine([FUNC], [dnl
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
274 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
275 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
276 fdefine([SELF], [])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
277 fdefine([ERR], [])dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
278 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
279
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
280 define([START_VALUE_ASSIGN], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
281 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
282 fdefine([INT], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
283 $1 = $2->Int32Value();
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
284 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
285 fdefine([NUMBER], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
286 $1 = $2->NumberValue();
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
287 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
288 fdefine([OBJ], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
289 $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
290 ])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
291 fdefine([ARRAY], [dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
292 $1 = $2;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
293 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
294 fdefine([STR], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
295 $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
296 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
297 fdefine([FUNC], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
298 $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
299 ])dnl
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
300 ])
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
301
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
302 define([START_METHOD_ARG_PASS], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
303 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
304 fdefine([INT], [arg_$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
305 fdefine([NUMBER], [arg_$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
306 fdefine([OBJ], [arg_$][1])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
307 fdefine([ARRAY], [arg_$][1])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
308 fdefine([STR], [arg_$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
309 fdefine([FUNC], [arg_$][1])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
310 fdefine([SELF], [self])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
311 fdefine([ERR], [&_err])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
312 fdefine([VAL], [&_err])dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
313 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
314
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
315 define([START_METHOD_RET_VAL], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
316 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
317 fdefine([INT], [dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
318 int _ret;
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
319 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
320 fdefine([NUMBER], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
321 double _ret;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
322 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
323 fdefine([OBJ], [dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
324 $][2 *_ret;
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
325 ])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
326 fdefine([ARRAY], [dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
327 Handle<Value> _ret;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
328 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
329 fdefine([STR], [dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
330 char *_ret;
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
331 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
332 fdefine([FUNC], [dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
333 Handle<Function> _ret;
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
334 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
335 fdefine([VAL], [dnl
670
f0b4fbcd1c51 Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents: 669
diff changeset
336 Handle<Value> _ret;
f0b4fbcd1c51 Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents: 669
diff changeset
337 ])dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
338 ])
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
339
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
340 define([START_VAR], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
341 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
342 fdefine([INT], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
343 int $1;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
344 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
345 fdefine([NUMBER], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
346 double $1;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
347 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
348 fdefine([OBJ], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
349 $][2 *$1;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
350 ])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
351 fdefine([ARRAY], [dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
352 Handle<Value> *$1;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
353 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
354 fdefine([STR], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
355 char *$1;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
356 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
357 fdefine([FUNC], [dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
358 Handle<Function> $1;
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
359 ])dnl
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
360 ])
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
361
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
362 define([START_METHOD_RET_ASSIGN], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
363 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
364 fdefine([INT], [_ret = (int)])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
365 fdefine([NUMBER], [_ret = (double)])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
366 fdefine([OBJ], [_ret = ($][2 *)])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
367 fdefine([ARRAY], [_ret = ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
368 fdefine([STR], [_ret = (char *)])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
369 fdefine([FUNC], [_ret = ])dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
370 fdefine([VAL], [_ret = ])dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
371 ])
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
372
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
373 define([START_METHOD_RET], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
374 VARFRAME[]dnl
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
375 fdefine([INT], [
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
376 _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
377 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
378 fdefine([NUMBER], [
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
379 _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
380 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
381 fdefine([OBJ], [
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
382 _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
383 ])dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
384 fdefine([ARRAY], [
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
385 _ret_val = _ret;
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
386 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
387 fdefine([STR], [
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
388 _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
389 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
390 fdefine([FUNC], [
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
391 _rt_val = _ret;
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
392 ])dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
393 fdefine([VAL], [
670
f0b4fbcd1c51 Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents: 669
diff changeset
394 _rt_val = _ret;
f0b4fbcd1c51 Support encapsulated method & function return Handle<Value> directly
Thinker K.F. Li <thinker@branda.to>
parents: 669
diff changeset
395 ])dnl
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
396 ])
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
397
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
398 define([STOP_METHOD_ARG], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
399 UNVARFRAME[]dnl
648
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
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
402 define([START_METHOD], [dnl
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
403 dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
404 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
405 dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
406 define([METHOD], [
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
407 VARFRAME[]dnl
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
408 dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
409 ifelse($][6, [], [], [dnl
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
410 foreach([ITER], ]$][6[, [EXPAND([fdefine]ITER)])dnl
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
411 ])dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
412 dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
413 static Handle<Value>
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
414 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
415 HandleScope scope;
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
416 int i;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
417 int argc = args.Length();
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
418 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
419 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
420 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
421 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
422 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
423 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
424
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
425 if(argc != $][4)
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
426 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
427 i = 0;
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
428 if(0[]dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
429 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
430 THROW("Invalid argument type");
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
431
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
432 i = 0;
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
433 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
434
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
435 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
436 if(_err)
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
437 THROW(_err);
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
438 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
439 ifelse($][5, [], [
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
440 return Null();
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
441 ], [dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
442 dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
443 dnl Modify returned object
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
444 dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
445 ifdef([MOD], [
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
446 MOD[](self, _ret_val);
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
447 ])dnl
669
eeea1b593a2f Add handle scope for function and method generated
Thinker K.F. Li <thinker@branda.to>
parents: 668
diff changeset
448 scope.Close(_ret_val);
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
449 return _ret_val;
649
2030e5d9f7f7 Support return value for methodes of JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 648
diff changeset
450 ])dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
451 }
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
452 UNVARFRAME[]dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
453 ])dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
454 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
455
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
456 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
457
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
458 define([SET_METHOD], [dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
459 define([METHOD], [dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
460 SET(proto_temp, "$][1",
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
461 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
462 ])dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
463 $1[]dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
464 undefine([METHOD])dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
465 ])
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
466
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
467 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
468 static Handle<Value>
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
469 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
470 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
471 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
472 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
473 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
474 Handle<Value> _ret_val;
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
475
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
476 _ret = $1(obj, self, index, &_err);
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
477 if(_err)
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
478 THROW(_err);
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
479 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
480 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
481 }
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
482 ])
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
483
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
484 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
485 static Handle<Value>
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
486 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
487 const AccessorInfo &info) {
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
488 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
489 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
490 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
491 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
492 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
493 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
494
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
495 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
496 THROW("Invalid value type");
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
497
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
498 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
499 _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
500 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
501 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
502 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
503 }
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
504 ])
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
505
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
506 define([INSTALL_INDEX_FUNCTIONS],[dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
507 define([FIRST], [$][1])dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
508 ifdef([GET_INDEX], [ifdef([SET_INDEX], [dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
509 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
510 PROJ_PREFIX[]STRUCT_NAME[]_set_index);
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
511 ], [dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
512 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
513 ])])dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
514 undefine([FIRST])dnl
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
515 ])
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
516
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
517 define([CTOR_INTERNAL], [dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
518 int argc = args.Length();
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
519 Handle<Object> self = args.This();
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
520 $4 *obj;
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
521 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
522 int i;
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
523
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
524 if(argc != $3)
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
525 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
526 i = 0;
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
527 if(0]dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
528 [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
529 THROW("Invalid argument type");
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
530
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
531 i = 0;
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
532 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
533
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
534 define([SEP], [])dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
535 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
536
678
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
537 WRAP(self, obj);]
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
538 ifdef([STMOD], [
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
539 STMOD(self, obj);
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
540 ])dnl
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
541 )
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
542
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
543 dnl
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
544 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
545 dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
546 define([STRUCT], [dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
547 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
548 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
549 dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
550 VARFRAME[]dnl
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
551 ifelse([$5], [], [], [dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
552 foreach([ITER], $5, [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
553 EXPAND([fdefine]ITER)[]dnl
664
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
554 ])dnl
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
555 ])dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
556 dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
557 [
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
558 /* **************************************************
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
559 * STRUCT: $1
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
560 * 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
561 */
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
562 static Handle<Value>
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
563 ]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
564 ]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
565 return Null();
08fd45d119c9 Binding generator supports self-init constructor function
Thinker K.F. Li <thinker@branda.to>
parents: 663
diff changeset
566 [}
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
567
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
568 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
569
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
570 static Handle<Value>
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
571 ]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
572 Handle<Object> obj;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
573 Handle<Function> func;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
574
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
575 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
576 obj = func->NewInstance();
678
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
577 WRAP(obj, data);]
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
578 ifdef([STMOD], [
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
579 STMOD[(obj, data)];
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
580 ])dnl
40ba8915edc7 Support modifier function after creating a new object
Thinker K.F. Li <thinker@branda.to>
parents: 677
diff changeset
581 [ return obj;
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
582 }
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
583 ]dnl
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
584 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
585 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
586 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
587 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
588 [
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
589 static void
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
590 ]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
591 Handle<FunctionTemplate> func_temp;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
592 Handle<ObjectTemplate> inst_temp;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
593 Handle<ObjectTemplate> proto_temp;
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
594
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
595 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
596 func_temp->SetClassName(String::New("]STRUCT_NAME["));
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
597 ]ifdef([INHERIT], [dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
598 func_temp->Inherit(]PROJ_PREFIX[]INHERIT[_temp);
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
599 ])dnl
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
600 [ inst_temp = func_temp->InstanceTemplate();
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
601 inst_temp->SetInternalFieldCount(1);
682
4a38e571cfce Add ARRAY argument type and INHERIT supporting for STRUCT
Thinker K.F. Li <thinker@branda.to>
parents: 678
diff changeset
602 ]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
603 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
604
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
605 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
606 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
607
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
608 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
609 }]dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
610 dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
611 UNVARFRAME[]dnl
659
d4aa1cce0af7 Supporting setter/Getter of index of objects for JS
Thinker K.F. Li <thinker@branda.to>
parents: 657
diff changeset
612 dnl
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
613 ])
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
614
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
615 dnl
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
616 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
617 dnl return_type, options)
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
618 dnl
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
619 define([FUNCTION], [dnl
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
620 dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
621 VARFRAME[]dnl
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
622 ifelse($6, [], [], [dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
623 foreach([ITER], $6, [EXPAND([fdefine]ITER)])dnl
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
624 ])dnl
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
625 dnl
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
626 /* **************************************************
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
627 * [FUNCTION]: $1
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
628 * Generated by gen_v8_binding.m4
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
629 */
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
630 static Handle<Value>
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
631 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
632 HandleScope scope;
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
633 int argc = args.Length();
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
634 int i;
660
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
635 const char *_err = NULL;
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
636 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
637 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
638 Handle<Value> _ret_val;
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
639
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
640 if(argc != $4)
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
641 THROW("Invalid number of arguments (!=$][4)");
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
642 i = 0;
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
643 if(0]dnl
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
644 [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
645 THROW("Invalid argument type");
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
646
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
647 i = 0;
651
aa52883534fc Code generated by generator can be built
Thinker K.F. Li <thinker@branda.to>
parents: 650
diff changeset
648 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
649
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
650 define([SEP], [])dnl
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
651 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
652 if(_err)
dde4e3cc9529 Enabling error handling on binding
Thinker K.F. Li <thinker@branda.to>
parents: 659
diff changeset
653 THROW(_err);
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
654 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
655 ifelse($][5, [], [
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
656 return Null();
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
657 ], [dnl
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
658 dnl
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
659 dnl Modify returned object
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
660 dnl
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
661 ifdef([MOD], [
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
662 MOD[](self, _ret_val);
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
663 ])dnl
669
eeea1b593a2f Add handle scope for function and method generated
Thinker K.F. Li <thinker@branda.to>
parents: 668
diff changeset
664 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
665 return _ret_val;
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
666 ])dnl
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
667 }
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
668 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
669
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
670 static void
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
671 PROJ_PREFIX[]$1[]_init(void) {
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
672 Handle<FunctionTemplate> func_temp;
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
673
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
674 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
675 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
676 }
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
677 dnl
677
efa666d118e5 Use variable frame to maintain macros
Thinker K.F. Li <thinker@branda.to>
parents: 674
diff changeset
678 UNVARFRAME[]dnl
668
916dc9723086 Fix issue of return value of code generated
Thinker K.F. Li <thinker@branda.to>
parents: 664
diff changeset
679 dnl
650
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
680 ])
123e7eeff10c Generate JS binding for a function
Thinker K.F. Li <thinker@branda.to>
parents: 649
diff changeset
681
648
e13dbfd37eab JS binding generator and observer definition with the generator
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
682 divert([])dnl