Extension

Namespace: dmExtension Language: C++ Type: Defold C++ File: extension_gen.hpp Source: engine/extension/src/dmsdk/extension/extension_gen.hpp Include: dmsdk/extension/extension_gen.hpp

Functions for creating and controlling engine native extension libraries.

API

AppExitCode

Type: ENUM Engine exit code.

Members

AppParams

Type: STRUCT The extension app parameters

Members

AppParamsFinalize

Type: FUNCTION Finalizes an extension app params struct (deallocates internal memory)

Parameters

AppParamsGetAppExitCode

Type: FUNCTION get the app exit code

Parameters

Returns

AppParamsGetContext

Type: FUNCTION Gets a context using a specified name hash

Parameters

Returns

AppParamsGetContextByName

Type: FUNCTION Gets a context using a specified name

Parameters

Returns

AppParamsInitialize

Type: FUNCTION Initializes an extension app params struct NOTE: this is an opaque struct, do not use it’s members directly!

Parameters

AppParamsSetContext

Type: FUNCTION Sets a context using a specified name

Parameters

Returns

CallbackType

Type: ENUM Extra callback type for RegisterCallback function.

Members

DM_DECLARE_EXTENSION

Type: MACRO Declare and register new extension to the engine. This macro is used to declare the extension callback functions used by the engine to communicate with the extension.

Examples

Register a new extension:

DM_DECLARE_EXTENSION(MyExt, "MyExt", AppInitializeMyExt, AppFinalizeMyExt, InitializeMyExt, UpdateMyExt, OnEventMyExt, FinalizeMyExt);

DM_PLATFORM_ANDROID

Type: MACRO Set if the platform is Android

DM_PLATFORM_HTML5

Type: MACRO Set if the platform is Html5

DM_PLATFORM_IOS

Type: MACRO Set if the platform is iPhoneOS

DM_PLATFORM_LINUX

Type: MACRO Set if the platform is Linux

DM_PLATFORM_OSX

Type: MACRO Set if the platform is OSX

DM_PLATFORM_WINDOWS

Type: MACRO Set if the platform is Windows (on both x86 and x86_64)

Event

Type: STRUCT Extension event

EventID

Type: ENUM Event id enumeration. EVENT_ID_ICONIFYAPP and EVENT_ID_DEICONIFYAPP only available on

Members

ExtensionAppExitCode

Type: ENUM Engine exit code.

Members

ExtensionAppParams

Type: STRUCT The extension app parameters

Members

ExtensionAppParamsFinalize

Type: FUNCTION Finalizes an extension app params struct (deallocates internal memory)

Parameters

ExtensionAppParamsGetAppExitCode

Type: FUNCTION get the app exit code

Parameters

Returns

ExtensionAppParamsGetContext

Type: FUNCTION Gets a context using a specified name hash

Parameters

Returns

ExtensionAppParamsGetContextByName

Type: FUNCTION Gets a context using a specified name

Parameters

Returns

ExtensionAppParamsInitialize

Type: FUNCTION Initializes an extension app params struct NOTE: this is an opaque struct, do not use it’s members directly!

Parameters

ExtensionAppParamsSetContext

Type: FUNCTION Sets a context using a specified name

Parameters

Returns

ExtensionCallbackType

Type: ENUM Extra callback type for RegisterCallback function.

Members

ExtensionDescBufferSize

Type: FUNCTION Used when registering new extensions

ExtensionEvent

Type: STRUCT Extension event

ExtensionEventID

Type: ENUM Event id enumeration. EVENT_ID_ICONIFYAPP and EVENT_ID_DEICONIFYAPP only available on

Members

ExtensionParams

Type: STRUCT The global parameters avalable when registering and unregistering an extension

Members

ExtensionParamsFinalize

Type: FUNCTION Finalizes an extension params struct (deallocates internal memory)

Parameters

ExtensionParamsGetContext

Type: FUNCTION Gets a context using a specified name hash

Parameters

Returns

ExtensionParamsGetContextByName

Type: FUNCTION Gets a context using a specified name

Parameters

Returns

ExtensionParamsInitialize

Type: FUNCTION Initializes an extension params struct NOTE: this is an opaque struct, do not use it’s members directly!

Parameters

ExtensionParamsSetContext

Type: FUNCTION Sets a context using a specified name

Parameters

Returns

ExtensionRegister

Type: FUNCTION Extension declaration helper. Internal function. Use DM_DECLARE_EXTENSION

Parameters

ExtensionRegisteriOSUIApplicationDelegate

Type: FUNCTION Register an iOS application delegate for process-level callbacks such as launch and remote notification registration. Multiple delegates are supported (Max 32). Use application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: for launch. The older applicationDidFinishLaunching: callback is not synthesized. Defold uses the UIScene lifecycle. Application activity, URL and user activity callbacks are not forwarded from scenes; use ExtensionRegisteriOSUISceneDelegate. The game window is created after application launch. Use scene connection to access it, and scene connection options for cold-launch URLs and user activities.

Notes

Parameters

ExtensionRegisteriOSUISceneDelegate

Type: FUNCTION Register an iOS scene observer. Multiple delegates are supported (Max 32). Defold owns the single game window and its scene configuration. Registered observers receive scene connection/disconnection, activation/deactivation, foreground/background, openURLContexts, continueUserActivity, willContinueUserActivityWithType, didFailToContinueUserActivityWithType:error: and didUpdateUserActivity callbacks. Other optional delegate methods are not forwarded. No legacy UIApplicationDelegate callbacks are synthesized. Register before UIApplicationMain (for example in a static constructor) to receive the initial scene connection. Extension app-initialize is too late. Cold-launch URLs, user activities and notification responses are available in UISceneConnectionOptions. Scene connection may precede Lua initialization; extensions must retain any data they need to deliver to Lua later.

