forked from enlightenment/efl
eo: add API for querying the class type
a class can be a interface mixin abstract or regular. This adds a API for getting this information
This commit is contained in:
parent
a152ba6d5b
commit
5284ac36ca
|
@ -776,7 +776,8 @@ enum _Efl_Class_Type
|
|||
EFL_CLASS_TYPE_REGULAR = 0, /**< Regular class. */
|
||||
EFL_CLASS_TYPE_REGULAR_NO_INSTANT, /**< Regular non instant-able class. */
|
||||
EFL_CLASS_TYPE_INTERFACE, /**< Interface */
|
||||
EFL_CLASS_TYPE_MIXIN /**< Mixin */
|
||||
EFL_CLASS_TYPE_MIXIN, /**< Mixin */
|
||||
EFL_CLASS_TYPE_INVALID
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2003,6 +2004,14 @@ EAPI Eina_Value efl_property_reflection_get(Eo *obj, const char *property_name);
|
|||
|
||||
#include "efl_class.eo.h"
|
||||
|
||||
/**
|
||||
* @brief Get the type of this class.
|
||||
* @param klass The Efl_Class to get the type from.
|
||||
*
|
||||
* @return The type of this class or INVALID if the klass parameter was invalid.
|
||||
*/
|
||||
EAPI Efl_Class_Type efl_class_type_get(const Efl_Class *klass);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -1516,6 +1516,9 @@ efl_class_new(const Efl_Class_Description *desc, const Efl_Class *parent_id, ...
|
|||
return NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ERR("type cannot be INVALID");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1542,6 +1545,9 @@ efl_class_new(const Efl_Class_Description *desc, const Efl_Class *parent_id, ...
|
|||
case EFL_CLASS_TYPE_MIXIN:
|
||||
extn_list = eina_list_append(extn_list, extn);
|
||||
break;
|
||||
default:
|
||||
ERR("type cannot be INVALID");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
extn_id = va_arg(p_list, Eo_Id *);
|
||||
|
@ -3660,3 +3666,11 @@ end:
|
|||
|
||||
return EINA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
EAPI Efl_Class_Type
|
||||
efl_class_type_get(const Efl_Class *klass_id)
|
||||
{
|
||||
EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EFL_CLASS_TYPE_INVALID);
|
||||
|
||||
return klass->desc->type;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ main(int argc, char *argv[])
|
|||
fail_if(!efl_isa(SIMPLE_CLASS, INTERFACE2_CLASS));
|
||||
fail_if(efl_isa(INTERFACE_CLASS, INTERFACE2_CLASS));
|
||||
|
||||
fail_if(efl_class_type_get(INTERFACE_CLASS) != EFL_CLASS_TYPE_INTERFACE);
|
||||
|
||||
efl_unref(obj);
|
||||
efl_object_shutdown();
|
||||
return 0;
|
||||
|
|
|
@ -46,6 +46,9 @@ main(int argc, char *argv[])
|
|||
printf("%d\n", a);
|
||||
fail_if(a != 5);
|
||||
|
||||
fail_if(efl_class_type_get(MIXIN_CLASS) != EFL_CLASS_TYPE_MIXIN);
|
||||
|
||||
|
||||
efl_unref(obj);
|
||||
efl_object_shutdown();
|
||||
return 0;
|
||||
|
|
|
@ -1841,6 +1841,13 @@ EFL_START_TEST(eo_test_class_replacement)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(eo_test_class_type)
|
||||
{
|
||||
ck_assert_int_eq(efl_class_type_get(SIMPLE_CLASS), EFL_CLASS_TYPE_REGULAR);
|
||||
ck_assert_int_eq(efl_class_type_get((void*)0xAFFE), EFL_CLASS_TYPE_INVALID);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void eo_test_general(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_simple);
|
||||
|
@ -1870,4 +1877,5 @@ void eo_test_general(TCase *tc)
|
|||
tcase_add_test(tc, efl_object_destruct_test);
|
||||
tcase_add_test(tc, efl_object_auto_unref_test);
|
||||
tcase_add_test(tc, efl_object_size);
|
||||
tcase_add_test(tc, eo_test_class_type);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue