From d7cfbb6c7eac34348457a3e74631016282575f80 Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Thu, 28 Oct 2021 21:03:01 +0000 Subject: [PATCH 1/3] Update 'README.md' --- README.md | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b84e370..d963b2e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ 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 @@ -14,7 +14,7 @@ This library implements the macros required to define Aurora style interfaces. D ``` #### In your public API: -``` +```c LIB_INTERFACE(IInputMouseSubscriber, AUI_METHOD(void, onButtonPress, (AuUInt8, mb)), AUI_METHOD(void, onButtonTick, (AuUInt8, mb)), @@ -23,13 +23,32 @@ LIB_INTERFACE(IInputMouseSubscriber, ``` #### In a dedicated translation unit: -``` +```c++ #define MY_LIB_GEN_BINDINGS -#include <...> +#include +#include ``` -#### Usage Runtime Binding and Modern C++ +#### Usage: C++ inheritance (covers SWIG and CppSharp) ``` +#include +#include + +struct MyEventHandler : public IInputMouseSubscriber +{ + void onButtonPress(AuUInt8 mb) override; + void onButtonTick(AuUInt8 mb) override; + void onButtonUp(AuUInt8 mb) override; +}; + +static AuSPtr MyMouseSubscriber() +{ + return AuMakeShared(); +} +``` + +#### Usage: Runtime bindings and modern C++ +``` c++ // My language binding IInputMouseSubscriberFunctional test; test.onButtonPress = [](AuUInt8 btn) @@ -41,17 +60,8 @@ AuSPtr handle = AuUnsafeRaiiToShared(&test); // use handle with an Aurora API ``` -#### Usage C++ Native, SWIG, and CppSharp -``` -struct MyEventHandler : public IInputMouseSubscriber -{ - void onButtonPress(AuUInt8 mb) override; - void onButtonTick(AuUInt8 mb) override; - void onButtonUp(AuUInt8 mb) override; -}; - -auto handle = AuMakeShared(); -``` +## Dependencies +* [AuroraForEach](https://git.reece.sx/AuroraSupport/AuroraForEach) [header only] ##### Not recommended for small projects and/or people with a shred of sanity left ##### Possibly useful for API developers \ No newline at end of file From 1d158614bd096345617f8cdb30ba4670ec2a5dab Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Thu, 28 Oct 2021 21:22:04 +0000 Subject: [PATCH 2/3] [*] Improve readme by readding the <...> [*] Improve readme by readding the <...> include to indicate the user should include their public api to initialize the interfaces within that particular header --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d963b2e..4fc1f3d 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,14 @@ LIB_INTERFACE(IInputMouseSubscriber, #define MY_LIB_GEN_BINDINGS #include #include +#include <[MyPublicAPI].hpp> ``` #### Usage: C++ inheritance (covers SWIG and CppSharp) ``` #include #include +#include <[MyPublicAPI].hpp> struct MyEventHandler : public IInputMouseSubscriber { @@ -64,4 +66,4 @@ AuSPtr handle = AuUnsafeRaiiToShared(&test); * [AuroraForEach](https://git.reece.sx/AuroraSupport/AuroraForEach) [header only] ##### Not recommended for small projects and/or people with a shred of sanity left -##### Possibly useful for API developers \ No newline at end of file +##### Possibly useful for API developers \ No newline at end of file From a398b4eb2477f09f4bc861e33e54c13a3ddf1081 Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Thu, 28 Oct 2021 21:38:03 +0000 Subject: [PATCH 3/3] [*] Here wasn't the best place to demo AuUnsafeRaiiToShared --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4fc1f3d..72fbfe8 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,11 @@ static AuSPtr MyMouseSubscriber() #### Usage: Runtime bindings and modern C++ ``` c++ // My language binding -IInputMouseSubscriberFunctional test; -test.onButtonPress = [](AuUInt8 btn) +auto test = AuMakeShared(); +test->onButtonPress = [](AuUInt8 btn) { }; - -AuSPtr handle = AuUnsafeRaiiToShared(&test); -// use handle with an Aurora API ``` ## Dependencies