Notes

Parameters

Examples

// myextension_ios.mm
@interface MySceneDelegate : NSObject
- (void)scene:(UIScene*)scene willConnectToSession:(UISceneSession*)session options:(UISceneConnectionOptions*)options;
- (void)scene:(UIScene*)scene openURLContexts:(NSSet*)contexts;
@end

struct MySceneDelegateRegistration
{
    MySceneDelegate* m_Delegate;
    MySceneDelegateRegistration()
    {
        m_Delegate = [[MySceneDelegate alloc] init];
        dmExtension::RegisteriOSUISceneDelegate(m_Delegate);
    }
    ~MySceneDelegateRegistration()
    {
        dmExtension::UnregisteriOSUISceneDelegate(m_Delegate);
        [m_Delegate release];
    }
};
MySceneDelegateRegistration g_MySceneDelegateRegistration;

ExtensionResult

Type: ENUM Result enumeration.

Members

ExtensionUnregisteriOSUIApplicationDelegate

Type: FUNCTION Deregister a previously registered iOS application delegate. This function is only available on iOS.

Parameters

ExtensionUnregisteriOSUISceneDelegate

Type: FUNCTION Deregister a previously registered iOS scene observer on the main thread. This function is only available on iOS.

Parameters

FCallback

Type: TYPEDEF Callback typedef for functions passed to RegisterCallback().

Parameters

Returns

FExtensionAppFinalize

Type: TYPEDEF Callback when the app is being finalized

Parameters

Returns

FExtensionAppInitialize

Type: TYPEDEF Callback when the app is being initialized. Called before FExtensionInitialize

Notes

Parameters

Returns

FExtensionCallback

Type: TYPEDEF Callback typedef for functions passed to RegisterCallback().

Parameters

Returns

FExtensionFinalize

Type: TYPEDEF Calls for the finalization of an extension

Notes

Parameters

Returns

FExtensionInitialize

Type: TYPEDEF Callback when the app is being finalized

Parameters

Returns

FExtensionOnEvent

Type: TYPEDEF Receives an event from the engine

Parameters

FExtensionUpdate

Type: TYPEDEF Updates an extension. Called for each game frame.

Parameters

Returns

Params

Type: STRUCT The global parameters avalable when registering and unregistering an extension

Members

ParamsFinalize

Type: FUNCTION Finalizes an extension params struct (deallocates internal memory)

Parameters

ParamsGetContext

Type: FUNCTION Gets a context using a specified name hash

Parameters

Returns

ParamsGetContextByName

Type: FUNCTION Gets a context using a specified name

Parameters

Returns

ParamsInitialize

Type: FUNCTION Initializes an extension params struct NOTE: this is an opaque struct, do not use it’s members directly!

Parameters

ParamsSetContext

Type: FUNCTION Sets a context using a specified name

Parameters

Returns

RegisterCallback

Type: FUNCTION Generated from ExtensionRegisterCallback

RegisteriOSUIApplicationDelegate

Type: FUNCTION Register an iOS application delegate for process-level callbacks such as launch and remote notification registration. Multiple delegates are supported (Max 32). Use application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: for launch. The older applicationDidFinishLaunching: callback is not synthesized. Defold uses the UIScene lifecycle. Application activity, URL and user activity callbacks are not forwarded from scenes; use ExtensionRegisteriOSUISceneDelegate. The game window is created after application launch. Use scene connection to access it, and scene connection options for cold-launch URLs and user activities.

Notes

Parameters

RegisteriOSUISceneDelegate

Type: FUNCTION Register an iOS scene observer. Multiple delegates are supported (Max 32). Defold owns the single game window and its scene configuration. Registered observers receive scene connection/disconnection, activation/deactivation, foreground/background, openURLContexts, continueUserActivity, willContinueUserActivityWithType, didFailToContinueUserActivityWithType:error: and didUpdateUserActivity callbacks. Other optional delegate methods are not forwarded. No legacy UIApplicationDelegate callbacks are synthesized. Register before UIApplicationMain (for example in a static constructor) to receive the initial scene connection. Extension app-initialize is too late. Cold-launch URLs, user activities and notification responses are available in UISceneConnectionOptions. Scene connection may precede Lua initialization; extensions must retain any data they need to deliver to Lua later.

Notes

Parameters

Examples

// myextension_ios.mm
@interface MySceneDelegate : NSObject
- (void)scene:(UIScene*)scene willConnectToSession:(UISceneSession*)session options:(UISceneConnectionOptions*)options;
- (void)scene:(UIScene*)scene openURLContexts:(NSSet*)contexts;
@end

struct MySceneDelegateRegistration
{
    MySceneDelegate* m_Delegate;
    MySceneDelegateRegistration()
    {
        m_Delegate = [[MySceneDelegate alloc] init];
        dmExtension::RegisteriOSUISceneDelegate(m_Delegate);
    }
    ~MySceneDelegateRegistration()
    {
        dmExtension::UnregisteriOSUISceneDelegate(m_Delegate);
        [m_Delegate release];
    }
};
MySceneDelegateRegistration g_MySceneDelegateRegistration;

Result

Type: ENUM Result enumeration.

Members

UnregisteriOSUIApplicationDelegate

Type: FUNCTION Deregister a previously registered iOS application delegate. This function is only available on iOS.

Parameters

UnregisteriOSUISceneDelegate

Type: FUNCTION Deregister a previously registered iOS scene observer on the main thread. This function is only available on iOS.

Parameters