MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / scriptRun

Method scriptRun

Source/ScriptingEngine.cpp:439–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439bool cScriptingEngine::scriptRun(const std::string& pJS, const std::string& pFilename) {
440 int success = DUK_EXEC_ERROR;
441
442 // Compile the JS into bytecode
443 duk_push_string(mContext, pFilename.c_str());
444 if (duk_pcompile_string_filename(mContext, 0, pJS.c_str()) != 0) {
445 g_Debugger->Error("Compile failed: ");
446 } else {
447
448 success = duk_pcall(mContext, 0);
449 if(success != DUK_EXEC_SUCCESS)
450 g_Debugger->Error("Execute failed: ");
451 }
452
453 if (duk_is_error(mContext, -1)) {
454 duk_get_prop_string(mContext, -1, "stack");
455 g_Debugger->Error(std::string(duk_safe_to_string(mContext, -1)));
456 }
457 else {
458 if (success != DUK_EXEC_SUCCESS)
459 g_Debugger->Error(std::string(duk_safe_to_string(mContext, -1)));
460 }
461
462 duk_pop(mContext);
463 return (success == DUK_EXEC_SUCCESS);
464}
465
466bool cScriptingEngine::Run(const std::string& pScript) {
467

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected