aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-09-17 09:59:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 14:26:46 +0200
commit6b5177a7565c7b4c4f49a636d135f8ea4e443506 (patch)
treebf3dfdd1bf74b1d9c0b21173b3e3132098486e81
parentf7cd6238ada2745eea13ceff168e7d65b7263866 (diff)
[new compiler] Cleanups
Make the v4 context to use for binding expressions/functions/signal handlers a member variable instead of a function parameter, as it doesn't change frequently. Change-Id: I8a73bbc3f37c116d29172d5c935c66ecf2f67a38 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp22
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h7
2 files changed, 17 insertions, 12 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 9260c1609e..924522836f 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -477,6 +477,7 @@ QmlObjectCreator::QmlObjectCreator(QQmlContextData *contextData, const QV4::Comp
, _ddata(0)
, _propertyCache(0)
, _vmeMetaObject(0)
+ , _qmlContext(0)
{
}
@@ -879,7 +880,7 @@ void QmlObjectCreator::setPropertyValue(QQmlPropertyData *property, const QV4::C
}
}
-void QmlObjectCreator::setupBindings(QV4::ExecutionContext *qmlContext)
+void QmlObjectCreator::setupBindings()
{
QQmlListProperty<void> savedList;
qSwap(_currentList, savedList);
@@ -904,15 +905,14 @@ void QmlObjectCreator::setupBindings(QV4::ExecutionContext *qmlContext)
}
- if (!setPropertyValue(qmlContext, property, i, binding))
+ if (!setPropertyValue(property, i, binding))
return;
}
qSwap(_currentList, savedList);
}
-bool QmlObjectCreator::setPropertyValue(QV4::ExecutionContext *qmlContext, QQmlPropertyData *property,
- int bindingIndex, const QV4::CompiledData::Binding *binding)
+bool QmlObjectCreator::setPropertyValue(QQmlPropertyData *property, int bindingIndex, const QV4::CompiledData::Binding *binding)
{
if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
const QV4::CompiledData::Object *obj = unit->objectAt(binding->value.objectIndex);
@@ -962,7 +962,7 @@ bool QmlObjectCreator::setPropertyValue(QV4::ExecutionContext *qmlContext, QQmlP
if (binding->type == QV4::CompiledData::Binding::Type_Script) {
QV4::Function *runtimeFunction = jsUnit->runtimeFunctions[binding->value.compiledScriptIndex];
- QV4::Value function = QV4::Value::fromObject(QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction));
+ QV4::Value function = QV4::Value::fromObject(QV4::FunctionObject::creatScriptFunction(_qmlContext, runtimeFunction));
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) {
int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex);
@@ -1062,7 +1062,7 @@ bool QmlObjectCreator::setPropertyValue(QV4::ExecutionContext *qmlContext, QQmlP
return true;
}
-void QmlObjectCreator::setupFunctions(QV4::ExecutionContext *qmlContext)
+void QmlObjectCreator::setupFunctions()
{
QQmlVMEMetaObject *vme = QQmlVMEMetaObject::get(_qobject);
@@ -1075,7 +1075,7 @@ void QmlObjectCreator::setupFunctions(QV4::ExecutionContext *qmlContext)
if (!property->isVMEFunction())
continue;
- QV4::FunctionObject *function = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction);
+ QV4::FunctionObject *function = QV4::FunctionObject::creatScriptFunction(_qmlContext, runtimeFunction);
vme->setVmeMethod(property->coreIndex, QV4::Value::fromObject(function));
}
}
@@ -1190,8 +1190,12 @@ bool QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi
QV4::ScopedValue qmlScopeFunction(valueScope, QV4::Value::fromObject(qmlBindingWrapper));
QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context();
- setupBindings(qmlContext);
- setupFunctions(qmlContext);
+ qSwap(_qmlContext, qmlContext);
+
+ setupBindings();
+ setupFunctions();
+
+ qSwap(_qmlContext, qmlContext);
qSwap(_createdBindings, createdBindings);
qSwap(_vmeMetaObject, vmeMetaObject);
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 62c344194e..6bdcf623ca 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -96,10 +96,10 @@ public:
private:
bool populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache);
- void setupBindings(QV4::ExecutionContext *qmlContext);
- bool setPropertyValue(QV4::ExecutionContext *qmlContext, QQmlPropertyData *property, int index, const QV4::CompiledData::Binding *binding);
+ void setupBindings();
+ bool setPropertyValue(QQmlPropertyData *property, int index, const QV4::CompiledData::Binding *binding);
void setPropertyValue(QQmlPropertyData *property, const QV4::CompiledData::Binding *binding);
- void setupFunctions(QV4::ExecutionContext *qmlContext);
+ void setupFunctions();
QString stringAt(int idx) const { return unit->header.stringAt(idx); }
void recordError(const QV4::CompiledData::Location &location, const QString &description);
@@ -122,6 +122,7 @@ private:
QQmlVMEMetaObject *_vmeMetaObject;
QVector<QQmlAbstractBinding*> _createdBindings;
QQmlListProperty<void> _currentList;
+ QV4::ExecutionContext *_qmlContext;
};
QT_END_NAMESPACE