changeset 668:916dc9723086

Fix issue of return value of code generated
author Thinker K.F. Li <thinker@branda.to>
date Wed, 04 Aug 2010 22:07:13 +0800
parents 7315c6e953c3
children eeea1b593a2f
files tools/gen_v8_binding.m4
diffstat 1 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/gen_v8_binding.m4	Wed Aug 04 21:58:10 2010 +0800
+++ b/tools/gen_v8_binding.m4	Wed Aug 04 22:07:13 2010 +0800
@@ -369,11 +369,13 @@
     STRUCT_TYPE *obj = (STRUCT_TYPE *)UNWRAP(self);
     const char *_err = NULL;
 START_METHOD_RET_VAL[]$2[]STOP_METHOD_ARG[]dnl
+    Handle<Value> _ret_val;
 
     _ret = $1(obj, self, index, &_err);
     if(_err)
         THROW(_err);
 START_METHOD_RET[]$2[]STOP_METHOD_ARG[]dnl
+    return _ret_val;
 }
 ])
 
@@ -386,6 +388,7 @@
     const char *_err = NULL;
 START_VAR([in_value])[]$2[]STOP_METHOD_ARG[]dnl
 START_METHOD_RET_VAL[]$2[]STOP_METHOD_ARG[]dnl
+    Handle<Value> _ret_val;
 
     if(START_TYPE_CHK(value)[]![]$2[]STOP_METHOD_ARG)
         THROW("Invalid value type");
@@ -394,6 +397,7 @@
     _ret = $1(obj, self, index, in_value, &_err);
     if(_err) THROW(_err);
 START_METHOD_RET[]$2[]STOP_METHOD_ARG[]dnl
+    return _ret_val;
 }
 ])
 
@@ -503,9 +507,15 @@
 ])
 
 dnl
-dnl FUNCTION(func_name, real_func, arguments, arguement_count, return_type)
+dnl FUNCTION(func_name, real_func, arguments, arguement_count,
+dnl          return_type, options)
 dnl
 define([FUNCTION], [dnl
+dnl
+ifelse($6, [], [], [dnl
+foreach([ITER], $6, [EXPAND([define]ITER)])dnl
+])dnl
+dnl
 /* **************************************************
  * [FUNCTION]: $1
  * Generated by gen_v8_binding.m4
@@ -517,6 +527,7 @@
     const char *_err = NULL;
 foreach([ITER], ($3), [START_METHOD_ARG_VAR[]ITER[]STOP_METHOD_ARG])dnl
 START_METHOD_RET_VAL[]$5[]STOP_METHOD_ARG[]dnl
+    Handle<Value> _ret_val;
     
     if(argc != $4)
         THROW("Invalid number of arguments (!=$][4)");
@@ -535,6 +546,14 @@
 START_METHOD_RET[]$][5[]STOP_METHOD_ARG[]dnl
 ifelse($][5, [], [
     return Null();
+], [dnl
+dnl
+dnl Modify returned object
+dnl
+ifdef([MOD], [
+    MOD[](self, _ret_val);
+])dnl
+    return _ret_val;
 ])dnl
 }
 static Persistent<FunctionTemplate> PROJ_PREFIX[]$1[]_temp;
@@ -546,6 +565,11 @@
     func_temp = FunctionTemplate::New(PROJ_PREFIX[]$1);
     PROJ_PREFIX[]$1[]_temp = Persistent<FunctionTemplate>::New(func_temp);
 }
+dnl
+ifelse($6, [], [], [dnl
+foreach([ITER], $6, [EXPAND([undefine]ITER)])dnl
+])dnl
+dnl
 ])
 
 divert([])dnl