2021-10-05 21:01:39 +00:00
|
|
|
/***-
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece").
|
|
|
|
Licensed under the Unlicense license // Public Domain
|
|
|
|
|
|
|
|
File: AuroraInterfaces.hpp
|
|
|
|
Date: 2021-6-10
|
|
|
|
Author: Reece
|
|
|
|
Project: https://git.reece.sx/AuroraSupport/AuroraInterfaces, https://git.reece.sx/AuroraSupport/AuroraRuntime
|
|
|
|
Note: Aurora Runtime will ship with its own implementation of this
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2021-10-07 21:56:33 +00:00
|
|
|
#define AUI_BRACKET_SCOPE(...) __VA_ARGS__
|
|
|
|
|
2021-10-06 21:37:59 +00:00
|
|
|
#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__)
|
2021-10-06 14:11:53 +00:00
|
|
|
|
2021-10-06 21:37:59 +00:00
|
|
|
#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__)
|
2021-10-06 14:11:53 +00:00
|
|
|
|
2021-10-06 21:37:59 +00:00
|
|
|
#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__)
|
2021-10-05 21:01:39 +00:00
|
|
|
|
2021-10-06 21:37:59 +00:00
|
|
|
#define AUI_METHOD_IMPL(ret, name, params) virtual ret name(AUI_EXPAND_PARAMS params) = 0;
|
2021-10-06 14:11:53 +00:00
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \
|
|
|
|
AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)> name ## Functional; \
|
|
|
|
virtual ret name (AUI_EXPAND_PARAMS params) override \
|
|
|
|
{ \
|
|
|
|
return name ## Functional(AUI_EXPAND_PARAMS_PARAMS params); \
|
2021-10-05 21:01:39 +00:00
|
|
|
}
|
2021-10-07 16:03:20 +00:00
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_METHOD_FUNCTIONAL_TYPEDEF(ret, name, params) \
|
|
|
|
using name ## _t = AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)>;
|
|
|
|
|
|
|
|
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL(ret, name, params) \
|
|
|
|
name ## _t name ## Functional
|
2021-10-07 16:03:20 +00:00
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_CREF(ret, name, params) \
|
|
|
|
const name ## _t &name ## Functional
|
2021-10-07 16:03:20 +00:00
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_REF(ret, name, params) \
|
|
|
|
AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)> && name ## Functional
|
2021-10-07 16:03:20 +00:00
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#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)
|
2021-10-14 02:12:51 +00:00
|
|
|
#define AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_REF_A(ret, name, params) AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_REF(ret, name, params)
|
|
|
|
#define AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_REF_B(ret, name, params) , AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_REF(ret2, name, params)
|
2021-10-08 13:24:26 +00:00
|
|
|
|
|
|
|
#define AUI_METHOD_PROTOTYPE_ASSIGN(ret, name, params) \
|
2021-10-07 16:03:20 +00:00
|
|
|
name ## Functional(name ## Functional)
|
|
|
|
|
2021-10-14 02:12:51 +00:00
|
|
|
#define AUI_METHOD_FUNCTIONAL_ASSIGN_A(ret, name, params) : AUI_METHOD_PROTOTYPE_ASSIGN(ret, name, params)
|
2021-10-07 16:03:20 +00:00
|
|
|
#define AUI_METHOD_FUNCTIONAL_ASSIGN_B(ret, name, params) , AUI_METHOD_PROTOTYPE_ASSIGN(ret, name, params)
|
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_METHOD_FUNCTIONAL_FWD(ret, name, params) \
|
|
|
|
AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL(ret, name, params); \
|
2021-10-06 21:37:59 +00:00
|
|
|
virtual ret name (AUI_EXPAND_PARAMS params) override;
|
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_DEFINE_INTERFACE_START_STRUCT(name, ...) struct name \
|
2021-10-07 16:03:20 +00:00
|
|
|
{ \
|
2021-10-08 13:24:26 +00:00
|
|
|
AU_FOR_EACH_3(AUI_METHOD_IMPL, __VA_ARGS__) \
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(tmpl, name, ...) struct name ## Functional : name \
|
|
|
|
{ \
|
|
|
|
AU_FOR_EACH_3(AUI_METHOD_FUNCTIONAL_TYPEDEF, __VA_ARGS__) \
|
2021-10-07 16:03:20 +00:00
|
|
|
inline name ## Functional () {} \
|
|
|
|
inline ~name ## Functional () {} \
|
2021-10-14 02:12:51 +00:00
|
|
|
inline name ## Functional (AU_FOR_EACH_FIRST_3(AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_BASE_A, AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_BASE_B, __VA_ARGS__)) \
|
2021-10-07 16:03:20 +00:00
|
|
|
AU_FOR_EACH_FIRST_3(AUI_METHOD_FUNCTIONAL_ASSIGN_A, AUI_METHOD_FUNCTIONAL_ASSIGN_B, __VA_ARGS__) \
|
|
|
|
{} \
|
2021-10-14 02:12:51 +00:00
|
|
|
inline name ## Functional (AU_FOR_EACH_FIRST_3(AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_REF_A, AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_REF_B, __VA_ARGS__)) \
|
2021-10-08 13:24:26 +00:00
|
|
|
AU_FOR_EACH_FIRST_3(AUI_METHOD_FUNCTIONAL_ASSIGN_A, AUI_METHOD_FUNCTIONAL_ASSIGN_B, __VA_ARGS__) \
|
|
|
|
{} \
|
|
|
|
AU_FOR_EACH_3(tmpl, __VA_ARGS__) \
|
2021-10-07 16:03:20 +00:00
|
|
|
};
|
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, ...) AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(AUI_METHOD_FUNCTIONAL_FWD, name, __VA_ARGS__)
|
2021-10-07 16:03:20 +00:00
|
|
|
#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, ...) AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(AUI_METHOD_FUNCTIONAL_IMPL, name, __VA_ARGS__)
|
2021-10-05 21:01:39 +00:00
|
|
|
|
2021-10-08 13:24:26 +00:00
|
|
|
#define AUI_METHOD(...) AUI_BRACKET_SCOPE(__VA_ARGS__)
|
|
|
|
#define AUI_PARAMS(...) (__VA_ARGS__)
|
|
|
|
|
|
|
|
/// @deprecated
|
|
|
|
#define AUI_METHODS(...) AUI_BRACKET_SCOPE(__VA_ARGS__)
|
|
|
|
|
2021-10-06 14:11:53 +00:00
|
|
|
#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__)
|