SqPlus with VM Objects - Experimental

This is the un-official and temporary home of an experimental modification of SqPlus. I couldn't figure out how to add a new page to the Squirrel WIKI, so made this page.

First I'd like to thank both Alberto and John for their work on Squirrel and SqPlus. I've done quite a bit of research in the last week in trying to determine an appropriate scripting language for the product I'm involved with and Squirrel is getting close to winning ;)

It turns out the product is multi-threaded as it needs to render while doing other time-consuming file operations and shell interaction, and I'd like more than one thread to be scriptable, probably using a different VM on each thread.

To this end, I wasn't perfectly happy with the current implementation of the SqPlus SquirrelVM class as most of the members were static (please don't take this as criticism, what the current SqPlus implementation does already outdoes most other embeddable (embeddible?) scripting systems). Anyways, the current soln for managing multiple VMs didn't seem elegant to me. Even for single-threaded apps the current way is not very OO. With multiple threads you need to synchronize bindings between the threads. And in either case you have to manage VMPointers.

So... I decided to make SquirrelVM a real object (instead of, effectively, a namespace, which is what a class with only statics essentially implements). Also worthy of note is that the current implementation doesn't keep track of the iCallState member per VM anyways, so things would probably fall apart (unless I misunderstood something).

The idea is to have a 1-to-1 relationship between a SquirrelVM and a HSQUIRRELVM. SquirrelObjects would be associated with a particular VM. It would be used something like:

SquirrelVM vm(SquirrelVM::StdLib_All);
SquirrelObject helloWorld = vm.CompileBuffer("print(\"Hello World.\");");
vm.RunScript(helloWorld);


I (think) I've successfully made this change, but I'm certainly very new to SqPlus... I also must admit it spiralled away on me a little... the changes are just a tad more extensive than I initially thought they'd need to be ;)

The only function I was not really happy with was ArrayAppend cuz it needed a VM passed to it unnecessarily... it might be worth considering having the Squirrel base API support a per-vm user-data so that Sqplus can use it to hold a pointer back to the SquirrelVM... maybe...

Anyways, this new scheme can be found at:

SQUIRREL2_1_0_sqplus_20_experimental_vmobjects.zip

Meep, meep, WARNING, meep meep
This is currently experimental! It would be super if people gave it a go and posted comments in the Squirrel forums, but please don't use this in a production environment.

There are a total of 14 modified cpp/h files. The ones that are modded like SquirrelVM.cpp also have the original renamed like SquirrelVM_Backup.cpp so they can be compared. All the tests seem to run (VS8). The only project I can't build is the DXSquirrel one (but I did update the code... just don't have the right dx header).


Contact: tri <AT> tactile3d.com or post responses to appropriate threads in the Squirrel forums