annotate tools/gen_v8_binding.m4 @ 1134:bd0cfb8666b8

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