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 543e6ec23364aec9bbe8eef015ef2dfca59f2aaa
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 21 13:49:54 2026 -0600
eolian: a class's own source does not warn about what it deprecates
@deprecated declares a function with EINA_DEPRECATED in the header so
that its callers are warned. The class's generated .eo.c includes that
header and then defines the function's body, registers it in the op
table and, for a property, calls it from the reflection wrapper, so
every class that deprecates something would warn about itself on each
build, and fail with -Werror.
The generated source now turns -Wdeprecated-declarations off around
itself when its class defines or implements a deprecated function.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bin/eolian/main.c | 28 +++++++++++++++
src/tests/eolian/data/styles_ref.c | 67 ++++++++++++++++++++++++++++++++++++
src/tests/eolian/eolian_generation.c | 14 ++++++++
3 files changed, 109 insertions(+)
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 56b0d21950..6c6972141c 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -383,6 +383,26 @@ _write_stub_header(const Eolian_State *eos, const Eolian_State *state, const cha
return ret;
}
+static Eina_Bool
+_has_deprecated(const Eolian_Class *cl)
+{
+ Eina_Bool found = EINA_FALSE;
+ const Eolian_Implement *imp;
+
+ if (!cl) return EINA_FALSE;
+ Eina_Iterator *itr = eolian_class_implements_get(cl);
+ EINA_ITERATOR_FOREACH(itr, imp)
+ {
+ if (eolian_function_is_deprecated(eolian_implement_function_get(imp, NULL)))
+ {
+ found = EINA_TRUE;
+ break;
+ }
+ }
+ eina_iterator_free(itr);
+ return found;
+}
+
static Eina_Bool
_write_source(const Eolian_State *eos, const char *ofname,
const char *ifname, Eina_Bool eot)
@@ -392,8 +412,16 @@ _write_source(const Eolian_State *eos, const char *ofname,
Eina_Bool ret = EINA_FALSE;
const Eolian_Class *cl = eolian_state_class_by_file_get(eos, ifname);
+ /* The class itself defines and registers what it deprecates; only its
+ callers are to be warned. */
+ Eina_Bool deprecated = _has_deprecated(cl);
+ if (deprecated)
+ eina_strbuf_append(buf, "#pragma GCC diagnostic push\n"
+ "#pragma GCC diagnostic ignored \"-Wdeprecated-declarations\"\n\n");
eo_gen_types_source_gen(eolian_state_objects_by_file_get(eos, ifname), buf);
eo_gen_source_gen(cl, buf);
+ if (deprecated)
+ eina_strbuf_append(buf, "\n#pragma GCC diagnostic pop\n");
if (cl || eot)
{
/* always have at least a stub in order to allow unconditional generation */
diff --git a/src/tests/eolian/data/styles_ref.c b/src/tests/eolian/data/styles_ref.c
new file mode 100644
index 0000000000..a7c79b2117
--- /dev/null
+++ b/src/tests/eolian/data/styles_ref.c
@@ -0,0 +1,67 @@
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+
+void _styles_old_way(Eo *obj, Styles_Data *pd);
+
+EAPI EAPI_WEAK EFL_VOID_FUNC_BODY(styles_old_way);
+
+void _styles_new_way(Eo *obj, Styles_Data *pd);
+
+EAPI EAPI_WEAK EFL_VOID_FUNC_BODY(styles_new_way);
+
+int _styles_old_prop_get(const Eo *obj, Styles_Data *pd);
+
+
+static Eina_Value
+__eolian_styles_old_prop_get_reflect(const Eo *obj)
+{
+ int val = styles_old_prop_get(obj);
+ return eina_value_int_init(val);
+}
+
+EAPI EAPI_WEAK EFL_FUNC_BODY_CONST(styles_old_prop_get, int, 0);
+
+static Eina_Bool
+_styles_class_initializer(Efl_Class *klass)
+{
+ const Efl_Object_Ops *opsp = NULL;
+
+ const Efl_Object_Property_Reflection_Ops *ropsp = NULL;
+
+#ifndef STYLES_EXTRA_OPS
+#define STYLES_EXTRA_OPS
+#endif
+
+ EFL_OPS_DEFINE(ops,
+ EFL_OBJECT_OP_FUNC(styles_old_way, _styles_old_way),
+ EFL_OBJECT_OP_FUNC(styles_new_way, _styles_new_way),
+ EFL_OBJECT_OP_FUNC(styles_old_prop_get, _styles_old_prop_get),
+ STYLES_EXTRA_OPS
+ );
+ opsp = &ops;
+
+ static const Efl_Object_Property_Reflection refl_table[] = {
+ {"old_prop", NULL, __eolian_styles_old_prop_get_reflect},
+ };
+ static const Efl_Object_Property_Reflection_Ops rops = {
+ refl_table, EINA_C_ARRAY_LENGTH(refl_table)
+ };
+ ropsp = &rops;
+
+ return efl_class_functions_set(klass, opsp, ropsp);
+}
+
+static const Efl_Class_Description _styles_class_desc = {
+ EO_VERSION,
+ "Styles",
+ EFL_CLASS_TYPE_REGULAR,
+ sizeof(Styles_Data),
+ _styles_class_initializer,
+ NULL,
+ NULL
+};
+
+EFL_DEFINE_CLASS(styles_class_get, &_styles_class_desc, NULL, NULL);
+
+#pragma GCC diagnostic pop
diff --git a/src/tests/eolian/eolian_generation.c b/src/tests/eolian/eolian_generation.c
index 283b9e0496..4ed1ab48ff 100644
--- a/src/tests/eolian/eolian_generation.c
+++ b/src/tests/eolian/eolian_generation.c
@@ -143,6 +143,19 @@ EFL_START_TEST(eolian_styles_generation)
}
EFL_END_TEST
+/* The class's own source defines and reflects what it deprecates: only its
+ callers are warned, so the source silences the deprecation around itself. */
+EFL_START_TEST(eolian_deprecated_source_generation)
+{
+ char output_filepath[PATH_MAX + 128] = "";
+ snprintf(output_filepath, PATH_MAX, "%s/eolian_styles",
+ eina_environment_tmp_get());
+ _remove_ref(output_filepath, "eo.c");
+ fail_if(0 != _eolian_gen_execute(TESTS_SRC_DIR"/data/styles.eo", "-gc", output_filepath));
+ fail_if(!_files_compare(TESTS_SRC_DIR"/data/styles_ref.c", output_filepath, "eo.c"));
+}
+EFL_END_TEST
+
EFL_START_TEST(eolian_default_values_generation)
{
char output_filepath[PATH_MAX + 128] = "";
@@ -265,4 +278,5 @@ void eolian_generation_test(TCase *tc)
tcase_add_test(tc, eolian_function_pointers);
tcase_add_test(tc, owning);
tcase_add_test(tc, eolian_styles_generation);
+ tcase_add_test(tc, eolian_deprecated_source_generation);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.