summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-05 18:42:42 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-05 18:43:23 +0200
commit8192b8156246ca4b4f709fedbe771b5ec000d0d7 (patch)
tree862c740581e487fdf72bbe6a34b9e964a9d86d1d
parent6c905f1f8e734066161a5490f41a81c514de163a (diff)
C++ object must be casted to base class, before casting to void*
Added: JS example with changed names Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eoparser/xmlparser.py6
-rw-r--r--examples/elw_button_new_names.js161
2 files changed, 164 insertions, 3 deletions
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index 7b33b0f..0c7cd35 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -271,7 +271,7 @@ class JsVisitor(Visitor):
271 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)) 271 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\ 272 self.c_file.functions.append("{\n\
273 HandleScope scope;\n\ 273 HandleScope scope;\n\
274 static_cast<%s*>(data)->%s%s(event_info);\n\ 274 dynamic_cast<%s*>(static_cast<CElmObject*>(data))->%s%s(event_info);\n\
275 return EINA_TRUE;\n\ 275 return EINA_TRUE;\n\
276 (void) obj;\n\ 276 (void) obj;\n\
277 (void) desc;\n\ 277 (void) desc;\n\
@@ -294,10 +294,10 @@ class JsVisitor(Visitor):
294 {\n\ 294 {\n\
295 cb.%s.Dispose();\n\ 295 cb.%s.Dispose();\n\
296 cb.%s.Clear();\n\ 296 cb.%s.Clear();\n\
297 eo_do(eobj, eo_event_callback_del(%s, %s%s_wrapper, this));\n\ 297 eo_do(eobj, eo_event_callback_del(%s, %s%s_wrapper, dynamic_cast<CElmObject*>(this)));\n\
298 }\n"%(ev_prefix, ev_prefix, ev_prefix, _o.ev_id, self.func_name_prefix, ev)) 298 }\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\ 299 self.c_file.functions.append(" cb.%s = Persistent<Value>::New(val);\n\
300 eo_do(eobj, eo_event_callback_add(%s, %s%s_wrapper, this));\n"%(ev_prefix, _o.ev_id, self.func_name_prefix, ev)) 300 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))
301 self.c_file.functions.append("}\n") 301 self.c_file.functions.append("}\n")
302 self.c_file.functions.append("\n") 302 self.c_file.functions.append("\n")
303 303
diff --git a/examples/elw_button_new_names.js b/examples/elw_button_new_names.js
new file mode 100644
index 0000000..c906a64
--- /dev/null
+++ b/examples/elw_button_new_names.js
@@ -0,0 +1,161 @@
1//var elm = require('jse');
2var elm = require('jse');
3
4//var m = new elm.Mixin()
5
6function cb_add(par){
7 par.elw_alert_alert(par.elw_button_text + ": calback_added")
8}
9
10function cb_del(par){
11 par.elw_alert_alert(par.elw_button_text + ": calback_deleted")
12}
13
14//==============================
15var global_obj
16
17function freeze_this(par){
18 par.elw_alert_alert("Object: " + par.elw_button_text)
19 par.elw_alert_alert("Freezing cb for this obj")
20 global_obj = par
21 par.event_freeze()
22 par.elw_alert_alert("Freeze count = " + par.event_freeze_get())
23}
24
25function thaw_cb(par){
26 par.elw_alert_alert("Thawing cb for global_obj")
27 global_obj.event_thaw()
28}
29//==================================
30
31function numbers_cb(par){
32 par.elw_alert_alert("numbers_cb")
33 par.no_par()
34
35 par.ints(0, 0)
36 print (" === Testing int ===")
37
38 o = par.ints(1, 2, 3)
39 par.elw_alert_alert("xx: " + o.xx)
40 par.elw_alert_alert("yy: " + o.yy)
41
42 par.par_by_ref(1, 2, 3)
43
44
45 print (" === Testing floats ===")
46 a = 7.32
47 b = -21474.5134
48 o = par.floats(a, b)
49
50 par.elw_alert_alert("bb: " + o.bb)
51 par.elw_alert_alert("cc: " + o.cc)
52}
53
54function cb3(par, f)
55{
56 print(par)
57 print(f)
58 par.elw_alert_alert("callback called for: " + par.elw_button_text)
59 par.elw_alert_alert("getting size")
60
61 o = par.exevas_obj_size
62 par.elw_alert_alert("W: " + o.w)
63 par.elw_alert_alert("H: " + o.h)
64
65 o = par.exevas_obj_position
66 par.elw_alert_alert("X: " + o.x)
67 par.elw_alert_alert("Y: " + o.y)
68}
69
70
71
72var w = elm.ElwWin({
73 exevas_obj_size: { w: 300, h: 350},
74 elements: {
75 shalom_bt: elm.ElwButton({
76 elw_button_text: "Hello",
77 exevas_obj_position : {x: 30, y: 30},
78 exevas_obj_size: {w: 210, h: 60},
79 exevas_obj_color: {r: 159, g: 245, b: 255, a: 255},
80 eo_ev_callback_add : cb_add,
81 eo_ev_callback_del : cb_del,
82 ev_clicked : cb3
83 }),
84
85 ba: elm.ElwButton({
86 elw_button_text: "(B) ADD cb",
87 exevas_obj_position : {x: 30, y: 100},
88 exevas_obj_size: {w: 100, h: 50},
89 exevas_obj_color: {r: 255, g: 0, b: 255, a: 255},
90 ev_clicked : cb3
91 }),
92
93 red_bt: elm.ElwBoxedbutton({
94 elw_button_text: "Red button",
95 exevas_obj_position : {x: 140, y: 100},
96 exevas_obj_size: {w: 100, h: 50},
97 exevas_obj_color: {r: 255, g: 0, b: 5, a: 255},
98 ev_clicked : cb3
99
100 }),
101
102 but1: elm.ElwButton({
103 elw_button_text: "1st but in box",
104 //exevas_obj_position : { x: 250, y: 100},
105 //exevas_obj_size: { w: 90, h: 20},
106 exevas_obj_color: { r: 255, g: 0, b: 255, a: 255},
107 ev_clicked : thaw_cb
108 }),
109
110 but2: elm.ElwButton({
111 elw_button_text: "2nd but in box",
112 //exevas_obj_position : { x: 270, y: 150},
113 //exevas_obj_size: { w: 90, h: 50},
114 exevas_obj_color: {r: 240, g: 240, b: 0, a: 255},
115 ev_clicked : freeze_this
116 }),
117
118 box : elm.ElwBox ({
119 exevas_obj_position : {x: 140, y: 170},
120 exevas_obj_size: {w: 100, h: 50},
121 }),
122
123 pb: elm.ElwButton({
124 elw_button_text: "But in BB (num)",
125 //exevas_obj_position : { x: 310, y: 150},
126 //exevas_obj_size: { w: 70, h: 50},
127 exevas_obj_color: {r: 240, g: 240, b: 245, a: 255},
128 ev_clicked : numbers_cb
129 }),
130
131 ebb: elm.ElwBoxedbutton({
132 elw_button_text: "BoxedButton",
133 exevas_obj_position : {x: 30, y: 170},
134 exevas_obj_size: { w: 100, h: 50},
135 exevas_obj_color: { r: 100, g: 85, b: 255, a: 255},
136 //ev_clicked : freeze_all,
137 }),
138 }
139});
140
141
142var e = elm.realise(w);
143
144
145e.elements.box.elw_box_pack_end(e.elements.but1)
146e.elements.box.elw_box_pack_end(e.elements.but2)
147e.elements.ebb.elw_box_pack_end(e.elements.pb)
148
149//e.elements.shalom_bt.eo_ev_callback_add = cb_add
150e.elements.shalom_bt.ev_clicked = cb3
151
152
153
154elm.ElwWin.event_global_freeze()
155elm.ElwWin.event_global_thaw()
156
157
158
159
160
161