Removed AUI_METHODS

This commit is contained in:
Reece Wilson 2021-10-06 15:11:53 +01:00
parent f70d7e7dc6
commit c68e802f5a
2 changed files with 36 additions and 17 deletions

View File

@ -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;
/// @hideinitializer
#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \
std::function<ret(AU_FOR_EACH_2(AU_EMIT_FIRST, AU_STRIP_BRACKETS(params)))> name ## Functional; \
AuFunction<ret(AU_FOR_EACH_2(AU_EMIT_FIRST, AU_STRIP_BRACKETS(params)))> 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_FWD(ret, name, params) \
std::function<ret(AU_FOR_EACH_2(AU_EMIT_FIRST, AU_STRIP_BRACKETS(params)))> name ## Functional; \
AuFunction<ret(AU_FOR_EACH_2(AU_EMIT_FIRST, AU_STRIP_BRACKETS(params)))> 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__) };
/// @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_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)
#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__)

View File

@ -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: