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 c3d460807009d474edd30dae0e781ae9bd1b276b
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 7 18:51:04 2026 -0600

    eolian: serialize operators with their own symbols
    
    The operator tables of the _expression_ serializer started at the first
    real operator while the enums they are indexed by start at INVALID, so
    every operator printed as its successor: << became >>, unary minus
    became plus. Evaluated values were right; only the text was wrong, as
    seen in generated header comments (1 >> 0 for 1 << 0) and in pyolian,
    whose test had pinned the wrong sign of Stack_Layer_Min.
    
    Index the tables by enum value instead.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/eolian/database_expr_api.c | 18 +++++++++++++-----
 src/scripts/pyolian/test_eolian.py |  6 +++---
 src/tests/eolian/data/enum.eo      |  2 ++
 src/tests/eolian/eolian_parsing.c  | 13 +++++++++++++
 4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c
index 2917107c6d..8947b2ec27 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -136,15 +136,23 @@ eolian_expression_value_to_literal(const Eolian_Value *val)
      }
 }
 
+// Indexed by the operator enums, whose first value is INVALID
 static const char *_binops[] = {
-    "+", "-", "*", "/", "%",
-    "==", "!=", ">", "<", ">=", "<=",
-    "&&", "||",
-    "&", "|", "^", "<<", ">>"
+   [EOLIAN_BINOP_ADD] = "+", [EOLIAN_BINOP_SUB] = "-",
+   [EOLIAN_BINOP_MUL] = "*", [EOLIAN_BINOP_DIV] = "/",
+   [EOLIAN_BINOP_MOD] = "%",
+   [EOLIAN_BINOP_EQ] = "==", [EOLIAN_BINOP_NQ] = "!=",
+   [EOLIAN_BINOP_GT] = ">", [EOLIAN_BINOP_LT] = "<",
+   [EOLIAN_BINOP_GE] = ">=", [EOLIAN_BINOP_LE] = "<=",
+   [EOLIAN_BINOP_AND] = "&&", [EOLIAN_BINOP_OR] = "||",
+   [EOLIAN_BINOP_BAND] = "&", [EOLIAN_BINOP_BOR] = "|",
+   [EOLIAN_BINOP_BXOR] = "^",
+   [EOLIAN_BINOP_LSH] = "<<", [EOLIAN_BINOP_RSH] = ">>"
 };
 
 static const char *_unops[] = {
-    "-", "+", "!", "~"
+   [EOLIAN_UNOP_UNM] = "-", [EOLIAN_UNOP_UNP] = "+",
+   [EOLIAN_UNOP_NOT] = "!", [EOLIAN_UNOP_BNOT] = "~"
 };
 
 static Eina_Bool
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index 133b279084..16eb5e972e 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -688,12 +688,12 @@ class TestEolianExpression(object):
         exp = var.value
         assert isinstance(exp, eolian._expression_)
         assert exp.type == eolian.Eolian_Expression_Type.UNARY
-        assert float(exp.serialize) == 32768.0  # TODO is this a bug? isn't -1.0 =
-        assert exp.unary_operator == eolian.Eolian_Unary_Operator.UNM  # Invalid -> NO
+        assert float(exp.serialize) == -32768.0
+        assert exp.unary_operator == eolian.Eolian_Unary_Operator.UNM
         unary = exp.unary_expression
         assert isinstance(unary, eolian._expression_)
         assert unary.type == eolian.Eolian_Expression_Type.INT
-        assert float(exp.serialize) == 32768.0  # Bug too ?
+        assert float(unary.serialize) == 32768.0
 
         # TODO test_expression_binary
         #  exp.binary_operator # TODO find a better test (only works for BINARY expr)
diff --git a/src/tests/eolian/data/enum.eo b/src/tests/eolian/data/enum.eo
index cf8115d64a..83f72d8b3a 100644
--- a/src/tests/eolian/data/enum.eo
+++ b/src/tests/eolian/data/enum.eo
@@ -32,6 +32,8 @@ enum Value {
 
 const Pants: Value = Value.pants; [[Docs for var Pants. @since 1.66]]
 
+const Inverted: int = ~1; [[Docs for var Inverted. @since 1.66]]
+
 class Enum {
     [[Docs for class Enum. @since 1.66]]
     methods {
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index c914e4ec4f..f6859767fd 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -910,6 +910,19 @@ EFL_START_TEST(eolian_enum)
    fail_if(v.type != EOLIAN_EXPR_INT);
    fail_if(v.value.i != (1 << 2));
 
+   // Serialized operators match the source
+   fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag2")));
+   fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
+   name = eolian_expression_serialize(exp);
+   ck_assert_str_eq(name, "1 << 1");
+   eina_stringshare_del(name);
+
+   fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Inverted")));
+   fail_if(!(exp = eolian_constant_value_get(var)));
+   name = eolian_expression_serialize(exp);
+   ck_assert_str_eq(name, "~1");
+   eina_stringshare_del(name);
+
    fail_if(!(tdl = eolian_unit_enum_by_name_get(unit, "Name.Spaced")));
    fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "pants")));
 

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

Reply via email to