diff options
author | tasn <tasn> | 2012-08-23 10:47:11 +0000 |
---|---|---|
committer | tasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-08-23 10:47:11 +0000 |
commit | 605bea5ec6950ae488aea8e655e6bc9e2a1a6626 (patch) | |
tree | cd302cffae19af201d9429020b7a05bdae538e3b | |
parent | 5ff409b91f754f333896ceb0b36dfd693cb0541a (diff) | |
download | eobj-605bea5ec6950ae488aea8e655e6bc9e2a1a6626.tar.gz eobj-605bea5ec6950ae488aea8e655e6bc9e2a1a6626.tar.bz2 eobj-605bea5ec6950ae488aea8e655e6bc9e2a1a6626.zip |
Eo: Added a non-default constructor test.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@75616 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
-rw-r--r-- | src/tests/constructors/main.c | 10 | ||||
-rw-r--r-- | src/tests/constructors/simple.c | 17 | ||||
-rw-r--r-- | src/tests/constructors/simple.h | 2 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/tests/constructors/main.c b/src/tests/constructors/main.c index 9bcf095..04d8888 100644 --- a/src/tests/constructors/main.c +++ b/src/tests/constructors/main.c @@ -59,6 +59,16 @@ main(int argc, char *argv[]) obj = eo_add(SIMPLE7_CLASS, NULL); fail_if(obj); + my_init_count = 0; + obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7)); + fail_if(!obj); + + fail_if(my_init_count != 2); + eo_do(obj, simple_a_get(&a)); + fail_if(a != 7); + + eo_unref(obj); + eo_shutdown(); return ret; } diff --git a/src/tests/constructors/simple.c b/src/tests/constructors/simple.c index 856b2b4..5712534 100644 --- a/src/tests/constructors/simple.c +++ b/src/tests/constructors/simple.c @@ -42,6 +42,21 @@ _GET_SET_FUNC(b) extern int my_init_count; static void +_simple_constructor(Eo *obj, void *class_data, va_list *list) +{ + Private_Data *pd = class_data; + int a; + a = va_arg(*list, int); + + eo_do_super(obj, eo_constructor()); + + pd->a = a; + printf("%s %d\n", __func__, pd->a); + + my_init_count++; +} + +static void _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) { eo_do_super(obj, eo_constructor()); @@ -63,6 +78,7 @@ _class_constructor(Eo_Class *klass) const Eo_Op_Func_Description func_desc[] = { EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), + EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), _simple_constructor), EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get), EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set), @@ -82,6 +98,7 @@ _class_destructor(Eo_Class *klass EINA_UNUSED) } static const Eo_Op_Description op_desc[] = { + EO_OP_DESCRIPTION(SIMPLE_SUB_ID_CONSTRUCTOR, "Construct and set A."), EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"), EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"), EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"), diff --git a/src/tests/constructors/simple.h b/src/tests/constructors/simple.h index 773b737..ac3e287 100644 --- a/src/tests/constructors/simple.h +++ b/src/tests/constructors/simple.h @@ -6,6 +6,7 @@ extern EAPI Eo_Op SIMPLE_BASE_ID; enum { + SIMPLE_SUB_ID_CONSTRUCTOR, SIMPLE_SUB_ID_A_SET, SIMPLE_SUB_ID_A_GET, SIMPLE_SUB_ID_B_SET, @@ -15,6 +16,7 @@ enum { #define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id) +#define simple_constructor(a) SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(int, a) #define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a) #define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a) #define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b) |