From 8712c9a621bce3930245b42a6bf678cb4e9bd3e7 Mon Sep 17 00:00:00 2001 From: Reece Date: Sun, 29 May 2022 12:42:09 +0100 Subject: [PATCH] [*] Simplify linking with inline virtual override methods under fwd declare --- Include/AuroraInterfaces.hpp | 8 +++++--- README.md | 18 +----------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/Include/AuroraInterfaces.hpp b/Include/AuroraInterfaces.hpp index 1ec5700..b47a1f9 100644 --- a/Include/AuroraInterfaces.hpp +++ b/Include/AuroraInterfaces.hpp @@ -41,7 +41,7 @@ #define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \ name ## _t name ## Functional; \ - virtual ret name (AUI_EXPAND_PARAMS params) override \ + inline virtual ret name (AUI_EXPAND_PARAMS params) override \ { \ if (!name ## Functional) \ { \ @@ -96,7 +96,7 @@ AU_FOR_EACH_3(tmpl, __VA_ARGS__) \ }; -#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, ...) AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(AUI_METHOD_FUNCTIONAL_FWD, name, __VA_ARGS__) +#define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, ...) AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(AUI_METHOD_FUNCTIONAL_IMPL, name, __VA_ARGS__) #define AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, ...) AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(AUI_METHOD_FUNCTIONAL_IMPL, name, __VA_ARGS__) #define AUI_METHOD(returnValue, name, parameters) returnValue, name, parameters @@ -113,4 +113,6 @@ #define AUI_INTERFACE_FWD(name, ...) AUI_DEFINE_INTERFACE_START_STRUCT(name, __VA_ARGS__) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_FWD(name, __VA_ARGS__) /// Entrypoint into Aurora Interfaces | Forward declare and define in a single translation unit -#define AUI_INTERFACE_IMPL(name, ...) AUI_DEFINE_INTERFACE_START_STRUCT(name, __VA_ARGS__) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, __VA_ARGS__) AUI_PIN_ODR(name) \ No newline at end of file +#define AUI_INTERFACE_IMPL AUI_INTERFACE_FWD //(name, ...) AUI_DEFINE_INTERFACE_START_STRUCT(name, __VA_ARGS__) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, __VA_ARGS__) AUI_PIN_ODR(name) + +#define AUI_INTERFACE AUI_INTERFACE_FWD \ No newline at end of file diff --git a/README.md b/README.md index 72fbfe8..2f07328 100644 --- a/README.md +++ b/README.md @@ -4,32 +4,16 @@ This library implements the macros required to define Aurora style interfaces. D ## Example usage: -#### In your common header: -```c -#if defined(MY_LIB_GEN_BINDINGS) - #define LIB_INTERFACE(name, list) AUI_INTERFACE_IMPL(name, list) -#define - #define LIB_INTERFACE(name, list) AUI_INTERFACE_FWD(name, list) -#endif -``` #### In your public API: ```c -LIB_INTERFACE(IInputMouseSubscriber, +AUI_INTERFACE(IInputMouseSubscriber, AUI_METHOD(void, onButtonPress, (AuUInt8, mb)), AUI_METHOD(void, onButtonTick, (AuUInt8, mb)), AUI_METHOD(void, onButtonUp, (AuUInt8, mb)) ); ``` -#### In a dedicated translation unit: -```c++ -#define MY_LIB_GEN_BINDINGS -#include -#include -#include <[MyPublicAPI].hpp> -``` - #### Usage: C++ inheritance (covers SWIG and CppSharp) ``` #include