From 107ad90c6c8f7dd9d9330a2c8ffbd9109331bc07 Mon Sep 17 00:00:00 2001 From: tasn Date: Wed, 12 Sep 2012 11:31:58 +0000 Subject: [PATCH] Eo: Added eo_destructed_is. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@76518 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Eo.h | 11 +++++++++++ src/lib/eo.c | 8 ++++++++ src/tests/eo_suite/eo_test_general.c | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/src/lib/Eo.h b/src/lib/Eo.h index 08f0a1a..ffb46fb 100644 --- a/src/lib/Eo.h +++ b/src/lib/Eo.h @@ -744,6 +744,17 @@ EAPI void eo_manual_free_set(Eo *obj, Eina_Bool manual_free); EAPI void eo_manual_free(Eo *obj); /** + * @brief Checks if the object was already descructed (only relevant for manual_free objects). + * @param obj the object to check. + * This function checks if the object was already destructed (but not alraedy + * freed). It should only be used with objects that are supposed to be manually + * freed, but not yet freed (but possibly destructed). + * + * @see eo_manual_free_set() + */ +EAPI Eina_Bool eo_destructed_is(const Eo *obj); + +/** * @addtogroup Eo_Composite_Objects Composite Objects. * @{ */ diff --git a/src/lib/eo.c b/src/lib/eo.c index 59e11f3..9eaba3d 100644 --- a/src/lib/eo.c +++ b/src/lib/eo.c @@ -1545,6 +1545,14 @@ eo_composite_is(const Eo *comp_obj) return comp_obj->composite; } +EAPI Eina_Bool +eo_destructed_is(const Eo *obj) +{ + EO_MAGIC_RETURN_VAL(obj, EO_EINA_MAGIC, EINA_FALSE); + + return obj->del; +} + EAPI void eo_manual_free_set(Eo *obj, Eina_Bool manual_free) { diff --git a/src/tests/eo_suite/eo_test_general.c b/src/tests/eo_suite/eo_test_general.c index 0de71dc..0ab8153 100644 --- a/src/tests/eo_suite/eo_test_general.c +++ b/src/tests/eo_suite/eo_test_general.c @@ -231,12 +231,15 @@ START_TEST(eo_man_free) obj = eo_add(klass, NULL); fail_if(!obj); eo_manual_free(obj); + fail_if(eo_destructed_is(obj)); eo_unref(obj); + fail_if(!eo_destructed_is(obj)); eo_manual_free(obj); obj = eo_add(klass, NULL); fail_if(!obj); eo_unref(obj); + fail_if(!eo_destructed_is(obj)); eo_manual_free(obj); _man_should_con = EINA_FALSE; @@ -618,6 +621,7 @@ START_TEST(eo_magic_checks) eo_manual_free_set((Eo *) buf, EINA_TRUE); eo_manual_free((Eo *) buf); + eo_destructed_is((Eo *) buf); eo_unref(obj); -- 2.7.4