Update 'README.md'
This commit is contained in:
parent
d9d83f00cd
commit
d7cfbb6c7e
42
README.md
42
README.md
@ -5,7 +5,7 @@ This library implements the macros required to define Aurora style interfaces. D
|
|||||||
## Example usage:
|
## Example usage:
|
||||||
|
|
||||||
#### In your common header:
|
#### In your common header:
|
||||||
```
|
```c
|
||||||
#if defined(MY_LIB_GEN_BINDINGS)
|
#if defined(MY_LIB_GEN_BINDINGS)
|
||||||
#define LIB_INTERFACE(name, list) AUI_INTERFACE_IMPL(name, list)
|
#define LIB_INTERFACE(name, list) AUI_INTERFACE_IMPL(name, list)
|
||||||
#define
|
#define
|
||||||
@ -14,7 +14,7 @@ This library implements the macros required to define Aurora style interfaces. D
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### In your public API:
|
#### In your public API:
|
||||||
```
|
```c
|
||||||
LIB_INTERFACE(IInputMouseSubscriber,
|
LIB_INTERFACE(IInputMouseSubscriber,
|
||||||
AUI_METHOD(void, onButtonPress, (AuUInt8, mb)),
|
AUI_METHOD(void, onButtonPress, (AuUInt8, mb)),
|
||||||
AUI_METHOD(void, onButtonTick, (AuUInt8, mb)),
|
AUI_METHOD(void, onButtonTick, (AuUInt8, mb)),
|
||||||
@ -23,13 +23,32 @@ LIB_INTERFACE(IInputMouseSubscriber,
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### In a dedicated translation unit:
|
#### In a dedicated translation unit:
|
||||||
```
|
```c++
|
||||||
#define MY_LIB_GEN_BINDINGS
|
#define MY_LIB_GEN_BINDINGS
|
||||||
#include <...>
|
#include <AuroraForEach.hpp>
|
||||||
|
#include <AuroraInterfaces.hpp>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Usage Runtime Binding and Modern C++
|
#### Usage: C++ inheritance (covers SWIG and CppSharp)
|
||||||
```
|
```
|
||||||
|
#include <AuroraForEach.hpp>
|
||||||
|
#include <AuroraInterfaces.hpp>
|
||||||
|
|
||||||
|
struct MyEventHandler : public IInputMouseSubscriber
|
||||||
|
{
|
||||||
|
void onButtonPress(AuUInt8 mb) override;
|
||||||
|
void onButtonTick(AuUInt8 mb) override;
|
||||||
|
void onButtonUp(AuUInt8 mb) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
static AuSPtr<IInputMouseSubscriber> MyMouseSubscriber()
|
||||||
|
{
|
||||||
|
return AuMakeShared<MyEventHandler>();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Usage: Runtime bindings and modern C++
|
||||||
|
``` c++
|
||||||
// My language binding
|
// My language binding
|
||||||
IInputMouseSubscriberFunctional test;
|
IInputMouseSubscriberFunctional test;
|
||||||
test.onButtonPress = [](AuUInt8 btn)
|
test.onButtonPress = [](AuUInt8 btn)
|
||||||
@ -41,17 +60,8 @@ AuSPtr<IInputMouseSubscriber> handle = AuUnsafeRaiiToShared(&test);
|
|||||||
// use handle with an Aurora API
|
// use handle with an Aurora API
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Usage C++ Native, SWIG, and CppSharp
|
## Dependencies
|
||||||
```
|
* [AuroraForEach](https://git.reece.sx/AuroraSupport/AuroraForEach) [header only]
|
||||||
struct MyEventHandler : public IInputMouseSubscriber
|
|
||||||
{
|
|
||||||
void onButtonPress(AuUInt8 mb) override;
|
|
||||||
void onButtonTick(AuUInt8 mb) override;
|
|
||||||
void onButtonUp(AuUInt8 mb) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto handle = AuMakeShared<MyEventHandler>();
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Not recommended for small projects and/or people with a shred of sanity left
|
##### Not recommended for small projects and/or people with a shred of sanity left
|
||||||
##### Possibly useful for API developers
|
##### Possibly useful for API developers
|
Loading…
Reference in New Issue
Block a user