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:
Microsoft Visual Studio 2005
If Microsoft Visual studio's version is later than 2005, build a platform toolkit with v80.
V8 Java Script engine
Creating and Setting Up Projects
Creating Projects
Run [New Project] and then select [Win32 Project] on [Template > Visual C++ > Win32] menu. Enter a name for a new project and click [Confirm].
After confirming the settings, click [Next] button.
Select DLL among application program types on [Application Program Setting] menu. Click [Finish] button.
Setting Up Projects
Add v8.h path of V8 JavaScript Engine to [Additional Include Directories].
Add 'v8.lib' to [Additional Dependencies].
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.
ExtensionInitialize()
is not called until thenexacro._clearExtensionModule
function is called.The extension module carries out the tasks required for the initialization.
extern "C" __declspec(dllexport) bool ExtensionInitialize()
EntryPoint
In the stage of "EntryPoint", the following tasks are handled:
ExtensionEntryPoint sets EXTENSIONENTRYFUNCS
It is always called using the
nexacro._addExtensionModule
function on Nexacro Platform, and thev8::function
(and etc) is set on the JavaScript object, which is an argument.
extern "C" __declspec(dllexport) bool ExtensionEntryPoint(EXTENSIONENTRYFUNCS*)
Shutdown
ExtensionShutdown()
carries out tasks required when an extension module is not used anymore.
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.