efl-csharp: Add support for containers in events.
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Fri, 22 Feb 2019 17:02:26 +0000 (14:02 -0300)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:35 +0000 (20:49 +0900)
Summary: Using a simple wrapper as event parameters are not ownable.

Reviewers: vitor.sousa

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

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

src/bin/eolian_mono/eolian/mono/events.hh
src/tests/efl_mono/Events.cs
src/tests/efl_mono/dummy_test_object.eo
src/tests/efl_mono/libefl_mono_native_test.c

index c9cb686..20225b4 100644 (file)
@@ -76,7 +76,7 @@ struct unpack_event_args_visitor
    }
    bool operator()(attributes::complex_type_def const&) const
    {
-      return as_generator("UNSUPPORTED").generate(sink, attributes::unused, *context);
+      return as_generator("new " << eolian_mono::type << "(evt.Info, false, false)").generate(sink, type, *context);
    }
 };
 
index c3c0341..2cf8818 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Linq;
 
 namespace TestSuite
 {
@@ -164,18 +165,26 @@ class TestEoEvents
         Test.AssertEquals(sent_struct.Fobj, received_struct.Fobj);
     }
 
-    public static void event_in_init_callback()
+    public static void event_with_list_payload()
     {
-        int received = 0;
-        int sent = 42;
         var obj = new Dummy.TestObject();
-        obj.EvtWithIntEvt += (object sender, Dummy.TestObjectEvtWithIntEvt_Args e) => {
+        Eina.List<string> received = null;
+        Eina.List<string> sent = new Eina.List<string>();
+
+        sent.Append("Abc");
+        sent.Append("Def");
+        sent.Append("Ghi");
+
+        obj.EvtWithListEvt += (object sender, Dummy.TestObjectEvtWithListEvt_Args e) => {
             received = e.arg;
         };
 
-        obj.EmitEventWithInt(sent);
+        obj.EmitEventWithList(sent);
 
-        Test.AssertEquals(sent, received);
+        Test.AssertEquals(sent.Length, received.Length);
+        var pairs = sent.Zip(received, (string sentItem, string receivedItem) => new { Sent = sentItem, Received = receivedItem } );
+        foreach (var pair in pairs)
+            Test.AssertEquals(pair.Sent, pair.Received);
     }
 }
 
index 2081f3f..99e8d02 100644 (file)
@@ -1590,6 +1590,12 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
          }
       }
 
+      emit_event_with_list {
+         params {
+            @in data: list<string>;
+         }
+      }
+
       append_to_strbuf {
          params {
             @in buf: strbuf;
@@ -1685,5 +1691,6 @@ class Dummy.Test_Object extends Efl.Object implements Efl.Part, Dummy.Test_Iface
       evt,with,error @hot: Eina.Error;
       evt,with,struct @hot: Dummy.StructSimple;
       evt,with,struct,complex @hot: Dummy.StructComplex;
+      evt,with,list @hot: list<string>;
    }
 }
index 674d1f8..0cc3cbd 100644 (file)
@@ -3791,6 +3791,11 @@ void _dummy_test_object_emit_event_with_struct_complex(Eo *obj, EINA_UNUSED Dumm
     efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_STRUCT_COMPLEX, &data);
 }
 
+void _dummy_test_object_emit_event_with_list(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_List *data)
+{
+    efl_event_callback_legacy_call(obj, DUMMY_TEST_OBJECT_EVENT_EVT_WITH_LIST, data);
+}
+
 Efl_Object *_dummy_test_object_efl_part_part_get(EINA_UNUSED const Eo *obj, Dummy_Test_Object_Data *pd, const char *name)
 {
     if (!strcmp(name, "part_one"))