bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String&scriptString, NPVariant* result) { ProtectedPtr<JSGlobalObject> globalObject = this->globalObject(); if (!globalObject) return false; ExecState* exec = globalObject->globalExec(); JSLock lock(SilenceAssertionsOnly); JSValue thisValue = getOrCreateJSObject(globalObject, npObject); globalObject->globalData()->timeoutChecker.start(); Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(UString(scriptString.impl())), thisValue); globalObject->globalData()->timeoutChecker.stop(); ComplType completionType = completion.complType(); JSValue resultValue; if (completionType == Normal) { resultValue = completion.value(); if (!resultValue) resultValue = jsUndefined(); } else resultValue = jsUndefined(); exec->clearException(); convertJSValueToNPVariant(exec, resultValue, *result); return true; }
bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant) { if (o->_class == NPScriptObjectClass) { JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o); RootObject* rootObject = obj->rootObject; if (!rootObject || !rootObject->isValid()) return false; ExecState* exec = rootObject->globalObject()->globalExec(); JSLock lock(SilenceAssertionsOnly); String scriptString = convertNPStringToUTF16(s); ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject(); globalObject->globalData()->timeoutChecker.start(); Completion completion = JSC::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(scriptString), JSC::JSValue()); globalObject->globalData()->timeoutChecker.stop(); ComplType type = completion.complType(); JSValue result; if (type == Normal) { result = completion.value(); if (!result) result = jsUndefined(); } else result = jsUndefined(); convertValueToNPVariant(exec, result, variant); exec->clearException(); return true; } VOID_TO_NPVARIANT(*variant); return false; }