This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch eolian/improvements
in repository efl.
View the commit online.
commit fcc5c510e120021a86b1c6730f03a59c7939179a
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Aug 18 22:16:40 2026 -0600
eolian: refuse @nullable on a type that cannot be NULL
@nullable says NULL is a meaningful value. On a value type passed by value the C
parameter cannot hold one, so the annotation is a lie that nothing catches:
"Eina.Rect @nullable" generates "Eina_Rect r", and a binding reading the database
would emit an optional for an argument that has no way to be absent.
Require a type that can be NULL: a class handle, a string or other ownable, or
any type taken @by_ref. That last is also how stable API spells "pointer to a
value type", since ptr() is banned there, so the two annotations compose into
exactly what the tree needs:
@in region: const(Eina.Rect) @by_ref @nullable; -> const Eina_Rect *region
which is ABI-identical to the ptr(const(Eina.Rect)) @optional it replaces, while
saying what that spelling never could -- that the pointer is a pointer because
the value is optional, not because the type is large.
This was in the plan for @nullable and I left it out of the first commit; the
Efl.Gfx.Buffer rework is what proved it matters, since its region parameters are
exactly this shape. The test now covers all three cases: nullable on a class
handle and a string, nullable on a by-reference value struct, and nothing
nullable at all.
Co-Authored-By: Claude Opus 5 <[email protected]>
---
src/lib/eolian/database_validate.c | 14 ++++++++++++++
src/tests/eolian/data/nullable.eo | 12 ++++++++++++
src/tests/eolian/eolian_parsing.c | 8 ++++++++
3 files changed, 34 insertions(+)
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index b4cd8a0b63..3d2b744a59 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -560,6 +560,20 @@ _validate_param(Validate_State *vals, Eolian_Function_Parameter *param)
EINA_FALSE, EINA_FALSE))
return EINA_FALSE;
+ /* @nullable says NULL is a meaningful value, so the C type has to be able to
+ * hold one. On a value type passed by value it cannot, and the annotation
+ * would be a lie: require @by_ref there, which is also how stable API spells
+ * "pointer to a value type".
+ */
+ if (param->nullable && !param->by_ref &&
+ (param->type->type != EOLIAN_TYPE_CLASS) &&
+ !database_type_is_ownable(param->type->base.unit, param->type, EINA_FALSE, NULL))
+ {
+ _eo_parser_log(¶m->base,
+ "@nullable needs a type that can be NULL: add @by_ref, or use a class or string type");
+ return EINA_FALSE;
+ }
+
if (param->value && !_validate_expr(param->value, param->type, 0, param->by_ref))
return EINA_FALSE;
diff --git a/src/tests/eolian/data/nullable.eo b/src/tests/eolian/data/nullable.eo
index 79cc93899d..79746883a3 100644
--- a/src/tests/eolian/data/nullable.eo
+++ b/src/tests/eolian/data/nullable.eo
@@ -1,5 +1,11 @@
import base;
+struct Nullable_Box {
+ [[A plain value struct. @since 1.66]]
+ w: int; [[Width.]]
+ h: int; [[Height.]]
+}
+
class Nullable {
[[A class exercising the nullable qualifier.
@@ -14,6 +20,12 @@ class Nullable {
}
return: Base @nullable; [[$NULL when nothing matched.]]
}
+ by_ref_ok {
+ [[A value type may be nullable when taken by reference.]]
+ params {
+ @in geom: const(Nullable_Box) @by_ref @nullable; [[$NULL for all of it.]]
+ }
+ }
exact {
[[Looks something up and always finds it.]]
params {
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 0190e59daf..58afd5813e 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -1688,6 +1688,14 @@ EFL_START_TEST(eolian_nullable)
fail_if(eolian_parameter_is_nullable(param));
eina_iterator_free(iter);
+ /* a value type may be nullable when it is taken by reference */
+ fail_if(!(fid = eolian_class_function_by_name_get(cls, "by_ref_ok", EOLIAN_METHOD)));
+ iter = eolian_function_parameters_get(fid);
+ fail_if(!eina_iterator_next(iter, (void**)¶m));
+ fail_if(!eolian_parameter_is_nullable(param));
+ fail_if(!eolian_parameter_is_by_ref(param));
+ eina_iterator_free(iter);
+
/* exact(): nothing is nullable */
fail_if(!(fid = eolian_class_function_by_name_get(cls, "exact", EOLIAN_METHOD)));
fail_if(eolian_function_return_is_nullable(fid, EOLIAN_METHOD));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.