MCPcopy Create free account
hub / github.com/9miao/CrossApp / executeScript

Method executeScript

scripting/javascript/bindings/ScriptingCore.cpp:635–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635JSBool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp)
636{
637 if (argc >= 1) {
638 jsval* argv = JS_ARGV(cx, vp);
639 JSString* str = JS_ValueToString(cx, argv[0]);
640 JSStringWrapper path(str);
641 JSBool res = false;
642 if (argc == 2 && argv[1].isString()) {
643 JSString* globalName = JSVAL_TO_STRING(argv[1]);
644 JSStringWrapper name(globalName);
645 js::RootedObject* rootedGlobal = globals[name];
646 if (rootedGlobal) {
647 res = ScriptingCore::getInstance()->runScript(path, rootedGlobal->get());
648 } else {
649 JS_ReportError(cx, "Invalid global object: %s", (char*)name);
650 return JS_FALSE;
651 }
652 } else {
653 JSObject* glob = JS_GetGlobalForScopeChain(cx);
654 res = ScriptingCore::getInstance()->runScript(path, glob);
655 }
656 return res;
657 }
658 return JS_TRUE;
659}
660
661JSBool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp)
662{

Callers

nothing calls this directly

Calls 4

runScriptMethod · 0.80
JSVAL_TO_STRINGFunction · 0.50
isStringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected