Eo base: Add a property to indicate if the object is finalized;

This enables checking if an object is being created, or has already been
finalized. This is useful in functions that you want to allow
only during the creation phase (i.e inside the eo_add()).
This commit is contained in:
Tom Hacohen 2014-08-29 09:55:02 +01:00
parent 6c7e5b0a86
commit 2a0937b889
5 changed files with 27 additions and 0 deletions

View File

@ -951,6 +951,8 @@ _eo_add_internal_end(Eo *eo_id)
return NULL;
}
fptr->o.obj->finalized = EINA_TRUE;
_eo_unref(fptr->o.obj);
return (Eo *)eo_id;

View File

@ -34,6 +34,14 @@ Return event freeze count. */
int fcount; /*@ The event freeze count of the object */
}
}
finalized {
/*@ True if the object is already finalized, false otherwise. */
get {
}
values {
bool finalized;
}
}
}
methods {
constructor @constructor {

View File

@ -162,6 +162,14 @@ _eo_base_parent_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
return pd->parent;
}
EOLIAN static Eina_Bool
_eo_base_finalized_get(Eo *obj_id, Eo_Base_Data *pd EINA_UNUSED)
{
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
return obj->finalized;
}
/* Children accessor */
typedef struct _Eo_Children_Iterator Eo_Children_Iterator;
struct _Eo_Children_Iterator

View File

@ -100,6 +100,7 @@ struct _Eo_Object
Eina_Bool do_error:1;
Eina_Bool condtor_done:1;
Eina_Bool finalized:1;
Eina_Bool composite:1;
Eina_Bool del:1;

View File

@ -788,6 +788,14 @@ START_TEST(eo_add_do_and_custom)
fail_if(pd->a != 7);
eo_unref(obj);
Eina_Bool finalized;
obj = eo_add(SIMPLE_CLASS, NULL, finalized = eo_finalized_get());
fail_if(finalized);
finalized = eo_do(obj, eo_finalized_get());
fail_if(!finalized);
eo_unref(obj);
eo_shutdown();
}
END_TEST