summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-08-01 09:48:22 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2013-08-01 09:48:22 +0200
commit2b59a446e3993b5bdeb6ee2f292aaa8f379d6eb2 (patch)
treecf1618042e0f40f74e1c3acc48fa66738373b6a7
parent7c3f39bba8b58c2dc21b7be8b55dcb2ed11f4ab3 (diff)
downloadefl-2b59a446e3993b5bdeb6ee2f292aaa8f379d6eb2.tar.gz
eo2: eo2_simple uses eo2_add_custom
-rw-r--r--eo2test/TODO2
-rw-r--r--eo2test/eo2-bench.c9
-rw-r--r--eo2test/eo2_inherit.c2
-rw-r--r--eo2test/eo2_simple.c7
-rw-r--r--eo2test/eo2_simple.h2
5 files changed, 12 insertions, 10 deletions
diff --git a/eo2test/TODO b/eo2test/TODO
index 8ad9268353..6803280029 100644
--- a/eo2test/TODO
+++ b/eo2test/TODO
@@ -11,8 +11,6 @@
- m4 __attribute__ cleanup
-- Fix custom constructors
-
- Fix composite objects (?)
- Consider making classes just a regular Eo object? (Just need to bootstrap the first class).
diff --git a/eo2test/eo2-bench.c b/eo2test/eo2-bench.c
index 2e10f153d0..976dd5e4a8 100644
--- a/eo2test/eo2-bench.c
+++ b/eo2test/eo2-bench.c
@@ -113,16 +113,17 @@ do_batch_test()
int a, b, c;
Eo *eo_obj, *eo2_obj;
- a = b = c = 0;
eo_obj = eo_add(EO_SIMPLE_CLASS, NULL);
- eo2_obj = eo2_add(EO2_SIMPLE_CLASS, NULL);
+ eo2_obj = eo2_add_custom(EO2_SIMPLE_CLASS, NULL, eo2_simple_constructor(66));
/* EO check */
+ a = b = c = 0;
eo_do(eo_obj, eo_get(&a), eo_set(10), eo_inc(), eo_get(&b), eo_inc(), eo_inc(), eo_get(&c));
check(a, 66);
check(b, 11);
check(c, 13);
/* EO2 check */
+ a = b = c = 0;
eo2_do(eo2_obj,
a = eo2_get();
eo2_set(10);
@@ -181,7 +182,7 @@ virtual_test()
Eo *eo2_obj;
a = 0;
- eo2_obj = eo2_add(EO2_SIMPLE_CLASS, NULL);
+ eo2_obj = eo2_add_custom(EO2_SIMPLE_CLASS, NULL, eo2_simple_constructor(66));
eo2_do(eo2_obj, a = eo2_virtual(10); );
check(a, 0);
eo_del(eo2_obj);
@@ -208,7 +209,7 @@ cleanup_test()
int a;
Eo *eo2_obj;
- eo2_obj = eo2_add(EO2_SIMPLE_CLASS, NULL);
+ eo2_obj = eo2_add_custom(EO2_SIMPLE_CLASS, NULL, eo2_simple_constructor(66));
/* break */
a = 0;
diff --git a/eo2test/eo2_inherit.c b/eo2test/eo2_inherit.c
index 87fd445bc9..87969ec3e9 100644
--- a/eo2test/eo2_inherit.c
+++ b/eo2test/eo2_inherit.c
@@ -44,7 +44,7 @@ _constructor(Eo *obj, void *obj_data)
{
Private_Data *data = (Private_Data *) obj_data;
- eo2_do_super(obj, eo2_constructor());
+ eo2_do_super(obj, eo2_simple_constructor(66));
data->y = 68;
}
diff --git a/eo2test/eo2_simple.c b/eo2test/eo2_simple.c
index 4db228f6a7..e2bb873baf 100644
--- a/eo2test/eo2_simple.c
+++ b/eo2test/eo2_simple.c
@@ -42,14 +42,15 @@ EAPI EO2_VOID_CLASS_FUNC_BODYV(eo2_class_hello, EO2_CLASS_FUNC_CALL(a), int a);
EAPI EO2_FUNC_BODYV(eo2_virtual, int, EO2_FUNC_CALL(x), 0, int x);
static void
-_constructor(Eo *obj, void *obj_data)
+_constructor(Eo *obj, void *obj_data, int x)
{
Private_Data *data = (Private_Data *) obj_data;
eo2_do_super(obj, eo2_constructor());
- data->x = 66;
+ data->x = x;
}
+EAPI EO2_VOID_FUNC_BODYV(eo2_simple_constructor, EO2_FUNC_CALL(x), int x);
static void
_destructor(Eo *obj, void *obj_data EINA_UNUSED)
@@ -58,7 +59,7 @@ _destructor(Eo *obj, void *obj_data EINA_UNUSED)
}
static Eo2_Op_Description op_descs [] = {
- EO2_OP_FUNC_OVERRIDE(_constructor, eo2_constructor),
+ EO2_OP_FUNC(_constructor, eo2_simple_constructor, "Simple constructor"),
EO2_OP_FUNC_OVERRIDE(_destructor, eo2_destructor),
EO2_OP_FUNC(_inc, eo2_inc, "Inc X"),
EO2_OP_FUNC(_get, eo2_get, "Get X"),
diff --git a/eo2test/eo2_simple.h b/eo2test/eo2_simple.h
index 7ff9867104..53a1706730 100644
--- a/eo2test/eo2_simple.h
+++ b/eo2test/eo2_simple.h
@@ -13,6 +13,8 @@ EAPI int eo2_virtual(int in);
EAPI void eo2_class_hello(int a);
+EAPI void eo2_simple_constructor(int x);
+
EAPI const Eo_Class *eo2_simple_class_get(void);
#define EO2_SIMPLE_CLASS eo2_simple_class_get()