Menu

Embedding ObjectiveScript and other questions

2019-08-24
2019-08-24
  • Christopher Sosa

    Hi, i've discovered this project time ago and looks really interesting scripting language which uses static typing which is rare to see in scripting languages (an exception is AngelScript)

    I'm evaluating if i can use ObjectiveScript as long term for my game project (grow old tired of Lua/JS), but i can't find any documentation of how i can embed it, also if supports JIT or AOT (for platforms doesn't support JIT) there a way of how to do it?

    Thanks.

     
  • Michael Adelmann

    Hi Christopher,

    Currently documentation is rare if not missing at all. Sorry for that, but as always documentation is done last ;-). It should be easy to embed it, altough it is currently developed as a standalone project, so I did not trim it for that. Actually it depends on your build system but you should be able to acomplish it by including the complete source and link to the ObjectiveScript project (in Visual Studio this is a lib, as well as in CMake). Then all you would have to do is including the ObjectiveScript.h file and spawning an instance of the VirtualMachine class located in the Projects/Core/Core/VirtualMachine/ folder. Best example of this is the main.cpp file in the oscript subproject. Note that you should not have mulitple instances of the VirtualMachine class since its using a singleton to handle memory allocations, stack frames and so on but I see no reason why you wouldn't be able to run the "createScriptFromFile" method multiple times. Running scripts is as easy as it could be:

        ObjectiveScript::Runtime::Object result;
    
        ObjectiveScript::Script* script = mVirtualMachine.createScriptFromFile(<filename>, true);
    
        mVirtualMachine.run(script, mParameters, &result);
    

    This actually looks for a "Main" method in your script and executes it, but it not necessary to execute it to load its data into memory.

    I would very much like to know if you've been able to embed it in your project.

    Good luck with it

     

    Last edit: Michael Adelmann 2019-08-31

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.