Aurora Interfaces. Abstract API generation model for generating interfaces across language boundaries. Based on Aurora ForEach.
Go to file
2021-10-28 21:03:01 +00:00
Include [+] Made AuiFunction a customer overloadable type. Solves #1 2021-10-24 13:31:21 +01:00
.gitignore Add Aurora build file and .gitignore 2021-10-24 12:51:30 +01:00
Aurora.json Add Aurora build file and .gitignore 2021-10-24 12:51:30 +01:00
LICENSE.txt Initial Commit 2021-10-05 22:01:39 +01:00
README.md Update 'README.md' 2021-10-28 21:03:01 +00:00

Aurora Interfaces

This library implements the macros required to define Aurora style interfaces. Defines two classes implementable by SWIG, CppSharp, and classical event interface inheritance; and implementable by std::function for modern C++ and runtime language bindings respectively. The former is simply defined as a structure containing virtual methods as laid out by AUI_METHODs. Latterly, the base interface is extended and implemented by an array of overloaded method defintions and std::function member fields. The latter type variant includes type defintions of each functional type, where each method type is defined as IMyInterfaceFunctional::methodName_t; and includes a copy and a move constructor for when the implementation is available at time of construction.

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:

LIB_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:

#define MY_LIB_GEN_BINDINGS
#include <AuroraForEach.hpp>
#include <AuroraInterfaces.hpp>

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++

// My language binding
IInputMouseSubscriberFunctional test;
test.onButtonPress = [](AuUInt8 btn)
{

};

AuSPtr<IInputMouseSubscriber> handle = AuUnsafeRaiiToShared(&test);
// use handle with an Aurora API 

Dependencies

Possibly useful for API developers