Eo: Improved error reporting with failed constructors.
[profile/ivi/eobj.git] / examples / mixin / 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 _ab_sum_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
13 {
14    int a, b;
15    eo_query(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", eo_class_name_get(MY_CLASS), __func__);
20 }
21
22 static void
23 _constructor(Eo *obj, void *class_data EINA_UNUSED)
24 {
25    eo_constructor_super(obj);
26 }
27
28 static void
29 _destructor(Eo *obj, void *class_data EINA_UNUSED)
30 {
31    eo_destructor_super(obj);
32 }
33
34 static void
35 _class_constructor(Eo_Class *klass)
36 {
37    const Eo_Op_Func_Description func_desc[] = {
38         EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
39         EO_OP_FUNC_SENTINEL
40    };
41
42    eo_class_funcs_set(klass, func_desc);
43 }
44
45
46 static const Eo_Op_Description op_desc[] = {
47      EO_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_AB_SUM_GET, "i", "Get the sum of a and b."),
48      EO_OP_DESCRIPTION_SENTINEL
49 };
50
51 static const Eo_Class_Description class_desc = {
52      "Mixin",
53      EO_CLASS_TYPE_MIXIN,
54      EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
55      NULL,
56      0,
57      _constructor,
58      _destructor,
59      _class_constructor,
60      NULL
61 };
62
63 EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
64