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.
This commit is contained in:
Tom Hacohen 2016-04-26 16:19:44 +01:00
parent b1fce61caa
commit 106951a61d
4 changed files with 21 additions and 25 deletions

View File

@ -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()

View File

@ -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)
{

View File

@ -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.

View File

@ -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)