diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-04-01 17:08:13 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-04-06 11:06:30 +0200 |
commit | 3597e83592eaac72003e16eea234866abc5102cf (patch) | |
tree | 5af04c6c423a9a4b6f9da0592d6b0c62577831a8 /src/qmltyperegistrar | |
parent | 1a2ab822fa24733f83d6720d2af8498ecbd5cbda (diff) |
qmltyperegistrar: Follow the private includes setting in qmltypes
If the file names need to be prepended with "private/" in order to be
usable, that also holds for other tools that want to use them.
Therefore, also add the prefix to the qmltypes files. We won't have a
chance to figure this out again at a later point.
Furthermore, don't add file entries for types we cannot register anyway.
Change-Id: If04297db419e364f472b8ec627c599c0cbb4ffd9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmltyperegistrar')
-rw-r--r-- | src/qmltyperegistrar/qmltyperegistrar.cpp | 18 | ||||
-rw-r--r-- | src/qmltyperegistrar/qmltypesclassdescription.cpp | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp index 9f5553b880..c3ab61e621 100644 --- a/src/qmltyperegistrar/qmltyperegistrar.cpp +++ b/src/qmltyperegistrar/qmltyperegistrar.cpp @@ -298,8 +298,15 @@ int main(int argc, char **argv) } } + const bool privateIncludes = parser.isSet(privateIncludesOption); + auto resolvedInclude = [&](const QString &include) { + return (privateIncludes && include.endsWith(QLatin1String("_p.h"))) + ? QLatin1String("private/") + include + : include; + }; + auto processMetaObject = [&](const QJsonObject &metaObject) { - const QString include = metaObject[QLatin1String("inputFile")].toString(); + const QString include = resolvedInclude(metaObject[QLatin1String("inputFile")].toString()); const QJsonArray classes = metaObject[QLatin1String("classes")].toArray(); for (const auto &cls : classes) { QJsonObject classDef = cls.toObject(); @@ -367,13 +374,8 @@ int main(int argc, char **argv) const auto newEnd = std::unique(includes.begin(), includes.end()); includes.erase(newEnd, includes.end()); - const bool privateIncludes = parser.isSet(privateIncludesOption); - for (const QString &include : qAsConst(includes)) { - if (privateIncludes && include.endsWith(QLatin1String("_p.h"))) - fprintf(output, "\n#include <private/%s>", qPrintable(include)); - else - fprintf(output, "\n#include <%s>", qPrintable(include)); - } + for (const QString &include : qAsConst(includes)) + fprintf(output, "\n#include <%s>", qPrintable(include)); fprintf(output, "\n\n"); diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp index c63879f4d6..7756fda9e4 100644 --- a/src/qmltyperegistrar/qmltypesclassdescription.cpp +++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp @@ -62,7 +62,7 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, const QVector<QJsonObject> &foreign, CollectMode mode) { - if (file.isEmpty()) + if (file.isEmpty() && classDef->value(QLatin1String("registerable")).toBool()) file = classDef->value(QLatin1String("inputFile")).toString(); const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray(); for (const QJsonValue &classInfo : classInfos) { |