summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-04-14 10:36:09 +0100
committerTom Hacohen <tom@stosb.com>2014-04-14 10:54:08 +0100
commitd77a7ce4689becaee2a4076283be9460e65429f4 (patch)
treebcbc2a857ed054950d480cde4d1f02fd74ca7124
parent68a1f1941acdbde01a06983b7cb46624a2578abb (diff)
downloadefl-d77a7ce4689becaee2a4076283be9460e65429f4.tar.gz
Eo: eo_do now returns called func's value + default ret fix.
It's now completely valid to do: a = eo_do(obj, a_get()); or: b = eo_do(obj, a_set(1), b_get()); Also, the default return value for eo2 functions is now also returned when the object is invalid, not just when the object does not match class. It's a small refactor that fixed both issues at once. @feature @fix
-rw-r--r--src/lib/eo/Eo.h15
-rw-r--r--src/lib/eo/eo.c20
2 files changed, 23 insertions, 12 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 6e6979942d..13179b85de 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -570,16 +570,11 @@ EAPI void _eo_do_end(const Eo **ojb);
// eo object method calls batch,
#define _eo_do_common(eoid, clsid, is_super, ...) \
- do \
- { \
- const Eo *_eoid_ = eoid; \
- if (_eo_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__)) \
- { \
- const Eo *_id_clean_ EO_DO_CLEANUP = _eoid_; \
- __VA_ARGS__; \
- (void) _id_clean_; \
- } \
- } while (0)
+ ({ \
+ const Eo *_eoid_ EO_DO_CLEANUP = eoid; \
+ _eo_do_start(_eoid_, clsid, is_super, __FILE__, __FUNCTION__, __LINE__); \
+ __VA_ARGS__; \
+ })
#define eo_do(eoid, ...) _eo_do_common(eoid, NULL, EINA_FALSE, __VA_ARGS__)
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index a6c356ae97..4acf0f6b28 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -416,6 +416,7 @@ _eo_do_internal(const Eo *eo_id, const Eo_Class *cur_klass_id,
EAPI Eina_Bool
_eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, int line EINA_UNUSED)
{
+ Eina_Bool ret = EINA_TRUE;
Eo_Stack_Frame *fptr, *pfptr;
Eo_Call_Stack *stack = _eo_call_stack_get();
@@ -428,11 +429,16 @@ _eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, Eina_Bool is_super,
fptr++;
if (!_eo_do_internal(eo_id, cur_klass_id, is_super, fptr, pfptr))
- return EINA_FALSE;
+ {
+ fptr->o.obj = NULL;
+ fptr->cur_klass = NULL;
+
+ ret = EINA_FALSE;
+ }
stack->frame_ptr++;
- return EINA_TRUE;
+ return ret;
}
EAPI void
@@ -471,6 +477,10 @@ _eo_call_resolve(const char *func_name, const Eo_Op op, Eo_Op_Call_Data *call, c
if (op == EO_NOOP) return EINA_FALSE;
fptr = _eo_call_stack_get()->frame_ptr;
+
+ if (EINA_UNLIKELY(!fptr->o.obj))
+ return EINA_FALSE;
+
is_obj = !_eo_is_a_class(fptr->eo_id);
klass = (is_obj) ? fptr->o.obj->klass : fptr->o.kls;
@@ -639,6 +649,9 @@ _eo_api_op_id_get(const void *api_func, const char *file, int line)
Eina_Bool class_ref = _eo_is_a_class(stack->frame_ptr->eo_id);
+ if (EINA_UNLIKELY(!stack->frame_ptr->o.obj))
+ return EO_NOOP;
+
if (class_ref)
klass = stack->frame_ptr->o.kls;
else
@@ -800,6 +813,9 @@ _eo_add_internal_end(const char *file, int line, const Eo *eo_id)
return NULL;
}
+ if (EINA_UNLIKELY(!fptr->o.obj))
+ return NULL;
+
if (!fptr->o.obj->condtor_done || fptr->o.obj->do_error)
{
const _Eo_Class *klass = (fptr->cur_klass) ?