From bd8df9a9452cd02a5fb56736777f42d05fd9c831 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 19 Jun 2016 17:04:59 +1000 Subject: [PATCH] Mutators: extra pass for macro expansion --- qcsrc/common/mutators/base.qh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/mutators/base.qh b/qcsrc/common/mutators/base.qh index 4d92b5d40..c1f7501c9 100644 --- a/qcsrc/common/mutators/base.qh +++ b/qcsrc/common/mutators/base.qh @@ -120,9 +120,10 @@ ENDCLASS(CallbackChain) void RegisterHooks() {}; void RegisterCallbacks() {}; -#define _MUTATOR_HOOKABLE(id, ...) CallbackChain HOOK_##id; bool __Mutator_Send_##id(__VA_ARGS__) -#define MUTATOR_HOOKABLE(id, params) \ - _MUTATOR_HOOKABLE(id, int params(_MUTATOR_HANDLE_PARAMS, _MUTATOR_HANDLE_NOP)) { \ +#define MUTATOR_HOOKABLE(id, params) _MUTATOR_HOOKABLE(id, params) +#define _MUTATOR_HOOKABLE(id, params) \ + CallbackChain HOOK_##id; \ + bool __Mutator_Send_##id(int params(_MUTATOR_HANDLE_PARAMS, _MUTATOR_HANDLE_NOP)) { \ params(_MUTATOR_HANDLE_PUSHTMP, _MUTATOR_HANDLE_NOP) \ params(_MUTATOR_HANDLE_PREPARE, _MUTATOR_HANDLE_NOP) \ bool ret = CallbackChain_Call(HOOK_##id); \ @@ -132,10 +133,12 @@ void RegisterCallbacks() {}; return ret; \ } \ [[accumulate]] void RegisterHooks() { HOOK_##id = NEW(CallbackChain, #id); } + +#define MUTATOR_CALLHOOK(id, ...) _MUTATOR_CALLHOOK(id, __VA_ARGS__) #ifdef __STDC__ - #define MUTATOR_CALLHOOK(id, ...) APPLY(__Mutator_Send_##id, 0 P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__)) + #define _MUTATOR_CALLHOOK(id, ...) APPLY(__Mutator_Send_##id, 0 P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__)) #else - #define MUTATOR_CALLHOOK(id, ...) APPLY(__Mutator_Send_##id, 0, ##__VA_ARGS__) + #define _MUTATOR_CALLHOOK(id, ...) APPLY(__Mutator_Send_##id, 0, ##__VA_ARGS__) #endif enum { -- 2.39.2