diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 7f77b393cf..3d65d0a078 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -592,6 +592,50 @@ EAPI Eina_Bool eo_init(void); */ EAPI Eina_Bool eo_shutdown(void); +typedef struct _Eo_Internal _Eo; + +/* XXX: Essential, because we need to adjust objid for comp objects. */ +#define EO_FUNC(Name, Ret, Id, Func, DefRet, ...) \ +Ret \ +Name(_Eo *obj, Eo *objid, __VA_ARGS__) \ +{ \ + Ret (*func)(Eo *, __VA_ARGS__) = eo2_func_get(obj, Id(Name)); \ + if (func) \ + { \ + return Func; \ + } \ + else \ + { \ + return DefRet; \ + } \ +} + + +EAPI _Eo * eo2_do_start(Eo *obj_id); +#define eo2_func_get(obj_id, op) eo2_func_get_internal(obj_id, NULL, op) +EAPI void * eo2_func_get_internal(_Eo *obj, const Eo_Class *klass, Eo_Op op); + +/* FIXME: Don't use this unref, use an internal one. Reduce id resolution. */ + +#define eo2_do_end(obj) eo_unref(obj) + +#define eo_o _obj_, _objid_ + +#define eo2_do(objid, ...) \ +do \ +{ \ + Eo *_objid_ = obj; \ + _Eo *_obj_ = eo2_do_start(obj); \ + do { __VA_ARGS__ ; } while (0); \ + eo2_do_end(obj); \ +} while (0) + +#define eo2_class_do(clsid, ...) \ +do \ +{ \ + do { __VA_ARGS__ ; } while (0); \ +} while (0) + /** * @def eo_do * A convenience wrapper around eo_do_internal() diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 7842aa8a91..0cc724bda6 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -255,6 +255,41 @@ _eo_kls_itr_func_get(const _Eo_Class *cur_klass, Eo_Op op) return NULL; } +EAPI _Eo * +eo2_do_start(Eo *obj_id) +{ + EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL); + _eo_ref(obj); + return obj; +} + +static void * +_eo2_func_get(const _Eo_Class *cur_klass, Eo_Op op) +{ + { + const op_type_funcs *func = _eo_kls_itr_func_get(cur_klass, op); + if (EINA_LIKELY(func != NULL)) + { + return func->func; + } + } + + /* Try composite objects */ + /* FIXME!!! */ + return NULL; +} + +EAPI void * +eo2_func_get_internal(_Eo *obj, const Eo_Class *klass_id, Eo_Op op) +{ + const _Eo_Class *klass; + if (klass_id) + klass = _eo_class_pointer_get(klass_id); + else + klass = obj->klass; + return _eo2_func_get(klass, op); +} + #define _EO_OP_ERR_NO_OP_PRINT(file, line, op, klass) \ do \ { \