efl/src/tests/eo/suite/eo_test_class_simple.c

162 lines
4.0 KiB
C

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Eo.h"
#include "eo_test_class_simple.h"
#define MY_CLASS SIMPLE_CLASS
EAPI const Efl_Event_Description _EV_A_CHANGED =
EFL_EVENT_DESCRIPTION("a,changed");
EAPI const Efl_Event_Description _EV_A_CHANGED2 =
EFL_EVENT_DESCRIPTION("a,changed");
static void
_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
{
Simple_Public_Data *pd = class_data;
printf("%s %d\n", efl_class_name_get(MY_CLASS), a);
pd->a = a;
efl_event_callback_call(obj, EV_A_CHANGED, &pd->a);
}
static int
_a_get(Eo *obj EINA_UNUSED, void *class_data)
{
Simple_Public_Data *pd = class_data;
return pd->a;
}
static Eina_Bool
_a_print(Eo *obj EINA_UNUSED, void *class_data)
{
const Simple_Public_Data *pd = class_data;
printf("Print %s %d\n", efl_class_name_get(MY_CLASS), pd->a);
return EINA_TRUE;
}
static Eina_Bool
_class_hi_print(Efl_Class *klass, void *data EINA_UNUSED)
{
printf("Hi Print %s\n", efl_class_name_get(klass));
return EINA_TRUE;
}
EFL_FUNC_BODYV(simple_part_get, Eo *, NULL, EFL_FUNC_CALL(name), const char *name);
static Eo *
_part_get(Eo *obj, void *class_data EINA_UNUSED, const char *name EINA_UNUSED)
{
/* A normal part get will do something saner, we just create objects. */
return efl_add(SIMPLE_CLASS, obj);
}
EFL_VOID_FUNC_BODYV(simple_recursive, EFL_FUNC_CALL(n), int n);
static void
_recursive(Eo *obj, void *class_data EINA_UNUSED, int n)
{
static int count = 0;
if (count < n)
{
count++;
simple_recursive(obj, n);
}
else
count = 0;
}
static void
_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Efl_Dbg_Info *root)
{
efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, "Test list");
EFL_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
}
EFL_VOID_FUNC_BODYV(simple_a_set, EFL_FUNC_CALL(a), int a);
EFL_FUNC_BODY(simple_a_get, int, 0);
EFL_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE);
EFL_FUNC_BODY_CONST(simple_class_hi_print, Eina_Bool, EINA_FALSE);
EFL_VOID_FUNC_BODY(simple_pure_virtual);
EFL_VOID_FUNC_BODY(simple_no_implementation);
static Efl_Op_Description op_descs[] = {
EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
EFL_OBJECT_OP_FUNC(simple_a_get, _a_get),
EFL_OBJECT_OP_FUNC(simple_a_print, _a_print),
EFL_OBJECT_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print),
EFL_OBJECT_OP_FUNC(simple_recursive, _recursive),
EFL_OBJECT_OP_FUNC(simple_part_get, _part_get),
EFL_OBJECT_OP_FUNC(simple_pure_virtual, NULL),
EFL_OBJECT_OP_FUNC_OVERRIDE(efl_dbg_info_get, _dbg_info_get),
};
static const Efl_Class_Description class_desc = {
EO_VERSION,
"Simple",
EFL_CLASS_TYPE_REGULAR,
EFL_CLASS_DESCRIPTION_OPS(op_descs),
sizeof(Simple_Public_Data),
NULL,
NULL
};
EFL_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL)
static int
_beef_get(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED)
{
return 0xBEEF;
}
EFL_FUNC_BODY_CONST(simple2_class_beef_get, int, 0);
static Efl_Op_Description op_descs2[] = {
EFL_OBJECT_OP_CLASS_FUNC(simple2_class_beef_get, _beef_get),
};
static const Efl_Class_Description class_desc2 = {
EO_VERSION,
"Simple2",
EFL_CLASS_TYPE_REGULAR,
EFL_CLASS_DESCRIPTION_OPS(op_descs2),
0,
NULL,
NULL
};
EFL_DEFINE_CLASS(simple2_class_get, &class_desc2, EO_CLASS, NULL)
static Efl_Object*
_interface_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Efl_Object *klass)
{
if (klass == SEARCHABLE_CLASS) return obj;
return efl_provider_find(efl_super(obj, SEARCHABLE_CLASS), klass);
}
static Efl_Op_Description op_descs_searchable[] = {
EFL_OBJECT_OP_FUNC_OVERRIDE(efl_provider_find, _interface_get)
};
static const Efl_Class_Description class_desc_searchable = {
EO_VERSION,
"Searchable",
EFL_CLASS_TYPE_REGULAR,
EFL_CLASS_DESCRIPTION_OPS(op_descs_searchable),
0,
NULL,
NULL
};
EFL_DEFINE_CLASS(searchable_class_get, &class_desc_searchable, EO_CLASS, NULL)