Mercurial > MadButterfly
comparison tools/gen_v8_binding.m4 @ 674:5c8387fd123e
Support user defined accessors on binding generated
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 06 Aug 2010 00:50:40 +0800 |
parents | f0b4fbcd1c51 |
children | efa666d118e5 |
comparison
equal
deleted
inserted
replaced
673:f5d2ff34c6f6 | 674:5c8387fd123e |
---|---|
105 | 105 |
106 data = (STRUCT_TYPE *)UNWRAP(self); | 106 data = (STRUCT_TYPE *)UNWRAP(self); |
107 String::Utf8Value utf8(value->ToString()); | 107 String::Utf8Value utf8(value->ToString()); |
108 free(data->$][1); | 108 free(data->$][1); |
109 data->$][1 = strdup(*utf8); | 109 data->$][1 = strdup(*utf8); |
110 } | |
111 ]) | |
112 dnl | |
113 dnl ACCESSOR(name, getter, setter) | |
114 dnl | |
115 define([ACCESSOR], [ | |
116 static Handle<Value> | |
117 ]PROJ_PREFIX[]STRUCT_NAME[_get_$][1(Local<String> property, const AccessorInfo &info) { | |
118 Handle<Object> self = info.This(); | |
119 Handle<Value> _ret; | |
120 STRUCT_TYPE *data; | |
121 const char *err = NULL; | |
122 | |
123 data = (STRUCT_TYPE *)UNWRAP(self); | |
124 _ret = $][2(self, data, &err); | |
125 if(err) | |
126 THROW(err); | |
127 return _ret; | |
128 } | |
129 | |
130 static void | |
131 ]PROJ_PREFIX[]STRUCT_NAME[_set_$][1(Local<String> property, | |
132 Local<Value> value, | |
133 const AccessorInfo &info) { | |
134 Handle<Object> self = info.This(); | |
135 STRUCT_TYPE *data; | |
136 const char *err = NULL; | |
137 | |
138 data = (STRUCT_TYPE *)UNWRAP(self); | |
139 $][3(self, data, value, &err); | |
140 if(err) | |
141 THROW_noret(err); | |
110 } | 142 } |
111 ]) | 143 ]) |
112 divert([])dnl | 144 divert([])dnl |
113 ]) | 145 ]) |
114 | 146 |
116 divert([-1])dnl | 148 divert([-1])dnl |
117 undefine([INT]) | 149 undefine([INT]) |
118 undefine([NUMBER]) | 150 undefine([NUMBER]) |
119 undefine([OBJ]) | 151 undefine([OBJ]) |
120 undefine([STR]) | 152 undefine([STR]) |
153 undefine([ACCESSOR]) | |
121 divert([])dnl | 154 divert([])dnl |
122 ]) | 155 ]) |
123 | 156 |
124 define([SET_ACCESSSOR], [dnl | 157 define([SET_ACCESSSOR], [dnl |
125 define([INT], [$][1])dnl | 158 define([INT], [$][1])dnl |
126 define([NUMBER], [$][1])dnl | 159 define([NUMBER], [$][1])dnl |
127 define([OBJ], [$][1])dnl | 160 define([OBJ], [$][1])dnl |
128 define([STR], [$][1])dnl | 161 define([STR], [$][1])dnl |
162 define([ACCESSOR], [$][1])dnl | |
129 inst_temp->SetAccessor(String::New("$1"), | 163 inst_temp->SetAccessor(String::New("$1"), |
130 PROJ_PREFIX[]STRUCT_NAME[]_get_[]$1, | 164 PROJ_PREFIX[]STRUCT_NAME[]_get_[]$1, |
131 PROJ_PREFIX[]STRUCT_NAME[]_set_[]$1); | 165 PROJ_PREFIX[]STRUCT_NAME[]_set_[]$1); |
132 undefine([INT])dnl | 166 undefine([INT])dnl |
133 undefine([NUMBER])dnl | 167 undefine([NUMBER])dnl |
134 undefine([OBJ])dnl | 168 undefine([OBJ])dnl |
135 undefine([STR])dnl | 169 undefine([STR])dnl |
170 undefine([ACCESSOR])dnl | |
136 ]) | 171 ]) |
137 | 172 |
138 define([START_METHOD_ARG_VAR], [dnl | 173 define([START_METHOD_ARG_VAR], [dnl |
139 define([INT], [dnl | 174 define([INT], [dnl |
140 int arg_$][1; | 175 int arg_$][1; |