diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-27 19:24:18 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-28 09:23:16 (GMT) |
commit | 9e9f896312edf68584bea5c9b70ec0f1205a11ab (patch) | |
tree | e456f43d6a0701460ca58f3322cc190269804306 /src/script/api | |
parent | a10d523c5010e46b86a74d111342b1b26891cbdf (diff) | |
download | Qt-9e9f896312edf68584bea5c9b70ec0f1205a11ab.zip Qt-9e9f896312edf68584bea5c9b70ec0f1205a11ab.tar.gz Qt-9e9f896312edf68584bea5c9b70ec0f1205a11ab.tar.bz2 |
Make the 'arguments' object working when calling eval from native functions
The 'arguments' is not handled by JavaScriptCore for native function. We
have to do that manually
Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index ba1a31f..a3686ed 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -643,6 +643,12 @@ bool GlobalObject::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) { + QScriptEnginePrivate *engine = scriptEngineFromExec(exec); + if (propertyName == exec->propertyNames().arguments && engine->currentFrame->argumentCount() > 0) { + JSC::JSValue args = engine->scriptValueToJSCValue(engine->contextForFrame(engine->currentFrame)->argumentsObject()); + slot.setValue(args); + return true; + } if (customGlobalObject) return customGlobalObject->getOwnPropertySlot(exec, propertyName, slot); return JSC::JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot); @@ -2173,9 +2179,8 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file JSC::ExecState* exec = d->currentFrame; exec->clearException(); - if (!exec->globalData().dynamicGlobalObject) - exec->globalData().dynamicGlobalObject = d->originalGlobalObject(); JSC::ScopeChain scopeChain = JSC::ScopeChain(exec->scopeChain()); + JSC::DynamicGlobalObjectScope dynamicGlobalObjectScope(exec, exec->scopeChain()->globalObject()); JSC::Completion comp = JSC::evaluate(exec, scopeChain, JSC::makeSource(jscProgram, jscFileName, lineNumber)); if ((comp.complType() == JSC::Normal) || (comp.complType() == JSC::ReturnValue)) { |