# HG changeset patch # User Thinker K.F. Li # Date 1281027040 -28800 # Node ID 5c8387fd123ee7cf1e77a37e6ee58c9d68729df1 # Parent f5d2ff34c6f6d77c63aef1d5aa6b4212dda0bd6a Support user defined accessors on binding generated diff -r f5d2ff34c6f6 -r 5c8387fd123e tools/gen_v8_binding.m4 --- a/tools/gen_v8_binding.m4 Thu Aug 05 23:33:46 2010 +0800 +++ b/tools/gen_v8_binding.m4 Fri Aug 06 00:50:40 2010 +0800 @@ -109,6 +109,38 @@ data->$][1 = strdup(*utf8); } ]) +dnl +dnl ACCESSOR(name, getter, setter) +dnl + define([ACCESSOR], [ +static Handle +]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local property, const AccessorInfo &info) { + Handle self = info.This(); + Handle _ret; + STRUCT_TYPE *data; + const char *err = NULL; + + data = (STRUCT_TYPE *)UNWRAP(self); + _ret = $][2(self, data, &err); + if(err) + THROW(err); + return _ret; +} + +static void +]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local property, + Local value, + const AccessorInfo &info) { + Handle self = info.This(); + STRUCT_TYPE *data; + const char *err = NULL; + + data = (STRUCT_TYPE *)UNWRAP(self); + $][3(self, data, value, &err); + if(err) + THROW_noret(err); +} +]) divert([])dnl ]) @@ -118,6 +150,7 @@ undefine([NUMBER]) undefine([OBJ]) undefine([STR]) +undefine([ACCESSOR]) divert([])dnl ]) @@ -126,6 +159,7 @@ define([NUMBER], [$][1])dnl define([OBJ], [$][1])dnl define([STR], [$][1])dnl +define([ACCESSOR], [$][1])dnl inst_temp->SetAccessor(String::New("$1"), PROJ_PREFIX[]STRUCT_NAME[]_get_[]$1, PROJ_PREFIX[]STRUCT_NAME[]_set_[]$1); @@ -133,6 +167,7 @@ undefine([NUMBER])dnl undefine([OBJ])dnl undefine([STR])dnl +undefine([ACCESSOR])dnl ]) define([START_METHOD_ARG_VAR], [dnl