a3344571db48da30ef3e20fe09d079b3ef423a17
[profile/ivi/eobj.git] / src / tests / function_overrides / inherit2.c
1 #include "Eo.h"
2 #include "simple.h"
3
4 #include "inherit.h"
5 #include "inherit2.h"
6
7 #include "config.h"
8
9 #include "../eunit_tests.h"
10
11 EAPI Eo_Op INHERIT2_BASE_ID = 0;
12
13 #define MY_CLASS INHERIT2_CLASS
14
15 static void
16 _a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
17 {
18    int a;
19    a = va_arg(*list, int);
20    printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
21    eo_do(obj, simple_a_print());
22    eo_do_super(obj, simple_a_set(a + 1));
23
24    fail_if(eo_do_super(obj, simple_a_print()));
25 }
26
27 static void
28 _print(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
29 {
30    printf("Hey\n");
31    fail_if(eo_do_super(obj, inherit2_print()));
32 }
33
34 static void
35 _print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
36 {
37    printf("Hey2\n");
38 }
39
40 static void
41 _class_print(const Eo_Class *klass, va_list *list)
42 {
43    (void) list;
44    printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS));
45    fail_if(!eo_class_do_super(klass, simple_class_print()));
46    fail_if(eo_class_do_super(klass, simple_class_print2()));
47 }
48
49 static void
50 _class_constructor(Eo_Class *klass)
51 {
52    const Eo_Op_Func_Description func_desc[] = {
53         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
54         EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT), _print),
55         EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT2), _print2),
56         EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT), _class_print),
57         EO_OP_FUNC_SENTINEL
58    };
59
60    eo_class_funcs_set(klass, func_desc);
61 }
62
63 static const Eo_Op_Description op_desc[] = {
64      EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT, "Print hey"),
65      EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT2, "Print hey2"),
66      EO_OP_DESCRIPTION_SENTINEL
67 };
68
69 static const Eo_Class_Description class_desc = {
70      "Inherit2",
71      EO_CLASS_TYPE_REGULAR,
72      EO_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
73      NULL,
74      0,
75      _class_constructor,
76      NULL
77 };
78
79 EO_DEFINE_CLASS(inherit2_class_get, &class_desc, INHERIT_CLASS, NULL);
80