eo2: add EO_FUNC_BODY_VOID and EO_FUNC_BODY_VOIDV macros

This commit is contained in:
Jérémy Zurcher 2013-12-25 15:09:16 +01:00 committed by Tom Hacohen
parent 48c2c1dfba
commit 6bb29b378b
1 changed files with 8 additions and 5 deletions

View File

@ -624,8 +624,7 @@ typedef struct _Eo2_Op_Call_Data
#define eo2_o _obj_, _objid_
// to pass the internal function call to EO_FUNC_BODY (as Func parameter)
#define EO_FUNC_CALL() _func_(objid, call.data)
#define EO_FUNC_CALLV(...) _func_(objid, call.data, __VA_ARGS__)
#define EO_FUNC_CALL(...) _func_(objid, call.data, __VA_ARGS__)
// cache OP id, get real fct and object data then do the call
#define _EO_FUNC_COMMON(Name, Ret, Func, DefRet) \
@ -633,19 +632,21 @@ typedef struct _Eo2_Op_Call_Data
if ( op == EO_NOOP ) op = eo2_get_op_id(obj, (void*)Name); \
Eo2_Op_Call_Data call; \
if (!eo2_call_resolve(obj, op, &call)) return DefRet; \
__##Name##_func _func_ = (__##Name##_func) call.func; \
__##Name##_func _func_ = (__##Name##_func) call.func; \
return Func; \
/* XXX: Essential, because we need to adjust objid for comp objects. */
// to define an EAPI function
#define EO_FUNC_BODY(Name, Ret, Func, DefRet) \
#define EO_FUNC_BODY(Name, Ret, DefRet) \
Ret \
Name(_Eo *obj, Eo *objid) \
{ \
typedef Ret (*__##Name##_func)(Eo *, void *obj_data); \
_EO_FUNC_COMMON(Name, Ret, Func, DefRet) \
_EO_FUNC_COMMON(Name, Ret, _func_(objid, call.data), DefRet) \
}
#define EO_FUNC_BODY_VOID(Name) EO_FUNC_BODY(Name, void, )
#define EO_FUNC_BODYV(Name, Ret, Func, DefRet, ...) \
Ret \
Name(_Eo *obj, Eo *objid, __VA_ARGS__) \
@ -654,6 +655,8 @@ typedef struct _Eo2_Op_Call_Data
_EO_FUNC_COMMON(Name, Ret, Func, DefRet) \
}
#define EO_FUNC_BODY_VOIDV(Name, Func, ...) EO_FUNC_BODYV(Name, void, Func, , __VA_ARGS__)
// FIXME: OP ID
#define EO2_OP_CONSTRUCTOR(_private) { _private, NULL, 1, EO_OP_TYPE_REGULAR, "Constructor"}
#define EO2_OP_DESTRUCTOR(_private) { _private, NULL, 2, EO_OP_TYPE_REGULAR, "Destructor"}