comparison tools/gen_v8_binding.m4 @ 649:2030e5d9f7f7

Support return value for methodes of JS binding
author Thinker K.F. Li <thinker@branda.to>
date Thu, 29 Jul 2010 01:37:15 +0800
parents e13dbfd37eab
children 123e7eeff10c
comparison
equal deleted inserted replaced
648:e13dbfd37eab 649:2030e5d9f7f7
132 define([OBJ], [$][1])dnl 132 define([OBJ], [$][1])dnl
133 define([STR], [$][1])dnl 133 define([STR], [$][1])dnl
134 define([FUNC], [$][1])dnl 134 define([FUNC], [$][1])dnl
135 ]) 135 ])
136 136
137 define([START_METHOD_RET_VAL], [dnl
138 define([INT], [
139 int _ret;
140 ])dnl
141 define([OBJ], [
142 $][2 *_ret;
143 ])dnl
144 define([STR], [
145 char *_ret;
146 ])dnl
147 define([FUNC], [
148 Handle<Function> _ret;
149 ])dnl
150 ])
151
152 define([START_METHOD_RET_ASSIGN], [dnl
153 define([INT], [_ret = ])dnl
154 define([OBJ], [_ret = ])dnl
155 define([STR], [_ret = ])dnl
156 define([FUNC], [_ret = ])dnl
157 ])
158
159 define([START_METHOD_RET], [dnl
160 define([INT], [
161 return Integer::New(_ret);
162 ])dnl
163 define([OBJ], [
164 return PROJ_PREFIX[]STRUCT_NAME[]_$][1[]_new(_ret);
165 ])dnl
166 define([STR], [
167 return String::New(_ret);
168 ])dnl
169 define([FUNC], [
170 return _ret;
171 ])dnl
172 ])
173
137 define([STOP_METHOD_ARG], [dnl 174 define([STOP_METHOD_ARG], [dnl
138 undefine([INT])dnl 175 undefine([INT])dnl
139 undefine([OBJ])dnl 176 undefine([OBJ])dnl
140 undefine([STR])dnl 177 undefine([STR])dnl
141 undefine([FUNC])dnl 178 undefine([FUNC])dnl
147 PROJ_PREFIX[]STRUCT_NAME[]_$][1(const Arguments &args) { 184 PROJ_PREFIX[]STRUCT_NAME[]_$][1(const Arguments &args) {
148 int i; 185 int i;
149 int argc = args.Length(); 186 int argc = args.Length();
150 Handle<Object> self = args.This(); 187 Handle<Object> self = args.This();
151 STRUCT_TYPE *_self = (STRUCT_TYPE *)UNWRAP(self); 188 STRUCT_TYPE *_self = (STRUCT_TYPE *)UNWRAP(self);
152 foreach([ITER], $][3, [START_METHOD_ARG_VAR[]ITER[]STOP_METHOD_ARG]) 189 foreach([ITER], $][3, [START_METHOD_ARG_VAR[]ITER[]STOP_METHOD_ARG])dnl
190 START_METHOD_RET_VAL[]$][5[]STOP_METHOD_ARG
153 191
154 if(argc != $][4) 192 if(argc != $][4)
155 THROW("Invalid number of arguments (!=$][4)"); 193 THROW("Invalid number of arguments (!=$][4)");
156 i = 0; 194 i = 0;
157 if(0]dnl 195 if(0]dnl
159 THROW("Invalid argument type"); 197 THROW("Invalid argument type");
160 198
161 i = 0; 199 i = 0;
162 foreach([ITER], $][3, [START_METHOD_ARG_ASSIGN[]ITER[]STOP_METHOD_ARG])) 200 foreach([ITER], $][3, [START_METHOD_ARG_ASSIGN[]ITER[]STOP_METHOD_ARG]))
163 201
164 $][2(_self[]foreach([ITER], $][3, [START_METHOD_ARG_PASS[], ITER[]STOP_METHOD_ARG])); 202 START_METHOD_RET_ASSIGN[]$][5[]STOP_METHOD_ARG[]$][2(_self[]foreach([ITER], $][3, [START_METHOD_ARG_PASS[], ITER[]STOP_METHOD_ARG]));
203 START_METHOD_RET[]$][5[]STOP_METHOD_ARG[]dnl
204 ifelse($][5, [], [
205 return Null();
206 ])dnl
165 } 207 }
166 ])dnl 208 ])dnl
167 ]) 209 ])
168 210
169 define([STOP_METHOD], [undefine([METHOD])]) 211 define([STOP_METHOD], [undefine([METHOD])])