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