summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-03 18:27:12 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-03 18:33:33 +0200
commit7f5dececd242d13a1d7ade7903799e4d3835d6cb (patch)
treee0e6291c8c63fe9224869563bdf54d6c0e386430
parent36d2ea0229cbd666704078316ff89b49da664f00 (diff)
Typecheck on 'None' for input param(string or Eo*) in Py
- 'None' will be changed to 'NULL' - example updated Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/xmlparser.py15
-rw-r--r--examples/evas_elem_test.py4
2 files changed, 12 insertions, 7 deletions
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index c46e327..ea1beeb 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -938,15 +938,20 @@ class PyVisitor(Visitor):
938 if d == "in": 938 if d == "in":
939 in_params.append(py_type + ' _' + n) 939 in_params.append(py_type + ' _' + n)
940 if c_t_internal == "Eo*": 940 if c_t_internal == "Eo*":
941 l = " cdef %s %s = <%s> _%s"%(c_t_internal, n, c_t_internal, n + ".eo") 941 l = " cdef %s %s = NULL if _%s is None else <%s> _%s"%(c_t_internal, n, n, c_t_internal, n + ".eo")
942 function_lines.append(l)
942 elif c_t_internal == "Eo_Event_Cb": 943 elif c_t_internal == "Eo_Event_Cb":
943 l = " cdef %s %s = <%s> %s"%(c_t_internal, n, c_t_internal, "eodefault._object_callback") 944 l = " cdef %s %s = <%s> %s"%(c_t_internal, n, c_t_internal, "eodefault._object_callback")
945 function_lines.append(l)
944 else: 946 else:
945 if c_t_internal == "char*" : 947 if c_t_internal == "char*" :
946 l = " _%s = pytext_to_utf8(_%s)"%(n, n) 948 l = " _%s = None if _%s is None else pytext_to_utf8(_%s)"%(n, n, n)
949 function_lines.append(l)
950 l = " cdef %s %s = NULL if _%s is None else <%s> _%s"%(c_t_internal, n, n, c_t_internal, n)
951 function_lines.append(l)
952 else:
953 l = " cdef %s %s = <%s> _%s"%(c_t_internal, n, c_t_internal, n)
947 function_lines.append(l) 954 function_lines.append(l)
948 l = " cdef %s %s = <%s> _%s"%(c_t_internal, n, c_t_internal, n)
949 function_lines.append(l)
950 955
951 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*": 956 if c_t.find(c_t_internal) != -1 and c_t.replace(c_t_internal, "") == "*":
952 pass_params.append('&' + n) 957 pass_params.append('&' + n)
@@ -963,7 +968,7 @@ class PyVisitor(Visitor):
963 in_params.append('_' + n) 968 in_params.append('_' + n)
964 pass_params.append('&' + n) 969 pass_params.append('&' + n)
965 if c_t_internal == "Eo*": 970 if c_t_internal == "Eo*":
966 l = " cdef %s %s = <%s> _%s"%(c_t_internal, n, c_t_internal, n + ".eo") 971 l = " cdef %s %s = NULL if _%s is None else <%s> _%s"%(c_t_internal, n, n, c_t_internal, n + ".eo")
967 else: 972 else:
968 l = " cdef %s %s = <%s> _%s"%(c_t_internal, n, c_t_internal, n) 973 l = " cdef %s %s = <%s> _%s"%(c_t_internal, n, c_t_internal, n)
969 ret_params.append((n + '_', c_t_internal)) 974 ret_params.append((n + '_', c_t_internal))
diff --git a/examples/evas_elem_test.py b/examples/evas_elem_test.py
index 022f3e1..b1b8883 100644
--- a/examples/evas_elem_test.py
+++ b/examples/evas_elem_test.py
@@ -31,12 +31,12 @@ box = ElmBox(w1)
31box.evas_obj_size_hint_weight_set(1.0, 1.0) 31box.evas_obj_size_hint_weight_set(1.0, 1.0)
32w1.elm_obj_win_resize_object_add(box) 32w1.elm_obj_win_resize_object_add(box)
33box.evas_obj_visibility_set(1) 33box.evas_obj_visibility_set(1)
34box.elm_wdg_text_part_set(None, "Button")
35 34
36but = ElmButton(w1) 35but = ElmButton(w1)
37#but.text_set("Button")
38box.elm_obj_box_pack_end(but) 36box.elm_obj_box_pack_end(but)
39but.evas_obj_visibility_set(1) 37but.evas_obj_visibility_set(1)
38but.evas_obj_color_set(255, 255, 0, 255)
39but.elm_wdg_text_part_set(None, "Button")
40 40
41d = w1.elm_obj_win_screen_dpi_get() 41d = w1.elm_obj_win_screen_dpi_get()
42print d 42print d