csharp: Fix event registration in constructor.
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Fri, 24 Aug 2018 14:33:46 +0000 (11:33 -0300)
committerWooHyun Jung <wh0705.jung@samsung.com>
Wed, 29 Aug 2018 05:26:48 +0000 (14:26 +0900)
Summary:
The binding user should be able to register to events inside the initialization callback given to the constructor.

Fixes T7346

Reviewers: segfaultxavi, felipealmeida, vitor.sousa

Reviewed By: segfaultxavi, vitor.sousa

Subscribers: cedric, #reviewers, #committers, zmike

Tags: #efl

Maniphest Tasks: T7346

Differential Revision: https://phab.enlightenment.org/D6908

src/bin/eolian_mono/eolian/mono/klass.hh
src/tests/efl_mono/Events.cs

index ce90b4a..7b632da 100644 (file)
@@ -198,11 +198,11 @@ struct klass
              << scope_tab << scope_tab << "if(parent != null)\n"
              << scope_tab << scope_tab << scope_tab << "parent_ptr = parent.raw_handle;\n"
              << scope_tab << scope_tab << "handle = efl.eo.Globals._efl_add_internal_start(\"file\", 0, klass, parent_ptr, 1, 0);\n"
+             << scope_tab << scope_tab << "register_event_proxies();\n"
              << scope_tab << scope_tab << "if (init_cb != null) {\n"
              << scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
              << scope_tab << scope_tab << "}\n"
              << scope_tab << scope_tab << "handle = efl.eo.Globals._efl_add_end(handle, 1, 0);\n" // replace handle with the actual final handle
-             << scope_tab << scope_tab << "register_event_proxies();\n"
              << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
              << scope_tab << "}\n"
              << (class_type == "class" ? "" : "*/")
@@ -312,12 +312,12 @@ struct klass
              << scope_tab << scope_tab << scope_tab << "}\n"
              << scope_tab << scope_tab << "}\n"
              << scope_tab << scope_tab << "handle = efl.eo.Globals.instantiate_start(klass, parent);\n"
+             << scope_tab << scope_tab << "register_event_proxies();\n"
              << scope_tab << scope_tab << "if (init_cb != null) {\n"
              << scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
              << scope_tab << scope_tab << "}\n"
              << scope_tab << scope_tab << "handle = efl.eo.Globals.instantiate_end(handle);\n"
              << scope_tab << scope_tab << "efl.eo.Globals.data_set(this);\n"
-             << scope_tab << scope_tab << "register_event_proxies();\n"
              << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
              << scope_tab << "}\n"
              << scope_tab << "///<summary>Destructor.</summary>\n"
index 6f32689..a08cd8b 100644 (file)
@@ -149,5 +149,20 @@ class TestEoEvents
 
         Test.AssertEquals(sent_struct.Fstring, received_struct.Fstring);
     }
+
+    public static void event_in_init_callback()
+    {
+        int received = 0;
+        int sent = 42;
+        test.ITesting obj = new test.Testing(null, (test.ITesting t) => {
+            t.EvtWithIntEvt += (object sender, EvtWithIntEvt_Args e) => {
+                received = e.arg;
+            };
+        });
+
+        obj.EmitEventWithInt(sent);
+
+        Test.AssertEquals(sent, received);
+    }
 }
 }