Eo: Removed the const op concept.
[profile/ivi/eobj.git] / src / tests / composite_objects / simple.c
1 #include "Eo.h"
2 #include "simple.h"
3
4 #include "config.h"
5
6 EAPI Eo_Op SIMPLE_BASE_ID = 0;
7
8 EAPI const Eo_Event_Description _EV_A_CHANGED =
9         EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed.");
10
11 #define MY_CLASS SIMPLE_CLASS
12
13 static void
14 _a_set(Eo *obj, void *class_data, va_list *list)
15 {
16    Simple_Public_Data *pd = class_data;
17    int a;
18    a = va_arg(*list, int);
19    printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
20    pd->a = a;
21
22    eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
23 }
24
25 static void
26 _a_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
27 {
28    const Simple_Public_Data *pd = class_data;
29    int *a;
30    a = va_arg(*list, int *);
31    *a = pd->a;
32 }
33
34 static void
35 _class_constructor(Eo_Class *klass)
36 {
37    const Eo_Op_Func_Description func_desc[] = {
38         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
39         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
40         EO_OP_FUNC_SENTINEL
41    };
42
43    eo_class_funcs_set(klass, func_desc);
44 }
45
46 static const Eo_Op_Description op_desc[] = {
47      EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
48      EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
49      EO_OP_DESCRIPTION_SENTINEL
50 };
51
52 static const Eo_Event_Description *event_desc[] = {
53      EV_A_CHANGED,
54      NULL
55 };
56
57 static const Eo_Class_Description class_desc = {
58      "Simple",
59      EO_CLASS_TYPE_REGULAR,
60      EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
61      event_desc,
62      sizeof(Simple_Public_Data),
63      _class_constructor,
64      NULL
65 };
66
67 EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
68