blob: 26e091366acb5dfebbffadf5b677a1d8a834c05b (
plain) (
tree)
|
|
#define ARGS0()
#define ARGS1() a0
#define ARGS2() a1, ARGS1()
#define TYPEDARGS0()
#define TYPEDARGS1(type) type a0
#define TYPEDARGS2(type, ...) type a1, TYPEDARGS1(__VA_ARGS__)
#define MOCK_WRAPPER_IMPL(ret, fn) \
/* do common work */ \
static ret wrap_##fn(...);
// Utility to generate wrapper boilerplate for functions with *one* argument.
#define WRAP1(ret, fn, ty1) \
MOCK_WRAPPER_IMPL(ret, fn) \
\
extern "C" ret fn(TYPEDARGS1(ty1)) { \
return wrap_##fn(ARGS1()); \
}
// Utility to generate wrapper boilerplate for functions with *two* arguments.
#define WRAP2(ret, fn, ty1, ty2) \
MOCK_WRAPPER_IMPL(ret, fn) \
\
extern "C" ret fn(TYPEDARGS2(ty1, ty2)) { \
return wrap_##fn(ARGS2()); \
}
WRAP1(int, foo, const char*)
WRAP2(int, bar, const char*, const char*)
|