summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh12
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs2
-rw-r--r--src/bindings/mono/eo_mono/workaround.cs14
-rw-r--r--src/tests/efl_mono/Events.cs25
4 files changed, 45 insertions, 8 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 4eea1e852f..ef2c58f757 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -484,7 +484,11 @@ struct klass
484 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n" 484 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
485 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" 485 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
486 << scope_tab << scope_tab << "if (event_count == 0) {\n" 486 << scope_tab << scope_tab << "if (event_count == 0) {\n"
487 << scope_tab << scope_tab << scope_tab << "IntPtr desc = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, key);\n" 487 << scope_tab << scope_tab << scope_tab << "IntPtr desc = efl.Event_Description.GetNative(key);\n"
488 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
489 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to get native event {key}\");\n"
490 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
491 << scope_tab << scope_tab << scope_tab << "}\n"
488 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);\n" 492 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);\n"
489 << scope_tab << scope_tab << scope_tab << "if (!result) {\n" 493 << scope_tab << scope_tab << scope_tab << "if (!result) {\n"
490 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to add event proxy for event {key}\");\n" 494 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to add event proxy for event {key}\");\n"
@@ -500,7 +504,11 @@ struct klass
500 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n" 504 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
501 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" 505 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
502 << scope_tab << scope_tab << "if (event_count == 1) {\n" 506 << scope_tab << scope_tab << "if (event_count == 1) {\n"
503 << scope_tab << scope_tab << scope_tab << "efl.Event_Description desc = new efl.Event_Description(key);\n" 507 << scope_tab << scope_tab << scope_tab << "IntPtr desc = efl.Event_Description.GetNative(key);\n"
508 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
509 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to get native event {key}\");\n"
510 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
511 << scope_tab << scope_tab << scope_tab << "}\n"
504 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);\n" 512 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);\n"
505 << scope_tab << scope_tab << scope_tab << "if (!result) {\n" 513 << scope_tab << scope_tab << scope_tab << "if (!result) {\n"
506 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n" 514 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n"
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 499b1cc000..90f7f9b5ae 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -59,7 +59,7 @@ public class Globals {
59 System.IntPtr data); 59 System.IntPtr data);
60 [DllImport(efl.Libs.Eo)] public static extern bool efl_event_callback_del( 60 [DllImport(efl.Libs.Eo)] public static extern bool efl_event_callback_del(
61 System.IntPtr obj, 61 System.IntPtr obj,
62 efl.Event_Description desc, 62 IntPtr desc,
63 efl.Event_Cb cb, 63 efl.Event_Cb cb,
64 System.IntPtr data); 64 System.IntPtr data);
65 [DllImport(efl.Libs.Eo)] public static extern IntPtr 65 [DllImport(efl.Libs.Eo)] public static extern IntPtr
diff --git a/src/bindings/mono/eo_mono/workaround.cs b/src/bindings/mono/eo_mono/workaround.cs
index 207f5cab52..26afcefcb6 100644
--- a/src/bindings/mono/eo_mono/workaround.cs
+++ b/src/bindings/mono/eo_mono/workaround.cs
@@ -83,6 +83,14 @@ public struct Event_Description {
83 83
84 public Event_Description(string name) 84 public Event_Description(string name)
85 { 85 {
86 this.Name = GetNative(name);
87 this.Unfreezable = false;
88 this.Legacy_is = false;
89 this.Restart = false;
90 }
91
92 public static IntPtr GetNative(string name)
93 {
86 if (!descriptions.ContainsKey(name)) 94 if (!descriptions.ContainsKey(name))
87 { 95 {
88 IntPtr data = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, name); 96 IntPtr data = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, name);
@@ -93,11 +101,7 @@ public struct Event_Description {
93 } 101 }
94 descriptions.Add(name, data); 102 descriptions.Add(name, data);
95 } 103 }
96 104 return descriptions[name];
97 this.Name = descriptions[name];
98 this.Unfreezable = false;
99 this.Legacy_is = false;
100 this.Restart = false;
101 } 105 }
102}; 106};
103 107
diff --git a/src/tests/efl_mono/Events.cs b/src/tests/efl_mono/Events.cs
index a08cd8b367..9cf7795dca 100644
--- a/src/tests/efl_mono/Events.cs
+++ b/src/tests/efl_mono/Events.cs
@@ -165,4 +165,29 @@ class TestEoEvents
165 Test.AssertEquals(sent, received); 165 Test.AssertEquals(sent, received);
166 } 166 }
167} 167}
168
169class TestEventAddRemove
170{
171 public static void test_add_remove_event()
172 {
173 test.ITesting obj = new test.Testing();
174 bool called = true;
175
176 EventHandler<test.Testing.EvtWithIntEvt_Args> evtCb = (object sender, EvtWithIntEvt_Args e) => {
177 called = true;
178 };
179
180 obj.EvtWithIntEvt += evtCb;
181 obj.EmitEventWithInt(42);
182 Test.Assert(called);
183
184 called = false;
185 obj.EvtWithIntEvt -= evtCb;
186 obj.EmitEventWithInt(42);
187 Test.Assert(!called);
188
189
190
191 }
192}
168} 193}