diff options
author | tasn <tasn> | 2012-07-23 08:43:35 +0000 |
---|---|---|
committer | tasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-07-23 08:43:35 +0000 |
commit | 50a3537c3f75975c98cec1722a1d5b16b7c260cc (patch) | |
tree | 8e2c31bf583713da39b773daa4ad747a34df9436 | |
parent | d9f54232c051ea6fb9d3597d2b29473ffb7edef3 (diff) | |
download | eobj-50a3537c3f75975c98cec1722a1d5b16b7c260cc.tar.gz eobj-50a3537c3f75975c98cec1722a1d5b16b7c260cc.tar.bz2 eobj-50a3537c3f75975c98cec1722a1d5b16b7c260cc.zip |
Eo: Fixed bug with calling multiple ops in some cases.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@74313 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
-rw-r--r-- | src/lib/eo.c | 11 | ||||
-rw-r--r-- | src/tests/eo_suite/eo_test_general.c | 75 | ||||
-rw-r--r-- | src/tests/function_overrides/main.c | 3 |
3 files changed, 83 insertions, 6 deletions
diff --git a/src/lib/eo.c b/src/lib/eo.c index 3d0f498..2dc7a2e 100644 --- a/src/lib/eo.c +++ b/src/lib/eo.c @@ -375,20 +375,22 @@ eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...) prev_error = obj->do_error; _eo_ref(obj); - _eo_kls_itr_init(obj->klass, &obj->mro_itr, &prev_state); va_start(p_list, op_type); op = va_arg(p_list, Eo_Op); while (op) { + _eo_kls_itr_init(obj->klass, &obj->mro_itr, &prev_state); if (!_eo_op_internal(obj, op_type, op, &p_list)) { _EO_OP_ERR_NO_OP_PRINT(op, obj->klass); ret = EINA_FALSE; + _eo_kls_itr_end(&obj->mro_itr, &prev_state); break; } op = va_arg(p_list, Eo_Op); + _eo_kls_itr_end(&obj->mro_itr, &prev_state); } va_end(p_list); @@ -400,7 +402,6 @@ eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...) obj->do_error = prev_error; - _eo_kls_itr_end(&obj->mro_itr, &prev_state); return ret; } @@ -470,25 +471,25 @@ eo_class_do_internal(const Eo_Class *klass, ...) EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); - _eo_kls_itr_init(klass, &((Eo_Class *) klass)->mro_itr, &prev_state); - va_start(p_list, klass); op = va_arg(p_list, Eo_Op); while (op) { + _eo_kls_itr_init(klass, &((Eo_Class *) klass)->mro_itr, &prev_state); if (!_eo_class_op_internal((Eo_Class *) klass, op, &p_list)) { _EO_OP_ERR_NO_OP_PRINT(op, klass); ret = EINA_FALSE; + _eo_kls_itr_end(&((Eo_Class *) klass)->mro_itr, &prev_state); break; } + _eo_kls_itr_end(&((Eo_Class *) klass)->mro_itr, &prev_state); op = va_arg(p_list, Eo_Op); } va_end(p_list); - _eo_kls_itr_end(&((Eo_Class *) klass)->mro_itr, &prev_state); return ret; } diff --git a/src/tests/eo_suite/eo_test_general.c b/src/tests/eo_suite/eo_test_general.c index 0624f61..f6d872f 100644 --- a/src/tests/eo_suite/eo_test_general.c +++ b/src/tests/eo_suite/eo_test_general.c @@ -654,6 +654,80 @@ START_TEST(eo_magic_checks) } END_TEST +/* MULTI */ +static Eo_Op MULTI_BASE_ID; +#define MULTI_ID(sub_id) (MULTI_BASE_ID + sub_id) +#define multi_a_print() MULTI_ID(MULTI_SUB_ID_A_PRINT) +#define multi_class_hi_print() MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT) + +static void +_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED) +{ + printf("Hey\n"); +} + +static void +_class_hi_print(const Eo_Class *klass EINA_UNUSED, va_list *list EINA_UNUSED) +{ + printf("Hi\n"); +} + +enum { + MULTI_SUB_ID_A_PRINT, + MULTI_SUB_ID_CLASS_HI_PRINT, + MULTI_SUB_ID_LAST +}; + +static void +_eo_multiple_do_class_constructor(Eo_Class *klass) +{ + const Eo_Op_Func_Description func_desc[] = { + EO_OP_FUNC(MULTI_ID(MULTI_SUB_ID_A_PRINT), _a_print), + EO_OP_FUNC_CLASS(MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT), _class_hi_print), + EO_OP_FUNC_SENTINEL + }; + + eo_class_funcs_set(klass, func_desc); +} + +static const Eo_Op_Description _eo_multiple_do_op_desc[] = { + EO_OP_DESCRIPTION(MULTI_SUB_ID_A_PRINT, "Print property A"), + EO_OP_DESCRIPTION_CLASS(MULTI_SUB_ID_CLASS_HI_PRINT, "Print Hi"), + EO_OP_DESCRIPTION_SENTINEL +}; + + +START_TEST(eo_multiple_do) +{ + eo_init(); + + /* Usually should be const, not const only for the test... */ + static Eo_Class_Description class_desc = { + EO_VERSION, + "Inherit", + EO_CLASS_TYPE_REGULAR, + EO_CLASS_DESCRIPTION_OPS(&MULTI_BASE_ID, _eo_multiple_do_op_desc, MULTI_SUB_ID_LAST), + NULL, + 0, + _eo_multiple_do_class_constructor, + NULL + }; + + const Eo_Class *klass = eo_class_new(&class_desc, 0, SIMPLE_CLASS, NULL); + fail_if(!klass); + + Eo *obj = eo_add(klass, NULL); + fail_if(!obj); + + fail_if(!eo_do(obj, simple_a_print(), multi_a_print(), multi_a_print())); + fail_if(!eo_class_do(klass, simple_class_hi_print(), multi_class_hi_print(), multi_class_hi_print())); + + eo_unref(obj); + + eo_shutdown(); +} +END_TEST + void eo_test_general(TCase *tc) { tcase_add_test(tc, eo_generic_data); @@ -667,4 +741,5 @@ void eo_test_general(TCase *tc) tcase_add_test(tc, eo_static_classes); tcase_add_test(tc, eo_composite_tests); tcase_add_test(tc, eo_isa_tests); + tcase_add_test(tc, eo_multiple_do); } diff --git a/src/tests/function_overrides/main.c b/src/tests/function_overrides/main.c index 7e9d2e1..af39c67 100644 --- a/src/tests/function_overrides/main.c +++ b/src/tests/function_overrides/main.c @@ -30,7 +30,8 @@ main(int argc, char *argv[]) eo_unref(obj); obj = eo_add(INHERIT2_CLASS, NULL); - eo_do(obj, inherit2_print()); + fail_if(!eo_do(obj, inherit2_print())); + fail_if(!eo_do(obj, inherit2_print(), inherit2_print())); eo_unref(obj); obj = eo_add(SIMPLE_CLASS, NULL); |