[+] Made AuiFunction a customer overloadable type. Solves #1

This commit is contained in:
Reece Wilson 2021-10-24 13:29:03 +01:00
parent e9b8d45e0a
commit d9d83f00cd

View File

@ -10,6 +10,19 @@
***/
#pragma once
#if defined(AURORA_RUNTIME_AU_FUNC)
template<class T>
using AuiFunction = AURORA_RUNTIME_AU_FUNC<T>;
#elif defined(AUI_FUNC)
template<class T>
using AuiFunction = AUI_FUNC<T>;
#else
#include <functional>
template<class T>
using AuiFunction = std::function<T>;
#endif
#define AUI_BRACKET_SCOPE(...) __VA_ARGS__
#define AUI_EXPAND_PARAMS_JOINER_A(a, b) a b
@ -27,14 +40,14 @@
#define AUI_METHOD_IMPL(ret, name, params) virtual ret name(AUI_EXPAND_PARAMS params) = 0;
#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \
AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)> name ## Functional; \
name ## _t name ## Functional; \
virtual ret name (AUI_EXPAND_PARAMS params) override \
{ \
return name ## Functional(AUI_EXPAND_PARAMS_PARAMS params); \
}
#define AUI_METHOD_FUNCTIONAL_TYPEDEF(ret, name, params) \
using name ## _t = AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)>;
using name ## _t = AuiFunction<ret(AUI_EXPAND_PARAMS_TYPES params)>;
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL(ret, name, params) \
name ## _t name ## Functional
@ -43,7 +56,7 @@
const name ## _t &name ## Functional
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_REF(ret, name, params) \
AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)> && name ## Functional
name ## _t && name ## Functional
#define AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_BASE_A(ret, name, params) AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_CREF(ret, name, params)
#define AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_BASE_B(ret, name, params) , AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_CREF(ret, name, params)