Eobj: s/__UNUSED__/EINA_UNUSED/ I had no idea that exists.
[profile/ivi/eobj.git] / examples / mixin / mixin.c
1 #include "Eobj.h"
2 #include "mixin.h"
3 #include "simple.h"
4
5 #include "config.h"
6
7 EAPI Eobj_Op MIXIN_BASE_ID = 0;
8
9 static const Eobj_Class *_my_class = NULL;
10
11 static void
12 _ab_sum_get(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
13 {
14    int a, b;
15    eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b));
16    int *sum = va_arg(*list, int *);
17    if (sum)
18       *sum = a + b;
19    printf("%s %s\n", eobj_class_name_get(_my_class), __func__);
20 }
21
22 static void
23 _constructor(Eobj *obj, void *class_data EINA_UNUSED)
24 {
25    eobj_constructor_super(obj);
26 }
27
28 static void
29 _destructor(Eobj *obj, void *class_data EINA_UNUSED)
30 {
31    eobj_destructor_super(obj);
32 }
33
34 static void
35 _class_constructor(Eobj_Class *klass)
36 {
37    const Eobj_Op_Func_Description func_desc[] = {
38         EOBJ_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
39         EOBJ_OP_FUNC_SENTINEL
40    };
41
42    eobj_class_funcs_set(klass, func_desc);
43 }
44
45 const Eobj_Class *
46 mixin_class_get(void)
47 {
48    if (_my_class) return _my_class;
49
50    static const Eobj_Op_Description op_desc[] = {
51         EOBJ_OP_DESCRIPTION(MIXIN_SUB_ID_AB_SUM_GET, "i", "Get the sum of a and b."),
52         EOBJ_OP_DESCRIPTION_SENTINEL
53    };
54
55    static const Eobj_Class_Description class_desc = {
56         "Mixin",
57         EOBJ_CLASS_TYPE_MIXIN,
58         EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
59         NULL,
60         0,
61         _constructor,
62         _destructor,
63         _class_constructor,
64         NULL
65    };
66
67    _my_class = eobj_class_new(&class_desc, NULL, NULL);
68
69    return _my_class;
70 }