lauromoura pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=cb60b595d3bbbf9bafed05b7b5fdbf5dd8e04e44
commit cb60b595d3bbbf9bafed05b7b5fdbf5dd8e04e44 Author: Lauro Moura <lauromo...@expertisesolutions.com.br> Date: Thu Nov 7 17:59:40 2019 -0300 csharp: Make GetPart public. Summary: `efl_part_get` is protected in C due to the presence of `efl_part`, which does automatic refcount management in single method calls. The C# binding has no limitation on this as it already handles the lifetime for all objects. Fixes T8462 Reviewers: brunobelo, segfaultxavi, SanghyeonLee Reviewed By: SanghyeonLee Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8462 Differential Revision: https://phab.enlightenment.org/D10594 --- src/bin/eolian_mono/eolian/mono/function_helpers.hh | 5 +++++ src/tests/efl_mono/Parts.cs | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/bin/eolian_mono/eolian/mono/function_helpers.hh b/src/bin/eolian_mono/eolian/mono/function_helpers.hh index a8559fd5d3..4b9447f324 100644 --- a/src/bin/eolian_mono/eolian/mono/function_helpers.hh +++ b/src/bin/eolian_mono/eolian/mono/function_helpers.hh @@ -187,6 +187,11 @@ inline std::string function_scope_get(attributes::function_def const& f) case attributes::member_scope::scope_private: return "private "; case attributes::member_scope::scope_protected: + // Efl.Part.part.get is protected in C to force developers to use `efl_part`. + // There is no such restriction in C# as the binding takes care of the returned + // object lifetime. + if (f.c_name == "efl_part_get") + return "public "; return "protected "; case attributes::member_scope::scope_unknown: // This should trigger a compilation error diff --git a/src/tests/efl_mono/Parts.cs b/src/tests/efl_mono/Parts.cs index e1ff3d9028..33ae37d2a4 100644 --- a/src/tests/efl_mono/Parts.cs +++ b/src/tests/efl_mono/Parts.cs @@ -81,6 +81,20 @@ public static class TestMVVMParts } } +public static class TestNamedParts +{ + public static void named_parts() + { + var obj = new Dummy.PartHolder(); + var p1 = obj.GetPart("one"); + var p2 = obj.GetPart("two"); + Test.Assert(p1 is Dummy.TestObject); + Test.AssertEquals("part_one", p1.GetName()); + Test.Assert(p2 is Dummy.TestObject); + Test.AssertEquals("part_two", p2.GetName()); + } +} + #endif } --