summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-15 18:03:27 +0100
committerTom Hacohen <tom@stosb.com>2015-10-19 10:22:41 +0100
commit8bd7c9e4295a3d9c1732ec57c386633660abe303 (patch)
treeb3ac4c4a5b9cf6828d14d3e7b13fe749dc99a44a /src
parent37c07b07d492a37185b0e5dc404a6efa03c4ad16 (diff)
Eo: Move op resolve check to where it belongs (out of hot path).
It was put in the wrong place. It should abort early if it detects we can't resolve, and shouldn't check it if we already know it's OK.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eo/Eo.h7
-rw-r--r--src/lib/eo/eo.c14
-rw-r--r--src/tests/eo/suite/eo_test_call_errors.c2
3 files changed, 11 insertions, 12 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 6ddc238..19aba96 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -468,8 +468,11 @@ EAPI extern Eo_Hook_Call eo_hook_call_post;
468#define EO_FUNC_COMMON_OP(Name, DefRet) \ 468#define EO_FUNC_COMMON_OP(Name, DefRet) \
469 Eo_Op_Call_Data ___call; \ 469 Eo_Op_Call_Data ___call; \
470 static Eo_Op ___op = EO_NOOP; \ 470 static Eo_Op ___op = EO_NOOP; \
471 if (___op == EO_NOOP) \ 471 if (EINA_UNLIKELY(___op == EO_NOOP)) \
472 ___op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name)); \ 472 { \
473 ___op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name)); \
474 if (___op == EO_NOOP) return DefRet; \
475 } \
473 if (!_eo_call_resolve(#Name, ___op, &___call, __FILE__, __LINE__)) return DefRet; \ 476 if (!_eo_call_resolve(#Name, ___op, &___call, __FILE__, __LINE__)) return DefRet; \
474 _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \ 477 _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \
475 478
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 4e6d2eb..6af86d6 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -529,15 +529,6 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
529 529
530 klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls; 530 klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
531 531
532 if (op == EO_NOOP)
533 {
534 ERR("%s:%d: unable to resolve %s api func '%s' in class '%s'.",
535 file, line, (!is_obj ? "class" : "regular"),
536 func_name, klass->desc->name);
537
538 return EINA_FALSE;
539 }
540
541 /* If we have a current class, we need to itr to the next. */ 532 /* If we have a current class, we need to itr to the next. */
542 if (fptr->cur_klass) 533 if (fptr->cur_klass)
543 { 534 {
@@ -703,6 +694,11 @@ _eo_api_op_id_get(const void *api_func)
703#endif 694#endif
704 eina_spinlock_release(&_ops_storage_lock); 695 eina_spinlock_release(&_ops_storage_lock);
705 696
697 if (op == EO_NOOP)
698 {
699 ERR("Unable to resolve op for api func %p", api_func);
700 }
701
706 return op; 702 return op;
707} 703}
708 704
diff --git a/src/tests/eo/suite/eo_test_call_errors.c b/src/tests/eo/suite/eo_test_call_errors.c
index e6a9883..5a03cd8 100644
--- a/src/tests/eo/suite/eo_test_call_errors.c
+++ b/src/tests/eo/suite/eo_test_call_errors.c
@@ -37,7 +37,7 @@ START_TEST(eo_api_not_implemented_call)
37 Eo *obj = eo_add(SIMPLE_CLASS, NULL); 37 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
38 fail_if(!obj); 38 fail_if(!obj);
39 39
40 TEST_EO_ERROR("_eo_call_resolve", "%s:%d: unable to resolve %s api func '%s' in class '%s'."); 40 TEST_EO_ERROR("_eo_api_op_id_get", "Unable to resolve op for api func %p");
41 eo_do(obj, simple_no_implementation()); 41 eo_do(obj, simple_no_implementation());
42 fail_unless(ctx.did); 42 fail_unless(ctx.did);
43 43