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 b2ea066bdfc3f6430fb2f16ad0bcea3d1fcab0cb
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 12:31:32 2026 -0600

    eolian_mono: a struct with optional handle fields builds at its defaults
    
    Every field of a generated struct is optional and defaults to null, but
    the constructor dereferenced a hash, a binbuf or an Eina.Value field to
    reach .Handle or .GetNative(), so a struct holding one could not be
    constructed without it. The generator already emitted the null-safe form
    for Eo and Eina.Value_Ref fields right below; it does for these now too.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/eolian_mono/eolian/mono/struct_fields.hh | 10 ++++++----
 src/tests/efl_mono/Structs.cs                    |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/bin/eolian_mono/eolian/mono/struct_fields.hh b/src/bin/eolian_mono/eolian/mono/struct_fields.hh
index 9d861a0b65..c5db923bbd 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_fields.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_fields.hh
@@ -113,9 +113,10 @@ struct field_argument_assignment_generator
       else if ((complex && (complex->outer.base_type == "hash"))
             || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
         {
-           // Always assumes pointer
+           // Always assumes pointer. Every struct field is optional, so it may
+           // be null.
            if (!as_generator(
-                 "this." << string << " = " << string << ".Handle;\n")
+                 "this." << string << " = " << string << "?.Handle ?? System.IntPtr.Zero;\n")
                .generate(sink, std::make_tuple(field_name, field_name), context))
              return false;
         }
@@ -157,9 +158,10 @@ struct field_argument_assignment_generator
         }
       else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
         {
+           // An omitted Eina.Value field may be null too.
            if (!as_generator(
-                 "this." << string << " = " << string << ".GetNative();\n"
-               ).generate(sink, std::make_tuple(field_name, field_name), context))
+                 "this." << string << " = " << string << " is null ? default : " << string << ".GetNative();\n"
+               ).generate(sink, std::make_tuple(field_name, field_name, field_name), context))
              return false;
         }
       else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
diff --git a/src/tests/efl_mono/Structs.cs b/src/tests/efl_mono/Structs.cs
index c2fdc5135d..b8a4f4c606 100644
--- a/src/tests/efl_mono/Structs.cs
+++ b/src/tests/efl_mono/Structs.cs
@@ -60,6 +60,13 @@ internal class TestStructs
         value.Dispose();
         hash.Dispose();
     }
+
+    public static void complex_omitted_handles_construct()
+    {
+        var complex = new Dummy.StructComplex(fobj: null);
+        Test.AssertEquals(IntPtr.Zero, complex.Fhash.Handle);
+        Test.AssertEquals(IntPtr.Zero, complex.Fbinbuf.Handle);
+    }
 #endif
 
     public static void parameter_initialization()

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

Reply via email to