summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-02 10:57:23 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-02 11:12:28 +0200
commit534cb244f21ed2f3241bc56f7b35518874e029d1 (patch)
tree60c81acf827e2100c514844366c1c1f15b23c246
parent31e9ec33bb3b501abb4d21003de4be7d4776b3f3 (diff)
XMLparser::JSvisitor: func_name_prefix = '__' added into names of funcs for C++
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eo_js/elm.h14
-rw-r--r--eoparser/helper.py2
-rw-r--r--eoparser/xmlparser.py47
3 files changed, 34 insertions, 29 deletions
diff --git a/eo_js/elm.h b/eo_js/elm.h
index be88c11..25644d7 100644
--- a/eo_js/elm.h
+++ b/eo_js/elm.h
@@ -72,24 +72,24 @@ extern int log_domain;
72#define EO_GENERATE_PROPERTY_CALLBACKS(class_,name_) \ 72#define EO_GENERATE_PROPERTY_CALLBACKS(class_,name_) \
73 Handle<Value> Callback_## name_ ##_get(Local<String>, const AccessorInfo &info) { \ 73 Handle<Value> Callback_## name_ ##_get(Local<String>, const AccessorInfo &info) { \
74 HandleScope scope; \ 74 HandleScope scope; \
75 return scope.Close(GetObjectFromAccessorInfo<class_>(info)->name_ ##_get()); \ 75 return scope.Close(GetObjectFromAccessorInfo<class_>(info)->__## name_ ##_get()); \
76 } \ 76 } \
77 void Callback_## name_ ##_set(Local<String>, Local<Value> value, const AccessorInfo &info) { \ 77 void Callback_## name_ ##_set(Local<String>, Local<Value> value, const AccessorInfo &info) { \
78 HandleScope scope; \ 78 HandleScope scope; \
79 GetObjectFromAccessorInfo<class_>(info)->name_ ##_set(value); \ 79 GetObjectFromAccessorInfo<class_>(info)->__## name_ ##_set(value); \
80 } 80 }
81 81
82 82
83#define EO_GENERATE_PROPERTY_GET_CALLBACK(class_,name_) \ 83#define EO_GENERATE_PROPERTY_GET_CALLBACK(class_,name_) \
84 Handle<Value> Callback_## name_ ##_get(Local<String>, const AccessorInfo &info) { \ 84 Handle<Value> Callback_## name_ ##_get(Local<String>, const AccessorInfo &info) { \
85 HandleScope scope; \ 85 HandleScope scope; \
86 return scope.Close(GetObjectFromAccessorInfo<class_>(info)->name_ ##_get()); \ 86 return scope.Close(GetObjectFromAccessorInfo<class_>(info)->__## name_ ##_get()); \
87 } 87 }
88 88
89#define EO_GENERATE_PROPERTY_SET_CALLBACK(class_,name_) \ 89#define EO_GENERATE_PROPERTY_SET_CALLBACK(class_,name_) \
90 void Callback_## name_ ##_set(Local<String>, Local<Value> value, const AccessorInfo &info) { \ 90 void Callback_## name_ ##_set(Local<String>, Local<Value> value, const AccessorInfo &info) { \
91 HandleScope scope; \ 91 HandleScope scope; \
92 GetObjectFromAccessorInfo<class_>(info)->name_ ##_set(value); \ 92 GetObjectFromAccessorInfo<class_>(info)->__## name_ ##_set(value); \
93 } 93 }
94 94
95#define EO_GENERATE_PROPERTY_GET_EMPTY_CALLBACK(class_,name_) \ 95#define EO_GENERATE_PROPERTY_GET_EMPTY_CALLBACK(class_,name_) \
@@ -121,9 +121,13 @@ extern int log_domain;
121#define EO_GENERATE_METHOD_CALLBACKS(class_,name_) \ 121#define EO_GENERATE_METHOD_CALLBACKS(class_,name_) \
122 Handle<Value> Callback_## name_(const Arguments& args) { \ 122 Handle<Value> Callback_## name_(const Arguments& args) { \
123 HandleScope scope; \ 123 HandleScope scope; \
124 return scope.Close(GetObjectFromArguments<class_>(args)->name_(args)); \ 124 return scope.Close(GetObjectFromArguments<class_>(args)->__## name_(args)); \
125 } 125 }
126 126
127#define EO_GENERATE_STATIC_METHOD(class_, name_) \
128 static Handle<Value> static_## name_(const Arguments& args) { \
129 return Undefined(); \
130 }
127 131
128#define EO_REGISTER_STATIC_METHOD(_name) \ 132#define EO_REGISTER_STATIC_METHOD(_name) \
129 GetTemplate()->GetFunction()->ToObject()->Set(String::NewSymbol(#_name), FunctionTemplate::New(_name)->GetFunction()) 133 GetTemplate()->GetFunction()->ToObject()->Set(String::NewSymbol(#_name), FunctionTemplate::New(_name)->GetFunction())
diff --git a/eoparser/helper.py b/eoparser/helper.py
index 3dfb86d..3f4c15b 100644
--- a/eoparser/helper.py
+++ b/eoparser/helper.py
@@ -20,7 +20,7 @@ class _const:
20 self.MODULE = "module" #used as xml-tag 20 self.MODULE = "module" #used as xml-tag
21 self.PARSE_VERSION = "parse_version" #used as xml-tag 21 self.PARSE_VERSION = "parse_version" #used as xml-tag
22 self.NUM = "num" #used as xml-tag 22 self.NUM = "num" #used as xml-tag
23 self.VER_NUM = "1.0.0" 23 self.VER_NUM = "1.0.1"
24 self.TYPE = "type" #used as xml-tag 24 self.TYPE = "type" #used as xml-tag
25 self.CLASS_CONSTRUCTOR = "class_constructor" 25 self.CLASS_CONSTRUCTOR = "class_constructor"
26 self.BASE_ID = "base_id" 26 self.BASE_ID = "base_id"
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index a8eaf0c..6cf690c 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -152,6 +152,7 @@ class JsVisitor(Visitor):
152 152
153 def __init__(self): 153 def __init__(self):
154 self.visited_properties = [] 154 self.visited_properties = []
155 self.func_name_prefix = "__"
155 156
156 self.c_file = Abstract() 157 self.c_file = Abstract()
157 self.c_file.name = "" 158 self.c_file.name = ""
@@ -199,8 +200,8 @@ class JsVisitor(Visitor):
199 self.visited_properties.append(prop_name) 200 self.visited_properties.append(prop_name)
200 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 201 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
201 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 202 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
202 self.class_info.public.append(" Handle<Value> %s_get() const;\n"%(prop_name)) 203 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name))
203 self.class_info.public.append(" void %s_set(Handle<Value> val);\n"%(prop_name)) 204 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix, prop_name))
204 205
205 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name)) 206 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name))
206 self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(prop_name)) 207 self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(prop_name))
@@ -213,8 +214,8 @@ class JsVisitor(Visitor):
213 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 214 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
214 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 215 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
215 216
216 self.class_info.public.append(" Handle<Value> %s_get() const;\n"%(prop_name)) 217 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name))
217 self.class_info.public.append(" void %s_set(Handle<Value> val);\n"%(prop_name)) 218 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix, prop_name))
218 219
219 self.c_file.tmpl.append(" PROPERTY(%s)"% prop_name) 220 self.c_file.tmpl.append(" PROPERTY(%s)"% prop_name)
220 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name)) 221 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name))
@@ -226,8 +227,8 @@ class JsVisitor(Visitor):
226 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 227 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
227 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 228 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
228 229
229 self.class_info.public.append(" Handle<Value> %s_get() const;\n"%(prop_name)) 230 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name))
230 self.class_info.public.append(" void %s_set(Handle<Value> val);\n"%(prop_name)) 231 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix, prop_name))
231 232
232 self.c_file.tmpl.append(" PROPERTY(%s)"% prop_name) 233 self.c_file.tmpl.append(" PROPERTY(%s)"% prop_name)
233 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name)) 234 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name))
@@ -250,16 +251,16 @@ class JsVisitor(Visitor):
250 251
251 252
252 self.class_info.public.append("\n") 253 self.class_info.public.append("\n")
253 self.class_info.public.append(" Handle<Value> %s_get() const;\n"%(ev)) 254 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, ev))
254 self.class_info.public.append(" void %s_set(Handle<Value> val);\n"%(ev)) 255 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix,ev))
255 self.class_info.public.append(" void %s(void *event_info);\n"%(ev)) 256 self.class_info.public.append(" void %s%s(void *event_info);\n"%(self.func_name_prefix,ev))
256 self.class_info.public.append(" static Eina_Bool %s_wrapper(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);\n"%(ev)) 257 self.class_info.public.append(" static Eina_Bool %s%s_wrapper(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);\n"%(self.func_name_prefix,ev))
257 258
258 self.h_file.ev_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(ev)) 259 self.h_file.ev_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(ev))
259 self.h_file.ev_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(ev)) 260 self.h_file.ev_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(ev))
260 261
261 #event function 262 #event function
262 self.c_file.functions.append("void %s::%s(void *event_info) //parse of event_info need to be added \n"%(_o.cl_obj.kl_id, ev)) 263 self.c_file.functions.append("void %s::%s%s(void *event_info) //parse of event_info need to be added \n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev))
263 self.c_file.functions.append("{\n") 264 self.c_file.functions.append("{\n")
264 self.c_file.functions.append(" Handle<Function> callback(Function::Cast(*cb.%s));\n"%ev_prefix) 265 self.c_file.functions.append(" Handle<Function> callback(Function::Cast(*cb.%s));\n"%ev_prefix)
265 self.c_file.functions.append(" Handle<Value> args[1] = {jsObject};\n") 266 self.c_file.functions.append(" Handle<Value> args[1] = {jsObject};\n")
@@ -268,25 +269,25 @@ class JsVisitor(Visitor):
268 self.c_file.functions.append("\n") 269 self.c_file.functions.append("\n")
269 270
270 #event function wrapper 271 #event function wrapper
271 self.c_file.functions.append("Eina_Bool %s::%s_wrapper(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)\n"%(_o.cl_obj.kl_id, ev)) 272 self.c_file.functions.append("Eina_Bool %s::%s%s_wrapper(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev))
272 self.c_file.functions.append("{\n\ 273 self.c_file.functions.append("{\n\
273 HandleScope scope;\n\ 274 HandleScope scope;\n\
274 static_cast<%s*>(data)->%s(event_info);\n\ 275 static_cast<%s*>(data)->%s%s(event_info);\n\
275 return EINA_TRUE;\n\ 276 return EINA_TRUE;\n\
276 (void) obj;\n\ 277 (void) obj;\n\
277 (void) desc;\n\ 278 (void) desc;\n\
278 }\n"%(_o.cl_obj.kl_id, ev)) 279 }\n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev))
279 self.c_file.functions.append("\n") 280 self.c_file.functions.append("\n")
280 281
281 #event function get 282 #event function get
282 self.c_file.functions.append("Handle<Value> %s::%s_get() const\n"%(_o.cl_obj.kl_id, ev)) 283 self.c_file.functions.append("Handle<Value> %s::%s%s_get() const\n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev))
283 self.c_file.functions.append("{\n\ 284 self.c_file.functions.append("{\n\
284 return cb.%s;\n\ 285 return cb.%s;\n\
285 }\n"%ev_prefix) 286 }\n"%ev_prefix)
286 self.c_file.functions.append("\n") 287 self.c_file.functions.append("\n")
287 288
288 #event function set 289 #event function set
289 self.c_file.functions.append("void %s::%s_set(Handle<Value> val)\n"%(_o.cl_obj.kl_id, ev)) 290 self.c_file.functions.append("void %s::%s%s_set(Handle<Value> val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev))
290 self.c_file.functions.append("{\n") 291 self.c_file.functions.append("{\n")
291 self.c_file.functions.append(" if (!val->IsFunction())\n\ 292 self.c_file.functions.append(" if (!val->IsFunction())\n\
292 return;\n") 293 return;\n")
@@ -294,10 +295,10 @@ class JsVisitor(Visitor):
294 {\n\ 295 {\n\
295 cb.%s.Dispose();\n\ 296 cb.%s.Dispose();\n\
296 cb.%s.Clear();\n\ 297 cb.%s.Clear();\n\
297 eo_do(eobj, eo_event_callback_del(%s, %s_wrapper, this));\n\ 298 eo_do(eobj, eo_event_callback_del(%s, %s%s_wrapper, this));\n\
298 }\n"%(ev_prefix, ev_prefix, ev_prefix, _o.ev_id, ev)) 299 }\n"%(ev_prefix, ev_prefix, ev_prefix, _o.ev_id, self.func_name_prefix, ev))
299 self.c_file.functions.append(" cb.%s = Persistent<Value>::New(val);\n\ 300 self.c_file.functions.append(" cb.%s = Persistent<Value>::New(val);\n\
300 eo_do(eobj, eo_event_callback_add(%s, %s_wrapper, this));\n"%(ev_prefix, _o.ev_id, ev)) 301 eo_do(eobj, eo_event_callback_add(%s, %s%s_wrapper, this));\n"%(ev_prefix, _o.ev_id, self.func_name_prefix, ev))
301 self.c_file.functions.append("}\n") 302 self.c_file.functions.append("}\n")
302 self.c_file.functions.append("\n") 303 self.c_file.functions.append("\n")
303 304
@@ -357,7 +358,7 @@ class JsVisitor(Visitor):
357 358
358 #do not need to 359 #do not need to
359 self.c_file.cb_generate_macros.append("EO_GENERATE_METHOD_CALLBACKS(%s, %s);\n"%(_o.cl_obj.kl_id, _o.name)) 360 self.c_file.cb_generate_macros.append("EO_GENERATE_METHOD_CALLBACKS(%s, %s);\n"%(_o.cl_obj.kl_id, _o.name))
360 self.class_info.public.append(" Handle<Value> %s(const Arguments&);\n"%(_o.name)) 361 self.class_info.public.append(" Handle<Value> %s%s(const Arguments&);\n"%(self.func_name_prefix, _o.name))
361 362
362 self.c_file.tmpl.append(" METHOD(%s)"% _o.name) 363 self.c_file.tmpl.append(" METHOD(%s)"% _o.name)
363 self.h_file.meth_cb_headers.append(" Handle<Value> Callback_%s(const Arguments&);\n"%(_o.name)) 364 self.h_file.meth_cb_headers.append(" Handle<Value> Callback_%s(const Arguments&);\n"%(_o.name))
@@ -365,7 +366,7 @@ class JsVisitor(Visitor):
365 functions_tmp_save = list(self.c_file.functions) 366 functions_tmp_save = list(self.c_file.functions)
366 self.c_file.functions.append("/* generated by 'visit method() ' */\n") 367 self.c_file.functions.append("/* generated by 'visit method() ' */\n")
367 368
368 self.c_file.functions.append("Handle<Value> %s::%s(const Arguments& args)\n"%(_o.cl_obj.kl_id, _o.name)) 369 self.c_file.functions.append("Handle<Value> %s::%s%s(const Arguments& args)\n"%( _o.cl_obj.kl_id, self.func_name_prefix, _o.name))
369 self.c_file.functions.append("{\n") 370 self.c_file.functions.append("{\n")
370 self.c_file.functions.append(" HandleScope scope;\n") 371 self.c_file.functions.append(" HandleScope scope;\n")
371 372
@@ -467,7 +468,7 @@ class JsVisitor(Visitor):
467 # is called by prop_set_get_visit, to generate body for property getter 468 # is called by prop_set_get_visit, to generate body for property getter
468 def prop_get_generate(self, _o, params_tmp): 469 def prop_get_generate(self, _o, params_tmp):
469 self.c_file.functions.append("/* generated by 'prop_get_generate() ' */\n") 470 self.c_file.functions.append("/* generated by 'prop_get_generate() ' */\n")
470 self.c_file.functions.append("Handle<Value> %s::%s() const\n"%(_o.cl_obj.kl_id, _o.name)) 471 self.c_file.functions.append("Handle<Value> %s::%s%s() const\n"%(_o.cl_obj.kl_id, self.func_name_prefix, _o.name))
471 self.c_file.functions.append("{\n") 472 self.c_file.functions.append("{\n")
472 self.c_file.functions.append(" HandleScope scope;\n") 473 self.c_file.functions.append(" HandleScope scope;\n")
473 474
@@ -507,7 +508,7 @@ class JsVisitor(Visitor):
507 def prop_set_generate(self, _o, params_tmp): 508 def prop_set_generate(self, _o, params_tmp):
508 self.c_file.functions.append("/* generated by 'prop_set_generate() ' */\n") 509 self.c_file.functions.append("/* generated by 'prop_set_generate() ' */\n")
509 510
510 self.c_file.functions.append("void %s::%s(Handle<Value> val)\n"%(_o.cl_obj.kl_id, _o.name)) 511 self.c_file.functions.append("void %s::%s%s(Handle<Value> val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, _o.name))
511 self.c_file.functions.append("{\n") 512 self.c_file.functions.append("{\n")
512 513
513 pass_params = [] 514 pass_params = []