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 8d9b1a73ac340c4de379ff096ea53d3e09be0755
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 12:30:27 2026 -0600

    eolian_mono: constructors of set-only and keyword-named properties build
    
    A constructor naming a set-only property aborted generation outright.
    The lookup asked for EOLIAN_PROPERTY, which matches only a property
    declaring both a getter and a setter, so a class listing one in its
    constructors block found nothing and died. The lookup is by name; the
    type is decided from func.type immediately below it.
    
    Constructor parameter names never went through escape_keyword, which
    every other name in the generator does, so a property called interface
    emitted "interface" as a C# parameter and the file did not parse.
    
    A setter taking ptr(struct) is bound as ref, and ref wants an lvalue.
    The constructor body passed the result of GetParamHelper straight in,
    which is a call, and without the ref modifier the setter did not accept
    it either; it now holds the value in a local and passes it by ref.
    
    The generator output for the Efl, Ecore and Efl.Ui classes is unchanged.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/eolian_mono/eolian/mono/documentation.hh |  4 +-
 src/bin/eolian_mono/eolian/mono/parameter.hh     | 53 ++++++++++++++++++++----
 src/tests/efl_mono/Eo.cs                         | 12 ++++++
 src/tests/efl_mono/dummy_child.c                 | 22 ++++++++++
 src/tests/efl_mono/dummy_child.eo                | 34 +++++++++++++++
 5 files changed, 116 insertions(+), 9 deletions(-)

diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
index eac5e1a179..1bc90fbb49 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -231,7 +231,9 @@ struct documentation_generator
 
         auto my_context = grammar::context_replace_tag(class_context{klass_kind}, context);
 
-        auto function = eolian_class_function_by_name_get (klass, prop_name.c_str(), EOLIAN_PROPERTY);
+        // EOLIAN_PROPERTY only matches a property with both a getter and a
+        // setter, and a constructor may name a set-only one.
+        auto function = eolian_class_function_by_name_get (klass, prop_name.c_str(), EOLIAN_UNRESOLVED);
         attributes::function_def getter_func{function, ::EOLIAN_PROP_GET, nullptr, unit};
         attributes::function_def setter_func{function, ::EOLIAN_PROP_SET, nullptr, unit};
         attributes::property_def prop{function, getter_func, setter_func, unit};
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index 59faa0d493..6fc3a02787 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -1634,6 +1634,8 @@ struct constructor_parameter_name_generator
      auto name = name_helpers::managed_name(target_name);
      name[0] = std::tolower(name[0]);
 
+     name = name_helpers::escape_keyword(name);
+
      return as_generator(string).generate(sink, name, context);
    }
 
@@ -1676,23 +1678,58 @@ struct constructor_invocation_generator
   bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context const& context) const
   {
      auto params = ctor.function.parameters;
+
+     // Each name is used twice below, and its generator takes a parameter_def.
+     std::vector<std::string> names;
+     for (auto&& param : params)
+       {
+          std::string name;
+          if (!as_generator(constructor_parameter_name(ctor)).generate(std::back_inserter(name), param, context))
+            return false;
+          names.push_back(name);
+       }
+
      if (!as_generator(
                        scope_tab << "if (" <<
                        (efl::eolian::grammar::attribute_reorder<-1>
                         ("Efl.Eo.Globals.ParamHelperCheck(" << constructor_parameter_name(ctor) << ")") % " || ") << ")\n"
                        << scope_tab(2) << scope_tab << "{\n"
-                       << scope_tab(2) << scope_tab << scope_tab << name_helpers::managed_method_name(ctor.function) << "("
              ).generate(sink, params, context))
        return false;
 
-     size_t idx = 0;
-
-     for (auto&& param : params)
+     // A setter taking ptr(struct) is bound as 'ref', which needs an lvalue --
+     // GetParamHelper returns a value, so hold it in a local first.
+     std::vector<std::string> args;
+     for (size_t i = 0; i < params.size(); i++)
        {
-          idx++;
-          if (!as_generator(
-              "Efl.Eo.Globals.GetParamHelper(" << constructor_parameter_name(ctor) << ")" << ((idx < params.size()) ? ", " : "")
-              ).generate(sink, param, context))
+          auto&& param = params[i];
+          std::string fetch = "Efl.Eo.Globals.GetParamHelper(" + names[i] + ")";
+          std::string modifier = direction_modifier(param);
+
+          if (modifier.empty())
+            {
+               args.push_back(fetch);
+            }
+          else
+            {
+               std::string tmp = "_ctor_" + names[i];
+               if (!as_generator(
+                     scope_tab(2) << scope_tab << scope_tab << "var " << string << " = " << string << ";\n"
+                   ).generate(sink, std::make_tuple(tmp, fetch), context))
+                 return false;
+               args.push_back(modifier + tmp);
+            }
+       }
+
+     if (!as_generator(
+               scope_tab(2) << scope_tab << scope_tab << string << "("
+         ).generate(sink, name_helpers::managed_method_name(ctor.function), context))
+       return false;
+
+     for (size_t i = 0; i < args.size(); i++)
+       {
+          std::string arg = args[i] + ((i + 1 < args.size()) ? ", " : "");
+          if (!as_generator(string).generate(sink, arg, context))
             return false;
        }
 
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index fa101cc548..f827215770 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -583,6 +583,18 @@ class TestConstructors
         Test.Assert(!obj.IfaceWasSet);
         obj.Dispose();
     }
