diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-05-29 10:45:37 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 10:44:05 +0200 |
commit | 7be4e64b4bac6e6b5a90eec74b9f2b661c60db3a (patch) | |
tree | 41d2f586576787ffa71e567398391f7ab504ae89 | |
parent | e5595a4b3010b1bb4b6f80a0339271a7b26934de (diff) |
shiboken: Replace 'typedef' by 'using'
Apply Fixits by Qt Creator with some amendments.
Remove iterator types by using auto instead.
Change-Id: I8a75323da6ae5cdcc6b67af8be9376408953986b
Reviewed-by: Christian Tismer <tismer@stackless.com>
43 files changed, 133 insertions, 145 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 90664ef32..d996d35dd 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -3198,13 +3198,12 @@ template <class Container> static void debugFormatSequence(QDebug &d, const char *key, const Container& c, const char *separator = ", ") { - typedef typename Container::const_iterator ConstIt; if (c.isEmpty()) return; - const ConstIt begin = c.begin(); - const ConstIt end = c.end(); + const auto begin = c.begin(); + const auto end = c.end(); d << "\n " << key << '[' << c.size() << "]=("; - for (ConstIt it = begin; it != end; ++it) { + for (auto it = begin; it != end; ++it) { if (it != begin) d << separator; d << *it; diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h index 82488ccba..453ab7c27 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h @@ -173,7 +173,7 @@ public: AbstractMetaFunctionList m_globalFunctions; AbstractMetaEnumList m_globalEnums; - typedef QMap<QString, AbstractMetaBuilder::RejectReason> RejectMap; + using RejectMap = QMap<QString, AbstractMetaBuilder::RejectReason>; RejectMap m_rejectedClasses; RejectMap m_rejectedEnums; diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index acf01cce5..8aebbc5e2 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -1732,7 +1732,7 @@ QPropertySpec *AbstractMetaClass::propertySpecForReset(const QString &name) cons return nullptr; } -typedef QHash<const AbstractMetaClass *, AbstractMetaTypeList> AbstractMetaClassBaseTemplateInstantiationsMap; +using AbstractMetaClassBaseTemplateInstantiationsMap = QHash<const AbstractMetaClass *, AbstractMetaTypeList>; Q_GLOBAL_STATIC(AbstractMetaClassBaseTemplateInstantiationsMap, metaClassBaseTemplateInstantiations); bool AbstractMetaClass::hasTemplateBaseClassInstantiations() const diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index 6480257c7..779da7d2d 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -292,7 +292,7 @@ class AbstractMetaType { Q_GADGET public: - typedef QVector<Indirection> Indirections; + using Indirections = QVector<Indirection>; enum TypeUsagePattern { InvalidPattern, diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h b/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h index 9ff11d44e..617ebcf4f 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang_typedefs.h @@ -39,13 +39,13 @@ class AbstractMetaEnumValue; class AbstractMetaFunction; class AbstractMetaType; -typedef QVector<AbstractMetaArgument *> AbstractMetaArgumentList; -typedef QVector<AbstractMetaClass *> AbstractMetaClassList; -typedef QVector<AbstractMetaEnum *> AbstractMetaEnumList; -typedef QVector<AbstractMetaEnumValue *> AbstractMetaEnumValueList; -typedef QVector<AbstractMetaField *> AbstractMetaFieldList; -typedef QVector<AbstractMetaFunction *> AbstractMetaFunctionList; -typedef QVector<AbstractMetaType *> AbstractMetaTypeList; -typedef QVector<const AbstractMetaType *> AbstractMetaTypeCList; +using AbstractMetaArgumentList = QVector<AbstractMetaArgument *>; +using AbstractMetaClassList = QVector<AbstractMetaClass *>; +using AbstractMetaEnumList = QVector<AbstractMetaEnum *>; +using AbstractMetaEnumValueList = QVector<AbstractMetaEnumValue *>; +using AbstractMetaFieldList = QVector<AbstractMetaField *>; +using AbstractMetaFunctionList = QVector<AbstractMetaFunction *>; +using AbstractMetaTypeList = QVector<AbstractMetaType *>; +using AbstractMetaTypeCList = QVector<const AbstractMetaType *>; #endif // ABSTRACTMETALANG_TYPEDEFS_H diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp index bd3ea9f18..881fdebb2 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp @@ -256,13 +256,11 @@ void ApiExtractor::setLanguageLevel(const LanguageLevel languageLevel) template <class Container> static void debugFormatSequence(QDebug &d, const char *key, const Container& c) { - typedef typename Container::const_iterator ConstIt; if (c.isEmpty()) return; - const ConstIt begin = c.begin(); - const ConstIt end = c.end(); + const auto begin = c.begin(); d << "\n " << key << '[' << c.size() << "]=("; - for (ConstIt it = begin; it != end; ++it) { + for (auto it = begin, end = c.end(); it != end; ++it) { if (it != begin) d << ", "; d << *it; diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 3ced0e06c..8d1b4debf 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -144,9 +144,9 @@ static bool isSigned(CXTypeKind kind) class BuilderPrivate { public: - typedef QHash<CXCursor, ClassModelItem> CursorClassHash; - typedef QHash<CXCursor, TypeDefModelItem> CursorTypedefHash; - typedef QHash<CXType, TypeInfo> TypeInfoHash; + using CursorClassHash = QHash<CXCursor, ClassModelItem>; + using CursorTypedefHash = QHash<CXCursor, TypeDefModelItem>; + using TypeInfoHash = QHash<CXType, TypeInfo>; explicit BuilderPrivate(BaseVisitor *bv) : m_baseVisitor(bv), m_model(new CodeModel) { @@ -645,11 +645,9 @@ static inline CXCursor definitionFromTypeRef(const CXCursor &typeRefCursor) template <class Item> // ArgumentModelItem, VariableModelItem void BuilderPrivate::qualifyTypeDef(const CXCursor &typeRefCursor, const QSharedPointer<Item> &item) const { - typedef typename CursorTypedefHash::const_iterator ConstIt; - TypeInfo type = item->type(); if (type.qualifiedName().size() == 1) { // item's type is unqualified. - const ConstIt it = m_cursorTypedefHash.constFind(definitionFromTypeRef(typeRefCursor)); + const auto it = m_cursorTypedefHash.constFind(definitionFromTypeRef(typeRefCursor)); if (it != m_cursorTypedefHash.constEnd() && !it.value()->scope().isEmpty()) { type.setQualifiedName(it.value()->scope() + type.qualifiedName()); item->setType(type); diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.h b/sources/shiboken2/ApiExtractor/clangparser/clangparser.h index 36b9e0bd1..4248be853 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.h +++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.h @@ -43,12 +43,12 @@ struct Diagnostic; class SourceFileCache { public: - typedef QPair<const char *, const char *> Snippet; + using Snippet = QPair<const char *, const char *>; Snippet getCodeSnippet(const CXCursor &cursor); private: - typedef QHash<QString, QByteArray> FileBufferCache; + using FileBufferCache = QHash<QString, QByteArray>; FileBufferCache m_fileBufferCache; }; @@ -56,8 +56,8 @@ private: class BaseVisitor { Q_DISABLE_COPY(BaseVisitor) public: - typedef QVector<Diagnostic> Diagnostics; - typedef SourceFileCache::Snippet CodeSnippet; + using Diagnostics = QVector<Diagnostic>; + using CodeSnippet = SourceFileCache::Snippet; enum StartTokenResult { Error, Skip, Recurse }; diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h index 2546d5998..738b51bb4 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h +++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h @@ -73,7 +73,7 @@ struct SourceLocation SourceLocation getExpansionLocation(const CXSourceLocation &location); -typedef QPair<SourceLocation, SourceLocation> SourceRange; +using SourceRange =QPair<SourceLocation, SourceLocation>; SourceLocation getCursorLocation(const CXCursor &cursor); CXString getFileNameFromLocation(const CXSourceLocation &location); @@ -100,7 +100,7 @@ CXDiagnosticSeverity maxSeverity(const QVector<Diagnostic> &ds); // Parse a template argument list "a<b<c,d>,e>" and invoke a handler // with each match (level and string). Return begin and end of the list. -typedef std::function<void(int /*level*/, const QStringRef &)> TemplateArgumentHandler; +using TemplateArgumentHandler = std::function<void (int, const QStringRef &)>; QPair<int, int> parseTemplateArgumentList(const QString &l, const TemplateArgumentHandler &handler, diff --git a/sources/shiboken2/ApiExtractor/dependency.h b/sources/shiboken2/ApiExtractor/dependency.h index d563e9094..7168ea3bc 100644 --- a/sources/shiboken2/ApiExtractor/dependency.h +++ b/sources/shiboken2/ApiExtractor/dependency.h @@ -42,6 +42,6 @@ struct Dependency { AbstractMetaClass *child; }; -typedef QVector<Dependency> Dependencies; +using Dependencies = QVector<Dependency>; #endif // DEPENDENCY_H diff --git a/sources/shiboken2/ApiExtractor/graph.cpp b/sources/shiboken2/ApiExtractor/graph.cpp index c2ac81e6c..95a80197e 100644 --- a/sources/shiboken2/ApiExtractor/graph.cpp +++ b/sources/shiboken2/ApiExtractor/graph.cpp @@ -38,8 +38,7 @@ struct Graph::GraphPrivate { enum Color { WHITE, GRAY, BLACK }; - typedef QVector<QSet<int> > Edges; - typedef QSet<int>::const_iterator EdgeIterator; + using Edges = QVector<QSet<int> >; Edges edges; @@ -50,11 +49,10 @@ struct Graph::GraphPrivate void dfsVisit(int node, Graph::Indexes &result, QVector<Color> &colors) const { colors[node] = GRAY; - EdgeIterator it = edges[node].begin(); - for (; it != edges[node].end(); ++it) { - if (colors[*it] == WHITE) - dfsVisit(*it, result, colors); - else if (colors[*it] == GRAY) // This is not a DAG! + for (const auto &c : edges.at(node)) { + if (colors[c] == WHITE) + dfsVisit(c, result, colors); + else if (colors[c] == GRAY) // This is not a DAG! return; } colors[node] = BLACK; diff --git a/sources/shiboken2/ApiExtractor/header_paths.h b/sources/shiboken2/ApiExtractor/header_paths.h index 01d830921..0c25702ef 100644 --- a/sources/shiboken2/ApiExtractor/header_paths.h +++ b/sources/shiboken2/ApiExtractor/header_paths.h @@ -67,6 +67,6 @@ public: } }; -typedef QList<HeaderPath> HeaderPaths; +using HeaderPaths = QList<HeaderPath>; #endif // HEADER_PATHS_H diff --git a/sources/shiboken2/ApiExtractor/include.h b/sources/shiboken2/ApiExtractor/include.h index c312dd6cc..f7dfea5a7 100644 --- a/sources/shiboken2/ApiExtractor/include.h +++ b/sources/shiboken2/ApiExtractor/include.h @@ -88,6 +88,6 @@ QTextStream& operator<<(QTextStream& out, const Include& include); QDebug operator<<(QDebug d, const Include &i); #endif -typedef QVector<Include> IncludeList; +using IncludeList = QVector<Include>; #endif diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index b022f0c60..f8408e859 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -53,9 +53,8 @@ private: template <class T> static QSharedPointer<T> findModelItem(const QVector<QSharedPointer<T> > &list, const QString &name) { - typedef typename QVector<QSharedPointer<T> >::const_iterator It; - const It it = std::find_if(list.begin(), list.end(), ModelItemNamePredicate<T>(name)); - return it != list.end() ? *it : QSharedPointer<T>(); + const auto it = std::find_if(list.cbegin(), list.cend(), ModelItemNamePredicate<T>(name)); + return it != list.cend() ? *it : QSharedPointer<T>(); } // --------------------------------------------------------------------------- @@ -800,12 +799,10 @@ static void formatScopeHash(QDebug &d, const char *prefix, const Hash &h, const char *separator = ", ", bool trailingNewLine = false) { - typedef typename Hash::ConstIterator HashIterator; if (!h.isEmpty()) { d << prefix << '[' << h.size() << "]("; - const HashIterator begin = h.begin(); - const HashIterator end = h.end(); - for (HashIterator it = begin; it != end; ++it) { // Omit the names as they are repeated + const auto begin = h.cbegin(); + for (auto it = begin, end = h.cend(); it != end; ++it) { // Omit the names as they are repeated if (it != begin) d << separator; d << it.value().data(); diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.h b/sources/shiboken2/ApiExtractor/parser/codemodel.h index 6f3c17613..03d43d614 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.h @@ -101,7 +101,7 @@ class TypeInfo { friend class TypeParser; public: - typedef QVector<Indirection> Indirections; + using Indirections = QVector<Indirection>; TypeInfo() : flags(0), m_referenceType(NoReference) {} diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h b/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h index f67c64221..54dbe78dc 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h +++ b/sources/shiboken2/ApiExtractor/parser/codemodel_fwd.h @@ -51,32 +51,32 @@ class _VariableModelItem; class _MemberModelItem; class TypeInfo; -typedef QSharedPointer<_ArgumentModelItem> ArgumentModelItem; -typedef QSharedPointer<_ClassModelItem> ClassModelItem; -typedef QSharedPointer<_CodeModelItem> CodeModelItem; -typedef QSharedPointer<_EnumModelItem> EnumModelItem; -typedef QSharedPointer<_EnumeratorModelItem> EnumeratorModelItem; -typedef QSharedPointer<_FileModelItem> FileModelItem; -typedef QSharedPointer<_FunctionModelItem> FunctionModelItem; -typedef QSharedPointer<_NamespaceModelItem> NamespaceModelItem; -typedef QSharedPointer<_ScopeModelItem> ScopeModelItem; -typedef QSharedPointer<_TemplateParameterModelItem> TemplateParameterModelItem; -typedef QSharedPointer<_TypeDefModelItem> TypeDefModelItem; -typedef QSharedPointer<_VariableModelItem> VariableModelItem; -typedef QSharedPointer<_MemberModelItem> MemberModelItem; +using ArgumentModelItem = QSharedPointer<_ArgumentModelItem>; +using ClassModelItem = QSharedPointer<_ClassModelItem>; +using CodeModelItem = QSharedPointer<_CodeModelItem>; +using EnumModelItem = QSharedPointer<_EnumModelItem>; +using EnumeratorModelItem = QSharedPointer<_EnumeratorModelItem>; +using FileModelItem = QSharedPointer<_FileModelItem>; +using FunctionModelItem = QSharedPointer<_FunctionModelItem>; +using NamespaceModelItem = QSharedPointer<_NamespaceModelItem>; +using ScopeModelItem = QSharedPointer<_ScopeModelItem>; +using TemplateParameterModelItem = QSharedPointer<_TemplateParameterModelItem>; +using TypeDefModelItem = QSharedPointer<_TypeDefModelItem>; +using VariableModelItem = QSharedPointer<_VariableModelItem>; +using MemberModelItem = QSharedPointer<_MemberModelItem>; -typedef QVector<ArgumentModelItem> ArgumentList; -typedef QVector<ClassModelItem> ClassList; -typedef QVector<CodeModelItem> ItemList; -typedef QVector<EnumModelItem> EnumList; -typedef QVector<EnumeratorModelItem> EnumeratorList; -typedef QVector<FileModelItem> FileList; -typedef QVector<FunctionModelItem> FunctionList; -typedef QVector<NamespaceModelItem> NamespaceList; -typedef QVector<ScopeModelItem> ScopeList; -typedef QVector<TemplateParameterModelItem> TemplateParameterList; -typedef QVector<TypeDefModelItem> TypeDefList; -typedef QVector<VariableModelItem> VariableList; -typedef QVector<MemberModelItem> MemberList; +using ArgumentList = QVector<ArgumentModelItem>; +using ClassList = QVector<ClassModelItem>; +using ItemList = QVector<CodeModelItem>; +using EnumList = QVector<EnumModelItem>; +using EnumeratorList = QVector<EnumeratorModelItem>; +using FileList = QVector<FileModelItem>; +using FunctionList = QVector<FunctionModelItem>; +using NamespaceList = QVector<NamespaceModelItem>; +using ScopeList = QVector<ScopeModelItem>; +using TemplateParameterList = QVector<TemplateParameterModelItem>; +using TypeDefList = QVector<TypeDefModelItem>; +using VariableList = QVector<VariableModelItem>; +using MemberList = QVector<MemberModelItem>; #endif // CODEMODEL_FWD_H diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 06667caaf..256262f99 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -51,8 +51,8 @@ static QString wildcardToRegExp(QString w) return w; } -typedef QPair<QRegularExpression, QVersionNumber> ApiVersion; -typedef QVector<ApiVersion> ApiVersions; +using ApiVersion =QPair<QRegularExpression, QVersionNumber>; +using ApiVersions = QVector<ApiVersion>; Q_GLOBAL_STATIC(ApiVersions, apiVersions) @@ -85,7 +85,7 @@ struct IntTypeNormalizationEntry QString replacement; }; -typedef QVector<IntTypeNormalizationEntry> IntTypeNormalizationEntries; +using IntTypeNormalizationEntries = QVector<IntTypeNormalizationEntry>; static const IntTypeNormalizationEntries &intTypeNormalizationEntries() { diff --git a/sources/shiboken2/ApiExtractor/typedatabase_typedefs.h b/sources/shiboken2/ApiExtractor/typedatabase_typedefs.h index f9591609e..0bb5cde1d 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase_typedefs.h +++ b/sources/shiboken2/ApiExtractor/typedatabase_typedefs.h @@ -40,8 +40,8 @@ class TemplateEntry; class TypeEntry; class TypedefEntry; -typedef QVector<TypeEntry *> TypeEntryList; -typedef QMap<QString, TemplateEntry *> TemplateEntryMap; +using TypeEntryList = QVector<TypeEntry *>; +using TemplateEntryMap =QMap<QString, TemplateEntry *>; template <class Key, class Value> struct QMultiMapConstIteratorRange // A range of iterator for a range-based for loop @@ -55,14 +55,14 @@ struct QMultiMapConstIteratorRange // A range of iterator for a range-based for ConstIterator m_end; }; -typedef QMultiMap<QString, TypeEntry *> TypeEntryMultiMap; -typedef QMultiMapConstIteratorRange<QString, TypeEntry *> TypeEntryMultiMapConstIteratorRange; +using TypeEntryMultiMap = QMultiMap<QString, TypeEntry *>; +using TypeEntryMultiMapConstIteratorRange = QMultiMapConstIteratorRange<QString, TypeEntry *>; -typedef QMap<QString, TypeEntry *> TypeEntryMap; -typedef QMap<QString, TypedefEntry *> TypedefEntryMap; +using TypeEntryMap = QMap<QString, TypeEntry *>; +using TypedefEntryMap = QMap<QString, TypedefEntry *>; -typedef QVector<const ContainerTypeEntry *> ContainerTypeEntryList; +using ContainerTypeEntryList = QVector<const ContainerTypeEntry *>; using NamespaceTypeEntryList = QVector<NamespaceTypeEntry *>; -typedef QVector<const PrimitiveTypeEntry *> PrimitiveTypeEntryList; +using PrimitiveTypeEntryList = QVector<const PrimitiveTypeEntry *>; #endif // TYPEDATABASE_TYPEDEFS_H diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h index 485dc981a..2f3677ffa 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.h +++ b/sources/shiboken2/ApiExtractor/typesystem.h @@ -55,7 +55,7 @@ QT_END_NAMESPACE class EnumTypeEntry; class FlagsTypeEntry; -typedef QMap<int, QString> ArgumentMap; +using ArgumentMap = QMap<int, QString>; class TemplateInstance; @@ -1225,7 +1225,7 @@ public: enum TypeFlag { Deprecated = 0x4 }; - typedef QFlags<TypeFlag> TypeFlags; + Q_DECLARE_FLAGS(TypeFlags, TypeFlag) enum CopyableFlag { CopyableSet, @@ -1427,6 +1427,8 @@ private: TypeSystem::AllowThread m_allowThread = TypeSystem::AllowThread::Unspecified; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(ComplexTypeEntry::TypeFlags) + class TypedefEntry : public ComplexTypeEntry { public: @@ -1722,7 +1724,7 @@ public: bool replaceOriginalTargetToNativeConversions() const; void setReplaceOriginalTargetToNativeConversions(bool replaceOriginalTargetToNativeConversions); - typedef QVector<TargetToNativeConversion*> TargetToNativeConversions; + using TargetToNativeConversions = QVector<TargetToNativeConversion *>; bool hasTargetToNativeConversions() const; TargetToNativeConversions& targetToNativeConversions(); const TargetToNativeConversions& targetToNativeConversions() const; diff --git a/sources/shiboken2/ApiExtractor/typesystem_typedefs.h b/sources/shiboken2/ApiExtractor/typesystem_typedefs.h index 5cea587ed..fd702793e 100644 --- a/sources/shiboken2/ApiExtractor/typesystem_typedefs.h +++ b/sources/shiboken2/ApiExtractor/typesystem_typedefs.h @@ -43,9 +43,9 @@ struct FunctionModification; using AddedFunctionPtr = QSharedPointer<AddedFunction>; using AddedFunctionList = QVector<AddedFunctionPtr>; -typedef QVector<CodeSnip> CodeSnipList; -typedef QVector<DocModification> DocModificationList; -typedef QVector<FieldModification> FieldModificationList; -typedef QVector<FunctionModification> FunctionModificationList; +using CodeSnipList = QVector<CodeSnip>; +using DocModificationList = QVector<DocModification>; +using FieldModificationList = QVector<FieldModification>; +using FunctionModificationList = QVector<FunctionModification>; #endif // TYPESYSTEM_TYPEDEFS_H diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index 9d4201bc5..dde281f0e 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -173,8 +173,8 @@ private: class Generator { public: - typedef QPair<QString, QString> OptionDescription; - typedef QVector<OptionDescription> OptionDescriptions; + using OptionDescription = QPair<QString, QString>; + using OptionDescriptions = QVector<OptionDescription>; /// Optiosn used around the generator code enum Option { @@ -414,8 +414,8 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options) -typedef QSharedPointer<Generator> GeneratorPtr; -typedef QVector<GeneratorPtr> Generators; +using GeneratorPtr = QSharedPointer<Generator>; +using Generators = QVector<GeneratorPtr>; #endif // GENERATOR_H diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index 4c84e0d47..25daea99e 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -59,9 +59,9 @@ static inline QString skipDeprecatedOption() { return QStringLiteral("skip-depre static const char helpHint[] = "Note: use --help or -h for more information.\n"; -typedef QMap<QString, QString> CommandArgumentMap; +using CommandArgumentMap = QMap<QString, QString>; -typedef Generator::OptionDescriptions OptionDescriptions; +using OptionDescriptions = Generator::OptionDescriptions; static void printOptions(QTextStream &s, const OptionDescriptions &options) { diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index 205ca5e99..1b4ac7b74 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -2110,7 +2110,7 @@ void QtDocGenerator::writeFunction(QTextStream& s, const AbstractMetaClass* cppC static void writeFancyToc(QTextStream& s, const QStringList& items, int cols = 4) { - typedef QMap<QChar, QStringList> TocMap; + using TocMap = QMap<QChar, QStringList>; TocMap tocMap; QChar Q = QLatin1Char('Q'); QChar idx; diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h index 86404c873..53e292d22 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h @@ -67,7 +67,7 @@ public: TableCell(const char* text) : data(QLatin1String(text)) {} }; - typedef QList<TableCell> TableRow; + using TableRow = QList<TableCell>; class Table : public QList<TableRow> { public: diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 60ef30d16..0d197eab3 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -214,8 +214,7 @@ QVector<AbstractMetaFunctionList> CppGenerator::filterGroupedOperatorFunctions(c uint queryIn) { // ( func_name, num_args ) => func_list - typedef QMap<QPair<QString, int >, AbstractMetaFunctionList> ResultMap; - ResultMap results; + QMap<QPair<QString, int>, AbstractMetaFunctionList> results; const AbstractMetaClass::OperatorQueryOptions query(queryIn); const AbstractMetaFunctionList &funcs = metaClass->operatorOverloads(query); for (AbstractMetaFunction *func : funcs) { @@ -237,7 +236,7 @@ QVector<AbstractMetaFunctionList> CppGenerator::filterGroupedOperatorFunctions(c } QVector<AbstractMetaFunctionList> result; result.reserve(results.size()); - for (ResultMap::const_iterator it = results.cbegin(), end = results.cend(); it != end; ++it) + for (auto it = results.cbegin(), end = results.cend(); it != end; ++it) result.append(it.value()); return result; } @@ -257,8 +256,7 @@ const AbstractMetaFunction *CppGenerator::boolCast(const AbstractMetaClass *meta && func->arguments().isEmpty() ? func : nullptr; } -typedef QMap<QString, AbstractMetaFunctionList> FunctionGroupMap; -typedef FunctionGroupMap::const_iterator FunctionGroupMapIt; +using FunctionGroupMap = QMap<QString, AbstractMetaFunctionList>; // Prevent ELF symbol qt_version_tag from being generated into the source static const char includeQDebug[] = @@ -3765,11 +3763,9 @@ QString CppGenerator::multipleInheritanceInitializerFunctionName(const AbstractM return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("_mi_init"); } -typedef QHash<QString, QPair<QString, QString> >::const_iterator ProtocolIt; - bool CppGenerator::supportsMappingProtocol(const AbstractMetaClass *metaClass) { - for (ProtocolIt it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) { + for (auto it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) { if (metaClass->hasFunction(it.key())) return true; } @@ -3787,7 +3783,7 @@ bool CppGenerator::supportsNumberProtocol(const AbstractMetaClass *metaClass) bool CppGenerator::supportsSequenceProtocol(const AbstractMetaClass *metaClass) { - for (ProtocolIt it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) { + for (auto it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) { if (metaClass->hasFunction(it.key())) return true; } @@ -4074,7 +4070,7 @@ void CppGenerator::writeTypeAsSequenceDefinition(QTextStream &s, const AbstractM { bool hasFunctions = false; QMap<QString, QString> funcs; - for (ProtocolIt it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) { + for (auto it = m_sequenceProtocol.cbegin(), end = m_sequenceProtocol.cend(); it != end; ++it) { const QString &funcName = it.key(); const AbstractMetaFunction *func = metaClass->findFunction(funcName); funcs[funcName] = func ? cpythonFunctionName(func).prepend(QLatin1Char('&')) : QString(); @@ -4107,7 +4103,7 @@ void CppGenerator::writeTypeAsMappingDefinition(QTextStream &s, const AbstractMe { bool hasFunctions = false; QMap<QString, QString> funcs; - for (ProtocolIt it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) { + for (auto it = m_mappingProtocol.cbegin(), end = m_mappingProtocol.cend(); it != end; ++it) { const QString &funcName = it.key(); const AbstractMetaFunction *func = metaClass->findFunction(funcName); funcs[funcName] = func ? cpythonFunctionName(func).prepend(QLatin1Char('&')) : QLatin1String("0"); diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.h b/sources/shiboken2/generator/shiboken2/overloaddata.h index c9304d461..4fd4199e5 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.h +++ b/sources/shiboken2/generator/shiboken2/overloaddata.h @@ -38,12 +38,12 @@ QT_FORWARD_DECLARE_CLASS(QDebug) class ShibokenGenerator; class OverloadData; -typedef QVector<OverloadData *> OverloadDataList; +using OverloadDataList = QVector<OverloadData *>; class OverloadData { public: - typedef QVector<const AbstractMetaFunction *> MetaFunctionList; + using MetaFunctionList = QVector<const AbstractMetaFunction *>; OverloadData(const AbstractMetaFunctionList &overloads, const ShibokenGenerator *generator); ~OverloadData(); diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index b5f37cc57..bfd14d20c 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2011,7 +2011,7 @@ static QString getConverterTypeSystemVariableArgument(const QString &code, int p qFatal("Unbalanced parenthesis on type system converter variable call."); return arg; } -typedef QPair<QString, QString> StringPair; +using StringPair = QPair<QString, QString>; void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString &code) { diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index 02231f1a0..84b3137b8 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -418,7 +418,7 @@ protected: // All data about extended converters: the type entries of the target type, and a // list of AbstractMetaClasses accepted as argument for the conversion. - typedef QHash<const TypeEntry *, QVector<const AbstractMetaClass *> > ExtendedConverterData; + using ExtendedConverterData = QHash<const TypeEntry *, QVector<const AbstractMetaClass *> >; /// Returns all extended conversions for the current module. ExtendedConverterData getExtendedConverters() const; @@ -491,9 +491,9 @@ private: QString functionReturnType(const AbstractMetaFunction *func, Options options = NoOption) const; /// Utility function for writeCodeSnips. - typedef QPair<const AbstractMetaArgument *, QString> ArgumentVarReplacementPair; - typedef QVector<ArgumentVarReplacementPair> ArgumentVarReplacementList; - ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunction *func, + using ArgumentVarReplacementPair = QPair<const AbstractMetaArgument *, QString>; + using ArgumentVarReplacementList = QVector<ArgumentVarReplacementPair>; + ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunction* func, bool usePyArgs, TypeSystem::Language language, const AbstractMetaArgument *lastArg); @@ -542,7 +542,7 @@ private: bool m_useIsNullAsNbNonZero = false; bool m_avoidProtectedHack = false; - typedef QHash<QString, AbstractMetaType *> AbstractMetaTypeCache; + using AbstractMetaTypeCache = QHash<QString, AbstractMetaType *>; AbstractMetaTypeCache m_metaTypeFromStringCache; /// Type system converter variable replacement names and regular expressions. diff --git a/sources/shiboken2/libshiboken/basewrapper_p.h b/sources/shiboken2/libshiboken/basewrapper_p.h index d119c7ec6..56a647b21 100644 --- a/sources/shiboken2/libshiboken/basewrapper_p.h +++ b/sources/shiboken2/libshiboken/basewrapper_p.h @@ -58,7 +58,7 @@ namespace Shiboken * This mapping associates a method and argument of an wrapper object with the wrapper of * said argument when it needs the binding to help manage its reference count. */ -typedef std::unordered_multimap<std::string, PyObject *> RefCountMap; +using RefCountMap = std::unordered_multimap<std::string, PyObject *> ; /// Linked list of SbkBaseWrapper pointers using ChildrenList = std::set<SbkObject *>; @@ -198,7 +198,7 @@ private: class BaseAccumulatorVisitor : public HierarchyVisitor { public: - typedef std::vector<SbkObjectType *> Result; + using Result = std::vector<SbkObjectType *>; bool visit(SbkObjectType *node) override; diff --git a/sources/shiboken2/libshiboken/bindingmanager.cpp b/sources/shiboken2/libshiboken/bindingmanager.cpp index 97ffb1cf2..b6660a5bc 100644 --- a/sources/shiboken2/libshiboken/bindingmanager.cpp +++ b/sources/shiboken2/libshiboken/bindingmanager.cpp @@ -52,13 +52,13 @@ namespace Shiboken { -typedef std::unordered_map<const void *, SbkObject *> WrapperMap; +using WrapperMap = std::unordered_map<const void *, SbkObject *>; class Graph { public: - typedef std::vector<SbkObjectType *> NodeList; - typedef std::unordered_map<SbkObjectType *, NodeList> Edges; + using NodeList = std::vector<SbkObjectType *>; + using Edges = std::unordered_map<SbkObjectType *, NodeList>; Edges m_edges; diff --git a/sources/shiboken2/libshiboken/helper.h b/sources/shiboken2/libshiboken/helper.h index 6c29ad728..eca87b351 100644 --- a/sources/shiboken2/libshiboken/helper.h +++ b/sources/shiboken2/libshiboken/helper.h @@ -90,7 +90,7 @@ class AutoArrayPointer T *data; }; -typedef unsigned long long ThreadId; +using ThreadId = unsigned long long; LIBSHIBOKEN_API ThreadId currentThreadId(); LIBSHIBOKEN_API ThreadId mainThreadId(); diff --git a/sources/shiboken2/libshiboken/sbkconverter.cpp b/sources/shiboken2/libshiboken/sbkconverter.cpp index b5246932f..a7b66b8cc 100644 --- a/sources/shiboken2/libshiboken/sbkconverter.cpp +++ b/sources/shiboken2/libshiboken/sbkconverter.cpp @@ -51,7 +51,7 @@ static SbkConverter **PrimitiveTypeConverters; -typedef std::unordered_map<std::string, SbkConverter *> ConvertersMap; +using ConvertersMap = std::unordered_map<std::string, SbkConverter *>; static ConvertersMap converters; namespace Shiboken { diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h index 84de2099a..5af1b3fd5 100644 --- a/sources/shiboken2/libshiboken/sbkconverter_p.h +++ b/sources/shiboken2/libshiboken/sbkconverter_p.h @@ -54,8 +54,8 @@ extern "C" { -typedef std::pair<IsConvertibleToCppFunc, PythonToCppFunc> ToCppConversion; -typedef std::vector<ToCppConversion> ToCppConversionVector; +using ToCppConversion = std::pair<IsConvertibleToCppFunc, PythonToCppFunc>; +using ToCppConversionVector = std::vector<ToCppConversion>; /** * \internal diff --git a/sources/shiboken2/libshiboken/sbkmodule.cpp b/sources/shiboken2/libshiboken/sbkmodule.cpp index 7864471c0..9321725d6 100644 --- a/sources/shiboken2/libshiboken/sbkmodule.cpp +++ b/sources/shiboken2/libshiboken/sbkmodule.cpp @@ -43,10 +43,10 @@ #include <unordered_map> /// This hash maps module objects to arrays of Python types. -typedef std::unordered_map<PyObject *, PyTypeObject **> ModuleTypesMap; +using ModuleTypesMap = std::unordered_map<PyObject *, PyTypeObject **> ; /// This hash maps module objects to arrays of converters. -typedef std::unordered_map<PyObject *, SbkConverter **> ModuleConvertersMap; +using ModuleConvertersMap = std::unordered_map<PyObject *, SbkConverter **>; /// All types produced in imported modules are mapped here. static ModuleTypesMap moduleTypes; diff --git a/sources/shiboken2/tests/libminimal/typedef.h b/sources/shiboken2/tests/libminimal/typedef.h index 8e3455652..b8d6faacd 100644 --- a/sources/shiboken2/tests/libminimal/typedef.h +++ b/sources/shiboken2/tests/libminimal/typedef.h @@ -34,7 +34,7 @@ #include <vector> // Test wrapping of a typedef -typedef std::vector<int> MyArrayInt; +using MyArrayInt = std::vector<int>; LIBMINIMAL_API bool arrayFuncInt(std::vector<int> a); LIBMINIMAL_API bool arrayFuncIntTypedef(MyArrayInt a); @@ -43,7 +43,7 @@ LIBMINIMAL_API std::vector<int> arrayFuncIntReturn(int size); LIBMINIMAL_API MyArrayInt arrayFuncIntReturnTypedef(int size); // Test wrapping of a typedef of a typedef -typedef MyArrayInt MyArray; +using MyArray = MyArrayInt; LIBMINIMAL_API bool arrayFunc(std::vector<int> a); LIBMINIMAL_API bool arrayFuncTypedef(MyArray a); diff --git a/sources/shiboken2/tests/libsample/handle.h b/sources/shiboken2/tests/libsample/handle.h index 18221c763..824c28b9a 100644 --- a/sources/shiboken2/tests/libsample/handle.h +++ b/sources/shiboken2/tests/libsample/handle.h @@ -33,14 +33,14 @@ /* See http://bugs.pyside.org/show_bug.cgi?id=1105. */ namespace Foo { - typedef unsigned long HANDLE; + using HANDLE = unsigned long; } class LIBSAMPLE_API OBJ { }; -typedef OBJ* HANDLE; +using HANDLE = OBJ *; class LIBSAMPLE_API HandleHolder { @@ -63,7 +63,7 @@ private: }; struct LIBSAMPLE_API PrimitiveStruct {}; -typedef struct PrimitiveStruct* PrimitiveStructPtr; +using PrimitiveStructPtr = struct PrimitiveStruct *; struct LIBSAMPLE_API PrimitiveStructPointerHolder { PrimitiveStructPtr primitiveStructPtr; diff --git a/sources/shiboken2/tests/libsample/listuser.h b/sources/shiboken2/tests/libsample/listuser.h index 92360884f..7e67039d9 100644 --- a/sources/shiboken2/tests/libsample/listuser.h +++ b/sources/shiboken2/tests/libsample/listuser.h @@ -39,7 +39,7 @@ class LIBSAMPLE_API ListUser { public: - typedef std::list<Point*> PointList; + using PointList = std::list<Point *>; enum ListOfSomething { ListOfPoint, diff --git a/sources/shiboken2/tests/libsample/objecttype.h b/sources/shiboken2/tests/libsample/objecttype.h index cb5823c5b..1f2a9c7e8 100644 --- a/sources/shiboken2/tests/libsample/objecttype.h +++ b/sources/shiboken2/tests/libsample/objecttype.h @@ -69,7 +69,7 @@ class LIBSAMPLE_API ObjectType { public: // ### Fixme: Use uintptr_t in C++ 11 - typedef size_t Identifier; + using Identifier = size_t; explicit ObjectType(ObjectType *parent = nullptr); virtual ~ObjectType(); diff --git a/sources/shiboken2/tests/libsample/photon.h b/sources/shiboken2/tests/libsample/photon.h index b9fc6532d..1dcb4f83e 100644 --- a/sources/shiboken2/tests/libsample/photon.h +++ b/sources/shiboken2/tests/libsample/photon.h @@ -93,8 +93,8 @@ template class LIBSAMPLE_API TemplateBase<IdentityType>; template class LIBSAMPLE_API TemplateBase<DuplicatorType>; #endif -typedef TemplateBase<IdentityType> ValueIdentity; -typedef TemplateBase<DuplicatorType> ValueDuplicator; +using ValueIdentity = TemplateBase<IdentityType>; +using ValueDuplicator = TemplateBase<DuplicatorType>; LIBSAMPLE_API int callCalculateForValueDuplicatorPointer(ValueDuplicator* value); LIBSAMPLE_API int callCalculateForValueDuplicatorReference(ValueDuplicator& value); diff --git a/sources/shiboken2/tests/libsample/polygon.h b/sources/shiboken2/tests/libsample/polygon.h index 3eafa3094..728332d1a 100644 --- a/sources/shiboken2/tests/libsample/polygon.h +++ b/sources/shiboken2/tests/libsample/polygon.h @@ -37,7 +37,7 @@ class LIBSAMPLE_API Polygon { public: - typedef std::list<Point> PointList; + using PointList = std::list<Point>; Polygon() {} Polygon(double x, double y); diff --git a/sources/shiboken2/tests/libsample/size.h b/sources/shiboken2/tests/libsample/size.h index c72021231..76502b416 100644 --- a/sources/shiboken2/tests/libsample/size.h +++ b/sources/shiboken2/tests/libsample/size.h @@ -188,8 +188,8 @@ inline const Size operator/(const Size& s, double div) return Size(s.m_width / div, s.m_height / div); } -typedef double real; -typedef unsigned short ushort; +using real = double; +using ushort = unsigned short; class LIBSAMPLE_API SizeF { public: diff --git a/sources/shiboken2/tests/libsample/str.h b/sources/shiboken2/tests/libsample/str.h index 4af00e5b6..2f7cee8c3 100644 --- a/sources/shiboken2/tests/libsample/str.h +++ b/sources/shiboken2/tests/libsample/str.h @@ -71,7 +71,7 @@ private: LIBSAMPLE_API Str operator+(int number, const Str& str); LIBSAMPLE_API unsigned int strHash(const Str& str); -typedef Str PStr; +using PStr = Str; LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix); LIBSAMPLE_API void duplicatePStr(PStr *pstr = nullptr); diff --git a/sources/shiboken2/tests/libsample/strlist.h b/sources/shiboken2/tests/libsample/strlist.h index 27fc05e6e..43aa15390 100644 --- a/sources/shiboken2/tests/libsample/strlist.h +++ b/sources/shiboken2/tests/libsample/strlist.h @@ -60,6 +60,6 @@ private: CtorEnum m_ctorUsed; }; -typedef StrList PStrList; +using PStrList = StrList; #endif // STRLIST_H |