diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-21 09:29:58 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-21 09:31:01 +0200 |
commit | 41f75250d5b391dd99a84712fa68f606ef5c06b9 (patch) | |
tree | 4911506e0d88ba2741861b0baf107270018ef17d | |
parent | 200a869441562d62e7fc0867599097e0599f0411 (diff) | |
parent | 642b2ce0e155df452821a84726a2b0226cb65f70 (diff) |
Merge branch 'wip/v4' of qtdeclarative into dev
Pull in the remaining bits of the new compiler/vme branch.
Change-Id: I4706011c5eaf35f893d0733c4e130a31ce0ebb66
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 5 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 32 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 11 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 1 |
6 files changed, 41 insertions, 17 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index 804604affc..6e4b5fa8c9 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -1273,6 +1273,11 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio const QString &signalName = stringAt(signal->nameIndex); customSignals.insert(signalName, signal->parameterStringList(parsedQML->jsGenerator.strings)); } + + for (QmlProperty *property = obj->properties->first; property; property = property->next) { + const QString propName = stringAt(property->nameIndex); + customSignals.insert(propName, QStringList()); + } } QHash<QString, QStringList>::ConstIterator entry = customSignals.find(propertyName); diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index a4da5ce116..bf2cb8e5c5 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -805,7 +805,7 @@ void Codegen::variableDeclaration(VariableDeclaration *ast) assert(expr.code); initializer = *expr; - if (! _env->parent || _function->insideWithOrCatch) { + if (! _env->parent || _function->insideWithOrCatch || _mode == QmlBinding) { // it's global code. move(_block->NAME(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), initializer); } else { @@ -1356,6 +1356,9 @@ V4IR::Expr *Codegen::identifier(const QString &name, int line, int col) Environment *e = _env; V4IR::Function *f = _function; + if (_mode == QmlBinding) + return _block->NAME(name, line, col); + while (f && e->parent) { if (f->insideWithOrCatch || (f->isNamedExpression && f->name == name)) return _block->NAME(name, line, col); diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 3c8a50ad4f..5ed75a1e06 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -896,10 +896,6 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) enginePriv->referenceScarceResources(); QObject *rv = 0; if (enginePriv->useNewCompiler) { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); - if (cc->compilationUnit && !cc->compilationUnit->engine) - cc->compilationUnit->linkToEngine(v4); - state.creator = new QmlObjectCreator(context, cc); rv = state.creator->create(start); if (!rv) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index b4201fd10a..fe7995ea59 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -486,6 +486,10 @@ QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledD , _vmeMetaObject(0) , _qmlContext(0) { + QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); + if (compiledData->compilationUnit && !compiledData->compilationUnit->engine) + compiledData->compilationUnit->linkToEngine(v4); + } QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent) @@ -938,16 +942,26 @@ void QmlObjectCreator::setupBindings() qSwap(_currentList, savedList); QQmlPropertyData *property = 0; + bool defaultPropertyQueried = false; + QQmlPropertyData *defaultProperty = 0; const QV4::CompiledData::Binding *binding = _compiledObject->bindingTable(); for (quint32 i = 0; i < _compiledObject->nBindings; ++i, ++binding) { + QString name = stringAt(binding->propertyNameIndex); + if (name.isEmpty()) + property = 0; + if (!property || (i > 0 && (binding - 1)->propertyNameIndex != binding->propertyNameIndex)) { - QString name = stringAt(binding->propertyNameIndex); if (!name.isEmpty()) property = _propertyCache->property(name, _qobject, context); - else - property = 0; + else { + if (!defaultPropertyQueried) { + defaultProperty = _propertyCache->defaultProperty(); + defaultPropertyQueried = true; + } + property = defaultProperty; + } if (property && property->isQList()) { void *argv[1] = { (void*)&_currentList }; @@ -1155,10 +1169,18 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent) QQmlType *type = typeRef.type; if (type) { instance = type->create(); + if (!instance) { + recordError(obj->location, tr("Unable to create object of type %1").arg(stringAt(obj->inheritedTypeNameIndex))); + return 0; + } } else { Q_ASSERT(typeRef.component); QmlObjectCreator subCreator(context, typeRef.component); instance = subCreator.create(); + if (!instance) { + errors += subCreator.errors; + return 0; + } } // ### use no-event variant if (parent) @@ -1289,6 +1311,8 @@ bool QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi setupBindings(); setupFunctions(); + allCreatedBindings.append(_createdBindings); + qSwap(_qmlContext, qmlContext); qSwap(_createdBindings, createdBindings); @@ -1298,8 +1322,6 @@ bool QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi qSwap(_compiledObject, obj); qSwap(_qobject, instance); - allCreatedBindings.append(_createdBindings); - return errors.isEmpty(); } diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 842eb53a3b..1bd3ba25d5 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2182,9 +2182,8 @@ void QQmlTypeData::dataReceived(const Data &data) QList<QQmlError> errors; // ### convert to use new data structure once old compiler is gone. - QList<QQmlScript::Import> imports; - if (m_useNewCompiler) { - imports.reserve(parsedQML->imports.size()); + if (m_useNewCompiler && m_newImports.isEmpty()) { + m_newImports.reserve(parsedQML->imports.size()); foreach (QV4::CompiledData::Import *i, parsedQML->imports) { QQmlScript::Import import; import.uri = parsedQML->stringAt(i->uriIndex); @@ -2202,13 +2201,11 @@ void QQmlTypeData::dataReceived(const Data &data) } - imports << import; + m_newImports << import; } - } else { - imports = scriptParser.imports(); } - foreach (const QQmlScript::Import &import, imports) { + foreach (const QQmlScript::Import &import, m_useNewCompiler ? m_newImports : scriptParser.imports()) { if (!addImport(import, &errors)) { Q_ASSERT(errors.size()); QQmlError error(errors.takeFirst()); diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index a2d07bbe2f..be1ffba09e 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -459,6 +459,7 @@ private: QQmlScript::Parser scriptParser; // --- new compiler QScopedPointer<QtQml::ParsedQML> parsedQML; + QList<QQmlScript::Import> m_newImports; // --- QList<ScriptReference> m_scripts; |