From c67f199b2f24b5759e87e9c67761dca7f1dbd4d1 Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Thu, 7 Mar 2019 10:54:35 +0100 Subject: [PATCH] efl-csharp: Respect beta in constructor parameters. Summary: Fixes compilation after Efl.Ui.Win parameter changes. Also removed an unused var and now we pass the beta option to the eolian mono invocation for the tests. Fixes T7723 Reviewers: segfaultxavi, felipealmeida, vitor.sousa Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7723 Differential Revision: https://phab.enlightenment.org/D8150 --- src/bin/eolian_mono/eolian/mono/klass.hh | 7 ++++- src/bindings/mono/meson.build | 8 ++++- src/tests/efl_mono/Eo.cs | 30 +++++++++++++++++- src/tests/efl_mono/dummy_child.eo | 32 ++++++++++++++++++-- src/tests/efl_mono/libefl_mono_native_test.c | 25 +++++++++++++++ src/tests/efl_mono/meson.build | 6 ++-- 6 files changed, 100 insertions(+), 8 deletions(-) diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh index 993378fa21..199dd8c321 100644 --- a/src/bin/eolian_mono/eolian/mono/klass.hh +++ b/src/bin/eolian_mono/eolian/mono/klass.hh @@ -510,7 +510,12 @@ struct klass ).generate(sink, attributes::unused, context)) return false; - auto constructors = helpers::reorder_constructors(cls.get_all_constructors()); + auto all_constructors = helpers::reorder_constructors(cls.get_all_constructors()); + decltype (all_constructors) constructors; + + std::copy_if(all_constructors.cbegin(), all_constructors.cend(), std::back_inserter(constructors), [&context](attributes::constructor_def const& ctor) { + return !blacklist::is_function_blacklisted(ctor.function, context); + }); // Public (API) constructors if (!as_generator( diff --git a/src/bindings/mono/meson.build b/src/bindings/mono/meson.build index 7582fc2723..60401dc899 100644 --- a/src/bindings/mono/meson.build +++ b/src/bindings/mono/meson.build @@ -146,11 +146,17 @@ efl_mono_dll_config = configure_file(input : 'efl_mono.dll.config.in', output : 'efl_mono.dll.config', configuration : efl_mono_conf_data) +extra_cs_args = runtime_assemblies + +if get_option('mono-beta') + extra_cs_args += '-d:EFL_BETA' +endif + efl_mono = library('efl_mono', mono_generator_target + mono_files + [efl_src], install : true, install_dir : join_paths(dir_lib, 'efl-mono-'+version_major), - cs_args : runtime_assemblies + cs_args : extra_cs_args ) efl_mono_test_suite_path=join_paths(meson.current_build_dir()) diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs index e955888a53..08c5e2dc4c 100644 --- a/src/tests/efl_mono/Eo.cs +++ b/src/tests/efl_mono/Eo.cs @@ -354,7 +354,11 @@ class TestEoGrandChildrenFinalize public sealed class GrandChild : Dummy.Child { +#if EFL_BETA + public GrandChild() : base(null, "", 0.0, 0) { } +#else public GrandChild() : base(null, "", 0.0) { } +#endif public int receivedValue = 0; public override Efl.Object FinalizeAdd() @@ -378,18 +382,43 @@ class TestConstructors int iface_prop = 42; string a = "LFE"; double b = 3.14; +#if EFL_BETA + int beta = 1337; +#endif + +#if EFL_BETA + var obj = new Dummy.Child(null, a, b, beta, iface_prop, 0); +#else var obj = new Dummy.Child(null, a, b, iface_prop); +#endif Test.AssertEquals(iface_prop, obj.IfaceProp); +#if EFL_BETA + obj = new Dummy.Child(parent: null, ifaceProp : iface_prop, doubleParamsA : a, doubleParamsB : b, + obligatoryBetaCtor : beta, + optionalBetaCtor : -beta); +#else obj = new Dummy.Child(parent: null, ifaceProp : iface_prop, doubleParamsA : a, doubleParamsB : b); +#endif Test.AssertEquals(iface_prop, obj.IfaceProp); + +#if EFL_BETA + Test.Assert(obj.ObligatoryBetaCtorWasCalled); + Test.Assert(obj.OptionalBetaCtorWasCalled); +#endif } public static void test_optional_constructor() { string a = "LFE"; double b = 3.14; +#if EFL_BETA + int beta = 2241; + var obj = new Dummy.Child(null, a, b, obligatoryBetaCtor : beta); + Test.Assert(!obj.OptionalBetaCtorWasCalled); +#else var obj = new Dummy.Child(null, a, b); +#endif Test.Assert(!obj.GetIfaceWasSet()); } } @@ -412,7 +441,6 @@ class TestProvider public static void test_find_provider() { // Tests only the direction C# -> C - var tmp = new Dummy.Numberwrapper(); var obj = new Dummy.TestObject(); Dummy.Numberwrapper provider = Dummy.Numberwrapper.static_cast(obj.FindProvider(typeof(Dummy.Numberwrapper))); Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper)); diff --git a/src/tests/efl_mono/dummy_child.eo b/src/tests/efl_mono/dummy_child.eo index b7845d9772..f6de361c45 100644 --- a/src/tests/efl_mono/dummy_child.eo +++ b/src/tests/efl_mono/dummy_child.eo @@ -13,13 +13,41 @@ class Dummy.Child extends Dummy.Test_Object { @property iface_was_set { get {} values { - data: bool; - } + data: bool; + } + } + + obligatory_beta_ctor @beta { + params { + @in a: int; + } + } + + optional_beta_ctor @beta { + params { + @in a: int; + } + } + + @property obligatory_beta_ctor_was_called { + get{} + values { + data: bool; + } + } + + @property optional_beta_ctor_was_called { + get{} + values { + data: bool; + } } } constructors { Dummy.Test_Iface.iface_prop @optional; .double_params; + .obligatory_beta_ctor; + .optional_beta_ctor @optional; } implements { Dummy.Test_Iface.iface_prop { get; set; } diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c index 8c17e05dd9..e4c7d72e50 100644 --- a/src/tests/efl_mono/libefl_mono_native_test.c +++ b/src/tests/efl_mono/libefl_mono_native_test.c @@ -87,6 +87,8 @@ typedef struct Dummy_Child_Data const char* a; double b; Eina_Bool iface_was_set; + Eina_Bool obligatory_beta_ctor_was_called; + Eina_Bool optional_beta_ctor_was_called; } Dummy_Child_Data; typedef struct Dummy_Inherit_Helper_Data @@ -3946,6 +3948,8 @@ _dummy_child_efl_object_constructor(Eo *obj, Dummy_Child_Data *pd) pd->iface_prop = 1984; pd->iface_was_set = EINA_FALSE; + pd->obligatory_beta_ctor_was_called = EINA_FALSE; + pd->optional_beta_ctor_was_called = EINA_FALSE; return obj; } @@ -3974,6 +3978,27 @@ Eina_Bool _dummy_child_iface_was_set_get(EINA_UNUSED const Eo* obj, Dummy_Child_ { return pd->iface_was_set; } + +void _dummy_child_obligatory_beta_ctor(EINA_UNUSED Eo* obj, Dummy_Child_Data *pd, EINA_UNUSED int a) +{ + pd->obligatory_beta_ctor_was_called = EINA_TRUE; +} + +void _dummy_child_optional_beta_ctor(EINA_UNUSED Eo* obj, Dummy_Child_Data *pd, EINA_UNUSED int a) +{ + pd->optional_beta_ctor_was_called = EINA_TRUE; +} + +Eina_Bool _dummy_child_obligatory_beta_ctor_was_called_get(EINA_UNUSED const Eo* obj, Dummy_Child_Data *pd) +{ + return pd->obligatory_beta_ctor_was_called; +} + +Eina_Bool _dummy_child_optional_beta_ctor_was_called_get(EINA_UNUSED const Eo* obj, Dummy_Child_Data *pd) +{ + return pd->optional_beta_ctor_was_called; +} + EOLIAN static void _dummy_child_class_constructor(Efl_Class *klass) { diff --git a/src/tests/efl_mono/meson.build b/src/tests/efl_mono/meson.build index ae1d76f167..52c6e3152e 100644 --- a/src/tests/efl_mono/meson.build +++ b/src/tests/efl_mono/meson.build @@ -25,7 +25,7 @@ foreach mono_gen_file : eo_files eo_file_targets += custom_target('eolian_mono_gen_'+mono_gen_file.underscorify()+'', input : mono_gen_file, output : [mono_gen_file + '.cs'], - command : [eolian_mono_gen, '-I', meson.current_source_dir(), eolian_include_directories, + command : [eolian_mono_gen, beta_option, '-I', meson.current_source_dir(), eolian_include_directories, '--dllimport', 'efl_mono_native_test', '-o', join_paths(meson.current_build_dir(), mono_gen_file + '.cs'), '@INPUT@']) @@ -34,7 +34,7 @@ endforeach efl_mono_test = library('efl_mono_test', eo_file_targets, link_with : [efl_mono], - cs_args : runtime_assemblies + cs_args : extra_cs_args ) efl_mono_src = [ @@ -64,7 +64,7 @@ efl_mono_src = [ efl_mono_suite = executable('efl-mono-suite', efl_mono_src, link_with : [efl_mono, efl_mono_test], - cs_args : runtime_assemblies + cs_args : extra_cs_args ) env = environment()