c17dea60c03527fd4d9198c1107756f609af864f
[profile/ivi/eobj.git] / src / tests / mixin / mixin2.c
1 #include "Eo.h"
2 #include "mixin.h"
3 #include "mixin2.h"
4 #include "simple.h"
5
6 #include "config.h"
7
8 #include "../eunit_tests.h"
9
10 #define MY_CLASS MIXIN2_CLASS
11
12 static void
13 _ab_sum_get(Eo *obj, void *class_data, va_list *list)
14 {
15    /* This cast is a hack just for the tests... */
16    Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data;
17    int *sum = va_arg(*list, int *);
18    printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
19    eo_do_super(obj, mixin_ab_sum_get(sum));
20
21    ++*sum;
22    pd->count += 2;
23
24      {
25         int _a, _b;
26         eo_do(obj, simple_a_get(&_a), simple_b_get(&_b));
27         fail_if(*sum != _a + _b + 1);
28      }
29 }
30
31 static void
32 _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
33 {
34    eo_do_super(obj, eo_constructor());
35 }
36
37 static void
38 _destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
39 {
40    eo_do_super(obj, eo_destructor());
41 }
42
43 static void
44 _class_constructor(Eo_Class *klass)
45 {
46    const Eo_Op_Func_Description func_desc[] = {
47         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
48         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
49         EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
50         EO_OP_FUNC_SENTINEL
51    };
52
53    eo_class_funcs_set(klass, func_desc);
54 }
55
56 static const Eo_Class_Description class_desc = {
57      EO_VERSION,
58      "Mixin2",
59      EO_CLASS_TYPE_MIXIN,
60      EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
61      NULL,
62      sizeof(Mixin2_Public_Data),
63      _class_constructor,
64      NULL
65 };
66
67 EO_DEFINE_CLASS(mixin2_class_get, &class_desc, MIXIN_CLASS, NULL);
68