| 633 | } |
| 634 | |
| 635 | JSBool 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 | |
| 661 | JSBool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp) |
| 662 | { |
nothing calls this directly
no test coverage detected