API: JS: VM - ov-studio/Vital.sandbox GitHub Wiki

━ APIs

━ Vital::Sandbox::JS::create()

@Objective: Creates a new VM.
vital_vm* vm = new Vital::Sandbox::JS::create();

━ Vital::Sandbox::JS::fetchVM()

@Objective: Retrieves vm by its state's reference.
vital_vm* vm = Vital::Sandbox::JS::fetchVM(vital_ref* vm);

━ Methods

━ vm::destroy()

@Objective: Destroys targetted vm.
bool result = vm -> destroy();

━ vm::pop()

@Objective: Pops specified number of values from top of the stack.
void result = vm -> pop(int count = 1);

━ vm::execute()

@Objective: Executes a C++ function safely on the vm while reporting encountered exceptions.
⚠️ To be used only within bound C++ functions.
int result = vm -> execute(std::function<int()> exec);

━ vm::loadString()

@Objective: Runs specified buffer on the vm.
bool result = vm -> loadString(std::string& buffer);

━ vm::throwError()

@Objective: Throws a error with call stack details.
bool result = vm -> throwError(std::string& error = "");
⚠️ **GitHub.com Fallback** ⚠️