42 lines
2.4 KiB
C++
42 lines
2.4 KiB
C++
/***-
|
|
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
|
|
|
|
#define AU_STRIP_BRACKETS_IMPL(X) X
|
|
#define AU_STRIP_BRACKETS(X) AU_STRIP_BRACKETS_IMPL(AU_BRACKET_SCOPE X)
|
|
|
|
#define AU_EMIT_FIRST(a, b) a
|
|
#define AU_EMIT_SECOND(a, b) b
|
|
#define AU_EMIT_BOTH(a, b) a b
|
|
|
|
#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<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))); \
|
|
}
|
|
|
|
#define AUI_METHOD_FUNCTIONAL_FWD(ret, name, params) \
|
|
std::function<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) };
|
|
|
|
|
|
#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)
|