summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-17 16:55:58 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-17 16:55:58 +0200
commit0f1e177277bcc61a123bfa58e77eeb19a573aee6 (patch)
tree39f8eb1535ae148f0eff2014f5cd5f7888aabd4a
parentb1f6b5a11e3e68d1645acb4736e3b05122944263 (diff)
JS gen: fixes to avoid name clash with 'val'-named var
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/xmlparser.py34
-rw-r--r--examples/elm_elm.js1
2 files changed, 18 insertions, 17 deletions
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index 0ccb38c..d3a197f 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -202,10 +202,10 @@ class JsVisitor(Visitor):
202 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 202 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
203 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 203 self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
204 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name)) 204 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name))
205 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix, prop_name)) 205 self.class_info.public.append(" void %s%s_set(Handle<Value> _val);\n"%(self.func_name_prefix, prop_name))
206 206
207 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name)) 207 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name))
208 self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(prop_name)) 208 self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> _val, const AccessorInfo &info);\n"%(prop_name))
209 self.c_file.tmpl.append(" PROPERTY(%s)"% prop_name) 209 self.c_file.tmpl.append(" PROPERTY(%s)"% prop_name)
210 210
211 211
@@ -216,11 +216,11 @@ class JsVisitor(Visitor):
216 #self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 216 #self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_GET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
217 217
218 #self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name)) 218 #self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name))
219 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix, prop_name)) 219 self.class_info.public.append(" void %s%s_set(Handle<Value> _val);\n"%(self.func_name_prefix, prop_name))
220 220
221 self.c_file.tmpl.append(" PROPERTY_SO(%s)"% prop_name) 221 self.c_file.tmpl.append(" PROPERTY_SO(%s)"% prop_name)
222 #self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name)) 222 #self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name))
223 self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(prop_name)) 223 self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> _val, const AccessorInfo &info);\n"%(prop_name))
224 224
225 elif _o.prop_type == const.GET_ONLY: 225 elif _o.prop_type == const.GET_ONLY:
226 self.visit_prop_set_get(_o) 226 self.visit_prop_set_get(_o)
@@ -229,11 +229,11 @@ class JsVisitor(Visitor):
229 #self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name)) 229 #self.c_file.cb_generate_macros.append("EO_GENERATE_PROPERTY_SET_EMPTY_CALLBACK(%s, %s);\n"%(_o.cl_obj.kl_id, prop_name))
230 230
231 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name)) 231 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, prop_name))
232 #self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix, prop_name)) 232 #self.class_info.public.append(" void %s%s_set(Handle<Value> _val);\n"%(self.func_name_prefix, prop_name))
233 233
234 self.c_file.tmpl.append(" PROPERTY_RO(%s)"% prop_name) 234 self.c_file.tmpl.append(" PROPERTY_RO(%s)"% prop_name)
235 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name)) 235 self.h_file.prop_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(prop_name))
236 #self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(prop_name)) 236 #self.h_file.prop_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> _val, const AccessorInfo &info);\n"%(prop_name))
237 237
238 elif _o.prop_type == const.METHOD: 238 elif _o.prop_type == const.METHOD:
239 self.visit_method(_o) 239 self.visit_method(_o)
@@ -253,12 +253,12 @@ class JsVisitor(Visitor):
253 253
254 self.class_info.public.append("\n") 254 self.class_info.public.append("\n")
255 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, ev)) 255 self.class_info.public.append(" Handle<Value> %s%s_get() const;\n"%(self.func_name_prefix, ev))
256 self.class_info.public.append(" void %s%s_set(Handle<Value> val);\n"%(self.func_name_prefix,ev)) 256 self.class_info.public.append(" void %s%s_set(Handle<Value> _val);\n"%(self.func_name_prefix,ev))
257 self.class_info.public.append(" void %s%s(void *event_info);\n"%(self.func_name_prefix,ev)) 257 self.class_info.public.append(" void %s%s(void *event_info);\n"%(self.func_name_prefix,ev))
258 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)) 258 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))
259 259
260 self.h_file.ev_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(ev)) 260 self.h_file.ev_cb_headers.append(" Handle<Value> Callback_%s_get(Local<String>, const AccessorInfo &info);\n"%(ev))
261 self.h_file.ev_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> val, const AccessorInfo &info);\n"%(ev)) 261 self.h_file.ev_cb_headers.append(" void Callback_%s_set(Local<String>, Local<Value> _val, const AccessorInfo &info);\n"%(ev))
262 262
263 #event function 263 #event function
264 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)) 264 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))
@@ -288,9 +288,9 @@ class JsVisitor(Visitor):
288 self.c_file.functions.append("\n") 288 self.c_file.functions.append("\n")
289 289
290 #event function set 290 #event function set
291 self.c_file.functions.append("void %s::%s%s_set(Handle<Value> val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev)) 291 self.c_file.functions.append("void %s::%s%s_set(Handle<Value> _val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, ev))
292 self.c_file.functions.append("{\n") 292 self.c_file.functions.append("{\n")
293 self.c_file.functions.append(" if (!val->IsFunction())\n\ 293 self.c_file.functions.append(" if (!_val->IsFunction())\n\
294 return;\n") 294 return;\n")
295 self.c_file.functions.append(" if (!cb.%s.IsEmpty())\n\ 295 self.c_file.functions.append(" if (!cb.%s.IsEmpty())\n\
296 {\n\ 296 {\n\
@@ -298,7 +298,7 @@ class JsVisitor(Visitor):
298 cb.%s.Clear();\n\ 298 cb.%s.Clear();\n\
299 eo_do(eobj, eo_event_callback_del(%s, %s%s_wrapper, dynamic_cast<CElmObject*>(this)));\n\ 299 eo_do(eobj, eo_event_callback_del(%s, %s%s_wrapper, dynamic_cast<CElmObject*>(this)));\n\
300 }\n"%(ev_prefix, ev_prefix, ev_prefix, _o.ev_id, self.func_name_prefix, ev)) 300 }\n"%(ev_prefix, ev_prefix, ev_prefix, _o.ev_id, self.func_name_prefix, ev))
301 self.c_file.functions.append(" cb.%s = Persistent<Value>::New(val);\n\ 301 self.c_file.functions.append(" cb.%s = Persistent<Value>::New(_val);\n\
302 eo_do(eobj, eo_event_callback_add(%s, %s%s_wrapper, dynamic_cast<CElmObject*>(this)));\n"%(ev_prefix, _o.ev_id, self.func_name_prefix, ev)) 302 eo_do(eobj, eo_event_callback_add(%s, %s%s_wrapper, dynamic_cast<CElmObject*>(this)));\n"%(ev_prefix, _o.ev_id, self.func_name_prefix, ev))
303 self.c_file.functions.append("}\n") 303 self.c_file.functions.append("}\n")
304 self.c_file.functions.append("\n") 304 self.c_file.functions.append("\n")
@@ -531,13 +531,13 @@ class JsVisitor(Visitor):
531 def prop_set_generate(self, _o, params_tmp): 531 def prop_set_generate(self, _o, params_tmp):
532 self.c_file.functions.append("/* generated by 'prop_set_generate() ' */\n") 532 self.c_file.functions.append("/* generated by 'prop_set_generate() ' */\n")
533 533
534 self.c_file.functions.append("void %s::%s%s(Handle<Value> val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, _o.name)) 534 self.c_file.functions.append("void %s::%s%s(Handle<Value> _val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, _o.name))
535 self.c_file.functions.append("{\n") 535 self.c_file.functions.append("{\n")
536 536
537 pass_params = [] 537 pass_params = []
538 add_end_func = [] 538 add_end_func = []
539 if len(params_tmp) > 1: 539 if len(params_tmp) > 1:
540 self.c_file.functions.append(" Local<Object> __o = val->ToObject();\n") 540 self.c_file.functions.append(" Local<Object> __o = _val->ToObject();\n")
541 541
542 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp: 542 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
543 casting = "(%s %s)"%(modifier, c_t) 543 casting = "(%s %s)"%(modifier, c_t)
@@ -568,17 +568,17 @@ class JsVisitor(Visitor):
568 casting = "(%s %s)"%(modifier, c_t) 568 casting = "(%s %s)"%(modifier, c_t)
569 if js_type == "ToString": 569 if js_type == "ToString":
570 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 570 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
571 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(val->%s()));\n"%(n, js_type)) 571 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_val->%s()));\n"%(n, js_type))
572 self.c_file.functions.append(" if (!strcmp(%s, \"null\")) %s = NULL;\n"%(n, n)) 572 self.c_file.functions.append(" if (!strcmp(%s, \"null\")) %s = NULL;\n"%(n, n))
573 add_end_func.append(" free(%s);\n"%n) 573 add_end_func.append(" free(%s);\n"%n)
574 pass_params.append(casting + n) 574 pass_params.append(casting + n)
575 elif js_type == "ToEo": 575 elif js_type == "ToEo":
576 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 576 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
577 self.c_file.functions.append(" %s = static_cast<CElmObject*>(val->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n)) 577 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_val->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n))
578 pass_params.append(casting + n) 578 pass_params.append(casting + n)
579 else: 579 else:
580 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 580 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
581 self.c_file.functions.append(" %s = val->%s()->Value();\n"%(n, js_type)) 581 self.c_file.functions.append(" %s = _val->%s()->Value();\n"%(n, js_type))
582 582
583 if c_t.find("*") != -1: 583 if c_t.find("*") != -1:
584 pass_params.append(casting + '&' + n) 584 pass_params.append(casting + '&' + n)
@@ -611,7 +611,7 @@ class JsVisitor(Visitor):
611 # is called by prop_set_get_visit, to generate body for property setter 611 # is called by prop_set_get_visit, to generate body for property setter
612 def prop_set_err_generate(self, _o, params_tmp): 612 def prop_set_err_generate(self, _o, params_tmp):
613 self.c_file.functions.append("/* generated by 'prop_set_err_generate() ' */\n") 613 self.c_file.functions.append("/* generated by 'prop_set_err_generate() ' */\n")
614 self.c_file.functions.append("void %s::%s%s(Handle<Value> val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, _o.name)) 614 self.c_file.functions.append("void %s::%s%s(Handle<Value> _val)\n"%(_o.cl_obj.kl_id, self.func_name_prefix, _o.name))
615 self.c_file.functions.append("{\n") 615 self.c_file.functions.append("{\n")
616 self.c_file.functions.append(" printf(\"%s : This method wasn't implemented becase of type issue\\n\",__func__);") 616 self.c_file.functions.append(" printf(\"%s : This method wasn't implemented becase of type issue\\n\",__func__);")
617 self.c_file.functions.append("}\n") 617 self.c_file.functions.append("}\n")
diff --git a/examples/elm_elm.js b/examples/elm_elm.js
index fb10fb0..d8c4f8d 100644
--- a/examples/elm_elm.js
+++ b/examples/elm_elm.js
@@ -172,6 +172,7 @@ w.elm_obj_win_center(1, 1)
172 172
173w.elements.ba.evas_obj_visibility = false 173w.elements.ba.evas_obj_visibility = false
174w.elements.ba.elm_wdg_text_part_set(null, "Button") 174w.elements.ba.elm_wdg_text_part_set(null, "Button")
175w.elements.shalom_bt.elm_wdg_text_part_set(null, "Big Button")
175w.elements.ba.evas_obj_visibility = true 176w.elements.ba.evas_obj_visibility = true
176var t = w.elements.ba.elm_wdg_text_part_get(null) 177var t = w.elements.ba.elm_wdg_text_part_get(null)
177print ("====================") 178print ("====================")