📜 ⬆️ ⬇️

ObjectScript API, integration with C ++. Part 2: executing a script on OS from C ++

ObjectScript is a new, open source object-oriented programming language. ObjectScript extends the capabilities of languages ​​such as JavaScript, Lua and PHP.

Part 2: executing a script on OS from C ++


Take the example code on OS from Part 1: working with the stack, calling OS functions from C ++ . Make the file main.os with the following contents:

print("10 * (3+2) = ", 10 * (3+2)) bar = {firsname="James", lastname="Bond"} bar.profession = "actor" print bar print(concat(5, " big differences")) 

A C ++ program that runs the script will look like this:
')
 #include "objectscript.h" using namespace ObjectScript; int main() { OS * os = OS::create(); os->require("main.os"); os->release(); return 0; } 

When the program is executed, the following is displayed in the console:

 10 * (3+2) = 50 {"firsname":"James","lastname":"Bond","profession":"actor"} 5 big differences 


You can download the ObjectScript sources and an example from this article at this link , open proj.win32 \ examples.sln , the run_os_prog project.

Other relevant ObjectScript articles:

Source: https://habr.com/ru/post/152813/


All Articles