Compare commits
No commits in common. "master" and "1.0" have entirely different histories.
29
.gitignore
vendored
29
.gitignore
vendored
@ -1,29 +0,0 @@
|
||||
Build_CompilerWorkingDirectory/*
|
||||
Build_Developers/*
|
||||
Build_Ship/*
|
||||
Build_Internal/*
|
||||
Build_Develop/*
|
||||
Build_CWD/*
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
*.vcxproj.user
|
||||
*.licenseheader
|
||||
*.dll
|
||||
*.exe
|
||||
*.obj
|
||||
*.so
|
||||
*.dynlib
|
||||
*.lib
|
||||
*.d
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.out
|
||||
.vs
|
||||
compile_flags.txt
|
||||
*.mk
|
||||
*.project
|
||||
*cmake
|
||||
.intellij
|
||||
.clion
|
||||
Makefile
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "AuroraInterfaces",
|
||||
"depends": "AuroraForEach",
|
||||
"include-depends": "AuroraForEach",
|
||||
"type": "generic",
|
||||
"include": "Include",
|
||||
"noLink": true
|
||||
}
|
@ -10,19 +10,6 @@
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
#if defined(AURORA_RUNTIME_AU_FUNC)
|
||||
template<class T>
|
||||
using AuiFunction = AURORA_RUNTIME_AU_FUNC<T>;
|
||||
#elif defined(AUI_FUNC)
|
||||
template<class T>
|
||||
using AuiFunction = AUI_FUNC<T>;
|
||||
#else
|
||||
#include <functional>
|
||||
|
||||
template<class T>
|
||||
using AuiFunction = std::function<T>;
|
||||
#endif
|
||||
|
||||
#define AUI_BRACKET_SCOPE(...) __VA_ARGS__
|
||||
|
||||
#define AUI_EXPAND_PARAMS_JOINER_A(a, b) a b
|
||||
@ -40,18 +27,14 @@
|
||||
#define AUI_METHOD_IMPL(ret, name, params) virtual ret name(AUI_EXPAND_PARAMS params) = 0;
|
||||
|
||||
#define AUI_METHOD_FUNCTIONAL_IMPL(ret, name, params) \
|
||||
name ## _t name ## Functional; \
|
||||
inline virtual ret name (AUI_EXPAND_PARAMS params) override \
|
||||
AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)> name ## Functional; \
|
||||
virtual ret name (AUI_EXPAND_PARAMS params) override \
|
||||
{ \
|
||||
if (!name ## Functional) \
|
||||
{ \
|
||||
return ret(); \
|
||||
} \
|
||||
return name ## Functional(AUI_EXPAND_PARAMS_PARAMS params); \
|
||||
}
|
||||
|
||||
#define AUI_METHOD_FUNCTIONAL_TYPEDEF(ret, name, params) \
|
||||
using name ## _t = AuiFunction<ret(AUI_EXPAND_PARAMS_TYPES params)>;
|
||||
using name ## _t = AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)>;
|
||||
|
||||
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL(ret, name, params) \
|
||||
name ## _t name ## Functional
|
||||
@ -60,12 +43,12 @@
|
||||
const name ## _t &name ## Functional
|
||||
|
||||
#define AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_REF(ret, name, params) \
|
||||
name ## _t && name ## Functional
|
||||
AuFunction<ret(AUI_EXPAND_PARAMS_TYPES params)> && name ## Functional
|
||||
|
||||
#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)
|
||||
#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(ret, name, params)
|
||||
#define AUI_METHOD_FUNCTIONAL_CTOR_PARAMS_REF_B(ret, name, params) , AUI_METHOD_PROTOTYPE_TO_FUNCTIONAL_REF(ret2, name, params)
|
||||
|
||||
#define AUI_METHOD_PROTOTYPE_ASSIGN(ret, name, params) \
|
||||
name ## Functional(name ## Functional)
|
||||
@ -96,23 +79,14 @@
|
||||
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_IMPL, name, __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_IMPL(name, ...) AUI_DEFINE_INTERFACE_START_FUNCTIONAL_BASE(AUI_METHOD_FUNCTIONAL_IMPL, name, __VA_ARGS__)
|
||||
|
||||
#define AUI_METHOD(returnValue, name, parameters) returnValue, name, parameters
|
||||
|
||||
/// Not recommended. This will make your code unnecessarily ugly
|
||||
#define AUI_METHOD(...) AUI_BRACKET_SCOPE(__VA_ARGS__)
|
||||
#define AUI_PARAMS(...) (__VA_ARGS__)
|
||||
|
||||
/// @deprecated
|
||||
#define AUI_METHODS(...) AUI_BRACKET_SCOPE(__VA_ARGS__)
|
||||
|
||||
#define AUI_PIN_ODR(name) static const name ## Functional AU_CONCAT(_Zignoreme_aui, __COUNTER__);
|
||||
|
||||
/// Entrypoint into Aurora Interfaces | Forward declare type
|
||||
#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 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
|
||||
#define AUI_INTERFACE_IMPL(name, ...) AUI_DEFINE_INTERFACE_START_STRUCT(name, __VA_ARGS__) AUI_DEFINE_INTERFACE_START_CPP_WRAPPER_IMPL(name, __VA_ARGS__)
|
55
README.md
55
README.md
@ -4,22 +4,45 @@ This library implements the macros required to define Aurora style interfaces. D
|
||||
|
||||
## Example usage:
|
||||
|
||||
#### In your common header:
|
||||
```
|
||||
#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
|
||||
AUI_INTERFACE(IInputMouseSubscriber,
|
||||
```
|
||||
LIB_INTERFACE(IInputMouseSubscriber,
|
||||
AUI_METHOD(void, onButtonPress, (AuUInt8, mb)),
|
||||
AUI_METHOD(void, onButtonTick, (AuUInt8, mb)),
|
||||
AUI_METHOD(void, onButtonUp, (AuUInt8, mb))
|
||||
);
|
||||
```
|
||||
|
||||
#### Usage: C++ inheritance (covers SWIG and CppSharp)
|
||||
#### In a dedicated translation unit:
|
||||
```
|
||||
#define MY_LIB_GEN_BINDINGS
|
||||
#include <...>
|
||||
```
|
||||
#include <AuroraForEach.hpp>
|
||||
#include <AuroraInterfaces.hpp>
|
||||
#include <[MyPublicAPI].hpp>
|
||||
|
||||
#### Usage Runtime Binding and Modern C++
|
||||
```
|
||||
// My language binding
|
||||
IInputMouseSubscriberFunctional test;
|
||||
test.onButtonPress = [](AuUInt8 btn)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
AuSPtr<IInputMouseSubscriber> handle = AuUnsafeRaiiToShared(&test);
|
||||
// use handle with an Aurora API
|
||||
```
|
||||
|
||||
#### Usage C++ Native, SWIG, and CppSharp
|
||||
```
|
||||
struct MyEventHandler : public IInputMouseSubscriber
|
||||
{
|
||||
void onButtonPress(AuUInt8 mb) override;
|
||||
@ -27,24 +50,8 @@ struct MyEventHandler : public IInputMouseSubscriber
|
||||
void onButtonUp(AuUInt8 mb) override;
|
||||
};
|
||||
|
||||
static AuSPtr<IInputMouseSubscriber> MyMouseSubscriber()
|
||||
{
|
||||
return AuMakeShared<MyEventHandler>();
|
||||
}
|
||||
auto handle = AuMakeShared<MyEventHandler>();
|
||||
```
|
||||
|
||||
#### Usage: Runtime bindings and modern C++
|
||||
``` c++
|
||||
// My language binding
|
||||
auto test = AuMakeShared<IInputMouseSubscriberFunctional>();
|
||||
test->onButtonPress = [](AuUInt8 btn)
|
||||
{
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
## 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
|
||||
##### Possibly useful for API developers
|
Loading…
Reference in New Issue
Block a user