summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-11-26 17:52:11 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-11-26 19:58:35 +0200
commit487679d53b150eede94255ea378371111371ac45 (patch)
treea9f9aa8e3d3717ef3d020c5cd55554970942d2e6
parentb0eb005003038b2b689bed79d223ae05d852bf59 (diff)
Removed modifier from type definitions. Added cast to params passing
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/xmlparser.py54
1 files changed, 43 insertions, 11 deletions
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index 2eea01d..8a7b610 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -376,6 +376,7 @@ class JsVisitor(Visitor):
376 add_this_func = True 376 add_this_func = True
377 for i, (n, modifier, c_t, d, p_t) in enumerate(_o.parameters): 377 for i, (n, modifier, c_t, d, p_t) in enumerate(_o.parameters):
378 c_t_tmp = self.cast(p_t) 378 c_t_tmp = self.cast(p_t)
379 casting = "(%s %s)"%(modifier, c_t)
379 380
380 js_type = "" 381 js_type = ""
381 c_t_internal = "" 382 c_t_internal = ""
@@ -398,18 +399,28 @@ class JsVisitor(Visitor):
398 if d == "in": 399 if d == "in":
399 self.c_file.functions.append(" Local<Value> _%s = args[%d];\n"%(n, in_param_counter)) 400 self.c_file.functions.append(" Local<Value> _%s = args[%d];\n"%(n, in_param_counter))
400 in_param_counter += 1 401 in_param_counter += 1
401 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n)) 402 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
402 403
403 if js_type == "ToString": 404 if js_type == "ToString":
404 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_%s->%s()));\n"%(n, n, js_type)) 405 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_%s->%s()));\n"%(n, n, js_type))
406 pass_params.append(casting + n)
405 elif js_type == "ToEo": 407 elif js_type == "ToEo":
406 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_%s->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n, n)) 408 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_%s->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n, n))
409 pass_params.append(casting + n)
407 else: 410 else:
408 self.c_file.functions.append(" %s = _%s->%s()->Value();\n"%(n, n, js_type)) 411 self.c_file.functions.append(" %s = _%s->%s()->Value();\n"%(n, n, js_type))
412
413 if c_t.find("*") != -1:
414 pass_params.append(casting + '&' + n)
415 else:
416 pass_params.append(casting + n)
417 """
409 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*": 418 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*":
410 pass_params.append('&' + n) 419 pass_params.append('&' + n)
411 else: 420 else:
412 pass_params.append(n) 421 pass_params.append(n)
422 """
423
413 elif d == "out": 424 elif d == "out":
414 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n)) 425 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
415 pass_params.append('&' + n) 426 pass_params.append('&' + n)
@@ -420,16 +431,16 @@ class JsVisitor(Visitor):
420 elif d == "in,out": 431 elif d == "in,out":
421 self.c_file.functions.append(" Local<Value> _%s = args[%d];\n"%(n, in_param_counter)) 432 self.c_file.functions.append(" Local<Value> _%s = args[%d];\n"%(n, in_param_counter))
422 in_param_counter += 1 433 in_param_counter += 1
423 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n)) 434 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
424 435
425 if js_type == "ToString": 436 if js_type == "ToString":
426 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_%s->%s()));\n"%(n, n, js_type)) 437 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_%s->%s()));\n"%(n, n, js_type))
427 elif js_type == "ToEo": 438 elif js_type == "ToEo":
428 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_%s->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n, n)) 439 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_%s->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n, n))
429 else: 440 else:
430 self.c_file.functions.append(" %s = _%s->%s()->Value();\n"%(n, n, js_type)) 441 self.c_file.functions.append(" %s = _%s->%s()->Value();\n"%(n, n, js_type))
431 442
432 pass_params.append('&' + n) 443 pass_params.append(casting + '&' + n)
433 js_constr = self.c_to_js_constr[js_type] 444 js_constr = self.c_to_js_constr[js_type]
434 ret_params.append((n, js_type, js_constr)) 445 ret_params.append((n, js_type, js_constr))
435 446
@@ -463,9 +474,10 @@ class JsVisitor(Visitor):
463 pass_params = [] 474 pass_params = []
464 ret_params = [] 475 ret_params = []
465 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp: 476 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
477 casting = "(%s %s)"%(modifier, c_t)
466 478
467 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n)) 479 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
468 pass_params.append('&' + n) 480 pass_params.append(casting + '&' + n)
469 481
470 js_constr = self.c_to_js_constr[js_type] 482 js_constr = self.c_to_js_constr[js_type]
471 ret_params.append((n, js_type, js_constr)) 483 ret_params.append((n, js_type, js_constr))
@@ -504,34 +516,54 @@ class JsVisitor(Visitor):
504 self.c_file.functions.append(" Local<Object> __o = val->ToObject();\n") 516 self.c_file.functions.append(" Local<Object> __o = val->ToObject();\n")
505 517
506 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp: 518 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
519 casting = "(%s %s)"%(modifier, c_t)
507 520
508 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n)) 521 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
509 if js_type == "ToString": 522 if js_type == "ToString":
510 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(__o->Get(String::NewSymbol(\"%s\"))->%s()));\n"%(n, n, js_type)) 523 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(__o->Get(String::NewSymbol(\"%s\"))->%s()));\n"%(n, n, js_type))
524 pass_params.append(casting + n)
525
511 else: 526 else:
512 self.c_file.functions.append(" %s = __o->Get(String::NewSymbol(\"%s\"))->%s()->Value();\n"%(n, n, js_type)) 527 self.c_file.functions.append(" %s = __o->Get(String::NewSymbol(\"%s\"))->%s()->Value();\n"%(n, n, js_type))
513 528
529 if c_t.find("*") != -1:
530 pass_params.append(casting + '&' + n)
531 else:
532 pass_params.append(casting + n)
533 """
514 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*": 534 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*":
515 pass_params.append('&' + n) 535 pass_params.append('&' + n)
516 else: 536 else:
517 pass_params.append(n) 537 pass_params.append(n)
538 """
518 539
519 elif len(params_tmp) == 1: 540 elif len(params_tmp) == 1:
520 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp: 541 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
521 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 542 casting = "(%s %s)"%(modifier, c_t)
522 if js_type == "ToString": 543 if js_type == "ToString":
544 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
523 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(val->%s()));\n"%(n, js_type)) 545 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(val->%s()));\n"%(n, js_type))
524 add_end_func.append(" free(%s);"%n) 546 add_end_func.append(" free(%s);"%n)
547 pass_params.append(casting + n)
525 elif js_type == "ToEo": 548 elif js_type == "ToEo":
549 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
526 self.c_file.functions.append(" %s = static_cast<CElmObject*>(val->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n)) 550 self.c_file.functions.append(" %s = static_cast<CElmObject*>(val->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n))
551 pass_params.append(casting + n)
527 else: 552 else:
553 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
528 self.c_file.functions.append(" %s = val->%s()->Value();\n"%(n, js_type)) 554 self.c_file.functions.append(" %s = val->%s()->Value();\n"%(n, js_type))
529 555
556 if c_t.find("*") != -1:
557 pass_params.append(casting + '&' + n)
558 else:
559 pass_params.append(casting + n)
530 560
561 """
531 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*": 562 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*":
532 pass_params.append('&' + n) 563 pass_params.append('&' + n)
533 else: 564 else:
534 pass_params.append(n) 565 pass_params.append(n)
566 """
535 567
536 self.c_file.functions.append(" eo_do(eobj, %s(%s));\n"%(_o.c_macro, ", ".join(pass_params))) 568 self.c_file.functions.append(" eo_do(eobj, %s(%s));\n"%(_o.c_macro, ", ".join(pass_params)))
537 self.c_file.functions += add_end_func 569 self.c_file.functions += add_end_func
@@ -845,7 +877,7 @@ class PyVisitor(Visitor):
845 877
846 if True:#"parameters" in fparams: 878 if True:#"parameters" in fparams:
847 879
848 for i, (n, c_t, d, p_t) in enumerate(_o.parameters): 880 for i, (n, modifier, c_t, d, p_t) in enumerate(_o.parameters):
849 c_t_tmp = self.cast(p_t) 881 c_t_tmp = self.cast(p_t)
850 882
851 py_type = "" 883 py_type = ""