command installer 

BlitzScript3D provides a handy utility Command Installer (bscvmCommandInstaller.bb) that will automatically build the bscvmCompilerCallIndex.bb and bscvmThreadCallIndex.bb modules used by the scripting engine for compilation and execution of scripts. Simply add paths to your code modules (*.bb) or Prototype Libraries (*.h) in the bscvmCommandInstall.txt, load and run bscvmCommandInstaller.

The bscvmCompilerCallIndex.bb and bscvmThreadCallIndex.bb modules contain a both contain a Function that work together. These functions are large Select Case Structures used by the Compiler and VM to select the command to execute. You have the option to manually edit bscvmCompilerCallIndex() and bscvmThreadCallIndex() to add and remove commands, or run Command Installer to do it automatically. Its recommended that you run the Command Installer anytime a change is made to your code modules and prototype libraries.

Prototype Libraries

The Command Installer can parse two types of statements: BlitzBasic Functions and Macro Definitions. Prototype Libs are files that contain only Macros. Macros are not code but, a special definition of code, so you can not use them in a BlitzBasic Code module. BlitzScript3D Engine uses a prototype file bscvm.h to define Blitz3D and BlitzScript Commands.

Example:

Macro label{code content}

Macro createcube{this\ax=CreateCube(this\arg[0])}

When parsing BlitzBasic Functions, the Command Installer will automatically generate the necessary code to work with the Script Engine's Register Variables. However, the contents of Macro are directly written as defined within the braces '{' '}'. Thus, the contents can contain a series of statements or what ever BlitzBasic code you wish. The commandlabel provides the label for the command. From within script Macros are parsed like any other command and follow the same rules.

Example (Prototype Macro):

Macro EntityBox{this\ax=CreateCube(this\arg[0])}

Example (Using the Macro in Blitzscript):

;Make a box;

box=entitybox(none)

Manual Edit

Writing Macros and manually editing the bscvmCompilerCallIndex.bb and bscvmThreadCallIndex.bb modules.is not very difficult, if one understands what Register Variables are used by the VM. A brief overview of these modules is warrented.

The bscvmCompilerCallIndex() Function makes Commands recognizable by compiler from scripts. Its Return values match the Command Index# called in the bscvmThreadCallIndex. You can add new commands to the scripting engine by adding a Case like so.

Case "your_command_label" Return Command_Index#

The bscvmThreadCallIndex() is called in the VM to executes Command calls.Command Parameter Values are stored in the Regiser Vars: this\arg[0-15] to be passed to the command. The Return Value from the command is stored in this\ax.

The Select Case Values are matched to the command_index in the bscvmCompilerCallIndex. You can add new commands to the scripting engine by adding a Case like so:

Add a Command w/ Arguments:
Case Index# Your_Function(this\arg[0])

Add a Command w/ Return Value:
Case Index# this\ax=Your_Function(this\arg[0])

Add a Command with no Arguments:
Case Index# Your_Function()

Add a Command w/Return Value and no Arguments:
Case Index# this\ax=Your_Function()