efl/src/tests/eo/interface/interface_simple.c

79 lines
1.9 KiB
C
Raw Normal View History

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "Eo.h"
2012-09-25 23:56:52 -07:00
#include "interface_interface.h"
#include "interface_interface2.h"
#include "interface_simple.h"
typedef struct
{
int a;
int b;
} Private_Data;
#define MY_CLASS SIMPLE_CLASS
#define _GET_SET_FUNC(name) \
2013-11-07 09:20:11 -08:00
static int \
_##name##_get(Eo *obj EINA_UNUSED, void *class_data) \
{ \
const Private_Data *pd = class_data; \
printf("%s %d\n", __func__, pd->name); \
2013-11-07 09:20:11 -08:00
return pd->name; \
} \
static void \
2013-11-07 09:20:11 -08:00
_##name##_set(Eo *obj EINA_UNUSED, void *class_data, int name) \
{ \
Private_Data *pd = class_data; \
pd->name = name; \
printf("%s %d\n", __func__, pd->name); \
2013-11-07 09:20:11 -08:00
} \
EO2_VOID_FUNC_BODYV(simple_##name##_set, EO2_FUNC_CALL(name), int name); \
EO2_FUNC_BODY(simple_##name##_get, int, 0);
_GET_SET_FUNC(a)
_GET_SET_FUNC(b)
2013-11-07 09:20:11 -08:00
static int
_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED)
{
int a, b;
2013-11-07 09:20:11 -08:00
eo2_do(obj, a = simple_a_get(), b = simple_b_get());
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
2013-11-07 09:20:11 -08:00
return a + b;
}
2013-11-07 09:20:11 -08:00
static int
_ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED)
{
int a, b;
2013-11-07 09:20:11 -08:00
eo2_do(obj, a = simple_a_get(), b = simple_b_get());
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
2013-11-07 09:20:11 -08:00
return a + b + 1;
}
2013-11-07 09:20:11 -08:00
static Eo2_Op_Description op_descs[] = {
EO2_OP_FUNC(simple_a_set, _a_set, "Set property a"),
EO2_OP_FUNC(simple_a_get, _a_get, "Get property a"),
EO2_OP_FUNC(simple_b_set, _b_set, "Set property b"),
EO2_OP_FUNC(simple_b_get, _b_get, "Get property b"),
EO2_OP_FUNC_OVERRIDE(interface_ab_sum_get, _ab_sum_get),
EO2_OP_FUNC_OVERRIDE(interface2_ab_sum_get2, _ab_sum_get2),
2013-11-07 09:20:11 -08:00
EO2_OP_SENTINEL
};
static const Eo_Class_Description class_desc = {
2013-11-07 09:20:11 -08:00
EO2_VERSION,
"Simple",
EO_CLASS_TYPE_REGULAR,
2013-11-07 09:20:11 -08:00
EO2_CLASS_DESCRIPTION_OPS(op_descs),
NULL,
sizeof(Private_Data),
2013-11-07 09:20:11 -08:00
NULL,
NULL
};
2013-11-07 09:20:11 -08:00
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, INTERFACE2_CLASS, NULL);