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 023be5d9985b550d301e2ebf915297ee8e6fb8a2
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 11 21:20:47 2026 -0600

    eo_cxx: an event that carries a string hands the handler the text
    
    The payload of a "string" event is the char const* itself
    (Efl.Ui.Textbox activated carries the text that way), but the C++
    binding read it as a pointer to a string_view and gave the handler a
    garbage view; building a std::string from it threw. The event payload
    is now converted from the char const*.
    
    A string event may also carry no string: Efl.Config's config,changed
    carries NULL when all values changed, and a string_view built with
    strlen on it crashed any C++ handler on that event. A NULL payload is
    an empty view.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bindings/cxx/eo_cxx/eo_cxx_interop.hh       | 10 +++++++++-
 src/tests/eolian_cxx/eolian_cxx_test_binding.cc | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
index 4dd6464304..bf3d71be05 100644
--- a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
+++ b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
@@ -652,10 +652,18 @@ T convert_to_event(void* value, typename std::enable_if< !std::is_pointer<T>::va
                       it here both are viable and neither wins, which made every
                       event carrying a bool -- Efl.Io.Reader's can_read,changed
                       among them -- impossible to attach a C++ handler to. */
-                   && !std::is_same<T, bool>::value>::type* = 0)
+                   && !std::is_same<T, bool>::value
+                   && !std::is_same<T, efl::eina::string_view>::value>::type* = 0)
 {
   return *static_cast<T*>(value);
 }
+/* An event whose payload is a "string" carries the char const* itself, not a
+   string_view over it, and may carry none (NULL). */
+template <typename T>
+T convert_to_event(void* value, typename std::enable_if<std::is_same<T, efl::eina::string_view>::value>::type* = 0)
+{
+  return value ? T(static_cast<char const*>(value)) : T(nullptr);
+}
 template <typename T>
 T convert_to_event(void* value, typename std::enable_if<std::is_same<T, bool>::value>::type* = 0)
 {
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
index 3c15ff21c2..47c4bc1840 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
@@ -586,9 +586,26 @@ EFL_START_TEST(eolian_cxx_test_beta_cascading)
 }
 EFL_END_TEST
 
+/* A "string" event carries a char const* (Efl.Ui.Textbox's activated carries
+ * the text that way), not a string_view. */
+EFL_START_TEST(eolian_cxx_test_string_event_payload)
+{
+  char const text[] = "a payload that is longer than a string_view is";
+  efl::eina::string_view v =
+    efl::eolian::convert_to_event<efl::eina::string_view>(const_cast<char*>(text));
+  std::string got(v);
+  ck_assert_str_eq(got.c_str(), text);
+
+  /* Efl.Config's config,changed carries NULL when every value changed. */
+  efl::eina::string_view none = efl::eolian::convert_to_event<efl::eina::string_view>(nullptr);
+  ck_assert(none.empty());
+}
+EFL_END_TEST
+
 void
 eolian_cxx_test_binding(TCase* tc)
 {
+   tcase_add_test(tc, eolian_cxx_test_string_event_payload);
    tcase_add_test(tc, eolian_cxx_test_string_arrays);
    tcase_add_test(tc, eolian_cxx_test_binding_constructor_only_required);
    tcase_add_test(tc, eolian_cxx_test_binding_constructor_all_optionals);

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

Reply via email to