From 106951a61de97459a1cc9cdc248408e204c061dc Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 26 Apr 2016 16:19:44 +0100 Subject: [PATCH] Eo: Make eo_del() an eo function. This was done following a feature request by @raster. There was no real reason for it not to be an eo function and this gives us more flexibility. The reason why this done was to provide a way for classes to do special things when an object deletion was requested, for example in the case of Evas, hide the object. --- src/lib/eo/Eo.h | 12 ------------ src/lib/eo/eo.c | 13 ------------- src/lib/eo/eo_base.eo | 9 +++++++++ src/lib/eo/eo_base_class.c | 12 ++++++++++++ 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 1d492b1f18..be78f8126f 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -854,18 +854,6 @@ EAPI void eo_del_intercept_set(Eo *obj, Eo_Del_Intercept del_intercept_func); */ EAPI Eo_Del_Intercept eo_del_intercept_get(const Eo *obj); -/** - * @brief Unrefs the object and reparents it to NULL. - * @param obj the object to work on. - * - * Because eo_del() unrefs and reparents to NULL, it doesn't really delete the - * object. - * - * @see eo_unref() - * @see eo_parent_set() - */ -EAPI void eo_del(const Eo *obj); - /** * @def eo_xref(obj, ref_obj) * Convenience macro around eo_xref_internal() diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index e88d74212b..7d707a4d10 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1371,19 +1371,6 @@ eo_unref(const Eo *obj_id) _eo_unref(obj); } -EAPI void -eo_del(const Eo *obj) -{ - if (eo_parent_get((Eo *) obj)) - { - eo_parent_set((Eo *) obj, NULL); - } - else - { - eo_unref(obj); - } -} - EAPI int eo_ref_get(const Eo *obj_id) { diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo index 19c50eb3dd..01ce46879f 100644 --- a/src/lib/eo/eo_base.eo +++ b/src/lib/eo/eo_base.eo @@ -74,6 +74,15 @@ abstract Eo.Base () parent: Eo.Base * @nullable; [[the new parent]] } } + del @const { + [[Unrefs the object and reparents it to NULL. + + Because eo_del() unrefs and reparents to NULL, it doesn't really delete the object. + + This method accepts a const object for convenience, so all objects + could be passed to it easily. + ]] + } @property id { [[ The id/name of the object. diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index 7e3c4421cf..d2c7168de5 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -594,6 +594,18 @@ _eo_base_comment_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd) return pd->ext->comment; } +EOLIAN static void +_eo_base_del(const Eo *obj, Eo_Base_Data *pd EINA_UNUSED) +{ + if (eo_parent_get((Eo *) obj)) + { + eo_parent_set((Eo *) obj, NULL); + } + else + { + eo_unref(obj); + } +} EOLIAN static void _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo *parent_id)