summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-11-25 11:46:06 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-11-25 11:46:06 +0200
commit7fdd74de204676d1594ae38297fe62ed8ee7bdb4 (patch)
tree2fd711bb17b51083dd570544cac30bdf320d5e6f
parentac31fd8e8db1072146582ecd01a010531d82eb67 (diff)
Added parsing modifier "const"
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/cparser.py7
-rw-r--r--eoparser/helper.py1
-rw-r--r--eoparser/xmlparser.py28
3 files changed, 19 insertions, 17 deletions
diff --git a/eoparser/cparser.py b/eoparser/cparser.py
index 35ca0d6..6e6f85e 100644
--- a/eoparser/cparser.py
+++ b/eoparser/cparser.py
@@ -300,6 +300,7 @@ class Cparser(object):
300 i = 0 300 i = 0
301 for tup in ss: 301 for tup in ss:
302 lst = list(tup) 302 lst = list(tup)
303 modifier = "const" if lst[0].find("const") != -1 else ""
303 lst[0] = lst[0].replace("const", "") 304 lst[0] = lst[0].replace("const", "")
304 lst[0] = " ".join(lst[0].split()) 305 lst[0] = " ".join(lst[0].split())
305 lst[0] = lst[0].replace(" *", "*") 306 lst[0] = lst[0].replace(" *", "*")
@@ -307,7 +308,7 @@ class Cparser(object):
307 if len(lst) == 2: 308 if len(lst) == 2:
308 try: 309 try:
309 tok = params_direction[i] 310 tok = params_direction[i]
310 params.append((lst[1], lst[0], tok)) 311 params.append((lst[1], modifier, lst[0], tok))
311 except IndexError: 312 except IndexError:
312 print "Warning: error in description %s in %s"%(s_tmp,self.cl_data[cl_id][const.H_FILE]) 313 print "Warning: error in description %s in %s"%(s_tmp,self.cl_data[cl_id][const.H_FILE])
313 314
@@ -383,8 +384,8 @@ class Cparser(object):
383 #defining parameter type 384 #defining parameter type
384 if const.PARAMETERS in cl_data[const.FUNCS][k]: 385 if const.PARAMETERS in cl_data[const.FUNCS][k]:
385 params = cl_data[const.FUNCS][k][const.PARAMETERS] 386 params = cl_data[const.FUNCS][k][const.PARAMETERS]
386 for v, t, d in params: 387 for v_name, modifier, t, d in params:
387 p = SubElement(m, const.PARAMETER, {const.NAME:v, const.C_TYPENAME:t, const.PRIMARY_TYPE : self.typedef_resolve(t),const.DIRECTION:d}) 388 p = SubElement(m, const.PARAMETER, {const.NAME:v_name, const.MODIFIER:modifier, const.C_TYPENAME:t, const.PRIMARY_TYPE : self.typedef_resolve(t),const.DIRECTION:d})
388 389
389 390
390 if const.EV_DESC in cl_data: 391 if const.EV_DESC in cl_data:
diff --git a/eoparser/helper.py b/eoparser/helper.py
index 507f23e..1c2215b 100644
--- a/eoparser/helper.py
+++ b/eoparser/helper.py
@@ -16,6 +16,7 @@ class _const:
16 16
17 self.NAME = "name" #used as xml-tag 17 self.NAME = "name" #used as xml-tag
18 self.C_NAME = "c_name" #used as xml-tag 18 self.C_NAME = "c_name" #used as xml-tag
19 self.MODIFIER = "modifier" #used as xml-tag
19 self.MODULE = "module" #used as xml-tag 20 self.MODULE = "module" #used as xml-tag
20 self.TYPE = "type" #used as xml-tag 21 self.TYPE = "type" #used as xml-tag
21 self.CLASS_CONSTRUCTOR = "class_constructor" 22 self.CLASS_CONSTRUCTOR = "class_constructor"
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index c75497f..6dd72a0 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -311,7 +311,7 @@ class JsVisitor(Visitor):
311 311
312 params_tmp = [] 312 params_tmp = []
313 add_this_func = True 313 add_this_func = True
314 for i, (n, c_t, d, p_t) in enumerate(_o.parameters): 314 for i, (n, modifier, c_t, d, p_t) in enumerate(_o.parameters):
315 if d != direction: 315 if d != direction:
316 print "Warning wrong direction: class: \"%s\"; property: \"%s\"; parameter: \"%s\"; direction: \"%s\""%(_o.cl_obj.c_name, prop_name + "_get", n, d) 316 print "Warning wrong direction: class: \"%s\"; property: \"%s\"; parameter: \"%s\"; direction: \"%s\""%(_o.cl_obj.c_name, prop_name + "_get", n, d)
317 print "Property \"%s\" will not be defined"%(prop_name + "_get") 317 print "Property \"%s\" will not be defined"%(prop_name + "_get")
@@ -328,7 +328,7 @@ class JsVisitor(Visitor):
328 add_this_func = False 328 add_this_func = False
329 break 329 break
330 js_type = self.internal_types[c_t_tmp][2] 330 js_type = self.internal_types[c_t_tmp][2]
331 params_tmp.append((c_t, n, d, c_t_internal, js_type)) 331 params_tmp.append((modifier, c_t, n, d, c_t_internal, js_type))
332 else: 332 else:
333 print "Warning: type: \"%s\" wasn't found in self.internal_types.\n Function \"%s\", from class \"%s\" will not be defined"%(c_t_tmp, prop_name + "_get", _o.cl_obj.c_name) 333 print "Warning: type: \"%s\" wasn't found in self.internal_types.\n Function \"%s\", from class \"%s\" will not be defined"%(c_t_tmp, prop_name + "_get", _o.cl_obj.c_name)
334 add_this_func = False 334 add_this_func = False
@@ -374,7 +374,7 @@ class JsVisitor(Visitor):
374 in_param_counter = 0 374 in_param_counter = 0
375 375
376 add_this_func = True 376 add_this_func = True
377 for i, (n, 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 379
380 js_type = "" 380 js_type = ""
@@ -399,7 +399,7 @@ class JsVisitor(Visitor):
399 if d == "in": 399 if d == "in":
400 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))
401 in_param_counter += 1 401 in_param_counter += 1
402 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 402 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
403 403
404 if js_type == "ToString": 404 if js_type == "ToString":
405 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))
@@ -412,7 +412,7 @@ class JsVisitor(Visitor):
412 else: 412 else:
413 pass_params.append(n) 413 pass_params.append(n)
414 elif d == "out": 414 elif d == "out":
415 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 415 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
416 pass_params.append('&' + n) 416 pass_params.append('&' + n)
417 417
418 js_constr = self.c_to_js_constr[js_type] 418 js_constr = self.c_to_js_constr[js_type]
@@ -421,14 +421,14 @@ class JsVisitor(Visitor):
421 elif d == "in,out": 421 elif d == "in,out":
422 self.c_file.functions.append(" Local<Value> _%s = args[%d];\n"%(n, in_param_counter)) 422 self.c_file.functions.append(" Local<Value> _%s = args[%d];\n"%(n, in_param_counter))
423 in_param_counter += 1 423 in_param_counter += 1
424 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 424 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
425 425
426 if js_type == "ToString": 426 if js_type == "ToString":
427 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_%s->%s()));\n"%(n, n, js_type)) 427 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(_%s->%s()));\n"%(n, n, js_type))
428 elif js_type == "ToEo": 428 elif js_type == "ToEo":
429 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_%s->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n, n)) 429 self.c_file.functions.append(" %s = static_cast<CElmObject*>(_%s->ToObject()->GetPointerFromInternalField(0))->GetEo();\n"%(n, n))
430 else: 430 else:
431 self.c_file.functions.append(" %s = _%s->%s()->Value();\n"%(n, n, js_type)) 431 self.c_file.functions.append(" %s = _%s->%s()->Value();\n"%(n, n, js_type))
432 432
433 pass_params.append('&' + n) 433 pass_params.append('&' + n)
434 js_constr = self.c_to_js_constr[js_type] 434 js_constr = self.c_to_js_constr[js_type]
@@ -463,9 +463,9 @@ class JsVisitor(Visitor):
463 463
464 pass_params = [] 464 pass_params = []
465 ret_params = [] 465 ret_params = []
466 for (c_t, n, d, c_t_internal, js_type) in params_tmp: 466 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
467 467
468 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 468 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
469 pass_params.append('&' + n) 469 pass_params.append('&' + n)
470 470
471 js_constr = self.c_to_js_constr[js_type] 471 js_constr = self.c_to_js_constr[js_type]
@@ -504,9 +504,9 @@ class JsVisitor(Visitor):
504 if len(params_tmp) > 1: 504 if len(params_tmp) > 1:
505 self.c_file.functions.append(" Local<Object> __o = val->ToObject();\n") 505 self.c_file.functions.append(" Local<Object> __o = val->ToObject();\n")
506 506
507 for (c_t, n, d, c_t_internal, js_type) in params_tmp: 507 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
508 508
509 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 509 self.c_file.functions.append(" %s %s %s;\n"%(modifier, c_t_internal, n))
510 if js_type == "ToString": 510 if js_type == "ToString":
511 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(__o->Get(String::NewSymbol(\"%s\"))->%s()));\n"%(n, n, js_type)) 511 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(__o->Get(String::NewSymbol(\"%s\"))->%s()));\n"%(n, n, js_type))
512 else: 512 else:
@@ -518,7 +518,7 @@ class JsVisitor(Visitor):
518 pass_params.append(n) 518 pass_params.append(n)
519 519
520 elif len(params_tmp) == 1: 520 elif len(params_tmp) == 1:
521 for (c_t, n, d, c_t_internal, js_type) in params_tmp: 521 for (modifier, c_t, n, d, c_t_internal, js_type) in params_tmp:
522 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n)) 522 self.c_file.functions.append(" %s %s;\n"%(c_t_internal, n))
523 if js_type == "ToString": 523 if js_type == "ToString":
524 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(val->%s()));\n"%(n, js_type)) 524 self.c_file.functions.append(" %s = strdup(*String::Utf8Value(val->%s()));\n"%(n, js_type))
@@ -1151,7 +1151,7 @@ class XMLparser(object):
1151 name = attrs[const.NAME] 1151 name = attrs[const.NAME]
1152 if name in self.python_reserved: 1152 if name in self.python_reserved:
1153 name += "__" 1153 name += "__"
1154 par_att.append((name, attrs[const.C_TYPENAME], attrs[const.DIRECTION], attrs[const.PRIMARY_TYPE])) 1154 par_att.append((name, attrs[const.MODIFIER], attrs[const.C_TYPENAME], attrs[const.DIRECTION], attrs[const.PRIMARY_TYPE]))
1155 1155
1156 elif name == const.INCLUDE: 1156 elif name == const.INCLUDE:
1157 self.includes.append(attrs[const.NAME]) 1157 self.includes.append(attrs[const.NAME])