From 8a71e2bd031230777dcfbb482af40a03b8d91507 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 4 Jun 2014 17:32:31 +0200 Subject: [PATCH] Cleanup: Get rid of the url and file name members in QQmlCompiledData This is part of the effor of moving members from QQmlCompiledData into QV4::CompilationUnit in order to eliminate the former in the long run. Change-Id: Icce7fe0ee9a49cb3a7677fd7020008fc55ecdcf6 Reviewed-by: Lars Knoll --- src/qml/compiler/qqmlirbuilder.cpp | 5 ++--- src/qml/compiler/qqmlirbuilder_p.h | 3 +-- src/qml/compiler/qqmltypecompiler.cpp | 2 +- src/qml/compiler/qqmltypecompiler_p.h | 2 +- src/qml/qml/qqmlbinding.cpp | 2 +- src/qml/qml/qqmlcompiler_p.h | 4 ++-- src/qml/qml/qqmlcomponent.cpp | 2 +- src/qml/qml/qqmlexpression.cpp | 2 +- src/qml/qml/qqmlincubator.cpp | 4 ++-- src/qml/qml/qqmlobjectcreator.cpp | 12 ++++++------ src/qml/qml/qqmltypeloader.cpp | 6 ++---- 11 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 28a4e23..f02e92c 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -558,9 +558,8 @@ IRBuilder::IRBuilder(const QSet &illegalNames) { } -bool IRBuilder::generateFromQml(const QString &code, const QString &url, const QString &urlString, Document *output) +bool IRBuilder::generateFromQml(const QString &code, const QString &url, Document *output) { - this->url = url; QQmlJS::AST::UiProgram *program = 0; { QQmlJS::Lexer lexer(&output->jsParserEngine); @@ -574,7 +573,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, const Q foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) { if (m.isWarning()) { - qWarning("%s:%d : %s", qPrintable(urlString), m.loc.startLine, qPrintable(m.message)); + qWarning("%s:%d : %s", qPrintable(url), m.loc.startLine, qPrintable(m.message)); continue; } diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 3438af4..1aac878 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -343,7 +343,7 @@ struct Q_QML_PRIVATE_EXPORT IRBuilder : public QQmlJS::AST::Visitor Q_DECLARE_TR_FUNCTIONS(QQmlCodeGenerator) public: IRBuilder(const QSet &illegalNames); - bool generateFromQml(const QString &code, const QString &url, const QString &urlString, Document *output); + bool generateFromQml(const QString &code, const QString &url, Document *output); static bool isSignalPropertyName(const QString &name); @@ -420,7 +420,6 @@ public: QQmlJS::MemoryPool *pool; QString sourceCode; - QString url; QV4::Compiler::JSUnitGenerator *jsGenerator; }; diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 3aad050..e1f68a6 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -298,7 +298,7 @@ bool QQmlTypeCompiler::compile() void QQmlTypeCompiler::recordError(const QQmlError &error) { QQmlError e = error; - e.setUrl(compiledData->url); + e.setUrl(url()); errors << e; } diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h index 3f311d8..caf1f93 100644 --- a/src/qml/compiler/qqmltypecompiler_p.h +++ b/src/qml/compiler/qqmltypecompiler_p.h @@ -84,7 +84,7 @@ public: const QV4::CompiledData::QmlUnit *qmlUnit() const; - QUrl url() const { return compiledData->url; } + QUrl url() const { return typeData->finalUrl(); } QQmlEnginePrivate *enginePrivate() const { return engine; } const QQmlImports *imports() const; QHash *resolvedTypes(); diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 074f568..68037c5 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -106,7 +106,7 @@ QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlConte Q_ASSERT(typeData); if (QQmlCompiledData *cdata = typeData->compiledData()) { - url = cdata->name; + url = cdata->fileName(); if (scriptPrivate->bindingId != QQmlBinding::Invalid) runtimeFunction = cdata->compilationUnit->runtimeFunctions.at(scriptPrivate->bindingId); } diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index 9f0f800..129d312 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -91,8 +91,8 @@ public: QQmlEngine *engine; - QString name; - QUrl url; + QString fileName() const { return compilationUnit->fileName(); } + QUrl url() const { return QUrl(fileName()); } QQmlTypeNameCache *importCache; int metaTypeId; diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 39a7d89..c247c7f 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -592,7 +592,7 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, QQmlCompiledData *cc, int start d->cc = cc; cc->addref(); d->start = start; - d->url = cc->url; + d->url = cc->url(); d->progress = 1.0; } diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index 4dc3704..e993ed9 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -161,7 +161,7 @@ QQmlExpression::QQmlExpression(const QQmlScriptString &script, QQmlContext *ctxt Q_ASSERT(typeData); if (QQmlCompiledData *cdata = typeData->compiledData()) { - d->url = cdata->name; + d->url = cdata->fileName(); d->line = scriptPrivate->lineNumber; d->column = scriptPrivate->columnNumber; diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 4cdeb19..0665a4a 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -283,7 +283,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) if (!compiledData) return; - QML_MEMORY_SCOPE_URL(compiledData->url); + QML_MEMORY_SCOPE_URL(compiledData->url()); QExplicitlySharedDataPointer protectThis(this); @@ -297,7 +297,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) if (!guardOk) { QQmlError error; - error.setUrl(compiledData->url); + error.setUrl(compiledData->url()); error.setDescription(QQmlComponent::tr("Object destroyed during incubation")); errors << error; progress = QQmlIncubatorPrivate::Completed; diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 65e302d..5eaea7d 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -179,8 +179,8 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI context = new QQmlContextData; context->isInternal = true; - context->url = compiledData->url; - context->urlString = compiledData->name; + context->url = compiledData->url(); + context->urlString = compiledData->fileName(); context->imports = compiledData->importCache; context->imports->addref(); context->setParent(parentContext); @@ -384,7 +384,7 @@ void QQmlObjectCreator::setPropertyValue(QQmlPropertyData *property, const QV4:: QString string = binding->valueAsString(&qmlUnit->header); // Encoded dir-separators defeat QUrl processing - decode them first string.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive); - QUrl value = string.isEmpty() ? QUrl() : compiledData->url.resolved(QUrl(string)); + QUrl value = string.isEmpty() ? QUrl() : compiledData->url().resolved(QUrl(string)); // Apply URL interceptor if (engine->urlInterceptor()) value = engine->urlInterceptor()->intercept(value, QQmlAbstractUrlInterceptor::UrlString); @@ -579,7 +579,7 @@ void QQmlObjectCreator::setPropertyValue(QQmlPropertyData *property, const QV4:: } else if (property->propType == qMetaTypeId >()) { Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String); QString urlString = binding->valueAsString(&qmlUnit->header); - QUrl u = urlString.isEmpty() ? QUrl() : compiledData->url.resolved(QUrl(urlString)); + QUrl u = urlString.isEmpty() ? QUrl() : compiledData->url().resolved(QUrl(urlString)); QList value; value.append(u); argv[0] = reinterpret_cast(&value); @@ -1006,7 +1006,7 @@ void QQmlObjectCreator::setupFunctions() void QQmlObjectCreator::recordError(const QV4::CompiledData::Location &location, const QString &description) { QQmlError error; - error.setUrl(compiledData->url); + error.setUrl(compiledData->url()); error.setLine(location.line); error.setColumn(location.column); error.setDescription(description); @@ -1063,7 +1063,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo sharedState->allCreatedObjects.push(instance); } else { Q_ASSERT(typeRef->component); - Q_QML_OC_PROFILE(sharedState->profiler, profiler.update(typeRef->component->name, + Q_QML_OC_PROFILE(sharedState->profiler, profiler.update(typeRef->component->fileName(), context->url, obj->location.line, obj->location.column)); if (typeRef->component->qmlUnit->isSingleton()) { diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 7fc08bd..1afc5bb 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2207,7 +2207,7 @@ void QQmlTypeData::dataReceived(const Data &data) QQmlEngine *qmlEngine = typeLoader()->engine(); m_document.reset(new QmlIR::Document(QV8Engine::getV4(qmlEngine)->debugger != 0)); QmlIR::IRBuilder compiler(QV8Engine::get(qmlEngine)->illegalNames()); - if (!compiler.generateFromQml(code, finalUrlString(), finalUrlString(), m_document.data())) { + if (!compiler.generateFromQml(code, finalUrlString(), m_document.data())) { QList errors; foreach (const QQmlJS::DiagnosticMessage &msg, compiler.errors) { QQmlError e; @@ -2332,10 +2332,8 @@ void QQmlTypeData::compile() Q_ASSERT(m_compiledData == 0); m_compiledData = new QQmlCompiledData(typeLoader()->engine()); - m_compiledData->url = finalUrl(); - m_compiledData->name = finalUrlString(); - QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler, m_compiledData->name); + QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler, finalUrlString()); QQmlTypeCompiler compiler(QQmlEnginePrivate::get(typeLoader()->engine()), m_compiledData, this, m_document.data()); if (!compiler.compile()) { -- 2.7.4