CANCapture Scripting
Pre-compiled byte code

Sometimes it may be useful to use pre-compiled bytecode instead of re-building the scripts every time a script is loaded. This can for example reduce load times, or if scripts are transferred over the net, it can reduce the transfer time for large scripts.

To save already compiled code you should call the SaveByteCode method on the asIScriptModule, passing in a pointer to the object that implements the asIBinaryStream interface. The script module will then push all the bytecode and related data onto this object with the Write method.

When loading the pre-compiled bytecode you should first get an instance of the asIScriptModule, just as if compiling a new script. Instead of calling AddScriptSection followed by Build you will call the LoadByteCode method, passing it a pointer to the binary stream object. The script module will then pull all the bytecode and related data from that object with the Read method to reconstruct the script module.

Things to remember