summaryrefslogtreecommitdiff
path: root/src/tests/eo
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-09-26 06:56:52 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-09-26 06:56:52 +0000
commit3b5a3448b7dfc53c2f129bdb04bea9f7a02741a6 (patch)
tree18ad8a6b1841e9832c85a46f887b2cd6d6dacc4b /src/tests/eo
parent195d31c73fef88cfaa803b07b2ae3cba983a4093 (diff)
merge: add eo
SVN revision: 77072
Diffstat (limited to 'src/tests/eo')
-rw-r--r--src/tests/eo/Makefile.am126
-rw-r--r--src/tests/eo/access/access_inherit.c49
-rw-r--r--src/tests/eo/access/access_inherit.h18
-rw-r--r--src/tests/eo/access/access_main.c27
-rw-r--r--src/tests/eo/access/access_simple.c70
-rw-r--r--src/tests/eo/access/access_simple.h26
-rw-r--r--src/tests/eo/access/access_simple_protected.h10
-rw-r--r--src/tests/eo/composite_objects/composite_objects_comp.c65
-rw-r--r--src/tests/eo/composite_objects/composite_objects_comp.h7
-rw-r--r--src/tests/eo/composite_objects/composite_objects_main.c65
-rw-r--r--src/tests/eo/composite_objects/composite_objects_simple.c71
-rw-r--r--src/tests/eo/composite_objects/composite_objects_simple.h28
-rw-r--r--src/tests/eo/constructors/constructors_main.c79
-rw-r--r--src/tests/eo/constructors/constructors_mixin.c70
-rw-r--r--src/tests/eo/constructors/constructors_mixin.h18
-rw-r--r--src/tests/eo/constructors/constructors_simple.c124
-rw-r--r--src/tests/eo/constructors/constructors_simple.h26
-rw-r--r--src/tests/eo/constructors/constructors_simple2.c42
-rw-r--r--src/tests/eo/constructors/constructors_simple2.h7
-rw-r--r--src/tests/eo/constructors/constructors_simple3.c40
-rw-r--r--src/tests/eo/constructors/constructors_simple3.h7
-rw-r--r--src/tests/eo/constructors/constructors_simple4.c24
-rw-r--r--src/tests/eo/constructors/constructors_simple4.h7
-rw-r--r--src/tests/eo/constructors/constructors_simple5.c40
-rw-r--r--src/tests/eo/constructors/constructors_simple5.h7
-rw-r--r--src/tests/eo/constructors/constructors_simple6.c42
-rw-r--r--src/tests/eo/constructors/constructors_simple6.h7
-rw-r--r--src/tests/eo/constructors/constructors_simple7.c43
-rw-r--r--src/tests/eo/constructors/constructors_simple7.h7
-rw-r--r--src/tests/eo/eunit_tests.h17
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit.c22
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit.h7
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit2.c82
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit2.h20
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit3.c44
-rw-r--r--src/tests/eo/function_overrides/function_overrides_inherit3.h7
-rw-r--r--src/tests/eo/function_overrides/function_overrides_main.c63
-rw-r--r--src/tests/eo/function_overrides/function_overrides_simple.c82
-rw-r--r--src/tests/eo/function_overrides/function_overrides_simple.h32
-rw-r--r--src/tests/eo/interface/interface_interface.c30
-rw-r--r--src/tests/eo/interface/interface_interface.h24
-rw-r--r--src/tests/eo/interface/interface_interface2.c31
-rw-r--r--src/tests/eo/interface/interface_interface2.h24
-rw-r--r--src/tests/eo/interface/interface_main.c37
-rw-r--r--src/tests/eo/interface/interface_simple.c100
-rw-r--r--src/tests/eo/interface/interface_simple.h47
-rw-r--r--src/tests/eo/mixin/mixin_inherit.c42
-rw-r--r--src/tests/eo/mixin/mixin_inherit.h7
-rw-r--r--src/tests/eo/mixin/mixin_main.c47
-rw-r--r--src/tests/eo/mixin/mixin_mixin.c67
-rw-r--r--src/tests/eo/mixin/mixin_mixin.h24
-rw-r--r--src/tests/eo/mixin/mixin_mixin2.c70
-rw-r--r--src/tests/eo/mixin/mixin_mixin2.h12
-rw-r--r--src/tests/eo/mixin/mixin_mixin3.c70
-rw-r--r--src/tests/eo/mixin/mixin_mixin3.h12
-rw-r--r--src/tests/eo/mixin/mixin_mixin4.c26
-rw-r--r--src/tests/eo/mixin/mixin_mixin4.h7
-rw-r--r--src/tests/eo/mixin/mixin_simple.c77
-rw-r--r--src/tests/eo/mixin/mixin_simple.h47
-rw-r--r--src/tests/eo/signals/signals_main.c183
-rw-r--r--src/tests/eo/signals/signals_simple.c112
-rw-r--r--src/tests/eo/signals/signals_simple.h31
-rw-r--r--src/tests/eo/suite/eo_suite.c106
-rw-r--r--src/tests/eo/suite/eo_suite.h11
-rw-r--r--src/tests/eo/suite/eo_test_class_errors.c350
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.c69
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.h30
-rw-r--r--src/tests/eo/suite/eo_test_general.c752
-rw-r--r--src/tests/eo/suite/eo_test_init.c22
69 files changed, 3995 insertions, 0 deletions
diff --git a/src/tests/eo/Makefile.am b/src/tests/eo/Makefile.am
new file mode 100644
index 0000000000..15241bb087
--- /dev/null
+++ b/src/tests/eo/Makefile.am
@@ -0,0 +1,126 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib/eo \
5-I$(top_builddir)/src/lib/eo \
6@EFL_EO_BUILD@ \
7@EO_CFLAGS@ \
8@CHECK_CFLAGS@
9
10check_PROGRAMS = \
11test_access \
12test_composite_objects \
13test_constructors \
14test_function_overrides \
15test_interface \
16test_mixin \
17test_signals
18
19if EFL_ENABLE_TESTS
20check_PROGRAMS += eo_suite
21endif
22
23test_access_SOURCES = \
24access/access_inherit.c \
25access/access_inherit.h \
26access/access_main.c \
27access/access_simple.c \
28access/access_simple.h \
29access/access_simple_protected.h
30
31test_access_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
32
33test_composite_objects_SOURCES = \
34composite_objects/composite_objects_comp.c \
35composite_objects/composite_objects_comp.h \
36composite_objects/composite_objects_main.c \
37composite_objects/composite_objects_simple.c \
38composite_objects/composite_objects_simple.h
39
40test_composite_objects_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
41
42test_constructors_SOURCES = \
43constructors/constructors_main.c \
44constructors/constructors_mixin.c \
45constructors/constructors_mixin.h \
46constructors/constructors_simple.c \
47constructors/constructors_simple.h \
48constructors/constructors_simple2.c \
49constructors/constructors_simple2.h \
50constructors/constructors_simple3.c \
51constructors/constructors_simple3.h \
52constructors/constructors_simple4.c \
53constructors/constructors_simple4.h \
54constructors/constructors_simple5.c \
55constructors/constructors_simple5.h \
56constructors/constructors_simple6.c \
57constructors/constructors_simple6.h \
58constructors/constructors_simple7.c \
59constructors/constructors_simple7.h
60
61test_constructors_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
62
63if EFL_ENABLE_TESTS
64
65eo_suite_SOURCES = \
66suite/eo_test_class_simple.c \
67suite/eo_test_class_simple.h \
68suite/eo_suite.c \
69suite/eo_suite.h \
70suite/eo_test_class_errors.c \
71suite/eo_test_general.c \
72suite/eo_test_init.c
73
74eo_suite_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@ @CHECK_LIBS@
75
76endif
77
78test_function_overrides_SOURCES = \
79function_overrides/function_overrides_inherit.c \
80function_overrides/function_overrides_inherit.h \
81function_overrides/function_overrides_inherit2.c \
82function_overrides/function_overrides_inherit2.h \
83function_overrides/function_overrides_inherit3.c \
84function_overrides/function_overrides_inherit3.h \
85function_overrides/function_overrides_main.c \
86function_overrides/function_overrides_simple.c \
87function_overrides/function_overrides_simple.h
88
89test_function_overrides_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
90
91test_interface_SOURCES = \
92interface/interface_interface.c \
93interface/interface_interface.h \
94interface/interface_interface2.c \
95interface/interface_interface2.h \
96interface/interface_main.c \
97interface/interface_simple.c \
98interface/interface_simple.h
99
100test_interface_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
101
102test_mixin_SOURCES = \
103mixin/mixin_inherit.c \
104mixin/mixin_inherit.h \
105mixin/mixin_main.c \
106mixin/mixin_mixin.c \
107mixin/mixin_mixin.h \
108mixin/mixin_mixin2.c \
109mixin/mixin_mixin2.h \
110mixin/mixin_mixin3.c \
111mixin/mixin_mixin3.h \
112mixin/mixin_mixin4.c \
113mixin/mixin_mixin4.h \
114mixin/mixin_simple.c \
115mixin/mixin_simple.h
116
117test_mixin_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
118
119test_signals_SOURCES = \
120signals/signals_main.c \
121signals/signals_simple.c \
122signals/signals_simple.h
123
124test_signals_LDADD = $(top_builddir)/src/lib/eo/libeo.la @EO_LIBS@
125
126EXTRA_DIST = eunit_tests.h
diff --git a/src/tests/eo/access/access_inherit.c b/src/tests/eo/access/access_inherit.c
new file mode 100644
index 0000000000..4d1c81efcd
--- /dev/null
+++ b/src/tests/eo/access/access_inherit.c
@@ -0,0 +1,49 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "access_simple.h"
7#include "access_simple_protected.h"
8#include "access_inherit.h"
9
10EAPI Eo_Op INHERIT_BASE_ID = 0;
11
12#define MY_CLASS INHERIT_CLASS
13
14static void
15_prot_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
16{
17 Simple_Protected_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
18 (void) list;
19 printf("%s %d\n", __func__, pd->protected_x1);
20}
21
22static void
23_class_constructor(Eo_Class *klass)
24{
25 const Eo_Op_Func_Description func_desc[] = {
26 EO_OP_FUNC(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print),
27 EO_OP_FUNC_SENTINEL
28 };
29
30 eo_class_funcs_set(klass, func_desc);
31}
32
33static const Eo_Op_Description op_desc[] = {
34 EO_OP_DESCRIPTION(INHERIT_SUB_ID_PROT_PRINT, "Print protected var x1."),
35 EO_OP_DESCRIPTION_SENTINEL
36};
37
38static const Eo_Class_Description class_desc = {
39 EO_VERSION,
40 "Inherit",
41 EO_CLASS_TYPE_REGULAR,
42 EO_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
43 NULL,
44 0,
45 _class_constructor,
46 NULL
47};
48
49EO_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL)
diff --git a/src/tests/eo/access/access_inherit.h b/src/tests/eo/access/access_inherit.h
new file mode 100644
index 0000000000..f701dae484
--- /dev/null
+++ b/src/tests/eo/access/access_inherit.h
@@ -0,0 +1,18 @@
1#ifndef INHERIT_H
2#define INHERIT_H
3
4extern EAPI Eo_Op INHERIT_BASE_ID;
5
6enum {
7 INHERIT_SUB_ID_PROT_PRINT,
8 INHERIT_SUB_ID_LAST
9};
10
11#define INHERIT_ID(sub_id) (INHERIT_BASE_ID + sub_id)
12
13#define inherit_prot_print() INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT)
14
15#define INHERIT_CLASS inherit_class_get()
16const Eo_Class *inherit_class_get(void);
17
18#endif
diff --git a/src/tests/eo/access/access_main.c b/src/tests/eo/access/access_main.c
new file mode 100644
index 0000000000..474f3b9a49
--- /dev/null
+++ b/src/tests/eo/access/access_main.c
@@ -0,0 +1,27 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "access_simple.h"
7#include "access_inherit.h"
8
9int
10main(int argc, char *argv[])
11{
12 (void) argc;
13 (void) argv;
14 eo_init();
15
16 Eo *obj = eo_add(INHERIT_CLASS, NULL);
17
18 eo_do(obj, simple_a_set(1), inherit_prot_print());
19
20 Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
21 printf("Pub: %d\n", pd->public_x2);
22
23 eo_unref(obj);
24 eo_shutdown();
25 return 0;
26}
27
diff --git a/src/tests/eo/access/access_simple.c b/src/tests/eo/access/access_simple.c
new file mode 100644
index 0000000000..42fa259e40
--- /dev/null
+++ b/src/tests/eo/access/access_simple.c
@@ -0,0 +1,70 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "access_simple.h"
7#include "access_simple_protected.h"
8
9EAPI Eo_Op SIMPLE_BASE_ID = 0;
10
11typedef struct
12{
13 Simple_Protected_Data protected;
14 int a;
15} Private_Data;
16
17EAPI const Eo_Event_Description _EV_A_CHANGED =
18 EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed.");
19
20#define MY_CLASS SIMPLE_CLASS
21
22static void
23_a_set(Eo *obj, void *class_data, va_list *list)
24{
25 Private_Data *pd = class_data;
26 int a;
27 a = va_arg(*list, int);
28 pd->a = a;
29 printf("%s %d\n", __func__, pd->a);
30
31 pd->protected.protected_x1 = a + 1;
32 pd->protected.public.public_x2 = a + 2;
33
34 eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
35}
36
37static void
38_class_constructor(Eo_Class *klass)
39{
40 const Eo_Op_Func_Description func_desc[] = {
41 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
42 EO_OP_FUNC_SENTINEL
43 };
44
45 eo_class_funcs_set(klass, func_desc);
46}
47
48static const Eo_Op_Description op_desc[] = {
49 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
50 EO_OP_DESCRIPTION_SENTINEL
51};
52
53static const Eo_Event_Description *event_desc[] = {
54 EV_A_CHANGED,
55 NULL
56};
57
58static const Eo_Class_Description class_desc = {
59 EO_VERSION,
60 "Simple",
61 EO_CLASS_TYPE_REGULAR,
62 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
63 event_desc,
64 sizeof(Private_Data),
65 _class_constructor,
66 NULL
67};
68
69EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
70
diff --git a/src/tests/eo/access/access_simple.h b/src/tests/eo/access/access_simple.h
new file mode 100644
index 0000000000..11624b7d20
--- /dev/null
+++ b/src/tests/eo/access/access_simple.h
@@ -0,0 +1,26 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_LAST
9};
10
11typedef struct
12{
13 int public_x2;
14} Simple_Public_Data;
15
16#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
17
18#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
19
20extern const Eo_Event_Description _EV_A_CHANGED;
21#define EV_A_CHANGED (&(_EV_A_CHANGED))
22
23#define SIMPLE_CLASS simple_class_get()
24const Eo_Class *simple_class_get(void);
25
26#endif
diff --git a/src/tests/eo/access/access_simple_protected.h b/src/tests/eo/access/access_simple_protected.h
new file mode 100644
index 0000000000..3cabcd804b
--- /dev/null
+++ b/src/tests/eo/access/access_simple_protected.h
@@ -0,0 +1,10 @@
1#ifndef SIMPLE_PROTECTED_H
2#define SIMPLE_PROTECTED_H
3
4typedef struct
5{
6 Simple_Public_Data public;
7 int protected_x1;
8} Simple_Protected_Data;
9
10#endif
diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c
new file mode 100644
index 0000000000..b15770c9da
--- /dev/null
+++ b/src/tests/eo/composite_objects/composite_objects_comp.c
@@ -0,0 +1,65 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "composite_objects_simple.h"
7#include "composite_objects_comp.h"
8
9#include "../eunit_tests.h"
10
11EAPI Eo_Op COMP_BASE_ID = 0;
12
13#define MY_CLASS COMP_CLASS
14
15static 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
23static 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
40static 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
52static 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
63EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_BASE_CLASS,
64 SIMPLE_CLASS, NULL);
65
diff --git a/src/tests/eo/composite_objects/composite_objects_comp.h b/src/tests/eo/composite_objects/composite_objects_comp.h
new file mode 100644
index 0000000000..95001b7020
--- /dev/null
+++ b/src/tests/eo/composite_objects/composite_objects_comp.h
@@ -0,0 +1,7 @@
1#ifndef COMP_H
2#define COMP_H
3
4#define COMP_CLASS comp_class_get()
5const Eo_Class *comp_class_get(void);
6
7#endif
diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c
new file mode 100644
index 0000000000..2e5d9ab005
--- /dev/null
+++ b/src/tests/eo/composite_objects/composite_objects_main.c
@@ -0,0 +1,65 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "composite_objects_simple.h"
7#include "composite_objects_comp.h"
8
9#include "../eunit_tests.h"
10
11static int cb_called = EINA_FALSE;
12
13static Eina_Bool
14_a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
15{
16 (void) desc;
17 (void) obj;
18 int new_a = *((int *) event_info);
19 printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
20
21 cb_called = EINA_TRUE;
22
23 return EO_CALLBACK_CONTINUE;
24}
25
26int
27main(int argc, char *argv[])
28{
29 (void) argc;
30 (void) argv;
31 eo_init();
32
33 Eo *obj = eo_add(COMP_CLASS, NULL);
34 eo_do(obj, eo_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL));
35
36 int a;
37 eo_do(obj, simple_a_set(1));
38 fail_if(!cb_called);
39
40 eo_do(obj, simple_a_get(&a));
41 fail_if(a != 1);
42
43 /* disable the callback forwarder, and fail if it's still called. */
44 Eo *simple;
45 eo_do(obj, eo_base_data_get("simple-obj", (void **) &simple));
46 eo_ref(simple);
47 eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, obj));
48
49 cb_called = EINA_FALSE;
50 eo_do(obj, simple_a_set(2));
51 fail_if(cb_called);
52
53 fail_if(!eo_composite_is(simple));
54 eo_composite_detach(simple, obj);
55 fail_if(eo_composite_is(simple));
56 eo_composite_attach(simple, obj);
57 fail_if(!eo_composite_is(simple));
58
59 eo_unref(simple);
60 eo_unref(obj);
61
62 eo_shutdown();
63 return 0;
64}
65
diff --git a/src/tests/eo/composite_objects/composite_objects_simple.c b/src/tests/eo/composite_objects/composite_objects_simple.c
new file mode 100644
index 0000000000..5420ef895d
--- /dev/null
+++ b/src/tests/eo/composite_objects/composite_objects_simple.c
@@ -0,0 +1,71 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "composite_objects_simple.h"
7
8EAPI Eo_Op SIMPLE_BASE_ID = 0;
9
10EAPI const Eo_Event_Description _EV_A_CHANGED =
11 EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed.");
12
13#define MY_CLASS SIMPLE_CLASS
14
15static void
16_a_set(Eo *obj, void *class_data, va_list *list)
17{
18 Simple_Public_Data *pd = class_data;
19 int a;
20 a = va_arg(*list, int);
21 printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
22 pd->a = a;
23
24 eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
25}
26
27static void
28_a_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
29{
30 const Simple_Public_Data *pd = class_data;
31 int *a;
32 a = va_arg(*list, int *);
33 *a = pd->a;
34}
35
36static void
37_class_constructor(Eo_Class *klass)
38{
39 const Eo_Op_Func_Description func_desc[] = {
40 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
41 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
42 EO_OP_FUNC_SENTINEL
43 };
44
45 eo_class_funcs_set(klass, func_desc);
46}
47
48static const Eo_Op_Description op_desc[] = {
49 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
50 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
51 EO_OP_DESCRIPTION_SENTINEL
52};
53
54static const Eo_Event_Description *event_desc[] = {
55 EV_A_CHANGED,
56 NULL
57};
58
59static const Eo_Class_Description class_desc = {
60 EO_VERSION,
61 "Simple",
62 EO_CLASS_TYPE_REGULAR,
63 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
64 event_desc,
65 sizeof(Simple_Public_Data),
66 _class_constructor,
67 NULL
68};
69
70EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
71
diff --git a/src/tests/eo/composite_objects/composite_objects_simple.h b/src/tests/eo/composite_objects/composite_objects_simple.h
new file mode 100644
index 0000000000..32a62465b8
--- /dev/null
+++ b/src/tests/eo/composite_objects/composite_objects_simple.h
@@ -0,0 +1,28 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_A_GET,
9 SIMPLE_SUB_ID_LAST
10};
11
12typedef struct
13{
14 int a;
15} Simple_Public_Data;
16
17#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
18
19#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
20#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
21
22extern const Eo_Event_Description _EV_A_CHANGED;
23#define EV_A_CHANGED (&(_EV_A_CHANGED))
24
25#define SIMPLE_CLASS simple_class_get()
26const Eo_Class *simple_class_get(void);
27
28#endif
diff --git a/src/tests/eo/constructors/constructors_main.c b/src/tests/eo/constructors/constructors_main.c
new file mode 100644
index 0000000000..c7db62d398
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_main.c
@@ -0,0 +1,79 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_simple.h"
7#include "constructors_simple2.h"
8#include "constructors_simple3.h"
9#include "constructors_simple4.h"
10#include "constructors_simple5.h"
11#include "constructors_simple6.h"
12#include "constructors_simple7.h"
13#include "constructors_mixin.h"
14
15#include "../eunit_tests.h"
16
17int my_init_count = 0;
18
19int
20main(int argc, char *argv[])
21{
22 int ret = 0;
23 (void) argc;
24 (void) argv;
25 eo_init();
26
27 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
28
29 fail_if(my_init_count != 2);
30
31 eo_do(obj, simple_a_set(1), simple_b_set(2));
32
33 int a, b;
34 eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_add_and_print(5));
35
36 eo_unref(obj);
37
38 fail_if(my_init_count != 0);
39
40 obj = eo_add(SIMPLE2_CLASS, NULL);
41 fail_if(obj);
42
43 obj = eo_add(SIMPLE3_CLASS, NULL);
44 fail_if(obj);
45
46 my_init_count = 0;
47 obj = eo_add(SIMPLE4_CLASS, NULL);
48
49 fail_if(my_init_count != 2);
50
51 eo_unref(obj);
52
53 fail_if(my_init_count != 0);
54
55 obj = eo_add(SIMPLE5_CLASS, NULL);
56 fail_if(!obj);
57 eo_unref(obj);
58
59 obj = eo_add(SIMPLE6_CLASS, NULL);
60 fail_if(!obj);
61 eo_unref(obj);
62
63 obj = eo_add(SIMPLE7_CLASS, NULL);
64 fail_if(obj);
65
66 my_init_count = 0;
67 obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7));
68 fail_if(!obj);
69
70 fail_if(my_init_count != 2);
71 eo_do(obj, simple_a_get(&a));
72 fail_if(a != 7);
73
74 eo_unref(obj);
75
76 eo_shutdown();
77 return ret;
78}
79
diff --git a/src/tests/eo/constructors/constructors_mixin.c b/src/tests/eo/constructors/constructors_mixin.c
new file mode 100644
index 0000000000..7e4be36e57
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_mixin.c
@@ -0,0 +1,70 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple.h"
8
9EAPI Eo_Op MIXIN_BASE_ID = 0;
10
11#define MY_CLASS MIXIN_CLASS
12
13static void
14_add_and_print_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
15{
16 int a, b, x;
17 eo_do(obj, simple_a_get(&a), simple_b_get(&b));
18 x = va_arg(*list, const int);
19 printf("%s %d\n", __func__, a + b + x);
20}
21
22extern int my_init_count;
23
24static void
25_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
26{
27 eo_do_super(obj, eo_constructor());
28
29 my_init_count++;
30}
31
32static void
33_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
34{
35 eo_do_super(obj, eo_destructor());
36
37 my_init_count--;
38}
39
40static 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(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
46 EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
47 EO_OP_FUNC_SENTINEL
48 };
49
50 eo_class_funcs_set(klass, func_desc);
51}
52
53static const Eo_Op_Description op_desc[] = {
54 EO_OP_DESCRIPTION(MIXIN_SUB_ID_ADD_AND_SET, "Add A + B + param and print it"),
55 EO_OP_DESCRIPTION_SENTINEL
56};
57
58static const Eo_Class_Description class_desc = {
59 EO_VERSION,
60 "Mixin",
61 EO_CLASS_TYPE_MIXIN,
62 EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
63 NULL,
64 0,
65 _class_constructor,
66 NULL
67};
68
69EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL);
70
diff --git a/src/tests/eo/constructors/constructors_mixin.h b/src/tests/eo/constructors/constructors_mixin.h
new file mode 100644
index 0000000000..9998b274f4
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_mixin.h
@@ -0,0 +1,18 @@
1#ifndef MIXIN_H
2#define MIXIN_H
3
4extern EAPI Eo_Op MIXIN_BASE_ID;
5
6enum {
7 MIXIN_SUB_ID_ADD_AND_SET,
8 MIXIN_SUB_ID_LAST
9};
10
11#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
12
13#define mixin_add_and_print(x) MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), EO_TYPECHECK(int, x)
14
15#define MIXIN_CLASS mixin_class_get()
16const Eo_Class *mixin_class_get(void);
17
18#endif
diff --git a/src/tests/eo/constructors/constructors_simple.c b/src/tests/eo/constructors/constructors_simple.c
new file mode 100644
index 0000000000..b598650d73
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple.c
@@ -0,0 +1,124 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple.h"
8
9EAPI Eo_Op SIMPLE_BASE_ID = 0;
10
11typedef struct
12{
13 int a;
14 int b;
15} Private_Data;
16
17#define MY_CLASS SIMPLE_CLASS
18
19static char *class_var = NULL;
20
21#define _GET_SET_FUNC(name) \
22static void \
23_##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
24{ \
25 const Private_Data *pd = class_data; \
26 int *name; \
27 name = va_arg(*list, int *); \
28 *name = pd->name; \
29 printf("%s %d\n", __func__, pd->name); \
30} \
31static void \
32_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
33{ \
34 Private_Data *pd = class_data; \
35 int name; \
36 name = va_arg(*list, int); \
37 pd->name = name; \
38 printf("%s %d\n", __func__, pd->name); \
39}
40
41_GET_SET_FUNC(a)
42_GET_SET_FUNC(b)
43
44extern int my_init_count;
45
46static void
47_simple_constructor(Eo *obj, void *class_data, va_list *list)
48{
49 Private_Data *pd = class_data;
50 int a;
51 a = va_arg(*list, int);
52
53 eo_do_super(obj, eo_constructor());
54
55 pd->a = a;
56 printf("%s %d\n", __func__, pd->a);
57
58 my_init_count++;
59}
60
61static void
62_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
63{
64 eo_do_super(obj, eo_constructor());
65
66 my_init_count++;
67}
68
69static void
70_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
71{
72 eo_do_super(obj, eo_destructor());
73
74 my_init_count--;
75}
76
77static void
78_class_constructor(Eo_Class *klass)
79{
80 const Eo_Op_Func_Description func_desc[] = {
81 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
82 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
83 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), _simple_constructor),
84 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
85 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
86 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
87 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
88 EO_OP_FUNC_SENTINEL
89 };
90
91 eo_class_funcs_set(klass, func_desc);
92
93 class_var = malloc(10);
94}
95
96static void
97_class_destructor(Eo_Class *klass EINA_UNUSED)
98{
99 free(class_var);
100}
101
102static const Eo_Op_Description op_desc[] = {
103 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_CONSTRUCTOR, "Construct and set A."),
104 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
105 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
106 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
107 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"),
108 EO_OP_DESCRIPTION_SENTINEL
109};
110
111static const Eo_Class_Description class_desc = {
112 EO_VERSION,
113 "Simple",
114 EO_CLASS_TYPE_REGULAR,
115 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
116 NULL,
117 sizeof(Private_Data),
118 _class_constructor,
119 _class_destructor
120};
121
122EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS,
123 MIXIN_CLASS, NULL);
124
diff --git a/src/tests/eo/constructors/constructors_simple.h b/src/tests/eo/constructors/constructors_simple.h
new file mode 100644
index 0000000000..7342d3402e
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple.h
@@ -0,0 +1,26 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_CONSTRUCTOR,
8 SIMPLE_SUB_ID_A_SET,
9 SIMPLE_SUB_ID_A_GET,
10 SIMPLE_SUB_ID_B_SET,
11 SIMPLE_SUB_ID_B_GET,
12 SIMPLE_SUB_ID_LAST
13};
14
15#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
16
17#define simple_constructor(a) SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(int, a)
18#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
19#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
20#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)
21#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b)
22
23#define SIMPLE_CLASS simple_class_get()
24const Eo_Class *simple_class_get(void);
25
26#endif
diff --git a/src/tests/eo/constructors/constructors_simple2.c b/src/tests/eo/constructors/constructors_simple2.c
new file mode 100644
index 0000000000..8aa771719d
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple2.c
@@ -0,0 +1,42 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple2.h"
8
9#define MY_CLASS SIMPLE2_CLASS
10
11static void
12_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
13{
14 eo_do_super(obj, eo_constructor());
15
16 eo_error_set(obj);
17}
18
19static void
20_class_constructor(Eo_Class *klass)
21{
22 const Eo_Op_Func_Description func_desc[] = {
23 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
24 EO_OP_FUNC_SENTINEL
25 };
26
27 eo_class_funcs_set(klass, func_desc);
28}
29
30static const Eo_Class_Description class_desc = {
31 EO_VERSION,
32 "Simple2",
33 EO_CLASS_TYPE_REGULAR,
34 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
35 NULL,
36 0,
37 _class_constructor,
38 NULL
39};
40
41EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO_BASE_CLASS, NULL);
42
diff --git a/src/tests/eo/constructors/constructors_simple2.h b/src/tests/eo/constructors/constructors_simple2.h
new file mode 100644
index 0000000000..e6549f3d2a
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple2.h
@@ -0,0 +1,7 @@
1#ifndef SIMPLE2_H
2#define SIMPLE2_H
3
4#define SIMPLE2_CLASS simple2_class_get()
5const Eo_Class *simple2_class_get(void);
6
7#endif
diff --git a/src/tests/eo/constructors/constructors_simple3.c b/src/tests/eo/constructors/constructors_simple3.c
new file mode 100644
index 0000000000..13453b76e3
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple3.c
@@ -0,0 +1,40 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple3.h"
8
9#define MY_CLASS SIMPLE3_CLASS
10
11static void
12_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
13{
14 (void) obj;
15}
16
17static void
18_class_constructor(Eo_Class *klass)
19{
20 const Eo_Op_Func_Description func_desc[] = {
21 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
22 EO_OP_FUNC_SENTINEL
23 };
24
25 eo_class_funcs_set(klass, func_desc);
26}
27
28static const Eo_Class_Description class_desc = {
29 EO_VERSION,
30 "Simple3",
31 EO_CLASS_TYPE_REGULAR,
32 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
33 NULL,
34 0,
35 _class_constructor,
36 NULL
37};
38
39EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO_BASE_CLASS, NULL);
40
diff --git a/src/tests/eo/constructors/constructors_simple3.h b/src/tests/eo/constructors/constructors_simple3.h
new file mode 100644
index 0000000000..e27f8f1ce4
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple3.h
@@ -0,0 +1,7 @@
1#ifndef SIMPLE3_H
2#define SIMPLE3_H
3
4#define SIMPLE3_CLASS simple3_class_get()
5const Eo_Class *simple3_class_get(void);
6
7#endif
diff --git a/src/tests/eo/constructors/constructors_simple4.c b/src/tests/eo/constructors/constructors_simple4.c
new file mode 100644
index 0000000000..abce301e3a
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple4.c
@@ -0,0 +1,24 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple.h"
8#include "constructors_simple4.h"
9
10#define MY_CLASS SIMPLE4_CLASS
11
12static const Eo_Class_Description class_desc = {
13 EO_VERSION,
14 "Simple4",
15 EO_CLASS_TYPE_REGULAR,
16 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
17 NULL,
18 0,
19 NULL,
20 NULL
21};
22
23EO_DEFINE_CLASS(simple4_class_get, &class_desc, SIMPLE_CLASS, MIXIN_CLASS, NULL);
24
diff --git a/src/tests/eo/constructors/constructors_simple4.h b/src/tests/eo/constructors/constructors_simple4.h
new file mode 100644
index 0000000000..fe8e862e6d
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple4.h
@@ -0,0 +1,7 @@
1#ifndef SIMPLE4_H
2#define SIMPLE4_H
3
4#define SIMPLE4_CLASS simple4_class_get()
5const Eo_Class *simple4_class_get(void);
6
7#endif
diff --git a/src/tests/eo/constructors/constructors_simple5.c b/src/tests/eo/constructors/constructors_simple5.c
new file mode 100644
index 0000000000..bd2f1a5b3b
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple5.c
@@ -0,0 +1,40 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple5.h"
8
9#define MY_CLASS SIMPLE5_CLASS
10
11static void
12_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
13{
14 (void) obj;
15}
16
17static void
18_class_constructor(Eo_Class *klass)
19{
20 const Eo_Op_Func_Description func_desc[] = {
21 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
22 EO_OP_FUNC_SENTINEL
23 };
24
25 eo_class_funcs_set(klass, func_desc);
26}
27
28static const Eo_Class_Description class_desc = {
29 EO_VERSION,
30 "Simple5",
31 EO_CLASS_TYPE_REGULAR,
32 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
33 NULL,
34 0,
35 _class_constructor,
36 NULL
37};
38
39EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO_BASE_CLASS, NULL);
40
diff --git a/src/tests/eo/constructors/constructors_simple5.h b/src/tests/eo/constructors/constructors_simple5.h
new file mode 100644
index 0000000000..9b262d4463
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple5.h
@@ -0,0 +1,7 @@
1#ifndef SIMPLE5_H
2#define SIMPLE5_H
3
4#define SIMPLE5_CLASS simple5_class_get()
5const Eo_Class *simple5_class_get(void);
6
7#endif
diff --git a/src/tests/eo/constructors/constructors_simple6.c b/src/tests/eo/constructors/constructors_simple6.c
new file mode 100644
index 0000000000..561556d4b0
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple6.c
@@ -0,0 +1,42 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple6.h"
8
9#define MY_CLASS SIMPLE6_CLASS
10
11static void
12_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
13{
14 eo_do_super(obj, eo_destructor());
15
16 eo_error_set(obj);
17}
18
19static void
20_class_constructor(Eo_Class *klass)
21{
22 const Eo_Op_Func_Description func_desc[] = {
23 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
24 EO_OP_FUNC_SENTINEL
25 };
26
27 eo_class_funcs_set(klass, func_desc);
28}
29
30static const Eo_Class_Description class_desc = {
31 EO_VERSION,
32 "Simple6",
33 EO_CLASS_TYPE_REGULAR,
34 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
35 NULL,
36 0,
37 _class_constructor,
38 NULL
39};
40
41EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO_BASE_CLASS, NULL);
42
diff --git a/src/tests/eo/constructors/constructors_simple6.h b/src/tests/eo/constructors/constructors_simple6.h
new file mode 100644
index 0000000000..97e7b5e360
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple6.h
@@ -0,0 +1,7 @@
1#ifndef SIMPLE6_H
2#define SIMPLE6_H
3
4#define SIMPLE6_CLASS simple6_class_get()
5const Eo_Class *simple6_class_get(void);
6
7#endif
diff --git a/src/tests/eo/constructors/constructors_simple7.c b/src/tests/eo/constructors/constructors_simple7.c
new file mode 100644
index 0000000000..de197bf4f4
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple7.c
@@ -0,0 +1,43 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "constructors_mixin.h"
7#include "constructors_simple7.h"
8#include "constructors_simple2.h"
9
10#include "../eunit_tests.h"
11
12#define MY_CLASS SIMPLE7_CLASS
13
14static void
15_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
16{
17 fail_if(eo_do_super(obj, eo_constructor()));
18}
19
20static void
21_class_constructor(Eo_Class *klass)
22{
23 const Eo_Op_Func_Description func_desc[] = {
24 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
25 EO_OP_FUNC_SENTINEL
26 };
27
28 eo_class_funcs_set(klass, func_desc);
29}
30
31static const Eo_Class_Description class_desc = {
32 EO_VERSION,
33 "Simple7",
34 EO_CLASS_TYPE_REGULAR,
35 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
36 NULL,
37 0,
38 _class_constructor,
39 NULL
40};
41
42EO_DEFINE_CLASS(simple7_class_get, &class_desc, SIMPLE2_CLASS, NULL);
43
diff --git a/src/tests/eo/constructors/constructors_simple7.h b/src/tests/eo/constructors/constructors_simple7.h
new file mode 100644
index 0000000000..a9a201e447
--- /dev/null
+++ b/src/tests/eo/constructors/constructors_simple7.h
@@ -0,0 +1,7 @@
1#ifndef SIMPLE7_H
2#define SIMPLE7_H
3
4#define SIMPLE7_CLASS simple7_class_get()
5const Eo_Class *simple7_class_get(void);
6
7#endif
diff --git a/src/tests/eo/eunit_tests.h b/src/tests/eo/eunit_tests.h
new file mode 100644
index 0000000000..000d18c015
--- /dev/null
+++ b/src/tests/eo/eunit_tests.h
@@ -0,0 +1,17 @@
1#ifndef _EUNIT_TESTS_H
2#define _EUNIT_TESTS_H
3
4#define _EUNIT_EXIT_CODE 1
5
6#define fail_if(x) \
7 do { \
8 if (x) \
9 { \
10 fprintf(stderr, "%s:%d - Failure '%s' is TRUE.", \
11 __FILE__, __LINE__, # x); \
12 exit(_EUNIT_EXIT_CODE); \
13 } \
14 } while (0)
15
16#endif
17
diff --git a/src/tests/eo/function_overrides/function_overrides_inherit.c b/src/tests/eo/function_overrides/function_overrides_inherit.c
new file mode 100644
index 0000000000..e2dadbec1b
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_inherit.c
@@ -0,0 +1,22 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "function_overrides_simple.h"
7#include "function_overrides_inherit.h"
8
9#define MY_CLASS INHERIT_CLASS
10
11static const Eo_Class_Description class_desc = {
12 EO_VERSION,
13 "Inherit",
14 EO_CLASS_TYPE_REGULAR,
15 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
16 NULL,
17 0,
18 NULL,
19 NULL
20};
21
22EO_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL);
diff --git a/src/tests/eo/function_overrides/function_overrides_inherit.h b/src/tests/eo/function_overrides/function_overrides_inherit.h
new file mode 100644
index 0000000000..2f33647958
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_inherit.h
@@ -0,0 +1,7 @@
1#ifndef INHERIT_H
2#define INHERIT_H
3
4#define INHERIT_CLASS inherit_class_get()
5const Eo_Class *inherit_class_get(void);
6
7#endif
diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.c b/src/tests/eo/function_overrides/function_overrides_inherit2.c
new file mode 100644
index 0000000000..1386759bc6
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_inherit2.c
@@ -0,0 +1,82 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "function_overrides_simple.h"
7#include "function_overrides_inherit.h"
8#include "function_overrides_inherit2.h"
9
10#include "../eunit_tests.h"
11
12EAPI Eo_Op INHERIT2_BASE_ID = 0;
13
14#define MY_CLASS INHERIT2_CLASS
15
16static void
17_a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
18{
19 int a;
20 a = va_arg(*list, int);
21 printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
22 eo_do(obj, simple_a_print());
23 eo_do_super(obj, simple_a_set(a + 1));
24
25 fail_if(!eo_do_super(obj, simple_a_print()));
26}
27
28static void
29_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
30{
31 printf("Hey\n");
32 fail_if(eo_do_super(obj, inherit2_print()));
33}
34
35static void
36_print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
37{
38 printf("Hey2\n");
39}
40
41static void
42_class_print(const Eo_Class *klass, va_list *list)
43{
44 (void) list;
45 printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS));
46 fail_if(!eo_class_do_super(klass, simple_class_print()));
47 fail_if(!eo_class_do_super(klass, simple_class_print2()));
48}
49
50static void
51_class_constructor(Eo_Class *klass)
52{
53 const Eo_Op_Func_Description func_desc[] = {
54 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
55 EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT), _print),
56 EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT2), _print2),
57 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT), _class_print),
58 EO_OP_FUNC_SENTINEL
59 };
60
61 eo_class_funcs_set(klass, func_desc);
62}
63
64static const Eo_Op_Description op_desc[] = {
65 EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT, "Print hey"),
66 EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT2, "Print hey2"),
67 EO_OP_DESCRIPTION_SENTINEL
68};
69
70static const Eo_Class_Description class_desc = {
71 EO_VERSION,
72 "Inherit2",
73 EO_CLASS_TYPE_REGULAR,
74 EO_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
75 NULL,
76 0,
77 _class_constructor,
78 NULL
79};
80
81EO_DEFINE_CLASS(inherit2_class_get, &class_desc, INHERIT_CLASS, NULL);
82
diff --git a/src/tests/eo/function_overrides/function_overrides_inherit2.h b/src/tests/eo/function_overrides/function_overrides_inherit2.h
new file mode 100644
index 0000000000..2bc0b0d36a
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_inherit2.h
@@ -0,0 +1,20 @@
1#ifndef INHERIT2_H
2#define INHERIT2_H
3
4extern EAPI Eo_Op INHERIT2_BASE_ID;
5
6enum {
7 INHERIT2_SUB_ID_PRINT,
8 INHERIT2_SUB_ID_PRINT2,
9 INHERIT2_SUB_ID_LAST
10};
11
12#define INHERIT2_ID(sub_id) (INHERIT2_BASE_ID + sub_id)
13
14#define inherit2_print() INHERIT2_ID(INHERIT2_SUB_ID_PRINT)
15#define inherit2_print2() INHERIT2_ID(INHERIT2_SUB_ID_PRINT2)
16
17#define INHERIT2_CLASS inherit2_class_get()
18const Eo_Class *inherit2_class_get(void);
19
20#endif
diff --git a/src/tests/eo/function_overrides/function_overrides_inherit3.c b/src/tests/eo/function_overrides/function_overrides_inherit3.c
new file mode 100644
index 0000000000..186291328a
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_inherit3.c
@@ -0,0 +1,44 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "function_overrides_simple.h"
7#include "function_overrides_inherit2.h"
8#include "function_overrides_inherit3.h"
9
10#define MY_CLASS INHERIT3_CLASS
11
12static void
13_a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
14{
15 int a;
16 a = va_arg(*list, int);
17 printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
18 eo_do_super(obj, simple_a_set(a + 1));
19}
20
21static void
22_class_constructor(Eo_Class *klass)
23{
24 const Eo_Op_Func_Description func_desc[] = {
25 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
26 EO_OP_FUNC_SENTINEL
27 };
28
29 eo_class_funcs_set(klass, func_desc);
30}
31
32static const Eo_Class_Description class_desc = {
33 EO_VERSION,
34 "Inherit3",
35 EO_CLASS_TYPE_REGULAR,
36 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
37 NULL,
38 0,
39 _class_constructor,
40 NULL
41};
42
43EO_DEFINE_CLASS(inherit3_class_get, &class_desc, INHERIT2_CLASS, NULL);
44
diff --git a/src/tests/eo/function_overrides/function_overrides_inherit3.h b/src/tests/eo/function_overrides/function_overrides_inherit3.h
new file mode 100644
index 0000000000..73436ba239
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_inherit3.h
@@ -0,0 +1,7 @@
1#ifndef INHERIT3_H
2#define INHERIT3_H
3
4#define INHERIT3_CLASS inherit3_class_get()
5const Eo_Class *inherit3_class_get(void);
6
7#endif
diff --git a/src/tests/eo/function_overrides/function_overrides_main.c b/src/tests/eo/function_overrides/function_overrides_main.c
new file mode 100644
index 0000000000..4ab695f982
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_main.c
@@ -0,0 +1,63 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "function_overrides_simple.h"
7#include "function_overrides_inherit.h"
8#include "function_overrides_inherit2.h"
9#include "function_overrides_inherit3.h"
10
11#include "../eunit_tests.h"
12
13int
14main(int argc, char *argv[])
15{
16 (void) argc;
17 (void) argv;
18 eo_init();
19
20 Eo *obj = eo_add(INHERIT2_CLASS, NULL);
21
22 eo_do(obj, simple_a_set(1));
23 Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
24 fail_if(pd->a != 2);
25
26 eo_unref(obj);
27
28 obj = eo_add(INHERIT3_CLASS, NULL);
29
30 eo_do(obj, simple_a_set(1));
31 pd = eo_data_get(obj, SIMPLE_CLASS);
32 fail_if(pd->a != 3);
33
34 eo_unref(obj);
35
36 obj = eo_add(INHERIT2_CLASS, NULL);
37 fail_if(!eo_do(obj, inherit2_print()));
38 fail_if(!eo_do(obj, inherit2_print(), inherit2_print()));
39 eo_unref(obj);
40
41 obj = eo_add(SIMPLE_CLASS, NULL);
42 fail_if(eo_do(obj, inherit2_print2()));
43
44 fail_if(eo_do_super(obj, simple_a_print()));
45
46 fail_if(eo_do(obj, simple_class_print()));
47
48 fail_if(!eo_class_do(SIMPLE_CLASS, simple_class_print()));
49 fail_if(!eo_class_do(INHERIT_CLASS, simple_class_print()));
50 fail_if(!eo_class_do(INHERIT2_CLASS, simple_class_print()));
51 fail_if(!eo_class_do(INHERIT3_CLASS, simple_class_print()));
52
53 fail_if(eo_class_do(SIMPLE_CLASS, simple_a_print()));
54
55 eo_do_super(obj, eo_constructor());
56 eo_do_super(obj, eo_destructor());
57
58 eo_unref(obj);
59
60 eo_shutdown();
61 return 0;
62}
63
diff --git a/src/tests/eo/function_overrides/function_overrides_simple.c b/src/tests/eo/function_overrides/function_overrides_simple.c
new file mode 100644
index 0000000000..1672943939
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_simple.c
@@ -0,0 +1,82 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "function_overrides_simple.h"
7
8#include "../eunit_tests.h"
9
10EAPI Eo_Op SIMPLE_BASE_ID = 0;
11
12#define MY_CLASS SIMPLE_CLASS
13
14static void
15_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
16{
17 Simple_Public_Data *pd = class_data;
18 int a;
19 a = va_arg(*list, int);
20 printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
21 pd->a = a;
22}
23
24static void
25_a_print(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
26{
27 const Simple_Public_Data *pd = class_data;
28 (void) list;
29 printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a);
30}
31
32static void
33_class_print(const Eo_Class *klass, va_list *list)
34{
35 (void) list;
36 printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS));
37 fail_if(eo_class_do_super(klass, simple_class_print()));
38 fail_if(eo_class_do_super(klass, simple_class_print2()));
39}
40
41static void
42_class_print2(const Eo_Class *klass, va_list *list)
43{
44 (void) list;
45 printf("Print %s-%s\n", eo_class_name_get(klass), eo_class_name_get(MY_CLASS));
46}
47
48static void
49_class_constructor(Eo_Class *klass)
50{
51 const Eo_Op_Func_Description func_desc[] = {
52 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
53 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
54 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT), _class_print),
55 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT2), _class_print2),
56 EO_OP_FUNC_SENTINEL
57 };
58
59 eo_class_funcs_set(klass, func_desc);
60}
61
62static const Eo_Op_Description op_desc[] = {
63 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
64 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "Print property A"),
65 EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_PRINT, "Print class name."),
66 EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_PRINT2, "Print2 class name."),
67 EO_OP_DESCRIPTION_SENTINEL
68};
69
70static const Eo_Class_Description class_desc = {
71 EO_VERSION,
72 "Simple",
73 EO_CLASS_TYPE_REGULAR,
74 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
75 NULL,
76 sizeof(Simple_Public_Data),
77 _class_constructor,
78 NULL
79};
80
81EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
82
diff --git a/src/tests/eo/function_overrides/function_overrides_simple.h b/src/tests/eo/function_overrides/function_overrides_simple.h
new file mode 100644
index 0000000000..3a620fa611
--- /dev/null
+++ b/src/tests/eo/function_overrides/function_overrides_simple.h
@@ -0,0 +1,32 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_A_PRINT,
9 SIMPLE_SUB_ID_CLASS_PRINT,
10 SIMPLE_SUB_ID_CLASS_PRINT2,
11 SIMPLE_SUB_ID_LAST
12};
13
14typedef struct
15{
16 int a;
17} Simple_Public_Data;
18
19#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
20
21#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
22#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT)
23#define simple_class_print() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT)
24#define simple_class_print2() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_PRINT2)
25
26extern const Eo_Event_Description _SIG_A_CHANGED;
27#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
28
29#define SIMPLE_CLASS simple_class_get()
30const Eo_Class *simple_class_get(void);
31
32#endif
diff --git a/src/tests/eo/interface/interface_interface.c b/src/tests/eo/interface/interface_interface.c
new file mode 100644
index 0000000000..c0dec7649d
--- /dev/null
+++ b/src/tests/eo/interface/interface_interface.c
@@ -0,0 +1,30 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "interface_interface.h"
7#include "interface_simple.h"
8
9EAPI Eo_Op INTERFACE_BASE_ID = 0;
10
11#define MY_CLASS INTERFACE_CLASS
12
13static const Eo_Op_Description op_desc[] = {
14 EO_OP_DESCRIPTION(INTERFACE_SUB_ID_AB_SUM_GET, "Get the sum of a and b."),
15 EO_OP_DESCRIPTION_SENTINEL
16};
17
18static const Eo_Class_Description class_desc = {
19 EO_VERSION,
20 "Interface",
21 EO_CLASS_TYPE_INTERFACE,
22 EO_CLASS_DESCRIPTION_OPS(&INTERFACE_BASE_ID, op_desc, INTERFACE_SUB_ID_LAST),
23 NULL,
24 0,
25 NULL,
26 NULL
27};
28
29EO_DEFINE_CLASS(interface_class_get, &class_desc, NULL, NULL)
30
diff --git a/src/tests/eo/interface/interface_interface.h b/src/tests/eo/interface/interface_interface.h
new file mode 100644
index 0000000000..4e161b8488
--- /dev/null
+++ b/src/tests/eo/interface/interface_interface.h
@@ -0,0 +1,24 @@
1#ifndef INTERFACE_H
2#define INTERFACE_H
3
4extern EAPI Eo_Op INTERFACE_BASE_ID;
5
6enum {
7 INTERFACE_SUB_ID_AB_SUM_GET,
8 INTERFACE_SUB_ID_LAST
9};
10
11#define INTERFACE_ID(sub_id) (INTERFACE_BASE_ID + sub_id)
12
13
14/**
15 * @def interface_ab_sum_get(sum)
16 * @brief Get sum of a,b integer elements
17 * @param[out] sum integer pointer to sum - value
18 */
19#define interface_ab_sum_get(sum) INTERFACE_ID(INTERFACE_SUB_ID_AB_SUM_GET), EO_TYPECHECK(int *, sum)
20
21#define INTERFACE_CLASS interface_class_get()
22const Eo_Class *interface_class_get(void);
23
24#endif
diff --git a/src/tests/eo/interface/interface_interface2.c b/src/tests/eo/interface/interface_interface2.c
new file mode 100644
index 0000000000..14d3f1d0f8
--- /dev/null
+++ b/src/tests/eo/interface/interface_interface2.c
@@ -0,0 +1,31 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "interface_interface.h"
7#include "interface_interface2.h"
8#include "interface_simple.h"
9
10EAPI Eo_Op INTERFACE2_BASE_ID = 0;
11
12#define MY_CLASS INTERFACE2_CLASS
13
14static const Eo_Op_Description op_desc[] = {
15 EO_OP_DESCRIPTION(INTERFACE2_SUB_ID_AB_SUM_GET2, "Print the sum of a and b."),
16 EO_OP_DESCRIPTION_SENTINEL
17};
18
19static const Eo_Class_Description class_desc = {
20 EO_VERSION,
21 "Interface2",
22 EO_CLASS_TYPE_INTERFACE,
23 EO_CLASS_DESCRIPTION_OPS(&INTERFACE2_BASE_ID, op_desc, INTERFACE2_SUB_ID_LAST),
24 NULL,
25 0,
26 NULL,
27 NULL
28};
29
30EO_DEFINE_CLASS(interface2_class_get, &class_desc, INTERFACE_CLASS, NULL)
31
diff --git a/src/tests/eo/interface/interface_interface2.h b/src/tests/eo/interface/interface_interface2.h
new file mode 100644
index 0000000000..5aa91f4fdc
--- /dev/null
+++ b/src/tests/eo/interface/interface_interface2.h
@@ -0,0 +1,24 @@
1#ifndef INTERFACE2_H
2#define INTERFACE2_H
3
4extern EAPI Eo_Op INTERFACE2_BASE_ID;
5
6enum {
7 INTERFACE2_SUB_ID_AB_SUM_GET2,
8 INTERFACE2_SUB_ID_LAST
9};
10
11#define INTERFACE2_ID(sub_id) (INTERFACE2_BASE_ID + sub_id)
12
13
14/**
15 * @def interface2_ab_sum_get2(sum)
16 * @brief Get sum of a,b integer elements
17 * @param[out] sum integer pointer to sum - value
18 */
19#define interface2_ab_sum_get2(sum) INTERFACE2_ID(INTERFACE2_SUB_ID_AB_SUM_GET2), EO_TYPECHECK(int *, sum)
20
21#define INTERFACE2_CLASS interface2_class_get()
22const Eo_Class *interface2_class_get(void);
23
24#endif
diff --git a/src/tests/eo/interface/interface_main.c b/src/tests/eo/interface/interface_main.c
new file mode 100644
index 0000000000..5fa65266f6
--- /dev/null
+++ b/src/tests/eo/interface/interface_main.c
@@ -0,0 +1,37 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "interface_simple.h"
7#include "interface_interface.h"
8#include "interface_interface2.h"
9
10#include "../eunit_tests.h"
11
12int
13main(int argc, char *argv[])
14{
15 (void) argc;
16 (void) argv;
17 eo_init();
18
19 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
20
21 eo_do(obj, simple_a_set(1), simple_b_set(2));
22
23 int a, b, sum = 0;
24 eo_do(obj, simple_a_get(&a), simple_b_get(&b), interface_ab_sum_get(&sum));
25 fail_if(sum != a + b);
26
27 sum = 0;
28 eo_do(obj, interface_ab_sum_get(&sum), interface_ab_sum_get(&sum));
29 fail_if(sum != a + b);
30 eo_do(obj, interface2_ab_sum_get2(&sum), interface2_ab_sum_get2(&sum));
31 fail_if(sum != a + b + 1);
32
33 eo_unref(obj);
34 eo_shutdown();
35 return 0;
36}
37
diff --git a/src/tests/eo/interface/interface_simple.c b/src/tests/eo/interface/interface_simple.c
new file mode 100644
index 0000000000..e6f3c156b5
--- /dev/null
+++ b/src/tests/eo/interface/interface_simple.c
@@ -0,0 +1,100 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "interface_interface.h"
7#include "interface_interface2.h"
8#include "interface_simple.h"
9
10EAPI Eo_Op SIMPLE_BASE_ID = 0;
11
12typedef struct
13{
14 int a;
15 int b;
16} Private_Data;
17
18#define MY_CLASS SIMPLE_CLASS
19
20#define _GET_SET_FUNC(name) \
21static void \
22_##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
23{ \
24 const Private_Data *pd = class_data; \
25 int *name; \
26 name = va_arg(*list, int *); \
27 *name = pd->name; \
28 printf("%s %d\n", __func__, pd->name); \
29} \
30static void \
31_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
32{ \
33 Private_Data *pd = class_data; \
34 int name; \
35 name = va_arg(*list, int); \
36 pd->name = name; \
37 printf("%s %d\n", __func__, pd->name); \
38}
39
40_GET_SET_FUNC(a)
41_GET_SET_FUNC(b)
42
43static void
44_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
45{
46 int a, b;
47 eo_do(obj, simple_a_get(&a), simple_b_get(&b));
48 int *sum = va_arg(*list, int *);
49 if (sum)
50 *sum = a + b;
51 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
52}
53
54static void
55_ab_sum_get2(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
56{
57 int a, b;
58 eo_do(obj, simple_a_get(&a), simple_b_get(&b));
59 int *sum = va_arg(*list, int *);
60 if (sum)
61 *sum = a + b + 1;
62 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
63}
64
65static void
66_class_constructor(Eo_Class *klass)
67{
68 const Eo_Op_Func_Description func_desc[] = {
69 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
70 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
71 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
72 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
73 EO_OP_FUNC(INTERFACE_ID(INTERFACE_SUB_ID_AB_SUM_GET), _ab_sum_get),
74 EO_OP_FUNC(INTERFACE2_ID(INTERFACE2_SUB_ID_AB_SUM_GET2), _ab_sum_get2),
75 EO_OP_FUNC_SENTINEL
76 };
77
78 eo_class_funcs_set(klass, func_desc);
79}
80
81static const Eo_Op_Description op_desc[] = {
82 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
83 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
84 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
85 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"),
86 EO_OP_DESCRIPTION_SENTINEL
87};
88
89static const Eo_Class_Description class_desc = {
90 EO_VERSION,
91 "Simple",
92 EO_CLASS_TYPE_REGULAR,
93 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
94 NULL,
95 sizeof(Private_Data),
96 _class_constructor,
97 NULL
98};
99
100EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE2_CLASS, NULL);
diff --git a/src/tests/eo/interface/interface_simple.h b/src/tests/eo/interface/interface_simple.h
new file mode 100644
index 0000000000..8df8131278
--- /dev/null
+++ b/src/tests/eo/interface/interface_simple.h
@@ -0,0 +1,47 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_A_GET,
9 SIMPLE_SUB_ID_B_SET,
10 SIMPLE_SUB_ID_B_GET,
11 SIMPLE_SUB_ID_LAST
12};
13
14#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
15
16/**
17 * @def simple_a_set(a)
18 * @brief Set value to a-property
19 * @param[in] a integer value to set
20 */
21#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
22
23/**
24 * @def simple_a_get(a)
25 * @brief Get value of a-property
26 * @param[out] integer pointer to a-value
27 */
28#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
29
30/**
31 * @def simple_b_set(b)
32 * @brief Set value to b-property
33 * @param[in] a integer value to set
34 */
35#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)
36
37/**
38 * @def simple_b_get(b)
39 * @brief Get value of b-property
40 * @param[out] integer pointer to b-value
41 */
42#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b)
43
44#define SIMPLE_CLASS simple_class_get()
45const Eo_Class *simple_class_get(void);
46
47#endif
diff --git a/src/tests/eo/mixin/mixin_inherit.c b/src/tests/eo/mixin/mixin_inherit.c
new file mode 100644
index 0000000000..4dc8fd9e15
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_inherit.c
@@ -0,0 +1,42 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_simple.h"
7#include "mixin_mixin4.h"
8#include "mixin_inherit.h"
9
10#define MY_CLASS INHERIT_CLASS
11
12static void
13_a_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
14{
15 int *name = va_arg(*list, int *);
16 eo_do_super(obj, simple_a_get(name));
17 printf("%s\n", __func__);
18}
19
20static void
21_class_constructor(Eo_Class *klass)
22{
23 const Eo_Op_Func_Description func_desc[] = {
24 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
25 EO_OP_FUNC_SENTINEL
26 };
27
28 eo_class_funcs_set(klass, func_desc);
29}
30
31static const Eo_Class_Description class_desc = {
32 EO_VERSION,
33 "Inherit",
34 EO_CLASS_TYPE_REGULAR,
35 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
36 NULL,
37 0,
38 _class_constructor,
39 NULL
40};
41
42EO_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, MIXIN4_CLASS, NULL);
diff --git a/src/tests/eo/mixin/mixin_inherit.h b/src/tests/eo/mixin/mixin_inherit.h
new file mode 100644
index 0000000000..2f33647958
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_inherit.h
@@ -0,0 +1,7 @@
1#ifndef INHERIT_H
2#define INHERIT_H
3
4#define INHERIT_CLASS inherit_class_get()
5const Eo_Class *inherit_class_get(void);
6
7#endif
diff --git a/src/tests/eo/mixin/mixin_main.c b/src/tests/eo/mixin/mixin_main.c
new file mode 100644
index 0000000000..bb19e9ca18
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_main.c
@@ -0,0 +1,47 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_simple.h"
7#include "mixin_inherit.h"
8#include "mixin_mixin.h"
9#include "mixin_mixin2.h"
10#include "mixin_mixin3.h"
11
12#include "../eunit_tests.h"
13
14int
15main(int argc, char *argv[])
16{
17 (void) argc;
18 (void) argv;
19 eo_init();
20
21 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
22
23 eo_do(obj, simple_a_set(1), simple_b_set(2));
24
25 int a, b, sum = 0;
26 eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_ab_sum_get(&sum));
27 fail_if(sum != a + b + 2); /* 2 for the two mixins... */
28
29 eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum));
30
31 Mixin2_Public_Data *pd2 = eo_data_get(obj, MIXIN2_CLASS);
32 fail_if(pd2->count != 6);
33
34 Mixin3_Public_Data *pd3 = eo_data_get(obj, MIXIN3_CLASS);
35 fail_if(pd3->count != 9);
36
37 eo_unref(obj);
38
39 obj = eo_add(INHERIT_CLASS, NULL);
40 eo_do(obj, simple_a_set(5), simple_a_get(&a));
41 fail_if(a != 5);
42
43 eo_unref(obj);
44 eo_shutdown();
45 return 0;
46}
47
diff --git a/src/tests/eo/mixin/mixin_mixin.c b/src/tests/eo/mixin/mixin_mixin.c
new file mode 100644
index 0000000000..b6fd59e367
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin.c
@@ -0,0 +1,67 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_mixin.h"
7#include "mixin_simple.h"
8
9EAPI Eo_Op MIXIN_BASE_ID = 0;
10
11#define MY_CLASS MIXIN_CLASS
12
13static void
14_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
15{
16 int a, b;
17 eo_do(obj, simple_a_get(&a), simple_b_get(&b));
18 int *sum = va_arg(*list, int *);
19 if (sum)
20 *sum = a + b;
21 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
22}
23
24static void
25_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
26{
27 eo_do_super(obj, eo_constructor());
28}
29
30static void
31_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
32{
33 eo_do_super(obj, eo_destructor());
34}
35
36static void
37_class_constructor(Eo_Class *klass)
38{
39 const Eo_Op_Func_Description func_desc[] = {
40 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
41 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
42 EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
43 EO_OP_FUNC_SENTINEL
44 };
45
46 eo_class_funcs_set(klass, func_desc);
47}
48
49
50static const Eo_Op_Description op_desc[] = {
51 EO_OP_DESCRIPTION(MIXIN_SUB_ID_AB_SUM_GET, "Get the sum of a and b."),
52 EO_OP_DESCRIPTION_SENTINEL
53};
54
55static const Eo_Class_Description class_desc = {
56 EO_VERSION,
57 "Mixin",
58 EO_CLASS_TYPE_MIXIN,
59 EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
60 NULL,
61 0,
62 _class_constructor,
63 NULL
64};
65
66EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
67
diff --git a/src/tests/eo/mixin/mixin_mixin.h b/src/tests/eo/mixin/mixin_mixin.h
new file mode 100644
index 0000000000..745e5c4683
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin.h
@@ -0,0 +1,24 @@
1#ifndef MIXIN_H
2#define MIXIN_H
3
4extern EAPI Eo_Op MIXIN_BASE_ID;
5
6enum {
7 MIXIN_SUB_ID_AB_SUM_GET,
8 MIXIN_SUB_ID_LAST
9};
10
11#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
12
13
14/**
15 * @def mixin_ab_sum_get(sum)
16 * @brief Get sum of a,b integer elements
17 * @param[out] sum integer pointer to sum - value
18 */
19#define mixin_ab_sum_get(sum) MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), EO_TYPECHECK(int *, sum)
20
21#define MIXIN_CLASS mixin_class_get()
22const Eo_Class *mixin_class_get(void);
23
24#endif
diff --git a/src/tests/eo/mixin/mixin_mixin2.c b/src/tests/eo/mixin/mixin_mixin2.c
new file mode 100644
index 0000000000..dbd7c97d00
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin2.c
@@ -0,0 +1,70 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_mixin.h"
7#include "mixin_mixin2.h"
8#include "mixin_simple.h"
9
10#include "../eunit_tests.h"
11
12#define MY_CLASS MIXIN2_CLASS
13
14static void
15_ab_sum_get(Eo *obj, void *class_data, va_list *list)
16{
17 /* This cast is a hack just for the tests... */
18 Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data;
19 int *sum = va_arg(*list, int *);
20 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
21 eo_do_super(obj, mixin_ab_sum_get(sum));
22
23 ++*sum;
24 pd->count += 2;
25
26 {
27 int _a, _b;
28 eo_do(obj, simple_a_get(&_a), simple_b_get(&_b));
29 fail_if(*sum != _a + _b + 1);
30 }
31}
32
33static void
34_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
35{
36 eo_do_super(obj, eo_constructor());
37}
38
39static void
40_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
41{
42 eo_do_super(obj, eo_destructor());
43}
44
45static void
46_class_constructor(Eo_Class *klass)
47{
48 const Eo_Op_Func_Description func_desc[] = {
49 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
50 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
51 EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
52 EO_OP_FUNC_SENTINEL
53 };
54
55 eo_class_funcs_set(klass, func_desc);
56}
57
58static const Eo_Class_Description class_desc = {
59 EO_VERSION,
60 "Mixin2",
61 EO_CLASS_TYPE_MIXIN,
62 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
63 NULL,
64 sizeof(Mixin2_Public_Data),
65 _class_constructor,
66 NULL
67};
68
69EO_DEFINE_CLASS(mixin2_class_get, &class_desc, MIXIN_CLASS, NULL);
70
diff --git a/src/tests/eo/mixin/mixin_mixin2.h b/src/tests/eo/mixin/mixin_mixin2.h
new file mode 100644
index 0000000000..6e4b692d41
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin2.h
@@ -0,0 +1,12 @@
1#ifndef MIXIN2_H
2#define MIXIN2_H
3
4typedef struct
5{
6 int count;
7} Mixin2_Public_Data;
8
9#define MIXIN2_CLASS mixin2_class_get()
10const Eo_Class *mixin2_class_get(void);
11
12#endif
diff --git a/src/tests/eo/mixin/mixin_mixin3.c b/src/tests/eo/mixin/mixin_mixin3.c
new file mode 100644
index 0000000000..08c2b5cc7b
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin3.c
@@ -0,0 +1,70 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_mixin.h"
7#include "mixin_mixin3.h"
8#include "mixin_simple.h"
9
10#include "../eunit_tests.h"
11
12#define MY_CLASS MIXIN3_CLASS
13
14static void
15_ab_sum_get(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
16{
17 /* This cast is just a hack for the test. */
18 Mixin3_Public_Data *pd = (Mixin3_Public_Data *) class_data;
19 int *sum = va_arg(*list, int *);
20 printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
21 eo_do_super(obj, mixin_ab_sum_get(sum));
22
23 ++*sum;
24 pd->count += 3;
25
26 {
27 int _a, _b;
28 eo_do(obj, simple_a_get(&_a), simple_b_get(&_b));
29 fail_if(*sum != _a + _b + 2);
30 }
31}
32
33static void
34_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
35{
36 eo_do_super(obj, eo_constructor());
37}
38
39static void
40_destructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
41{
42 eo_do_super(obj, eo_destructor());
43}
44
45static void
46_class_constructor(Eo_Class *klass)
47{
48 const Eo_Op_Func_Description func_desc[] = {
49 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
50 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
51 EO_OP_FUNC(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
52 EO_OP_FUNC_SENTINEL
53 };
54
55 eo_class_funcs_set(klass, func_desc);
56}
57
58static const Eo_Class_Description class_desc = {
59 EO_VERSION,
60 "Mixin3",
61 EO_CLASS_TYPE_MIXIN,
62 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
63 NULL,
64 sizeof(Mixin3_Public_Data),
65 _class_constructor,
66 NULL
67};
68
69EO_DEFINE_CLASS(mixin3_class_get, &class_desc, MIXIN_CLASS, NULL);
70
diff --git a/src/tests/eo/mixin/mixin_mixin3.h b/src/tests/eo/mixin/mixin_mixin3.h
new file mode 100644
index 0000000000..36b32c0aa8
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin3.h
@@ -0,0 +1,12 @@
1#ifndef MIXIN3_H
2#define MIXIN3_H
3
4typedef struct
5{
6 int count;
7} Mixin3_Public_Data;
8
9#define MIXIN3_CLASS mixin3_class_get()
10const Eo_Class *mixin3_class_get(void);
11
12#endif
diff --git a/src/tests/eo/mixin/mixin_mixin4.c b/src/tests/eo/mixin/mixin_mixin4.c
new file mode 100644
index 0000000000..cf8f16f965
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin4.c
@@ -0,0 +1,26 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_mixin.h"
7#include "mixin_mixin4.h"
8#include "mixin_simple.h"
9
10#include "../eunit_tests.h"
11
12#define MY_CLASS MIXIN4_CLASS
13
14static const Eo_Class_Description class_desc = {
15 EO_VERSION,
16 "Mixin4",
17 EO_CLASS_TYPE_MIXIN,
18 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
19 NULL,
20 0,
21 NULL,
22 NULL
23};
24
25EO_DEFINE_CLASS(mixin4_class_get, &class_desc, NULL, NULL);
26
diff --git a/src/tests/eo/mixin/mixin_mixin4.h b/src/tests/eo/mixin/mixin_mixin4.h
new file mode 100644
index 0000000000..7b520fad19
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_mixin4.h
@@ -0,0 +1,7 @@
1#ifndef MIXIN4_H
2#define MIXIN4_H
3
4#define MIXIN4_CLASS mixin4_class_get()
5const Eo_Class *mixin4_class_get(void);
6
7#endif
diff --git a/src/tests/eo/mixin/mixin_simple.c b/src/tests/eo/mixin/mixin_simple.c
new file mode 100644
index 0000000000..ff4600d727
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_simple.c
@@ -0,0 +1,77 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "mixin_mixin.h"
7#include "mixin_mixin2.h"
8#include "mixin_mixin3.h"
9#include "mixin_simple.h"
10
11EAPI Eo_Op SIMPLE_BASE_ID = 0;
12
13typedef struct
14{
15 int a;
16 int b;
17} Private_Data;
18
19#define MY_CLASS SIMPLE_CLASS
20
21#define _GET_SET_FUNC(name) \
22static void \
23_##name##_get(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
24{ \
25 const Private_Data *pd = class_data; \
26 int *name; \
27 name = va_arg(*list, int *); \
28 *name = pd->name; \
29 printf("%s %d\n", __func__, pd->name); \
30} \
31static void \
32_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
33{ \
34 Private_Data *pd = class_data; \
35 int name; \
36 name = va_arg(*list, int); \
37 pd->name = name; \
38 printf("%s %d\n", __func__, pd->name); \
39}
40
41_GET_SET_FUNC(a)
42_GET_SET_FUNC(b)
43
44static void
45_class_constructor(Eo_Class *klass)
46{
47 const Eo_Op_Func_Description func_desc[] = {
48 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
49 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
50 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
51 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
52 EO_OP_FUNC_SENTINEL
53 };
54
55 eo_class_funcs_set(klass, func_desc);
56}
57
58static const Eo_Op_Description op_desc[] = {
59 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
60 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
61 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
62 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "Get property B"),
63 EO_OP_DESCRIPTION_SENTINEL
64};
65
66static const Eo_Class_Description class_desc = {
67 EO_VERSION,
68 "Simple",
69 EO_CLASS_TYPE_REGULAR,
70 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
71 NULL,
72 sizeof(Private_Data),
73 _class_constructor,
74 NULL
75};
76
77EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL);
diff --git a/src/tests/eo/mixin/mixin_simple.h b/src/tests/eo/mixin/mixin_simple.h
new file mode 100644
index 0000000000..8df8131278
--- /dev/null
+++ b/src/tests/eo/mixin/mixin_simple.h
@@ -0,0 +1,47 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_A_GET,
9 SIMPLE_SUB_ID_B_SET,
10 SIMPLE_SUB_ID_B_GET,
11 SIMPLE_SUB_ID_LAST
12};
13
14#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
15
16/**
17 * @def simple_a_set(a)
18 * @brief Set value to a-property
19 * @param[in] a integer value to set
20 */
21#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
22
23/**
24 * @def simple_a_get(a)
25 * @brief Get value of a-property
26 * @param[out] integer pointer to a-value
27 */
28#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
29
30/**
31 * @def simple_b_set(b)
32 * @brief Set value to b-property
33 * @param[in] a integer value to set
34 */
35#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)
36
37/**
38 * @def simple_b_get(b)
39 * @brief Get value of b-property
40 * @param[out] integer pointer to b-value
41 */
42#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b)
43
44#define SIMPLE_CLASS simple_class_get()
45const Eo_Class *simple_class_get(void);
46
47#endif
diff --git a/src/tests/eo/signals/signals_main.c b/src/tests/eo/signals/signals_main.c
new file mode 100644
index 0000000000..4bf20caf62
--- /dev/null
+++ b/src/tests/eo/signals/signals_main.c
@@ -0,0 +1,183 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "signals_simple.h"
7
8#include "../eunit_tests.h"
9
10static int cb_count = 0;
11
12static Eina_Bool
13_null_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
14{
15 (void) desc;
16 (void) obj;
17 (void) data;
18 (void) event_info;
19 return EO_CALLBACK_CONTINUE;
20}
21
22static Eina_Bool
23_a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
24{
25 (void) desc;
26 (void) obj;
27 int new_a = *((int *) event_info);
28 printf("%s event_info:'%d' data:'%d'\n", __func__, new_a, (int) data);
29
30 cb_count++;
31
32 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _null_cb, (void *) 23423));
33 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _null_cb, (void *) 23423));
34
35 /* Stop as we reached the 3rd one. */
36 return (cb_count != 3);
37}
38
39int
40main(int argc, char *argv[])
41{
42 (void) argc;
43 (void) argv;
44 eo_init();
45
46 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
47 Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
48
49 /* The order of these two is undetermined. */
50 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
51 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
52 /* This will be called afterwards. */
53 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3));
54 /* This will never be called because the previous callback returns NULL. */
55 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4));
56
57 eo_do(obj, simple_a_set(1));
58
59 fail_if(cb_count != 3);
60
61 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3));
62 fail_if(pd->cb_count != 3);
63
64 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12));
65 fail_if(pd->cb_count != 3);
66
67 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4));
68 fail_if(pd->cb_count != 2);
69
70 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2));
71 fail_if(pd->cb_count != 1);
72
73 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1));
74 fail_if(pd->cb_count != 0);
75
76 /* Freeze/thaw. */
77 int fcount = 0;
78 cb_count = 0;
79 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
80 fail_if(pd->cb_count != 1);
81
82 eo_do(obj, eo_event_freeze_get(&fcount));
83 fail_if(fcount != 0);
84
85 eo_do(obj, eo_event_freeze());
86 eo_do(obj, eo_event_freeze_get(&fcount));
87 fail_if(fcount != 1);
88
89 eo_do(obj, eo_event_freeze());
90 eo_do(obj, eo_event_freeze_get(&fcount));
91 fail_if(fcount != 2);
92
93 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
94 fail_if(pd->cb_count != 1);
95
96 eo_do(obj, simple_a_set(2));
97 fail_if(cb_count != 0);
98 eo_do(obj, eo_event_thaw());
99 eo_do(obj, eo_event_freeze_get(&fcount));
100 fail_if(fcount != 1);
101
102 eo_do(obj, eo_event_thaw());
103 eo_do(obj, eo_event_freeze_get(&fcount));
104 fail_if(fcount != 0);
105
106 eo_do(obj, simple_a_set(3));
107 fail_if(cb_count != 2);
108
109 cb_count = 0;
110 eo_do(obj, eo_event_thaw());
111 eo_do(obj, eo_event_freeze_get(&fcount));
112 fail_if(fcount != 0);
113
114 eo_do(obj, eo_event_freeze());
115 eo_do(obj, eo_event_freeze_get(&fcount));
116 fail_if(fcount != 1);
117
118 eo_do(obj, simple_a_set(2));
119 fail_if(cb_count != 0);
120 eo_do(obj, eo_event_thaw());
121 eo_do(obj, eo_event_freeze_get(&fcount));
122 fail_if(fcount != 0);
123
124 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 1));
125 fail_if(pd->cb_count != 0);
126 eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 2));
127 fail_if(pd->cb_count != -1);
128
129 /* Global Freeze/thaw. */
130 fcount = 0;
131 cb_count = 0;
132 pd->cb_count = 0;
133 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1));
134 fail_if(pd->cb_count != 1);
135
136 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
137 fail_if(fcount != 0);
138
139 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze());
140 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
141 fail_if(fcount != 1);
142
143 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze());
144 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
145 fail_if(fcount != 2);
146
147 eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2));
148 fail_if(pd->cb_count != 1);
149
150 eo_do(obj, simple_a_set(2));
151 fail_if(cb_count != 0);
152 eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
153 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
154 fail_if(fcount != 1);
155
156 eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
157 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
158 fail_if(fcount != 0);
159
160 eo_do(obj, simple_a_set(3));
161 fail_if(cb_count != 2);
162
163 cb_count = 0;
164 eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
165 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
166 fail_if(fcount != 0);
167
168 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze());
169 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
170 fail_if(fcount != 1);
171
172 eo_do(obj, simple_a_set(2));
173 fail_if(cb_count != 0);
174 eo_class_do(EO_BASE_CLASS, eo_event_global_thaw());
175 eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount));
176 fail_if(fcount != 0);
177
178
179 eo_unref(obj);
180 eo_shutdown();
181 return 0;
182}
183
diff --git a/src/tests/eo/signals/signals_simple.c b/src/tests/eo/signals/signals_simple.c
new file mode 100644
index 0000000000..506d798138
--- /dev/null
+++ b/src/tests/eo/signals/signals_simple.c
@@ -0,0 +1,112 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "signals_simple.h"
7
8EAPI Eo_Op SIMPLE_BASE_ID = 0;
9
10typedef struct
11{
12 Simple_Public_Data pub;
13 int a;
14} Private_Data;
15
16EAPI const Eo_Event_Description _EV_A_CHANGED =
17 EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed.");
18
19#define MY_CLASS SIMPLE_CLASS
20
21static void
22_a_set(Eo *obj, void *class_data, va_list *list)
23{
24 Private_Data *pd = class_data;
25 int a;
26 a = va_arg(*list, int);
27 pd->a = a;
28 printf("%s %d\n", __func__, pd->a);
29
30 eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
31}
32
33Eina_Bool
34_cb_added(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
35{
36 Simple_Public_Data *pd = eo_data_get(obj, MY_CLASS);
37 const Eo_Event_Description *cb_desc = event_info;
38 (void) data;
39 (void) desc;
40
41 if (cb_desc != EV_A_CHANGED)
42 return EINA_TRUE;
43
44 pd->cb_count++;
45
46 printf("Added EV_A_CHANGED callback to %p. Count: %d\n", obj, pd->cb_count);
47 return EO_CALLBACK_CONTINUE;
48}
49
50Eina_Bool
51_cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
52{
53 Simple_Public_Data *pd = eo_data_get(obj, MY_CLASS);
54 const Eo_Event_Description *cb_desc = event_info;
55 (void) data;
56 (void) desc;
57
58 if (cb_desc != EV_A_CHANGED)
59 return EINA_TRUE;
60
61 pd->cb_count--;
62
63 printf("Removed EV_A_CHANGED callback from %p. Count: %d\n", obj, pd->cb_count);
64 return EO_CALLBACK_CONTINUE;
65}
66
67static void
68_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
69{
70 eo_do_super(obj, eo_constructor());
71
72 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, NULL));
73 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, NULL));
74
75 eo_do(obj, eo_base_data_set("cb_count", (intptr_t) 0, NULL));
76}
77
78static void
79_class_constructor(Eo_Class *klass)
80{
81 const Eo_Op_Func_Description func_desc[] = {
82 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
83 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
84 EO_OP_FUNC_SENTINEL
85 };
86
87 eo_class_funcs_set(klass, func_desc);
88}
89
90static const Eo_Op_Description op_desc[] = {
91 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
92 EO_OP_DESCRIPTION_SENTINEL
93};
94
95static const Eo_Event_Description *event_desc[] = {
96 EV_A_CHANGED,
97 NULL
98};
99
100static const Eo_Class_Description class_desc = {
101 EO_VERSION,
102 "Simple",
103 EO_CLASS_TYPE_REGULAR,
104 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
105 event_desc,
106 sizeof(Private_Data),
107 _class_constructor,
108 NULL
109};
110
111EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
112
diff --git a/src/tests/eo/signals/signals_simple.h b/src/tests/eo/signals/signals_simple.h
new file mode 100644
index 0000000000..d1f63bdd06
--- /dev/null
+++ b/src/tests/eo/signals/signals_simple.h
@@ -0,0 +1,31 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_LAST
9};
10
11typedef struct
12{
13 int cb_count;
14} Simple_Public_Data;
15
16#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
17
18/**
19 * @def simple_a_set(a)
20 * @brief Set value to a - property
21 * @param[in] a integer value to set
22 */
23#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
24
25extern const Eo_Event_Description _EV_A_CHANGED;
26#define EV_A_CHANGED (&(_EV_A_CHANGED))
27
28#define SIMPLE_CLASS simple_class_get()
29const Eo_Class *simple_class_get(void);
30
31#endif
diff --git a/src/tests/eo/suite/eo_suite.c b/src/tests/eo/suite/eo_suite.c
new file mode 100644
index 0000000000..0494136cef
--- /dev/null
+++ b/src/tests/eo/suite/eo_suite.c
@@ -0,0 +1,106 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include "Eo.h"
9#include "eo_suite.h"
10
11typedef struct _Eo_Test_Case Eo_Test_Case;
12
13struct _Eo_Test_Case
14{
15 const char *test_case;
16 void (*build)(TCase *tc);
17};
18
19static const Eo_Test_Case etc[] = {
20 { "Eo init", eo_test_init },
21 { "Eo general", eo_test_general },
22 { "Eo class errors", eo_test_class_errors },
23 { NULL, NULL }
24};
25
26static void
27_list_tests(void)
28{
29 const Eo_Test_Case *itr;
30
31 itr = etc;
32 fputs("Available Test Cases:\n", stderr);
33 for (; itr->test_case; itr++)
34 fprintf(stderr, "\t%s\n", itr->test_case);
35}
36static Eina_Bool
37_use_test(int argc, const char **argv, const char *test_case)
38{
39 if (argc < 1)
40 return 1;
41
42 for (; argc > 0; argc--, argv++)
43 if (strcmp(test_case, *argv) == 0)
44 return 1;
45 return 0;
46}
47
48static Suite *
49eo_suite_build(int argc, const char **argv)
50{
51 TCase *tc;
52 Suite *s;
53 int i;
54
55 s = suite_create("Eo");
56
57 for (i = 0; etc[i].test_case; ++i)
58 {
59 if (!_use_test(argc, argv, etc[i].test_case)) continue;
60 tc = tcase_create(etc[i].test_case);
61
62 etc[i].build(tc);
63
64 suite_add_tcase(s, tc);
65 tcase_set_timeout(tc, 0);
66 }
67
68 return s;
69}
70
71int
72main(int argc, char **argv)
73{
74 Suite *s;
75 SRunner *sr;
76 int i, failed_count;
77 eo_init();
78 setenv("CK_FORK", "no", 0);
79
80 for (i = 1; i < argc; i++)
81 if ((strcmp(argv[i], "-h") == 0) ||
82 (strcmp(argv[i], "--help") == 0))
83 {
84 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
85 argv[0]);
86 _list_tests();
87 return 0;
88 }
89 else if ((strcmp(argv[i], "-l") == 0) ||
90 (strcmp(argv[i], "--list") == 0))
91 {
92 _list_tests();
93 return 0;
94 }
95
96 s = eo_suite_build(argc - 1, (const char **)argv + 1);
97 sr = srunner_create(s);
98
99 srunner_run_all(sr, CK_ENV);
100 failed_count = srunner_ntests_failed(sr);
101 srunner_free(sr);
102
103 eo_shutdown();
104
105 return (failed_count == 0) ? 0 : 255;
106}
diff --git a/src/tests/eo/suite/eo_suite.h b/src/tests/eo/suite/eo_suite.h
new file mode 100644
index 0000000000..9d79f42f8e
--- /dev/null
+++ b/src/tests/eo/suite/eo_suite.h
@@ -0,0 +1,11 @@
1#ifndef _EO_SUITE_H
2#define _EO_SUITE_H
3
4#include <check.h>
5
6void eo_test_init(TCase *tc);
7void eo_test_general(TCase *tc);
8void eo_test_class_errors(TCase *tc);
9
10
11#endif /* _EO_SUITE_H */
diff --git a/src/tests/eo/suite/eo_test_class_errors.c b/src/tests/eo/suite/eo_test_class_errors.c
new file mode 100644
index 0000000000..77d9ef9c7a
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_class_errors.c
@@ -0,0 +1,350 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdio.h>
6
7#include "Eo.h"
8#include "eo_suite.h"
9#include "eo_test_class_simple.h"
10
11START_TEST(eo_incomplete_desc)
12{
13 eo_init();
14
15 const Eo_Class *klass;
16 static Eo_Op TMP_BASE_ID = EO_NOOP;
17
18 enum {
19 TEST_SUB_ID_FOO,
20 TEST_SUB_ID_FOO2,
21 TEST_SUB_ID_LAST
22 };
23
24 static const Eo_Op_Description op_desc[] = {
25 EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "Foo"),
26 EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "Foo2"),
27 EO_OP_DESCRIPTION_SENTINEL
28 };
29
30 static const Eo_Op_Description op_desc_wrong[] = {
31 EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "Foo2"),
32 EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "Foo"),
33 EO_OP_DESCRIPTION_SENTINEL
34 };
35
36 /* XXX: In real life this should be const, this is just for testing. */
37 static Eo_Class_Description class_desc = {
38 EO_VERSION,
39 "Simple",
40 EO_CLASS_TYPE_REGULAR,
41 EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, 1),
42 NULL,
43 0,
44 NULL,
45 NULL
46 };
47
48 klass = eo_class_new(&class_desc, NULL, NULL);
49 fail_if(klass);
50
51 class_desc.ops.base_op_id = &TMP_BASE_ID;
52 class_desc.ops.descs = NULL;
53
54 klass = eo_class_new(&class_desc, NULL, NULL);
55 fail_if(klass);
56
57 class_desc.ops.descs = op_desc;
58 class_desc.ops.count = TEST_SUB_ID_LAST + 1;
59
60 klass = eo_class_new(&class_desc, NULL, NULL);
61 fail_if(klass);
62
63 class_desc.ops.count = 0;
64
65 klass = eo_class_new(&class_desc, NULL, NULL);
66 fail_if(klass);
67
68 class_desc.ops.count = TEST_SUB_ID_LAST;
69 class_desc.ops.descs = op_desc_wrong;
70
71 klass = eo_class_new(&class_desc, NULL, NULL);
72 fail_if(klass);
73
74 class_desc.ops.descs = op_desc;
75 class_desc.name = NULL;
76
77 klass = eo_class_new(&class_desc, NULL, NULL);
78 fail_if(klass);
79
80 class_desc.name = "Simple";
81
82
83 klass = eo_class_new(NULL, NULL, NULL);
84 fail_if(klass);
85
86 /* Should create a class. */
87 klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
88 fail_if(!klass);
89
90 (void) klass;
91
92 eo_shutdown();
93}
94END_TEST
95
96START_TEST(eo_inherit_errors)
97{
98 eo_init();
99
100 const Eo_Class *klass;
101 const Eo_Class *klass_mixin;
102 const Eo_Class *klass_simple;
103
104 static const Eo_Class_Description class_desc_simple = {
105 EO_VERSION,
106 "Simple",
107 EO_CLASS_TYPE_REGULAR,
108 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
109 NULL,
110 0,
111 NULL,
112 NULL
113 };
114
115 static const Eo_Class_Description class_desc_mixin = {
116 EO_VERSION,
117 "Mixin",
118 EO_CLASS_TYPE_MIXIN,
119 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
120 NULL,
121 0,
122 NULL,
123 NULL
124 };
125
126 static Eo_Class_Description class_desc = {
127 EO_VERSION,
128 "General",
129 EO_CLASS_TYPE_MIXIN,
130 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
131 NULL,
132 0,
133 NULL,
134 NULL
135 };
136
137 klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
138 fail_if(!klass_mixin);
139
140 klass_simple = eo_class_new(&class_desc_simple, EO_BASE_CLASS, NULL);
141 fail_if(!klass_simple);
142
143 klass = eo_class_new(&class_desc, klass_simple, NULL);
144 fail_if(klass);
145
146 class_desc.type = EO_CLASS_TYPE_REGULAR;
147
148 klass = eo_class_new(&class_desc, klass_mixin, NULL);
149 fail_if(klass);
150
151 (void) klass;
152
153 eo_shutdown();
154}
155END_TEST
156
157START_TEST(eo_inconsistent_mro)
158{
159 eo_init();
160
161 const Eo_Class *klass;
162 const Eo_Class *klass_mixin;
163 const Eo_Class *klass_mixin2;
164 const Eo_Class *klass_mixin3;
165
166 static const Eo_Class_Description class_desc_simple = {
167 EO_VERSION,
168 "Simple",
169 EO_CLASS_TYPE_REGULAR,
170 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
171 NULL,
172 0,
173 NULL,
174 NULL
175 };
176
177 static const Eo_Class_Description class_desc_mixin = {
178 EO_VERSION,
179 "Mixin",
180 EO_CLASS_TYPE_MIXIN,
181 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
182 NULL,
183 0,
184 NULL,
185 NULL
186 };
187
188 static const Eo_Class_Description class_desc_mixin2 = {
189 EO_VERSION,
190 "Mixin2",
191 EO_CLASS_TYPE_MIXIN,
192 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
193 NULL,
194 0,
195 NULL,
196 NULL
197 };
198
199 static const Eo_Class_Description class_desc_mixin3 = {
200 EO_VERSION,
201 "Mixin3",
202 EO_CLASS_TYPE_MIXIN,
203 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
204 NULL,
205 0,
206 NULL,
207 NULL
208 };
209
210 klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
211 fail_if(!klass_mixin);
212
213 klass_mixin2 = eo_class_new(&class_desc_mixin2, klass_mixin, NULL);
214 fail_if(!klass_mixin2);
215
216 klass_mixin3 = eo_class_new(&class_desc_mixin3, klass_mixin, NULL);
217 fail_if(!klass_mixin3);
218
219 klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
220 fail_if(klass);
221
222 klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
223 fail_if(!klass);
224
225 klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
226 fail_if(!klass);
227
228 eo_shutdown();
229}
230END_TEST
231
232static void _stub_class_constructor(Eo_Class *klass EINA_UNUSED) {}
233
234START_TEST(eo_bad_interface)
235{
236 eo_init();
237
238 const Eo_Class *klass;
239
240 static Eo_Class_Description class_desc = {
241 EO_VERSION,
242 "Interface",
243 EO_CLASS_TYPE_INTERFACE,
244 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
245 NULL,
246 10,
247 NULL,
248 NULL
249 };
250
251 klass = eo_class_new(&class_desc, NULL, NULL);
252 fail_if(klass);
253
254 class_desc.data_size = 0;
255 class_desc.class_constructor = _stub_class_constructor;
256
257 klass = eo_class_new(&class_desc, NULL, NULL);
258 fail_if(!klass);
259
260 class_desc.class_constructor = NULL;
261 class_desc.class_destructor = _stub_class_constructor;
262
263 klass = eo_class_new(&class_desc, NULL, NULL);
264 fail_if(!klass);
265
266 class_desc.class_destructor = NULL;
267
268 klass = eo_class_new(&class_desc, NULL, NULL);
269 fail_if(!klass);
270
271 eo_shutdown();
272}
273END_TEST
274
275static int _const_ops_counter = 0;
276
277static void
278_const_ops_a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list)
279{
280 int a = va_arg(*list, int);
281 (void) a;
282 _const_ops_counter++;
283}
284
285static void
286_const_ops_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
287{
288 _const_ops_counter++;
289}
290
291static void
292_const_ops_class_hi_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
293{
294 _const_ops_counter++;
295}
296
297static void
298_const_ops_class_constructor(Eo_Class *klass)
299{
300 const Eo_Op_Func_Description func_desc[] = {
301 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), (eo_op_func_type) _const_ops_a_set),
302 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), (eo_op_func_type) _const_ops_a_print),
303 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), (eo_op_func_type_class) _const_ops_a_set),
304 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), (eo_op_func_type_class) _const_ops_a_print),
305 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), (eo_op_func_type) _const_ops_class_hi_print),
306 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), (eo_op_func_type) _const_ops_class_hi_print),
307 EO_OP_FUNC_SENTINEL
308 };
309
310 eo_class_funcs_set(klass, func_desc);
311}
312
313START_TEST(eo_op_types)
314{
315 eo_init();
316
317 const Eo_Class *klass;
318
319 static Eo_Class_Description class_desc = {
320 EO_VERSION,
321 "Simple",
322 EO_CLASS_TYPE_REGULAR,
323 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
324 NULL,
325 0,
326 _const_ops_class_constructor,
327 NULL
328 };
329
330 klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
331 fail_if(!klass);
332
333 /* Add class checks here... */
334 Eo *obj = eo_add(klass, NULL);
335 eo_do(obj, simple_a_set(7), simple_a_print(), simple_class_hi_print());
336
337 eo_unref(obj);
338
339 eo_shutdown();
340}
341END_TEST
342
343void eo_test_class_errors(TCase *tc)
344{
345 tcase_add_test(tc, eo_incomplete_desc);
346 tcase_add_test(tc, eo_inherit_errors);
347 tcase_add_test(tc, eo_inconsistent_mro);
348 tcase_add_test(tc, eo_bad_interface);
349 tcase_add_test(tc, eo_op_types);
350}
diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c
new file mode 100644
index 0000000000..224f5b5a54
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_class_simple.c
@@ -0,0 +1,69 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eo.h"
6#include "eo_test_class_simple.h"
7
8#define MY_CLASS SIMPLE_CLASS
9
10EAPI Eo_Op SIMPLE_BASE_ID = 0;
11
12static void
13_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
14{
15 Simple_Public_Data *pd = class_data;
16 int a;
17 a = va_arg(*list, int);
18 printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
19 pd->a = a;
20}
21
22static void
23_a_print(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
24{
25 const Simple_Public_Data *pd = class_data;
26 (void) list;
27 printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a);
28}
29
30static void
31_class_hi_print(const Eo_Class *klass, va_list *list)
32{
33 (void) list;
34 printf("Hi Print %s\n", eo_class_name_get(klass));
35}
36
37static void
38_class_constructor(Eo_Class *klass)
39{
40 const Eo_Op_Func_Description func_desc[] = {
41 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
42 EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
43 EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _class_hi_print),
44 EO_OP_FUNC_SENTINEL
45 };
46
47 eo_class_funcs_set(klass, func_desc);
48}
49
50static const Eo_Op_Description op_desc[] = {
51 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
52 EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "Print property A"),
53 EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_HI_PRINT, "Print Hi"),
54 EO_OP_DESCRIPTION_SENTINEL
55};
56
57static const Eo_Class_Description class_desc = {
58 EO_VERSION,
59 "Simple",
60 EO_CLASS_TYPE_REGULAR,
61 EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
62 NULL,
63 sizeof(Simple_Public_Data),
64 _class_constructor,
65 NULL
66};
67
68EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
69
diff --git a/src/tests/eo/suite/eo_test_class_simple.h b/src/tests/eo/suite/eo_test_class_simple.h
new file mode 100644
index 0000000000..9980b7b93a
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_class_simple.h
@@ -0,0 +1,30 @@
1#ifndef SIMPLE_H
2#define SIMPLE_H
3
4extern EAPI Eo_Op SIMPLE_BASE_ID;
5
6enum {
7 SIMPLE_SUB_ID_A_SET,
8 SIMPLE_SUB_ID_A_PRINT,
9 SIMPLE_SUB_ID_CLASS_HI_PRINT,
10 SIMPLE_SUB_ID_LAST
11};
12
13typedef struct
14{
15 int a;
16} Simple_Public_Data;
17
18#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
19
20#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
21#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT)
22#define simple_class_hi_print() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT)
23
24extern const Eo_Event_Description _SIG_A_CHANGED;
25#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
26
27#define SIMPLE_CLASS simple_class_get()
28const Eo_Class *simple_class_get(void);
29
30#endif
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
new file mode 100644
index 0000000000..0952613888
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -0,0 +1,752 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
6
7#include "Eo.h"
8#include "eo_suite.h"
9#include "eo_test_class_simple.h"
10
11START_TEST(eo_simple)
12{
13 eo_init();
14 Eo *obj = eo_add(EO_BASE_CLASS, NULL);
15 fail_if(obj);
16
17 obj = eo_add(SIMPLE_CLASS, NULL);
18 fail_if(!obj);
19 eo_do(obj, eo_constructor());
20 eo_do(obj, eo_destructor());
21 eo_unref(obj);
22
23 eo_shutdown();
24}
25END_TEST
26
27START_TEST(eo_data_fetch)
28{
29 eo_init();
30
31 /* Usually should be const, not const only for the test... */
32 static Eo_Class_Description class_desc = {
33 EO_VERSION,
34 "Simple2",
35 EO_CLASS_TYPE_REGULAR,
36 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
37 NULL,
38 10,
39 NULL,
40 NULL
41 };
42
43 const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
44 fail_if(!klass);
45
46 Eo *obj = eo_add(klass, NULL);
47 fail_if(!obj);
48#ifndef NDEBUG
49 fail_if(eo_data_get(obj, SIMPLE_CLASS));
50#endif
51 eo_unref(obj);
52
53 class_desc.data_size = 0;
54 klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
55 fail_if(!klass);
56
57 obj = eo_add(klass, NULL);
58 fail_if(!obj);
59 fail_if(eo_data_get(obj, klass));
60 eo_unref(obj);
61
62 eo_shutdown();
63}
64END_TEST
65
66START_TEST(eo_isa_tests)
67{
68 eo_init();
69
70 const Eo_Class *klass, *iface, *mixin;
71
72 {
73 /* Usually should be const, not const only for the test... */
74 static Eo_Class_Description class_desc = {
75 EO_VERSION,
76 "Iface",
77 EO_CLASS_TYPE_INTERFACE,
78 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
79 NULL,
80 0,
81 NULL,
82 NULL
83 };
84
85 iface = eo_class_new(&class_desc, NULL, NULL);
86 fail_if(!iface);
87 }
88
89 {
90 /* Usually should be const, not const only for the test... */
91 static Eo_Class_Description class_desc = {
92 EO_VERSION,
93 "Mixin",
94 EO_CLASS_TYPE_MIXIN,
95 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
96 NULL,
97 0,
98 NULL,
99 NULL
100 };
101
102 mixin = eo_class_new(&class_desc, NULL, NULL);
103 fail_if(!mixin);
104 }
105
106 {
107 /* Usually should be const, not const only for the test... */
108 static Eo_Class_Description class_desc = {
109 EO_VERSION,
110 "Simple2",
111 EO_CLASS_TYPE_REGULAR,
112 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
113 NULL,
114 10,
115 NULL,
116 NULL
117 };
118
119 klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL);
120 fail_if(!klass);
121 }
122
123 Eo *obj = eo_add(klass, NULL);
124 fail_if(!obj);
125 fail_if(eo_isa(obj, SIMPLE_CLASS));
126 fail_if(!eo_isa(obj, iface));
127 fail_if(!eo_isa(obj, mixin));
128 fail_if(!eo_isa(obj, klass));
129 fail_if(!eo_isa(obj, EO_BASE_CLASS));
130 eo_unref(obj);
131
132 obj = eo_add(SIMPLE_CLASS, NULL);
133 fail_if(!obj);
134 fail_if(eo_isa(obj, klass));
135 fail_if(eo_isa(obj, iface));
136 fail_if(eo_isa(obj, mixin));
137 fail_if(!eo_isa(obj, SIMPLE_CLASS));
138 fail_if(!eo_isa(obj, EO_BASE_CLASS));
139 eo_unref(obj);
140
141 eo_shutdown();
142}
143END_TEST
144
145
146START_TEST(eo_composite_tests)
147{
148 eo_init();
149
150 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
151 fail_if(!obj);
152 Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
153 fail_if(!obj2);
154
155 eo_composite_attach(obj2, obj);
156 eo_parent_set(obj2, NULL);
157 fail_if(eo_composite_is(obj2));
158
159 eo_unref(obj2);
160 eo_unref(obj);
161
162 eo_shutdown();
163}
164END_TEST
165
166static Eina_Bool _man_should_con = EINA_TRUE;
167static Eina_Bool _man_should_des = EINA_TRUE;
168
169static void
170_man_con(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
171{
172 if (_man_should_con)
173 eo_manual_free_set(obj, EINA_TRUE);
174 eo_do_super(obj, eo_constructor());
175}
176
177static void
178_man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
179{
180 eo_do_super(obj, eo_destructor());
181 if (_man_should_des)
182 eo_manual_free_set(obj, EINA_FALSE);
183}
184
185
186static void
187_man_class_constructor(Eo_Class *klass)
188{
189 const Eo_Op_Func_Description func_desc[] = {
190 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _man_con),
191 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
192 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
193 EO_OP_FUNC_SENTINEL
194 };
195
196 eo_class_funcs_set(klass, func_desc);
197}
198
199START_TEST(eo_man_free)
200{
201 eo_init();
202
203 /* Usually should be const, not const only for the test... */
204 static Eo_Class_Description class_desc = {
205 EO_VERSION,
206 "Simple2",
207 EO_CLASS_TYPE_REGULAR,
208 EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
209 NULL,
210 10,
211 _man_class_constructor,
212 NULL
213 };
214
215 const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
216 fail_if(!klass);
217
218 Eo *obj = eo_add(klass, NULL);
219 fail_if(!obj);
220 eo_unref(obj);
221
222 obj = eo_add(klass, NULL);
223 fail_if(!obj);
224 eo_manual_free(obj);
225 eo_unref(obj);
226
227 _man_should_des = EINA_FALSE;
228 klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
229 fail_if(!klass);
230
231 obj = eo_add(klass, NULL);
232 fail_if(!obj);
233 eo_manual_free(obj);
234 fail_if(eo_destructed_is(obj));
235 eo_unref(obj);
236 fail_if(!eo_destructed_is(obj));
237 eo_manual_free(obj);
238
239 obj = eo_add(klass, NULL);
240 fail_if(!obj);
241 eo_unref(obj);
242 fail_if(!eo_destructed_is(obj));
243 eo_manual_free(obj);
244
245 _man_should_con = EINA_FALSE;
246 klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
247 fail_if(!klass);
248
249 obj = eo_add(klass, NULL);
250 fail_if(!obj);
251 eo_manual_free(obj);
252 eo_unref(obj);
253
254 obj = eo_add(klass, NULL);
255 fail_if(!obj);
256 eo_manual_free_set(obj, EINA_TRUE);
257 eo_unref(obj);
258 eo_ref(obj);
259 eo_unref(obj);
260 eo_unref(obj);
261 eo_manual_free(obj);
262
263 obj = eo_add(klass, NULL);
264 fail_if(!obj);
265 eo_manual_free_set(obj, EINA_TRUE);
266 eo_unref(obj);
267 eo_ref(obj);
268 eo_unref(obj);
269 eo_unref(obj);
270 eo_unref(obj);
271 eo_unref(obj);
272 eo_manual_free(obj);
273
274 eo_shutdown();
275}
276END_TEST
277
278START_TEST(eo_refs)
279{
280 eo_init();
281 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
282 Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
283 Eo *obj3 = eo_add(SIMPLE_CLASS, NULL);
284
285 eo_xref(obj, obj2);
286 fail_if(eo_ref_get(obj) != 2);
287 eo_xref(obj, obj3);
288 fail_if(eo_ref_get(obj) != 3);
289
290 eo_xunref(obj, obj2);
291 fail_if(eo_ref_get(obj) != 2);
292 eo_xunref(obj, obj3);
293 fail_if(eo_ref_get(obj) != 1);
294
295#ifndef NDEBUG
296 eo_xunref(obj, obj3);
297 fail_if(eo_ref_get(obj) != 1);
298
299 eo_xref(obj, obj2);
300 fail_if(eo_ref_get(obj) != 2);
301
302 eo_xunref(obj, obj3);
303 fail_if(eo_ref_get(obj) != 2);
304
305 eo_xunref(obj, obj2);
306 fail_if(eo_ref_get(obj) != 1);
307#endif
308
309 /* Check we don't seg if there's an extra xref. */
310 eo_xref(obj, obj2);
311 eo_unref(obj);
312
313 eo_unref(obj);
314 eo_unref(obj2);
315 eo_unref(obj3);
316
317 /* Check hierarchy */
318 obj = eo_add(SIMPLE_CLASS, NULL);
319 obj2 = eo_add(SIMPLE_CLASS, obj);
320
321 Eo *wref;
322 eo_do(obj2, eo_wref_add(&wref));
323 fail_if(!wref);
324
325 eo_unref(obj2);
326
327 fail_if(!wref); /* Parent is still holding a reference. */
328
329 eo_unref(obj);
330
331 fail_if(wref);
332
333 /* Just check it doesn't seg atm. */
334 obj = eo_add(SIMPLE_CLASS, NULL);
335 eo_ref(obj);
336 eo_unref(obj);
337 eo_unref(obj);
338