Add Tizen 2.0 packaging
[profile/ivi/eobj.git] / src / tests / composite_objects / comp.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include "Eo.h"
6 #include "simple.h"
7 #include "comp.h"
8
9 #include "../eunit_tests.h"
10
11 EAPI Eo_Op COMP_BASE_ID = 0;
12
13 #define MY_CLASS COMP_CLASS
14
15 static void
16 _a_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
17 {
18    int *a;
19    a = va_arg(*list, int *);
20    eo_do_super(obj, simple_a_get(a));
21 }
22
23 static void
24 _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
25 {
26    eo_do_super(obj, eo_constructor());
27
28    Eo *simple = eo_add(SIMPLE_CLASS, obj);
29    eo_composite_attach(simple, obj);
30    eo_do(simple, eo_event_callback_forwarder_add(EV_A_CHANGED, obj));
31
32    fail_if(eo_composite_is(obj));
33    fail_if(!eo_composite_is(simple));
34
35    eo_do(obj, eo_base_data_set("simple-obj", simple, NULL));
36
37    eo_unref(simple);
38 }
39
40 static void
41 _class_constructor(Eo_Class *klass)
42 {
43    const Eo_Op_Func_Description func_desc[] = {
44         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
45         EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
46         EO_OP_FUNC_SENTINEL
47    };
48
49    eo_class_funcs_set(klass, func_desc);
50 }
51
52 static const Eo_Class_Description class_desc = {
53      EO_VERSION,
54      "Comp",
55      EO_CLASS_TYPE_REGULAR,
56      EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
57      NULL,
58      0,
59      _class_constructor,
60      NULL
61 };
62
63 EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_BASE_CLASS,
64       SIMPLE_CLASS, NULL);
65