Extension Modules

To use an extension module, you need to create a DLL. This chapter describes how to make a new module or how to use the existing modules.

Development Environment

You can create an extension module which can be used on Nexacro Platform by using a tool and a library:

Creating and Setting Up Projects

Creating Projects

  1. Run [New Project] and then select [Win32 Project] on [Template > Visual C++ > Win32] menu. Enter a name for a new project and click [Confirm].

1

  1. After confirming the settings, click [Next] button.

2

  1. Select DLL among application program types on [Application Program Setting] menu. Click [Finish] button.

Setting Up Projects

  1. Add v8.h path of V8 JavaScript Engine to [Additional Include Directories].

  2. Add 'v8.lib' to [Additional Dependencies].

  3. Add the v8 Lib path residing in [Additional Dependencies] to [Additional Library Directories].

Creating Extetion Modules

The Nexacro Platform engine reads/sets ExtensionInitialize information of extension modules. ExtensionInitialize carries out initial tasks to create modules and sets function pointer values such as the attach object.

Entry Functions

It defines a function which sets v8::Function on v8::Objec.

typedef bool (*pFnAttachObject)( v8::Handle<v8::Object>*);

Initialize

In the stage of "initialize", the following tasks are handled.

extern "C" __declspec(dllexport) bool ExtensionInitialize()

EntryPoint

In the stage of "EntryPoint", the following tasks are handled:

extern "C" __declspec(dllexport) bool ExtensionEntryPoint(EXTENSIONENTRYFUNCS*)

Shutdown

extern "C" __declspec(dllexport) void ExtensionShutdown()

Nexacro Platform APIs

Nexacro Platform APIs related to developing extension modules are as follows.

nexacro._addExtensionModule

It is used when loading extension modules.

nexacro._addExtensionModule = function(object, modulepath)

Argument

Description

object

It saves an extension module's properties, functions and etc.

modulepath

It designates the full path of an extension module.

You can use 'Path Alias' supported on Nexacro Platform.

var ext = {};
nexacro._addExtensionModule(ext, "c:/extension.dll");
nexacro._addExtensionModule(ext, "%COMPONENT%\extension.dll");

nexacro._clearExtensionModule

It is used to clear loaded extension modules when they are not used anymore.

nexacro._clearExtensionModule = function(modulepath)

Argument

Description

modulepath

It designates the full path of an extension module to be shut down.

You can use path alias provided by Nexacro Platform.

If a value is not given, all loaded extension modules will be shut down.

To prevent memory leak which can be caused when you continuously use objects of the extension modules deleted by the nexacro._clearExtensionModule function, do not use objects of unloaded modules.