From bb25b600eb298532a03244a251c1efc040e7ae50 Mon Sep 17 00:00:00 2001 From: Reece Date: Wed, 6 Oct 2021 22:37:59 +0100 Subject: [PATCH] Fixed multiple parameter support --- Include/AuroraInterfaces.hpp | 64 ++++++++++++++---------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/Include/AuroraInterfaces.hpp b/Include/AuroraInterfaces.hpp index 43ed779..653228e 100644 --- a/Include/AuroraInterfaces.hpp +++ b/Include/AuroraInterfaces.hpp @@ -10,51 +10,37 @@ ***/ #pragma once -/// @hideinitializer -#define AU_BRACKET_SCOPE(...) __VA_ARGS__ +#define AUI_EXPAND_PARAMS_JOINER_A(a, b) a b +#define AUI_EXPAND_PARAMS_JOINER_B(a, b) , a b +#define AUI_EXPAND_PARAMS(...) AU_FOR_EACH_FIRST_2(AUI_EXPAND_PARAMS_JOINER_A, AUI_EXPAND_PARAMS_JOINER_B, __VA_ARGS__) -/// @hideinitializer -#define AU_STRIP_BRACKETS_IMPL(X) X +#define AUI_EXPAND_PARAMS_TYPES_JOINER_A(a, b) a +#define AUI_EXPAND_PARAMS_TYPES_JOINER_B(a, b) , a +#define AUI_EXPAND_PARAMS_TYPES(...) AU_FOR_EACH_FIRST_2(AUI_EXPAND_PARAMS_TYPES_JOINER_A, AUI_EXPAND_PARAMS_TYPES_JOINER_B, __VA_ARGS__) -/// @hideinitializer -#define AU_STRIP_BRACKETS(X) AU_STRIP_BRACKETS_IMPL(AU_BRACKET_SCOPE X) +#define AUI_EXPAND_PARAMS_PARAMS_JOINER_A(a, b) b +#define AUI_EXPAND_PARAMS_PARAMS_JOINER_B(a, b) , b +#define AUI_EXPAND_PARAMS_PARAMS(...) AU_FOR_EACH_FIRST_2(AUI_EXPAND_PARAMS_PARAMS_JOINER_A, AUI_EXPAND_PARAMS_PARAMS_JOINER_B, __VA_ARGS__) -/// @hideinitializer -#define AU_EMIT_FIRST(a, b) a +#define AUI_METHOD_IMPL(ret, name, params) virtual ret name(AUI_EXPAND_PARAMS params) = 0; -/// @hideinitializer -#define AU_EMIT_SECOND(a, b) b - -/// @hideinitializer -#define AU_EMIT_BOTH(a, b) a b - -/// @hideinitializer -#define AUI_METHOD_IMPL(ret, name, params) virtual ret name(AU_FOR_EACH_2(AU_EMIT_BOTH, AU_STRIP_BRACKETS(params))) = 0; - -/// @hideinitializer -#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \ - AuFunction name ## Functional; \ - virtual ret name (AU_FOR_EACH_2(AU_EMIT_BOTH, AU_STRIP_BRACKETS(params))) override \ - { \ - return name ## Functional(AU_FOR_EACH_2(AU_EMIT_SECOND, AU_STRIP_BRACKETS(params))); \ +#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \ + AuFunction name ## Functional; \ + virtual ret name (AUI_EXPAND_PARAMS params) override \ + { \ + return name ## Functional(AUI_EXPAND_PARAMS_PARAMS params); \ } -/// @hideinitializer -#define AUI_METHOD_FUNCTIONAL_FWD(ret, name, params) \ - AuFunction name ## Functional; \ - virtual ret name (AU_FOR_EACH_2(AU_EMIT_BOTH, AU_STRIP_BRACKETS(params))) override; - -/// @hideinitializer -#define AUI_DEFINE_INTERFACE_START_STRUCT(name, ...) struct name { AU_FOR_EACH_3(AUI_METHOD_IMPL, __VA_ARGS__) }; - -/// @hideinitializer -#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, ...) struct nameFunctional : name { AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_FWD, __VA_ARGS__) }; - -/// @hideinitializer -#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, ...) struct nameFunctional : name { AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_IMPL, __VA_ARGS__) }; - -#define AUI_PARAMS(...) AU_BRACKET_SCOPE(__VA_ARGS__) -#define AUI_METHOD(...) AU_BRACKET_SCOPE(__VA_ARGS__) +#define AUI_METHOD_FUNCTIONAL_FWD(ret, name, params) \ + AuFunction name ## Functional; \ + virtual ret name (AUI_EXPAND_PARAMS params) override; + +#define AUI_DEFINE_INTERFACE_START_STRUCT(name, ...) struct name { AU_FOR_EACH_3(AUI_METHOD_IMPL, __VA_ARGS__) }; +#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, ...) struct name ## Functional : name { AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_FWD, __VA_ARGS__) }; +#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, ...) struct name ## Functional : name { AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_IMPL, __VA_ARGS__) }; +#define AUI_PARAMS(...) AU_BRACKET_SCOPE(__VA_ARGS__) +#define AUI_METHODS(...) AU_BRACKET_SCOPE(__VA_ARGS__) +#define AUI_METHOD(...) AU_BRACKET_SCOPE(__VA_ARGS__) #define AUI_INTERFACE_FWD(name, ...) AUI_DEFINE_INTERFACE_START_STRUCT(name, __VA_ARGS__) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, __VA_ARGS__) #define AUI_INTERFACE_IMPL(name, ...) AUI_DEFINE_INTERFACE_START_STRUCT(name, __VA_ARGS__) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, __VA_ARGS__) \ No newline at end of file