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 3988857c0aec80db30ebe0d0ecd08216ba5a7c41
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 13 22:10:43 2026 -0600

    eolian_cxx: give each function-pointer parameter its own template type
    
    parameter.hpp emitted F for every function-pointer parameter while
    klass_def.hpp declared F, G, ... in template_statement, so a method with
    two callbacks (Efl.Ui.View_Model.property_logic_add) declared "F get, F
    set" and a body that used an undeducible G, and could not be called
    with two callables of different types.
    
    Name each template parameter after the parameter it types, so the
    declaration and the body cannot disagree.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/eolian_cxx/grammar/klass_def.hpp          |  8 ++-----
 src/lib/eolian_cxx/grammar/parameter.hpp          |  2 +-
 src/tests/eolian_cxx/eolian_cxx_test_callbacks.cc | 21 +++++++++++++++++
 src/tests/eolian_cxx/fnptr.c                      | 16 +++++++++++++
 src/tests/eolian_cxx/fnptr.eo                     | 28 +++++++++++++++++++++++
 5 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 86fb61e8a3..3af7209ca3 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -967,15 +967,13 @@ struct function_def
   std::string template_statement() const
   {
      std::string statement;
-     char template_typename = 'F';
      for (auto const& param : this->parameters)
        {
           attributes::regular_type_def const* typ =
                 efl::eina::get<attributes::regular_type_def>(&param.type.original_type);
           if (typ && typ->is_function_ptr())
             {
-               char typenam[2] = { 0, };
-               typenam[0] = template_typename++;
+               std::string typenam = "F_" + param.param_name;
                if (statement.empty())
                  statement = std::string("template <typename ") + typenam;
                else
@@ -989,15 +987,13 @@ struct function_def
   std::vector<std::string> opening_statements() const
   {
      std::vector<std::string> statements;
-     char template_typename = 'F';
      for (auto const& param : this->parameters)
        {
           attributes::regular_type_def const* typ =
                 efl::eina::get<attributes::regular_type_def>(&param.type.original_type);
           if (typ && typ->is_function_ptr())
             {
-               char typenam[2] = { 0, };
-               typenam[0] = template_typename++;
+               std::string typenam = "F_" + param.param_name;
                std::string statement = "auto fw_" + param.param_name + " = new ::efl::eolian::function_wrapper<";
                statement += param.type.c_type + ", " + typenam + ", ::efl::eolian::" + param.type.c_type + "__function_tag>(" + param.param_name + ");";
                statements.push_back(statement);
diff --git a/src/lib/eolian_cxx/grammar/parameter.hpp b/src/lib/eolian_cxx/grammar/parameter.hpp
index 1410a0bddc..8d1a56fc5c 100644
--- a/src/lib/eolian_cxx/grammar/parameter.hpp
+++ b/src/lib/eolian_cxx/grammar/parameter.hpp
@@ -47,7 +47,7 @@ struct parameter_type_generator
       attributes::regular_type_def const* typ =
             efl::eina::get<attributes::regular_type_def>(&param.type.original_type);
       if (typ && typ->is_function_ptr())
-        return as_generator("F").generate(sink, attributes::unused, context);
+        return as_generator("F_" << string).generate(sink, param.param_name, context);
 
       return as_generator
         (
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_callbacks.cc b/src/tests/eolian_cxx/eolian_cxx_test_callbacks.cc
index bd9887f298..e7374f66da 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_callbacks.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_callbacks.cc
@@ -26,6 +26,7 @@
 #include <fnptr.eo.impl.hh>
 
 #include "eolian_cxx_suite.h"
+
 /* A callback returning a string converts what the lambda returns, which
  * takes the C type, the C++ type and the ownership. */
 EFL_START_TEST(eolian_cxx_test_callbacks_return_string)
@@ -40,8 +41,28 @@ EFL_START_TEST(eolian_cxx_test_callbacks_return_string)
 }
 EFL_END_TEST
 
+/* A method taking two function pointers: each gets a template parameter of
+ * its own, so two callables of different types can be given. */
+EFL_START_TEST(eolian_cxx_test_callbacks_two_types)
+{
+  efl::eo::eo_init init;
+
+  nonamespace::Fnptr obj(efl::eo::instantiate);
+  int offset = 100;
+  int calls = 0;
+
+  int r = obj.apply([&calls](int x) { ++calls; return x + 1; },
+                    [&calls, offset](int x) { ++calls; return x * 2 + offset; },
+                    10);
+
+  ck_assert_int_eq(calls, 2);
+  ck_assert_int_eq(r, 11 + 120);
+}
+EFL_END_TEST
+
 void
 eolian_cxx_test_callbacks(TCase* tc)
 {
   tcase_add_test(tc, eolian_cxx_test_callbacks_return_string);
+  tcase_add_test(tc, eolian_cxx_test_callbacks_two_types);
 }
diff --git a/src/tests/eolian_cxx/fnptr.c b/src/tests/eolian_cxx/fnptr.c
index f9cb74ca5c..947cba1a9e 100644
--- a/src/tests/eolian_cxx/fnptr.c
+++ b/src/tests/eolian_cxx/fnptr.c
@@ -27,4 +27,20 @@ _fnptr_text(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED,
    return text;
 }
 
+static int
+_fnptr_apply(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED,
+             void *first_data, Fnptr_Int_Func first, Eina_Free_Cb first_free_cb,
+             void *second_data, Fnptr_Twice_Func second, Eina_Free_Cb second_free_cb,
+             int value)
+{
+   int r = 0;
+
+   if (first) r += first(first_data, value);
+   if (first_free_cb) first_free_cb(first_data);
+   if (second) r += second(second_data, value);
+   if (second_free_cb) second_free_cb(second_data);
+
+   return r;
+}
+
 #include "fnptr.eo.c"
diff --git a/src/tests/eolian_cxx/fnptr.eo b/src/tests/eolian_cxx/fnptr.eo
index 5be9a0f961..0c6a2f8164 100644
--- a/src/tests/eolian_cxx/fnptr.eo
+++ b/src/tests/eolian_cxx/fnptr.eo
@@ -6,6 +6,22 @@ function Fnptr_Text_Func {
    return: string; [[The text.]]
 };
 
+function Fnptr_Int_Func {
+   [[A callback taking and returning an int. @since 1.66]]
+   params {
+      @in x: int; [[The argument.]]
+   }
+   return: int; [[The result.]]
+};
+
+function Fnptr_Twice_Func {
+   [[Another callback type, so a method can take two different ones. @since 1.66]]
+   params {
+      @in x: int; [[The argument.]]
+   }
+   return: int; [[The result.]]
+};
+
 class Fnptr extends Efl.Object {
    [[A class with methods taking function pointers. @since 1.66]]
    data: null;
@@ -21,5 +37,17 @@ class Fnptr extends Efl.Object {
          }
          return: string; [[The text $cb returned.]]
       }
+      apply {
+         [[Calls $first then $second with $value and adds what they return.
+
+           The callbacks are freed through their free functions before the
+           method returns, unless they are $null. @since 1.66]]
+         params {
+            @in first: Fnptr_Int_Func; [[Called first.]]
+            @in second: Fnptr_Twice_Func; [[Called second.]]
+            @in value: int; [[The value to pass them.]]
+         }
+         return: int; [[The sum of both results.]]
+      }
    }
 }

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

Reply via email to