Add function to check smart type based on pointer alone. Useful when we have access to the class used to create the object.

SVN revision: 47413
This commit is contained in:
Iván Briano 2010-03-24 08:43:39 +00:00
parent f96faf0b67
commit c1b67b4798
2 changed files with 30 additions and 0 deletions

View File

@ -1765,6 +1765,7 @@ struct _Evas_Smart_Cb_Description
EAPI void evas_object_smart_member_del (Evas_Object *obj) EINA_ARG_NONNULL(1);
EAPI Evas_Object *evas_object_smart_parent_get (const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI Eina_Bool evas_object_smart_type_check (const Evas_Object *obj, const char *type) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
EAPI Eina_Bool evas_object_smart_type_check_ptr (const Evas_Object *obj, const char *type) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
EAPI Eina_List *evas_object_smart_members_get (const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI Evas_Smart *evas_object_smart_smart_get (const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI void *evas_object_smart_data_get (const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;

View File

@ -288,6 +288,35 @@ evas_object_smart_type_check(const Evas_Object *obj, const char *type)
return EINA_FALSE;
}
/**
* Checks the Smart type of the object and its parents using pointer comparison
* @param obj the Evas_Object to check the type of
* @param type the type to check for. Must be the name pointer in the smart class used to create the object
* @return EINA_TRUE if @a obj or any of its parents if of type @a type, EINA_FALSE otherwise
* @ingroup Evas_Smart_Object_Group
*/
EAPI Eina_Bool
evas_object_smart_type_check_ptr(const Evas_Object *obj, const char *type)
{
const Evas_Smart_Class *sc;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return EINA_FALSE;
MAGIC_CHECK_END();
if (!obj->smart.smart)
return EINA_FALSE;
sc = obj->smart.smart->smart_class;
while (sc)
{
if (sc->name == type)
return EINA_TRUE;
sc = sc->parent;
}
return EINA_FALSE;
}
/**
* Gets the list of the member objects of an Evas_Object
* @param obj the Evas_Object you want to get the list of member objects