+
+#if EFL_BETA
+    public static void test_set_only_constructor_properties()
+    {
+        var simple = new Dummy.StructSimple(fint: 7);
+        var obj = new Dummy.Child(null, "LFE", 3.14, 1337,
+                                  kw_interface: 5, simpleStruct: simple);
+        Test.AssertEquals(5, obj.InterfaceValue);
+        Test.AssertEquals(7, obj.SimpleStructFint);
+        obj.Dispose();
+    }
+#endif
 }
 
 class TestInterfaceConcrete
diff --git a/src/tests/efl_mono/dummy_child.c b/src/tests/efl_mono/dummy_child.c
index 79002a6222..497587ad10 100644
--- a/src/tests/efl_mono/dummy_child.c
+++ b/src/tests/efl_mono/dummy_child.c
@@ -20,6 +20,8 @@ typedef struct Dummy_Child_Data
   int iface_prop;
   const char* a;
   double b;
+  int interface_value;
+  int simple_struct_fint;
   Eina_Bool iface_was_set;
   Eina_Bool obligatory_beta_ctor_was_called;
   Eina_Bool optional_beta_ctor_was_called;
@@ -85,6 +87,26 @@ Eina_Bool _dummy_child_optional_beta_ctor_was_called_get(EINA_UNUSED const Eo* o
     return pd->optional_beta_ctor_was_called;
 }
 
+void _dummy_child_interface_set(EINA_UNUSED Eo *obj, Dummy_Child_Data *pd, int value)
+{
+    pd->interface_value = value;
+}
+
+void _dummy_child_simple_struct_set(EINA_UNUSED Eo *obj, Dummy_Child_Data *pd, Dummy_StructSimple *value)
+{
+    pd->simple_struct_fint = value->fint;
+}
+
+int _dummy_child_interface_value_get(EINA_UNUSED const Eo *obj, Dummy_Child_Data *pd)
+{
+    return pd->interface_value;
+}
+
+int _dummy_child_simple_struct_fint_get(EINA_UNUSED const Eo *obj, Dummy_Child_Data *pd)
+{
+    return pd->simple_struct_fint;
+}
+
 EOLIAN static void
 _dummy_child_class_constructor(Efl_Class *klass)
 {
diff --git a/src/tests/efl_mono/dummy_child.eo b/src/tests/efl_mono/dummy_child.eo
index 2b476a5b81..ca3deaf00b 100644
--- a/src/tests/efl_mono/dummy_child.eo
+++ b/src/tests/efl_mono/dummy_child.eo
@@ -46,12 +46,46 @@ class Dummy.Child extends Dummy.Test_Object {
           data: bool;
         }
       }
+
+      @property interface {
+        [[A set-only constructor property named after a C# keyword. @since 1.66]]
+        set {}
+        values {
+          value: int;
+        }
+      }
+
+      @property simple_struct @beta {
+        [[A set-only constructor property taking a struct by pointer. @since 1.66]]
+        set {}
+        values {
+          value: ptr(Dummy.StructSimple);
+        }
+      }
+
+      @property interface_value {
+        [[What the interface constructor property was set to. @since 1.66]]
+        get {}
+        values {
+          value: int;
+        }
+      }
+
+      @property simple_struct_fint {
+        [[The fint field of what simple_struct was set to. @since 1.66]]
+        get {}
+        values {
+          value: int;
+        }
+      }
    }
    constructors {
       Dummy.Test_Iface.iface_prop @optional;
       .double_params;
       .obligatory_beta_ctor;
       .optional_beta_ctor @optional;
+      .interface @optional;
+      .simple_struct @optional;
    }
    implements {
       Dummy.Test_Iface.iface_prop { get; set; }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to