ae93708a6b401664dbf5ec16216ded0a209c8105
[profile/ivi/eobj.git] / src / tests / mixin / simple.c
1 #include "Eo.h"
2 #include "mixin.h"
3 #include "mixin2.h"
4 #include "mixin3.h"
5 #include "simple.h"
6
7 #include "config.h"
8
9 EAPI Eo_Op SIMPLE_BASE_ID = 0;
10
11 typedef struct
12 {
13    int a;
14    int b;
15 } Private_Data;
16
17 #define MY_CLASS SIMPLE_CLASS
18
19 #define _GET_SET_FUNC(name) \
20 static void \
21 _##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
22 { \
23    const Private_Data *pd = class_data; \
24    int *name; \
25    name = va_arg(*list, int *); \
26    *name = pd->name; \
27    printf("%s %d\n", __func__, pd->name); \
28 } \
29 static void \
30 _##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
31 { \
32    Private_Data *pd = class_data; \
33    int name; \
34    name = va_arg(*list, int); \
35    pd->name = name; \
36    printf("%s %d\n", __func__, pd->name); \
37 }
38
39 _GET_SET_FUNC(a)
40 _GET_SET_FUNC(b)
41
42 static void
43 _class_constructor(Eo_Class *klass)
44 {
45    const Eo_Op_Func_Description func_desc[] = {
46         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
47         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
48         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
49         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
50         EO_OP_FUNC_SENTINEL
51    };
52
53    eo_class_funcs_set(klass, func_desc);
54 }
55
56 static const Eo_Op_Description op_desc[] = {
57      EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
58      EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
59      EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
60      EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"),
61      EO_OP_DESCRIPTION_SENTINEL
62 };
63
64 static const Eo_Class_Description class_desc = {
65      EO_VERSION,
66      "Simple",
67      EO_CLASS_TYPE_REGULAR,
68      EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
69      NULL,
70      sizeof(Private_Data),
71      _class_constructor,
72      NULL
73 };
74
75 EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL);