From c68e802f5a9dbfd237ff6fa3bb57d0eab3d9f602 Mon Sep 17 00:00:00 2001 From: Reece Date: Wed, 6 Oct 2021 15:11:53 +0100 Subject: [PATCH] Removed AUI_METHODS --- Include/AuroraInterfaces.hpp | 51 +++++++++++++++++++++++++----------- README.md | 2 +- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Include/AuroraInterfaces.hpp b/Include/AuroraInterfaces.hpp index dd0eeb6..43ed779 100644 --- a/Include/AuroraInterfaces.hpp +++ b/Include/AuroraInterfaces.hpp @@ -10,32 +10,51 @@ ***/ #pragma once +/// @hideinitializer +#define AU_BRACKET_SCOPE(...) __VA_ARGS__ + +/// @hideinitializer #define AU_STRIP_BRACKETS_IMPL(X) X + +/// @hideinitializer #define AU_STRIP_BRACKETS(X) AU_STRIP_BRACKETS_IMPL(AU_BRACKET_SCOPE X) +/// @hideinitializer #define AU_EMIT_FIRST(a, b) a + +/// @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; -#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \ - std::function 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))); \ + +/// @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_FWD(ret, name, params) \ - std::function name ## Functional; \ +/// @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; - -#define AUI_DEFINE_INTERFACE_START_STRUCT(name, list) struct name { AU_FOR_EACH_3(AUI_METHOD_IMPL, list) }; -#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, list) struct nameFunctional : name { AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_FWD, list) }; -#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, list) struct nameFunctional : name { AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_IMPL, list) }; +/// @hideinitializer +#define AUI_DEFINE_INTERFACE_START_STRUCT(name, ...) struct name { AU_FOR_EACH_3(AUI_METHOD_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, list) AUI_DEFINE_INTERFACE_START_STRUCT(name, list) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, list) -#define AUI_INTERFACE_IMPL(name, list) AUI_DEFINE_INTERFACE_START_STRUCT(name, list) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, list) +/// @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_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 diff --git a/README.md b/README.md index 49ba904..1f5053b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Aurora Interfaces -This library implements the macros required to define Aurora style interfaces. Defines two classes. Implementable by SWIG, CppSharp, and classical OOP override event interface; and implementable by std::function for modern C++ and runtime language bindings respectively. The former is simply defined as a structure containing virtual methods as laid out by AUI_METHODS. Latterly, the base interface is extended and implemented by an array of virtual override method defintions and std::function member fields. +This library implements the macros required to define Aurora style interfaces. Defines two classes. Implementable by SWIG, CppSharp, and classical OOP override event interface; and implementable by std::function for modern C++ and runtime language bindings respectively. The former is simply defined as a structure containing virtual methods as laid out by AUI_METHODs. Latterly, the base interface is extended and implemented by an array of overloaded method defintions and std::function member fields. ## Example usage: