diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-03-29 12:44:43 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-04-06 08:36:07 +0000 |
commit | 4517c70f43a6eac7aae0d632320ca127837011f5 (patch) | |
tree | d977d79e1802ec5afa0d2b670cfe19e43e6aaf61 | |
parent | 69d28aa054cb43cbc0f68b2cc18fbedcbca1e0d5 (diff) |
TypeDatabase: Replace QList by QVector
QList will be deprecated in Qt.
Split out a new header typedatabase_typedefs.h with typedefs from
typesystem_typedefs.h.
Change-Id: I15fc1f7edcdc682c32b2e9b935858681e02d35c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | ApiExtractor/apiextractor.h | 1 | ||||
-rw-r--r-- | ApiExtractor/typedatabase.cpp | 24 | ||||
-rw-r--r-- | ApiExtractor/typedatabase.h | 9 | ||||
-rw-r--r-- | ApiExtractor/typedatabase_typedefs.h | 49 | ||||
-rw-r--r-- | ApiExtractor/typesystem_typedefs.h | 10 | ||||
-rw-r--r-- | generator/generator.cpp | 4 | ||||
-rw-r--r-- | generator/generator.h | 5 | ||||
-rw-r--r-- | generator/shiboken2/cppgenerator.cpp | 2 | ||||
-rw-r--r-- | generator/shiboken2/headergenerator.cpp | 6 | ||||
-rw-r--r-- | generator/shiboken2/shibokengenerator.cpp | 6 |
10 files changed, 79 insertions, 37 deletions
diff --git a/ApiExtractor/apiextractor.h b/ApiExtractor/apiextractor.h index 1080ff5..ea46e1b 100644 --- a/ApiExtractor/apiextractor.h +++ b/ApiExtractor/apiextractor.h @@ -33,6 +33,7 @@ #include "dependency.h" #include "abstractmetalang_typedefs.h" #include "apiextractormacros.h" +#include "typedatabase_typedefs.h" #include "typesystem_typedefs.h" #include <QStringList> diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp index 005f93d..d9a741f 100644 --- a/ApiExtractor/typedatabase.cpp +++ b/ApiExtractor/typedatabase.cpp @@ -175,7 +175,7 @@ FunctionTypeEntry* TypeDatabase::findFunctionType(const QString& name) const TypeEntry* TypeDatabase::findType(const QString& name) const { - const QList<TypeEntry *> &entries = findTypes(name); + const TypeEntryList &entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry && (!entry->isPrimitive() || static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType())) { @@ -185,7 +185,7 @@ TypeEntry* TypeDatabase::findType(const QString& name) const return 0; } -QList<TypeEntry *> TypeDatabase::findTypes(const QString &name) const +TypeEntryList TypeDatabase::findTypes(const QString &name) const { return m_entries.value(name); } @@ -201,10 +201,10 @@ SingleTypeEntryHash TypeDatabase::entries() const return returned; } -QList<const PrimitiveTypeEntry*> TypeDatabase::primitiveTypes() const +PrimitiveTypeEntryList TypeDatabase::primitiveTypes() const { TypeEntryHash entries = allEntries(); - QList<const PrimitiveTypeEntry*> returned; + PrimitiveTypeEntryList returned; for (TypeEntryHash::const_iterator it = entries.cbegin(), end = entries.cend(); it != end; ++it) { for (TypeEntry *typeEntry : it.value()) { if (typeEntry->isPrimitive()) @@ -214,10 +214,10 @@ QList<const PrimitiveTypeEntry*> TypeDatabase::primitiveTypes() const return returned; } -QList<const ContainerTypeEntry*> TypeDatabase::containerTypes() const +ContainerTypeEntryList TypeDatabase::containerTypes() const { TypeEntryHash entries = allEntries(); - QList<const ContainerTypeEntry*> returned; + ContainerTypeEntryList returned; for (TypeEntryHash::const_iterator it = entries.cbegin(), end = entries.cend(); it != end; ++it) { for (TypeEntry *typeEntry : it.value()) { if (typeEntry->isContainer()) @@ -435,7 +435,7 @@ bool TypeDatabase::parseFile(QIODevice* device, bool generate) PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const { - const QList<TypeEntry *> &entries = findTypes(name); + const TypeEntryList &entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry && entry->isPrimitive() && static_cast<PrimitiveTypeEntry*>(entry)->preferredTargetLangType()) @@ -447,7 +447,7 @@ PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const { - const QList<TypeEntry *> &entries = findTypes(name); + const TypeEntryList &entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry && entry->isComplex()) return static_cast<ComplexTypeEntry*>(entry); @@ -457,7 +457,7 @@ ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const { - const QList<TypeEntry*> &entries = findTypes(name); + const TypeEntryList &entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry && entry->isObject()) return static_cast<ObjectTypeEntry*>(entry); @@ -467,7 +467,7 @@ ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const NamespaceTypeEntry* TypeDatabase::findNamespaceType(const QString& name) const { - const QList<TypeEntry *> &entries = findTypes(name); + const TypeEntryList &entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry && entry->isNamespace()) return static_cast<NamespaceTypeEntry*>(entry); @@ -513,7 +513,7 @@ static bool compareTypeEntriesByName(const TypeEntry* t1, const TypeEntry* t2) static void _computeTypeIndexes() { TypeDatabase* tdb = TypeDatabase::instance(); - typedef QMap<int, QList<TypeEntry*> > GroupedTypeEntries; + typedef QMap<int, TypeEntryList> GroupedTypeEntries; GroupedTypeEntries groupedEntries; // Group type entries by revision numbers @@ -538,7 +538,7 @@ static void _computeTypeIndexes() GroupedTypeEntries::iterator it = groupedEntries.begin(); for (; it != groupedEntries.end(); ++it) { // Remove duplicates - QList<TypeEntry*>::iterator newEnd = std::unique(it.value().begin(), it.value().end()); + TypeEntryList::iterator newEnd = std::unique(it.value().begin(), it.value().end()); it.value().erase(newEnd, it.value().end()); // Sort the type entries by name qSort(it.value().begin(), newEnd, compareTypeEntriesByName); diff --git a/ApiExtractor/typedatabase.h b/ApiExtractor/typedatabase.h index 4255cf4..870002b 100644 --- a/ApiExtractor/typedatabase.h +++ b/ApiExtractor/typedatabase.h @@ -31,6 +31,7 @@ #include "apiextractormacros.h" #include "include.h" +#include "typedatabase_typedefs.h" #include "typesystem_enums.h" #include "typesystem_typedefs.h" @@ -95,9 +96,9 @@ public: SingleTypeEntryHash entries() const; - QList<const PrimitiveTypeEntry*> primitiveTypes() const; + PrimitiveTypeEntryList primitiveTypes() const; - QList<const ContainerTypeEntry*> containerTypes() const; + ContainerTypeEntryList containerTypes() const; void addRejection(const QString& className, const QString& functionName, const QString& fieldName, const QString& enumName); @@ -150,7 +151,7 @@ public: void formatDebug(QDebug &d) const; #endif private: - QList<TypeEntry *> findTypes(const QString &name) const; + TypeEntryList findTypes(const QString &name) const; QString modifiedTypesystemFilepath(const QString &tsFile) const; bool m_suppressWarnings; @@ -167,7 +168,7 @@ private: QStringList m_typesystemPaths; QHash<QString, bool> m_parsedTypesystemFiles; - QList<TypeRejection> m_rejections; + QVector<TypeRejection> m_rejections; QStringList m_dropTypeEntries; }; diff --git a/ApiExtractor/typedatabase_typedefs.h b/ApiExtractor/typedatabase_typedefs.h new file mode 100644 index 0000000..95859a3 --- /dev/null +++ b/ApiExtractor/typedatabase_typedefs.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of PySide2. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TYPEDATABASE_TYPEDEFS_H +#define TYPEDATABASE_TYPEDEFS_H + +#include <QtCore/QHash> +#include <QtCore/QString> +#include <QtCore/QVector> + +class ContainerTypeEntry; +class PrimitiveTypeEntry; +class TemplateEntry; +class TypeEntry; + +typedef QVector<TypeEntry *> TypeEntryList; +typedef QHash<QString, TypeEntryList> TypeEntryHash; +typedef QHash<QString, TypeEntry *> SingleTypeEntryHash; +typedef QHash<QString, TemplateEntry *> TemplateEntryHash; + +typedef QVector<const ContainerTypeEntry *> ContainerTypeEntryList; +typedef QVector<const PrimitiveTypeEntry *> PrimitiveTypeEntryList; + +#endif // TYPEDATABASE_TYPEDEFS_H diff --git a/ApiExtractor/typesystem_typedefs.h b/ApiExtractor/typesystem_typedefs.h index 4849ee3..4f29dec 100644 --- a/ApiExtractor/typesystem_typedefs.h +++ b/ApiExtractor/typesystem_typedefs.h @@ -34,26 +34,16 @@ #include <QtCore/QVector> class CodeSnip; -class ContainerTypeEntry; class DocModification; -class PrimitiveTypeEntry; -class TemplateEntry; -class TypeEntry; struct AddedFunction; struct FieldModification; struct FunctionModification; -typedef QHash<QString, QList<TypeEntry *> > TypeEntryHash; -typedef QHash<QString, TypeEntry *> SingleTypeEntryHash; -typedef QHash<QString, TemplateEntry *> TemplateEntryHash; - typedef QVector<AddedFunction> AddedFunctionList; typedef QVector<CodeSnip> CodeSnipList; -typedef QList<const ContainerTypeEntry *> ContainerTypeEntryList; typedef QVector<DocModification> DocModificationList; typedef QVector<FieldModification> FieldModificationList; typedef QVector<FunctionModification> FunctionModificationList; -typedef QList<const PrimitiveTypeEntry *> PrimitiveTypeEntryList; #endif // TYPESYSTEM_TYPEDEFS_H diff --git a/generator/generator.cpp b/generator/generator.cpp index 61c1ede..b1cf5cf 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -223,12 +223,12 @@ AbstractMetaEnumList Generator::globalEnums() const return m_d->apiextractor->globalEnums(); } -QList<const PrimitiveTypeEntry*> Generator::primitiveTypes() const +PrimitiveTypeEntryList Generator::primitiveTypes() const { return m_d->apiextractor->primitiveTypes(); } -QList<const ContainerTypeEntry*> Generator::containerTypes() const +ContainerTypeEntryList Generator::containerTypes() const { return m_d->apiextractor->containerTypes(); } diff --git a/generator/generator.h b/generator/generator.h index 386b9d5..c48f008 100644 --- a/generator/generator.h +++ b/generator/generator.h @@ -30,6 +30,7 @@ #define GENERATOR_H #include <abstractmetalang_typedefs.h> +#include <typedatabase_typedefs.h> #include <dependency.h> #include <QtCore/QObject> #include <QtCore/QSharedPointer> @@ -168,10 +169,10 @@ public: AbstractMetaEnumList globalEnums() const; /// Returns all primitive types found by APIExtractor - QList<const PrimitiveTypeEntry*> primitiveTypes() const; + PrimitiveTypeEntryList primitiveTypes() const; /// Returns all container types found by APIExtractor - QList<const ContainerTypeEntry*> containerTypes() const; + ContainerTypeEntryList containerTypes() const; /// Returns an AbstractMetaEnum for a given EnumTypeEntry, or NULL if not found. const AbstractMetaEnum* findAbstractMetaEnum(const EnumTypeEntry* typeEntry) const; diff --git a/generator/shiboken2/cppgenerator.cpp b/generator/shiboken2/cppgenerator.cpp index 76b80ba..aeee881 100644 --- a/generator/shiboken2/cppgenerator.cpp +++ b/generator/shiboken2/cppgenerator.cpp @@ -5428,7 +5428,7 @@ bool CppGenerator::finishGeneration() writeEnumsInitialization(s, globalEnums); s << INDENT << "// Register primitive types converters." << endl; - const QList<const PrimitiveTypeEntry *> &primitiveTypeList = primitiveTypes(); + const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *pte : primitiveTypeList) { if (!pte->generateCode() || !pte->isCppPrimitive()) continue; diff --git a/generator/shiboken2/headergenerator.cpp b/generator/shiboken2/headergenerator.cpp index 2742f31..9f33a45 100644 --- a/generator/shiboken2/headergenerator.cpp +++ b/generator/shiboken2/headergenerator.cpp @@ -354,7 +354,7 @@ bool HeaderGenerator::finishGeneration() // TODO-CONVERTER ------------------------------------------------------------------------------ // Using a counter would not do, a fix must be made to APIExtractor's getTypeIndex(). macrosStream << "// Converter indices" << endl; - const QList<const PrimitiveTypeEntry *> &primitives = primitiveTypes(); + const PrimitiveTypeEntryList &primitives = primitiveTypes(); int pCount = 0; for (const PrimitiveTypeEntry *ptype : primitives) { /* Note: do not generate indices for typedef'd primitive types @@ -466,7 +466,7 @@ bool HeaderGenerator::finishGeneration() if (!primitiveTypes().isEmpty()) { s << "// Conversion Includes - Primitive Types" << endl; - const QList<const PrimitiveTypeEntry*> &primitiveTypeList = primitiveTypes(); + const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *ptype : primitiveTypeList) s << ptype->include(); s << endl; @@ -474,7 +474,7 @@ bool HeaderGenerator::finishGeneration() if (!containerTypes().isEmpty()) { s << "// Conversion Includes - Container Types" << endl; - const QList<const ContainerTypeEntry *> &containerTypeList = containerTypes(); + const ContainerTypeEntryList &containerTypeList = containerTypes(); for (const ContainerTypeEntry *ctype : containerTypeList) s << ctype->include(); s << endl; diff --git a/generator/shiboken2/shibokengenerator.cpp b/generator/shiboken2/shibokengenerator.cpp index 54f4990..b601e14 100644 --- a/generator/shiboken2/shibokengenerator.cpp +++ b/generator/shiboken2/shibokengenerator.cpp @@ -1497,7 +1497,7 @@ ShibokenGenerator::ExtendedConverterData ShibokenGenerator::getExtendedConverter QList<const CustomConversion*> ShibokenGenerator::getPrimitiveCustomConversions() { QList<const CustomConversion*> conversions; - const QList<const PrimitiveTypeEntry *> &primitiveTypeList = primitiveTypes(); + const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *type : primitiveTypeList) { if (!shouldGenerateTypeEntry(type) || !isUserPrimitive(type) || !type->customConversion()) continue; @@ -2456,10 +2456,10 @@ bool ShibokenGenerator::doSetup(const QMap<QString, QString>& args) TypeDatabase* td = TypeDatabase::instance(); QStringList snips; - const QList<const PrimitiveTypeEntry *> &primitiveTypeList = primitiveTypes(); + const PrimitiveTypeEntryList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *type : primitiveTypeList) getCode(snips, type); - const QList<const ContainerTypeEntry *> &containerTypeList = containerTypes(); + const ContainerTypeEntryList &containerTypeList = containerTypes(); for (const ContainerTypeEntry *type : containerTypeList) getCode(snips, type); const AbstractMetaClassList &classList = classes(); |