eac643dca0564d7522121796b921c23506a37be5
[profile/ivi/eobj.git] / examples / constructors / mixin.c
1 #include "Eo.h"
2 #include "mixin.h"
3 #include "simple.h"
4
5 #include "config.h"
6
7 EAPI Eo_Op MIXIN_BASE_ID = 0;
8
9 #define MY_CLASS MIXIN_CLASS
10
11 static void
12 _add_and_print_set(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
13 {
14    int a, b, x;
15    eo_query(obj, simple_a_get(&a), simple_b_get(&b));
16    x = va_arg(*list, const int);
17    printf("%s %d\n", __func__, a + b + x);
18 }
19
20 extern int my_init_count;
21
22 static void
23 _constructor(Eo *obj, void *class_data EINA_UNUSED)
24 {
25    eo_constructor_super(obj);
26
27    my_init_count++;
28 }
29
30 static void
31 _destructor(Eo *obj, void *class_data EINA_UNUSED)
32 {
33    eo_destructor_super(obj);
34
35    my_init_count--;
36 }
37
38 static void
39 _class_constructor(Eo_Class *klass)
40 {
41    const Eo_Op_Func_Description func_desc[] = {
42         EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
43         EO_OP_FUNC_SENTINEL
44    };
45
46    eo_class_funcs_set(klass, func_desc);
47 }
48
49 static const Eo_Op_Description op_desc[] = {
50      EO_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_ADD_AND_SET, "i", "Add A + B + param and print it"),
51      EO_OP_DESCRIPTION_SENTINEL
52 };
53
54 static const Eo_Class_Description class_desc = {
55      "Mixin",
56      EO_CLASS_TYPE_MIXIN,
57      EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
58      NULL,
59      0,
60      _constructor,
61      _destructor,
62      _class_constructor,
63      NULL
64 };
65
66 EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL);
67