summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-10 15:59:55 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-10 16:00:50 (GMT)
commit336f0bf740842ab8defdbf482a7f043de95857e4 (patch)
tree4d98d5257634f8def710d73eacefcb8e876e302b /src/script
parent43c82a93c698f4a1eaa460839f905f1923c2b046 (diff)
downloadQt-336f0bf740842ab8defdbf482a7f043de95857e4.zip
Qt-336f0bf740842ab8defdbf482a7f043de95857e4.tar.gz
Qt-336f0bf740842ab8defdbf482a7f043de95857e4.tar.bz2
implement QScriptContext::setActivationObject()
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/qscriptcontext.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index 0d2f20c..d6440b0 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -468,15 +468,31 @@ void QScriptContext::setActivationObject(const QScriptValue &activation)
{
if (!activation.isObject())
return;
+ else if (activation.engine() != engine()) {
+ qWarning("QScriptContext::setActivationObject() failed: "
+ "cannot set an object created in "
+ "a different engine");
+ return;
+ }
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
JSC::JSObject *object = JSC::asObject(engine->scriptValueToJSCValue(activation));
+ if (object == engine->originalGlobalObjectProxy)
+ object = engine->originalGlobalObject();
if (!object->isVariableObject()) {
- qWarning("QScriptContext::setActivationObject(): not an activation object");
+ qWarning("QScriptContext::setActivationObject() failed: not an activation object");
return;
}
-// ### look for variableObject in d->frame->scopeChain, replace by object
- qWarning("QScriptContext::setActivationObject() not implemented");
+
+ // replace the first activation object in the scope chain
+ JSC::ScopeChainNode *node = frame->scopeChain();
+ while (node != 0) {
+ if (node->object->isVariableObject()) {
+ node->object = object;
+ break;
+ }
+ node = node->next;
+ }
}
/*!