This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit d88350bca43a8fdd2a7d4152a0e7d0f2e3aea49c
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 12:32:47 2026 -0600
eolian_mono: a C# override of a property getter answered nothing to C
The native wrapper for a property getter, the function C calls when the
object might be a C# subclass, read the property into a local named ret
that nothing afterwards looked at:
System.String _ret_var = default(System.String);
try
{
var ret = ((Object)ws.Target).Name;
}
...
return _ret_var;
So the epilogue handed back the _ret_var it had initialized to default
and every out parameter went back untouched, for every property getter
in the tree. It has been latent rather than live: 595cb754b3 made the
accessors internal, and it is the same commit that introduced this, so
no subclass outside the binding assembly could override a getter and
notice. The moment an accessor becomes reachable it is a silent wrong
answer rather than a failure.
Reading through the accessor is the honest fix: it has exactly the shape
of the C function, which is the only form that can carry a value and a
success flag at once. It does not work for interfaces, whose accessors
are internal, so an interface carries only the property. There the
values are spread from the property over the wrapper's own locals,
which covers every shape an interface has: none pairs a return with out
parameters, the one shape a property cannot express.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../eolian_mono/eolian/mono/property_definition.hh | 67 +++++++++++++++-------
src/tests/efl_mono/Inheritance.cs | 49 ++++++++++++++++
src/tests/efl_mono/dummy_inherit_helper.eo | 23 ++++++++
src/tests/efl_mono/dummy_test_object.c | 26 +++++++++
src/tests/efl_mono/dummy_test_object.eo | 7 +++
5 files changed, 151 insertions(+), 21 deletions(-)
diff --git a/src/bin/eolian_mono/eolian/mono/property_definition.hh b/src/bin/eolian_mono/eolian/mono/property_definition.hh
index 827454fd10..9f1aac4ad0 100644
--- a/src/bin/eolian_mono/eolian/mono/property_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/property_definition.hh
@@ -235,9 +235,11 @@ struct native_property_function_definition_generator
if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
return false;
+ bool cast_to_interface =
+ (implementing_klass->type == attributes::class_type::interface_) ||
+ ((implementing_klass->type == attributes::class_type::mixin) && !f.is_static);
std::string klass_cast_name;
- if ((implementing_klass->type == attributes::class_type::interface_) ||
- ((implementing_klass->type == attributes::class_type::mixin) && !f.is_static))
+ if (cast_to_interface)
klass_cast_name = name_helpers::klass_interface_name(*implementing_klass);
else
klass_cast_name = name_helpers::klass_inherit_name(*implementing_klass);
@@ -291,29 +293,52 @@ struct native_property_function_definition_generator
}
else if (!is_set/* && has_wrapper_getter*/)
{
- if(!as_generator
- (
- indent << scope_tab << scope_tab << scope_tab << "var ret = "
- << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).")
- << string
+ // The accessor has the shape of the C function, the only form that
+ // can carry a value and a success flag at once. An interface has only
+ // the property, its accessors being internal, so there the values are
+ // spread from the property over the wrapper's locals. No interface
+ // pairs a return with out parameters, which a property cannot express.
+ if (!cast_to_interface)
+ {
+ if(!as_generator
+ (
+ indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
+ << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
+ << "(" << (native_argument_invocation % ", ") << ");\n"
+ )
+ .generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters), context))
+ return false;
+ }
+ else
+ {
+ std::string lhs;
+ if (return_type != "void")
+ lhs = "_ret_var";
+ else
+ {
+ if(!as_generator((native_tuple_argument_invocation % ", "))
+ .generate(std::back_inserter(lhs), f.values, context))
+ return false;
+ if (f.values.size() > 1)
+ lhs = "(" + lhs + ")";
+ }
- )
- .generate(sink, std::make_tuple(name_helpers::property_managed_name(property)), context))
- return false;
+ if(!as_generator
+ (
+ indent << scope_tab << scope_tab << scope_tab << lhs << " = "
+ << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).")
+ << string
+ )
+ .generate(sink, std::make_tuple(name_helpers::property_managed_name(property)), context))
+ return false;
- if(!f.keys.empty() && !as_generator(lit("[(") << (native_argument_invocation % ", ") << ")]").generate (sink, f.keys, context))
- return false;
-
- if (!as_generator(";\n").generate (sink, attributes::unused, context))
- return false;
+ if(!f.keys.empty() && !as_generator(lit("[(") << (native_argument_invocation % ", ") << ")]").generate (sink, f.keys, context))
+ return false;
+ if (!as_generator(";\n").generate (sink, attributes::unused, context))
+ return false;
+ }
}
- // else if (!as_generator
- // (indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
- // << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
- // << "(" << (native_argument_invocation % ", ") << ");\n"
- // ).generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters), context))
- // return false;
if(!as_generator
(
diff --git a/src/tests/efl_mono/Inheritance.cs b/src/tests/efl_mono/Inheritance.cs
index 852a639029..996443f569 100644
--- a/src/tests/efl_mono/Inheritance.cs
+++ b/src/tests/efl_mono/Inheritance.cs
@@ -91,6 +91,55 @@ class TestInheritance
}
}
+ // A C# subclass that overrides property getters rather than methods. The
+ // three shapes a getter can have -- a plain value, values through out
+ // parameters, and a value with a success flag beside it -- each reach C
+ // through a different line of the generated wrapper.
+ internal class InheritProperties : Dummy.TestObject
+ {
+ internal override int GetIntProp()
+ {
+ return 42;
+ }
+
+ internal override void GetMultiValuedProp(out int prop1, out int prop2)
+ {
+ prop1 = 7;
+ prop2 = 9;
+ }
+
+ internal override Eina.SuccessFlag GetReturnTypeGetProp(out int i)
+ {
+ i = 11;
+ return (Eina.SuccessFlag)(char)1;
+ }
+ }
+
+ public static void test_inherit_property_getter()
+ {
+ var obj = new InheritProperties();
+ Test.AssertEquals(42, Dummy.InheritHelper.ReceiveDummyAndCallIntProp(obj));
+ obj.Dispose();
+ }
+
+ public static void test_inherit_property_getter_out_values()
+ {
+ var obj = new InheritProperties();
+ Dummy.InheritHelper.ReceiveDummyAndCallMultiValuedProp(obj, out int prop1, out int prop2);
+ Test.AssertEquals(7, prop1);
+ Test.AssertEquals(9, prop2);
+ obj.Dispose();
+ }
+
+ public static void test_inherit_property_getter_with_return()
+ {
+ var obj = new InheritProperties();
+ var flag = Dummy.InheritHelper.ReceiveDummyAndCallReturnTypeProp(obj, out int i);
+ Test.AssertEquals(11, i);
+ Test.Assert((char)flag != '\0', "the override's success flag reached C");
+ obj.Dispose();
+ }
+
public static void test_inherit_from_regular_class()
{
var obj = new Inherit1();
diff --git a/src/tests/efl_mono/dummy_inherit_helper.eo b/src/tests/efl_mono/dummy_inherit_helper.eo
index 9bc909e206..ea5444076c 100644
--- a/src/tests/efl_mono/dummy_inherit_helper.eo
+++ b/src/tests/efl_mono/dummy_inherit_helper.eo
@@ -7,6 +7,29 @@ class Dummy.Inherit_Helper extends Efl.Object {
}
return: int;
}
+ receive_dummy_and_call_int_prop @static {
+ [[ Reads int_prop off the object, so C sees what a C# override answered. ]]
+ params {
+ @in x: Dummy.Test_Object;
+ }
+ return: int;
+ }
+ receive_dummy_and_call_multi_valued_prop @static {
+ [[ Reads a getter whose values come back through out parameters. ]]
+ params {
+ @in x: Dummy.Test_Object;
+ @out prop1: int;
+ @out prop2: int;
+ }
+ }
+ receive_dummy_and_call_return_type_prop @static {
+ [[ Reads a getter that answers a value and a success flag at once. ]]
+ params {
+ @in x: Dummy.Test_Object;
+ @out i: int;
+ }
+ return: Eina.Success_Flag;
+ }
receive_dummy_and_call_in_stringshare @static {
params {
@in x: Dummy.Inherit_Iface;
diff --git a/src/tests/efl_mono/dummy_test_object.c b/src/tests/efl_mono/dummy_test_object.c
index aae44e06fb..b1dc123299 100644
--- a/src/tests/efl_mono/dummy_test_object.c
+++ b/src/tests/efl_mono/dummy_test_object.c
@@ -27,6 +27,7 @@ typedef struct Dummy_Test_Object_Data
Eina_Value *stored_value;
Dummy_StructSimple stored_struct;
int stored_int;
+ int int_prop;
Eina_Promise *promise;
Eina_List *list_for_accessor;
int setter_only;
@@ -4602,6 +4603,16 @@ Dummy_MyInt _dummy_test_object_bypass_typedef(EINA_UNUSED Eo *obj, EINA_UNUSED D
return data;
}
+int _dummy_test_object_int_prop_get(Eo const* obj EINA_UNUSED, Dummy_Test_Object_Data* pd)
+{
+ return pd->int_prop;
+}
+
+void _dummy_test_object_int_prop_set(Eo* obj EINA_UNUSED, Dummy_Test_Object_Data* pd, int i)
+{
+ pd->int_prop = i;
+}
+
void _dummy_test_object_multi_valued_prop_get(Eo const* obj EINA_UNUSED, Dummy_Test_Object_Data* pd, int* prop1, int* prop2)
{
*prop1 = pd->prop1;
@@ -4824,6 +4835,21 @@ int _dummy_inherit_helper_receive_dummy_and_call_int_out(Dummy_Test_Object *x)
return v;
}
+int _dummy_inherit_helper_receive_dummy_and_call_int_prop(Dummy_Test_Object *x)
+{
+ return dummy_test_object_int_prop_get (x);
+}
+
+void _dummy_inherit_helper_receive_dummy_and_call_multi_valued_prop(Dummy_Test_Object *x, int *prop1, int *prop2)
+{
+ dummy_test_object_multi_valued_prop_get (x, prop1, prop2);
+}
+
+Eina_Success_Flag _dummy_inherit_helper_receive_dummy_and_call_return_type_prop(Dummy_Test_Object *x, int *i)
+{
+ return dummy_test_object_return_type_get_prop_get (x, i);
+}
+
const char* _dummy_inherit_helper_receive_dummy_and_call_in_stringshare(Dummy_Test_Object *x)
{
return dummy_inherit_iface_stringshare_test (x, eina_stringshare_add("hello world"));
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index 85740f8b06..6ed3c2fe6c 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -1576,6 +1576,13 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
return: Dummy.MyInt;
}
+ @property int_prop {
+ [[ A plain single valued property: its getter answers through the return. ]]
+ get {}
+ set {}
+ values { i: int; }
+ }
+
@property multi_valued_prop {
[[ A multi valued property. ]]
get {}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.