vitorsousa pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7943a69b0df744183450a48eca0f818d748c2875
commit 7943a69b0df744183450a48eca0f818d748c2875 Author: Lauro Moura <[email protected]> Date: Fri Feb 22 14:02:26 2019 -0300 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 c9cb686803..20225b4f41 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 c3c034166d..2cf881804b 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<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); } } diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo index 2081f3f4e0..99e8d0256d 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<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>; } } diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c index 674d1f8f23..0cc3cbd32c 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")) --
