summaryrefslogtreecommitdiff
path: root/legacy/eobj
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-07-23 08:43:35 +0000
committerTom Hacohen <tom@stosb.com>2012-07-23 08:43:35 +0000
commitfc5eaf662d027ddec57605fed0c554ca55dd6736 (patch)
tree59aa0f2e9e80711efc64698b76399e5c0a45e08b /legacy/eobj
parentbe181af5dc090c49fb8d6de7abdcb94c975d5d61 (diff)
Eo: Fixed bug with calling multiple ops in some cases.
SVN revision: 74313
Diffstat (limited to 'legacy/eobj')
-rw-r--r--legacy/eobj/src/lib/eo.c11
-rw-r--r--legacy/eobj/src/tests/eo_suite/eo_test_general.c75
-rw-r--r--legacy/eobj/src/tests/function_overrides/main.c3
3 files changed, 83 insertions, 6 deletions
diff --git a/legacy/eobj/src/lib/eo.c b/legacy/eobj/src/lib/eo.c
index 3d0f498b01..2dc7a2ecfe 100644
--- a/legacy/eobj/src/lib/eo.c
+++ b/legacy/eobj/src/lib/eo.c
@@ -375,20 +375,22 @@ eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...)
375 375
376 prev_error = obj->do_error; 376 prev_error = obj->do_error;
377 _eo_ref(obj); 377 _eo_ref(obj);
378 _eo_kls_itr_init(obj->klass, &obj->mro_itr, &prev_state);
379 378
380 va_start(p_list, op_type); 379 va_start(p_list, op_type);
381 380
382 op = va_arg(p_list, Eo_Op); 381 op = va_arg(p_list, Eo_Op);
383 while (op) 382 while (op)
384 { 383 {
384 _eo_kls_itr_init(obj->klass, &obj->mro_itr, &prev_state);
385 if (!_eo_op_internal(obj, op_type, op, &p_list)) 385 if (!_eo_op_internal(obj, op_type, op, &p_list))
386 { 386 {
387 _EO_OP_ERR_NO_OP_PRINT(op, obj->klass); 387 _EO_OP_ERR_NO_OP_PRINT(op, obj->klass);
388 ret = EINA_FALSE; 388 ret = EINA_FALSE;
389 _eo_kls_itr_end(&obj->mro_itr, &prev_state);
389 break; 390 break;
390 } 391 }
391 op = va_arg(p_list, Eo_Op); 392 op = va_arg(p_list, Eo_Op);
393 _eo_kls_itr_end(&obj->mro_itr, &prev_state);
392 } 394 }
393 395
394 va_end(p_list); 396 va_end(p_list);
@@ -400,7 +402,6 @@ eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...)
400 402
401 obj->do_error = prev_error; 403 obj->do_error = prev_error;
402 404
403 _eo_kls_itr_end(&obj->mro_itr, &prev_state);
404 return ret; 405 return ret;
405} 406}
406 407
@@ -470,25 +471,25 @@ eo_class_do_internal(const Eo_Class *klass, ...)
470 471
471 EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE); 472 EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, EINA_FALSE);
472 473
473 _eo_kls_itr_init(klass, &((Eo_Class *) klass)->mro_itr, &prev_state);
474
475 va_start(p_list, klass); 474 va_start(p_list, klass);
476 475
477 op = va_arg(p_list, Eo_Op); 476 op = va_arg(p_list, Eo_Op);
478 while (op) 477 while (op)
479 { 478 {
479 _eo_kls_itr_init(klass, &((Eo_Class *) klass)->mro_itr, &prev_state);
480 if (!_eo_class_op_internal((Eo_Class *) klass, op, &p_list)) 480 if (!_eo_class_op_internal((Eo_Class *) klass, op, &p_list))
481 { 481 {
482 _EO_OP_ERR_NO_OP_PRINT(op, klass); 482 _EO_OP_ERR_NO_OP_PRINT(op, klass);
483 ret = EINA_FALSE; 483 ret = EINA_FALSE;
484 _eo_kls_itr_end(&((Eo_Class *) klass)->mro_itr, &prev_state);
484 break; 485 break;
485 } 486 }
487 _eo_kls_itr_end(&((Eo_Class *) klass)->mro_itr, &prev_state);
486 op = va_arg(p_list, Eo_Op); 488 op = va_arg(p_list, Eo_Op);
487 } 489 }
488 490
489 va_end(p_list); 491 va_end(p_list);
490 492
491 _eo_kls_itr_end(&((Eo_Class *) klass)->mro_itr, &prev_state);
492 return ret; 493 return ret;
493} 494}
494 495
diff --git a/legacy/eobj/src/tests/eo_suite/eo_test_general.c b/legacy/eobj/src/tests/eo_suite/eo_test_general.c
index 0624f61276..f6d872f705 100644
--- a/legacy/eobj/src/tests/eo_suite/eo_test_general.c
+++ b/legacy/eobj/src/tests/eo_suite/eo_test_general.c
@@ -654,6 +654,80 @@ START_TEST(eo_magic_checks)
654} 654}
655END_TEST 655END_TEST
656 656
657/* MULTI */
658static Eo_Op MULTI_BASE_ID;
659#define MULTI_ID(sub_id) (MULTI_BASE_ID + sub_id)
660#define multi_a_print() MULTI_ID(MULTI_SUB_ID_A_PRINT)
661#define multi_class_hi_print() MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT)
662
663static void
664_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
665{
666 printf("Hey\n");
667}
668
669static void
670_class_hi_print(const Eo_Class *klass EINA_UNUSED, va_list *list EINA_UNUSED)
671{
672 printf("Hi\n");
673}
674
675enum {
676 MULTI_SUB_ID_A_PRINT,
677 MULTI_SUB_ID_CLASS_HI_PRINT,
678 MULTI_SUB_ID_LAST
679};
680
681static void
682_eo_multiple_do_class_constructor(Eo_Class *klass)
683{
684 const Eo_Op_Func_Description func_desc[] = {
685 EO_OP_FUNC(MULTI_ID(MULTI_SUB_ID_A_PRINT), _a_print),
686 EO_OP_FUNC_CLASS(MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT), _class_hi_print),
687 EO_OP_FUNC_SENTINEL
688 };
689
690 eo_class_funcs_set(klass, func_desc);
691}
692
693static const Eo_Op_Description _eo_multiple_do_op_desc[] = {
694 EO_OP_DESCRIPTION(MULTI_SUB_ID_A_PRINT, "Print property A"),
695 EO_OP_DESCRIPTION_CLASS(MULTI_SUB_ID_CLASS_HI_PRINT, "Print Hi"),
696 EO_OP_DESCRIPTION_SENTINEL
697};
698
699
700START_TEST(eo_multiple_do)
701{
702 eo_init();
703
704 /* Usually should be const, not const only for the test... */
705 static Eo_Class_Description class_desc = {
706 EO_VERSION,
707 "Inherit",
708 EO_CLASS_TYPE_REGULAR,
709 EO_CLASS_DESCRIPTION_OPS(&MULTI_BASE_ID, _eo_multiple_do_op_desc, MULTI_SUB_ID_LAST),
710 NULL,
711 0,
712 _eo_multiple_do_class_constructor,
713 NULL
714 };
715
716 const Eo_Class *klass = eo_class_new(&class_desc, 0, SIMPLE_CLASS, NULL);
717 fail_if(!klass);
718
719 Eo *obj = eo_add(klass, NULL);
720 fail_if(!obj);
721
722 fail_if(!eo_do(obj, simple_a_print(), multi_a_print(), multi_a_print()));
723 fail_if(!eo_class_do(klass, simple_class_hi_print(), multi_class_hi_print(), multi_class_hi_print()));
724
725 eo_unref(obj);
726
727 eo_shutdown();
728}
729END_TEST
730
657void eo_test_general(TCase *tc) 731void eo_test_general(TCase *tc)
658{ 732{
659 tcase_add_test(tc, eo_generic_data); 733 tcase_add_test(tc, eo_generic_data);
@@ -667,4 +741,5 @@ void eo_test_general(TCase *tc)
667 tcase_add_test(tc, eo_static_classes); 741 tcase_add_test(tc, eo_static_classes);
668 tcase_add_test(tc, eo_composite_tests); 742 tcase_add_test(tc, eo_composite_tests);
669 tcase_add_test(tc, eo_isa_tests); 743 tcase_add_test(tc, eo_isa_tests);
744 tcase_add_test(tc, eo_multiple_do);
670} 745}
diff --git a/legacy/eobj/src/tests/function_overrides/main.c b/legacy/eobj/src/tests/function_overrides/main.c
index 7e9d2e162a..af39c67265 100644
--- a/legacy/eobj/src/tests/function_overrides/main.c
+++ b/legacy/eobj/src/tests/function_overrides/main.c
@@ -30,7 +30,8 @@ main(int argc, char *argv[])
30 eo_unref(obj); 30 eo_unref(obj);
31 31
32 obj = eo_add(INHERIT2_CLASS, NULL); 32 obj = eo_add(INHERIT2_CLASS, NULL);
33 eo_do(obj, inherit2_print()); 33 fail_if(!eo_do(obj, inherit2_print()));
34 fail_if(!eo_do(obj, inherit2_print(), inherit2_print()));
34 eo_unref(obj); 35 eo_unref(obj);
35 36
36 obj = eo_add(SIMPLE_CLASS, NULL); 37 obj = eo_add(SIMPLE_CLASS, NULL);