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 ec2067b37e70357b97c3436faa7d432c0ec8b6bb
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 11 20:33:45 2026 -0600
cxx: a bool is a bool in an eina value
eina::value had no trait for bool, so value(true) came out as an int
value. Consumers that check the type, Efl.Filter_Model's answer among
them, then ignored the answer, and the natural
promise<bool>.resolve(value(true)) kept nothing. Add a trait mapping
bool to EINA_VALUE_TYPE_BOOL, read back through an Eina_Bool.
No code in the tree relied on bool becoming an int: there is no
value(bool) or get<bool> in eina_cxx, eo_cxx, the generated conversions,
tests or examples.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bindings/cxx/eina_cxx/eina_value.hh | 35 +++++++++++++++++++++++++++++++
src/tests/eina_cxx/eina_cxx_test_value.cc | 19 +++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/src/bindings/cxx/eina_cxx/eina_value.hh b/src/bindings/cxx/eina_cxx/eina_value.hh
index 1407740711..11036f2989 100644
--- a/src/bindings/cxx/eina_cxx/eina_value.hh
+++ b/src/bindings/cxx/eina_cxx/eina_value.hh
@@ -207,6 +207,41 @@ struct _eina_value_traits<short>
}
};
+/**
+ * @internal
+ *
+ * A bool is a EINA_VALUE_TYPE_BOOL, not an int: consumers of boolean values
+ * (Efl.Filter_Model's answer, for one) check the type. The C side stores an
+ * Eina_Bool, which is not a C++ bool, so it is read through one.
+ */
+template <>
+struct _eina_value_traits<bool>
+ : _eina_value_traits_base<bool>
+{
+ static ::Eina_Value_Type const* value_type()
+ {
+ return EINA_VALUE_TYPE_BOOL;
+ }
+ static void set( ::Eina_Value* v, bool c)
+ {
+ ::eina_value_set(v, c ? EINA_TRUE : EINA_FALSE);
+ }
+ static bool get( ::Eina_Value* v)
+ {
+ if(EINA_VALUE_TYPE_BOOL == eina_value_type_get(v))
+ {
+ Eina_Bool vv;
+ if(::eina_value_get(v, &vv))
+ return vv != EINA_FALSE;
+ else
+ EFL_CXX_THROW(eina::system_error(eina::get_error_code()));
+ }
+ else
+ EFL_CXX_THROW(eina::system_error(EINA_ERROR_VALUE_FAILED,
+ eina::eina_error_category()));
+ }
+};
+
/**
* @internal
*/
diff --git a/src/tests/eina_cxx/eina_cxx_test_value.cc b/src/tests/eina_cxx/eina_cxx_test_value.cc
index 6ee78c790f..9acf0b487e 100644
--- a/src/tests/eina_cxx/eina_cxx_test_value.cc
+++ b/src/tests/eina_cxx/eina_cxx_test_value.cc
@@ -55,6 +55,24 @@ EFL_START_TEST(eina_cxx_value_constructors)
}
EFL_END_TEST
+EFL_START_TEST(eina_cxx_value_bool)
+{
+ efl::eina::eina_init init;
+
+ efl::eina::value vtrue(true);
+ ck_assert(::eina_value_type_get(vtrue.native_handle()) == EINA_VALUE_TYPE_BOOL);
+ ck_assert(efl::eina::get<bool>(vtrue) == true);
+
+ efl::eina::value vfalse(false);
+ ck_assert(::eina_value_type_get(vfalse.native_handle()) == EINA_VALUE_TYPE_BOOL);
+ ck_assert(efl::eina::get<bool>(vfalse) == false);
+
+ /* An int is still an int, and is not read as a bool. */
+ efl::eina::value vint(1);
+ ck_assert(::eina_value_type_get(vint.native_handle()) == EINA_VALUE_TYPE_INT);
+}
+EFL_END_TEST
+
EFL_START_TEST(eina_cxx_value_get)
{
efl::eina::eina_init init;
@@ -209,6 +227,7 @@ EFL_END_TEST
void
eina_test_value(TCase* tc)
{
+ tcase_add_test(tc, eina_cxx_value_bool);
tcase_add_test(tc, eina_cxx_value_constructors);
tcase_add_test(tc, eina_cxx_value_get);
tcase_add_test(tc, eina_cxx_value_wrong_get);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.