From 49d9030dcc009c308d042bbeb99f2a30bd0d2580 Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Fri, 22 Feb 2019 14:02:26 -0300 Subject: [PATCH] efl-csharp: Add support for containers in events. 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 | 2 +- src/tests/efl_mono/Events.cs | 21 +++++++++++++++------ src/tests/efl_mono/dummy_test_object.eo | 7 +++++++ src/tests/efl_mono/libefl_mono_native_test.c | 5 +++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh index c9cb686..20225b4 100644 --- a/src/bin/eolian_mono/eolian/mono/events.hh +++ b/src/bin/eolian_mono/eolian/mono/events.hh @@ -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); } }; diff --git a/src/tests/efl_mono/Events.cs b/src/tests/efl_mono/Events.cs index c3c0341..2cf8818 100644 --- a/src/tests/efl_mono/Events.cs +++ b/src/tests/efl_mono/Events.cs @@ -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 received = null; + Eina.List sent = new Eina.List(); + + 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); } } diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo index 2081f3f..99e8d02 100644 --- a/src/tests/efl_mono/dummy_test_object.eo +++ b/src/tests/efl_mono/dummy_test_object.eo @@ -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; + } + } + 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; } } diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c index 674d1f8..0cc3cbd 100644 --- a/src/tests/efl_mono/libefl_mono_native_test.c +++ b/src/tests/efl_mono/libefl_mono_native_test.c @@ -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")) -- 2.7.4