summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-28 01:01:19 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-28 01:01:19 (GMT)
commitbb8fcc568f63ea1ba2107ebbba3845073f378d94 (patch)
tree83da43a476510c874c92110ccc72c18f7214e900 /src/declarative/qml
parent43697c982237f634f89ce661b1b363b8bfa383a7 (diff)
parent59c58576efd3ceff7add46a359fd99e56a2fb279 (diff)
downloadQt-bb8fcc568f63ea1ba2107ebbba3845073f378d94.zip
Qt-bb8fcc568f63ea1ba2107ebbba3845073f378d94.tar.gz
Qt-bb8fcc568f63ea1ba2107ebbba3845073f378d94.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts: src/declarative/qml/qdeclarativeglobalscriptclass.cpp
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp12
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp45
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp2
5 files changed, 40 insertions, 31 deletions
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 2221d78..60e9dd3 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -660,10 +660,9 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(enginePriv->contextClass->newUrlContext(url));
- scriptContext->pushScope(enginePriv->globalClass->globalObject());
+ scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject());
- QScriptValue scope = scriptEngine->newObject();
- scriptContext->setActivationObject(scope);
+ QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine);
scriptContext->pushScope(scope);
scriptEngine->evaluate(code, url, 1);
@@ -686,10 +685,9 @@ void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(enginePriv->contextClass->newUrlContext(this, 0, url));
- scriptContext->pushScope(enginePriv->globalClass->globalObject());
-
- QScriptValue scope = scriptEngine->newObject();
- scriptContext->setActivationObject(scope);
+ scriptContext->pushScope(enginePriv->globalClass->staticGlobalObject());
+
+ QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(scriptEngine);
scriptContext->pushScope(scope);
scriptEngine->evaluate(code, url, 1);
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index b1aecfa..8ae5f2f 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -145,7 +145,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *ex
if (!dd->cachedClosures.at(progIdx)) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(ep->contextClass->newSharedContext());
- scriptContext->pushScope(ep->globalClass->globalObject());
+ scriptContext->pushScope(ep->globalClass->staticGlobalObject());
dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
scriptEngine->popContext();
}
@@ -188,7 +188,7 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex
} else {
scriptContext->pushScope(ep->contextClass->newContext(context, object));
}
- scriptContext->pushScope(ep->globalClass->globalObject());
+ scriptContext->pushScope(ep->globalClass->staticGlobalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program, fileName, lineNumber);
ep->scriptEngine.popContext();
return rv;
@@ -206,7 +206,7 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex
} else {
scriptContext->pushScope(ep->contextClass->newContext(context, object));
}
- scriptContext->pushScope(ep->globalClass->globalObject());
+ scriptContext->pushScope(ep->globalClass->staticGlobalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
@@ -369,7 +369,7 @@ QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool *
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
data->expressionContext = ep->contextClass->newContext(data->context(), data->me);
scriptContext->pushScope(data->expressionContext);
- scriptContext->pushScope(ep->globalClass->globalObject());
+ scriptContext->pushScope(ep->globalClass->staticGlobalObject());
if (data->expressionRewritten) {
data->expressionFunction = scriptEngine->evaluate(data->expression,
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 3e22c82..d43443d 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -42,10 +42,13 @@
#include "private/qdeclarativeglobalscriptclass_p.h"
#include <QtCore/qstringlist.h>
+#include <QtCore/qvector.h>
#include <QtScript/qscriptstring.h>
#include <QtScript/qscriptengine.h>
#include <QtScript/qscriptvalueiterator.h>
+#include <private/qscriptdeclarativeclass_p.h>
+
QT_BEGIN_NAMESPACE
/*
@@ -57,26 +60,34 @@ QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engi
QString eval = QLatin1String("eval");
QString version = QLatin1String("version");
- QScriptValue globalObject = engine->globalObject();
+ QScriptValue originalGlobalObject = engine->globalObject();
- m_globalObject = engine->newObject();
QScriptValue newGlobalObject = engine->newObject();
- QScriptValueIterator iter(globalObject);
-
- while (iter.hasNext()) {
- iter.next();
-
- QString name = iter.name();
-
- if (name == version)
- continue;
-
- if (name != eval)
- m_globalObject.setProperty(iter.scriptName(), iter.value());
- newGlobalObject.setProperty(iter.scriptName(), iter.value());
-
- m_illegalNames.insert(name);
+ {
+ QScriptValueIterator iter(originalGlobalObject);
+ QVector<QString> names;
+ QVector<QScriptValue> values;
+ QVector<QScriptValue::PropertyFlags> flags;
+ while (iter.hasNext()) {
+ iter.next();
+
+ QString name = iter.name();
+
+ if (name == version)
+ continue;
+
+ if (name != eval) {
+ names.append(name);
+ values.append(iter.value());
+ flags.append(iter.flags() | QScriptValue::Undeletable);
+ }
+ newGlobalObject.setProperty(iter.scriptName(), iter.value());
+
+ m_illegalNames.insert(name);
+ }
+ m_staticGlobalObject = QScriptDeclarativeClass::newStaticScopeObject(
+ engine, names.size(), names.constData(), values.constData(), flags.constData());
}
newGlobalObject.setScriptClass(this);
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index fb44e5d..b42b7bd 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -72,13 +72,13 @@ public:
void explicitSetProperty(const QStringList &, const QList<QScriptValue> &);
- const QScriptValue &globalObject() const { return m_globalObject; }
+ const QScriptValue &staticGlobalObject() const { return m_staticGlobalObject; }
const QSet<QString> &illegalNames() const { return m_illegalNames; }
private:
QSet<QString> m_illegalNames;
- QScriptValue m_globalObject;
+ QScriptValue m_staticGlobalObject;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
index c29005a..f26b54f 100644
--- a/src/declarative/qml/qdeclarativeinclude.cpp
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -240,7 +240,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine);
scriptContext->pushScope(ep->contextClass->newUrlContext(context, 0, urlString));
- scriptContext->pushScope(ep->globalClass->globalObject());
+ scriptContext->pushScope(ep->globalClass->staticGlobalObject());
QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5);
scriptContext->pushScope(scope);
scriptContext->setActivationObject(scope);