So I've started making the VM and test app now. The VM compiles to a .lib file, and you #include "DruinkScript.h", which will include the other files.
I'm not entirely sure how to lay the code out though. Usually I have a Code folder in the solution directory, and then one folder for each .cpp/.h pair. But I want the client apps to be able to just include one file, which will include others, so I guess I'll stuff all the headers into one folder, and seperate them out using the filters in the IDE. That way I should end up with the classic "include" "src" "lib" "bin" folders that libs like Lua dish out.
I'm aiming to make the VM as simple as possible to start up and get scripts loaded, it'll probably be something like:
#include "DruinkScript/DruinkScript.h"#include int main(int, char**){ DruinkScript::VM theVM; theVM.Init(); DruinkScript::Script* pScript = theVM.LoadScript("Test.ds"); if(!pScript) { printf("Failed to load script: %s\n", theVM.GetError()); return -1; } while(!pScript->Finished()) { pScript->Run(50); // Execute up to 50 opcodes this cycle } pScript->Release(); return 0;}
Yes, that doesn't show much, I know. But it's a start. The function binding will probably be via functors, since I hate writing static member functions that just call a non-static member.
I'm not entirely sure how I'll handle multiple scripts, I think the above method should lend itself pretty well to handling that without much bother though.
Anyway. Work...