summaryrefslogtreecommitdiff
path: root/src/tests/eo/mixin/mixin_mixin2.c
blob: 93f30f6156905b2c53729f17ae35a8876467835d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "mixin_mixin.h"
#include "mixin_mixin2.h"
#include "mixin_simple.h"

#include "../eunit_tests.h"

#define MY_CLASS MIXIN2_CLASS

static int
_ab_sum_get(Eo *obj, void *class_data)
{
   /* This cast is a hack just for the tests... */
   Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data;
   int sum = 0;
   printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
   sum = mixin_ab_sum_get(eo_super(obj, MY_CLASS));

   ++sum;
   pd->count += 2;

     {
        int _a = 0, _b = 0;
        _a = simple_a_get(obj);
        _b = simple_b_get(obj);
        fail_if(sum != _a + _b + 1);
     }

   return sum;
}

static Eo *
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
   obj = eo_constructor(eo_super(obj, MY_CLASS));
   return obj;
}

static void
_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
{
   eo_destructor(eo_super(obj, MY_CLASS));
}

static Eo_Op_Description op_descs[] = {
     EO_OP_FUNC_OVERRIDE(eo_constructor, _constructor),
     EO_OP_FUNC_OVERRIDE(eo_destructor, _destructor),
     EO_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get),
};

static const Eo_Class_Description class_desc = {
     EO_VERSION,
     "Mixin2",
     EO_CLASS_TYPE_MIXIN,
     EO_CLASS_DESCRIPTION_OPS(op_descs),
     NULL,
     sizeof(Mixin2_Public_Data),
     NULL,
     NULL
};

EO_DEFINE_CLASS(mixin2_class_get, &class_desc, MIXIN_CLASS, NULL);