newspeoplefor developersdocumentationdownloads

Scripting Support
[Nebula Kernel]


Detailed Description

This section of the documentation covers Nebula script system and it's subsystems.

Overview

Nebula's scripting system integrates with its Object System to provide scripting support in multiple languages.

The script server connects the internal language-independent scripting mechanism to a specific scripting language. It translates commands emitted from objects into script statements, and back into commands that are understood by an object's Dispatch() method. So scripting in Nebula2 means invoking script commands directly on C++ objects. It can be possible if a class is derived from nRoot. Saying other, every nRoot derived class is scriptable.

The script server also implements an ipc port to allow external applications (running in another process or another machine) to talk to local objects. See Inter-Process Communication sectoin for the details.

See also:
Writing A New nRoot Derived Class page for more details about scriptable class.
Out of the box, Nebula supports TCL and a binary script server (which is for persistence rather than scripting directly). See nTclServer section for more details. However, there are contributed modules that provide scripting support for other languages:

Note:
MiroTcl is light-weight version of Tcl. It is written for Nebula2 based on Tcl and reduced it's command to 36 commands and it's size to 160KB from 660KB. It is good for minimal envrionments like game consoles.

Running Script

Nebula provides a way to run script file or specific script function within its console or c++.

Within Console

You can run script file with 'get' command within Nebula console:
    >get d:\data\scripts\foo.n2
    

Within C++

You can run a script file with nScriptServer::RunScript() function:
    scriptServer->RunScript("data/scripts/foo.n2", result);

You can also run a specific script function of a script file by calling nScriptServer::RunFunction() function:

    scriptServer->RunFunction("OnStartUp", result);

Note that "OnStartUp" script function does not have any in-arguments. nScriptServer::RunFunction() cannot run a script function which has any in-arguments.

Any results happened from the execution will be passed to the second in-arguments.


Modules

 Automatic scripting wrappers
 nCmdProtoNativeCPP classes are used to make easier thet definition of the script commands in Nebula classes (programmed in C++). It avoids to have to program the wrapper manually in plain C language. It does not add any incompatibility. Main features:
 nTclServer

Classes

class  nCmd
class  nCmdProto
class  nCmdProtoNative
 A factory for nCmd objects that correspond to natively implemented script commands. More...
class  nCmdProtoNativeCPP< TClass, TR, TListIn, TListOut, TClassCast >
class  nCmdProtoTraits< TR, TListIn, TListOut >
class  nScriptServer
class  nBinScriptServer
class  nTclServer

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.