From 7be4e64b4bac6e6b5a90eec74b9f2b661c60db3a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 May 2019 10:45:37 +0200 Subject: 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 --- .../shiboken2/ApiExtractor/abstractmetabuilder.cpp | 7 ++- .../shiboken2/ApiExtractor/abstractmetabuilder_p.h | 2 +- .../shiboken2/ApiExtractor/abstractmetalang.cpp | 2 +- sources/shiboken2/ApiExtractor/abstractmetalang.h | 2 +- .../ApiExtractor/abstractmetalang_typedefs.h | 16 +++---- sources/shiboken2/ApiExtractor/apiextractor.cpp | 6 +-- .../ApiExtractor/clangparser/clangbuilder.cpp | 10 ++--- .../ApiExtractor/clangparser/clangparser.h | 8 ++-- .../ApiExtractor/clangparser/clangutils.h | 4 +- sources/shiboken2/ApiExtractor/dependency.h | 2 +- sources/shiboken2/ApiExtractor/graph.cpp | 12 +++-- sources/shiboken2/ApiExtractor/header_paths.h | 2 +- sources/shiboken2/ApiExtractor/include.h | 2 +- .../shiboken2/ApiExtractor/parser/codemodel.cpp | 11 ++--- sources/shiboken2/ApiExtractor/parser/codemodel.h | 2 +- .../shiboken2/ApiExtractor/parser/codemodel_fwd.h | 52 +++++++++++----------- sources/shiboken2/ApiExtractor/typedatabase.cpp | 6 +-- .../shiboken2/ApiExtractor/typedatabase_typedefs.h | 16 +++---- sources/shiboken2/ApiExtractor/typesystem.h | 8 ++-- .../shiboken2/ApiExtractor/typesystem_typedefs.h | 8 ++-- sources/shiboken2/generator/generator.h | 8 ++-- sources/shiboken2/generator/main.cpp | 4 +- .../shiboken2/generator/qtdoc/qtdocgenerator.cpp | 2 +- sources/shiboken2/generator/qtdoc/qtdocgenerator.h | 2 +- .../shiboken2/generator/shiboken2/cppgenerator.cpp | 18 +++----- .../shiboken2/generator/shiboken2/overloaddata.h | 4 +- .../generator/shiboken2/shibokengenerator.cpp | 2 +- .../generator/shiboken2/shibokengenerator.h | 10 ++--- sources/shiboken2/libshiboken/basewrapper_p.h | 4 +- sources/shiboken2/libshiboken/bindingmanager.cpp | 6 +-- sources/shiboken2/libshiboken/helper.h | 2 +- sources/shiboken2/libshiboken/sbkconverter.cpp | 2 +- sources/shiboken2/libshiboken/sbkconverter_p.h | 4 +- sources/shiboken2/libshiboken/sbkmodule.cpp | 4 +- sources/shiboken2/tests/libminimal/typedef.h | 4 +- sources/shiboken2/tests/libsample/handle.h | 6 +-- sources/shiboken2/tests/libsample/listuser.h | 2 +- sources/shiboken2/tests/libsample/objecttype.h | 2 +- sources/shiboken2/tests/libsample/photon.h | 4 +- sources/shiboken2/tests/libsample/polygon.h | 2 +- sources/shiboken2/tests/libsample/size.h | 4 +- sources/shiboken2/tests/libsample/str.h | 2 +- sources/shiboken2/tests/libsample/strlist.h | 2 +- 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 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 RejectMap; + using RejectMap = QMap; 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 AbstractMetaClassBaseTemplateInstantiationsMap; +using AbstractMetaClassBaseTemplateInstantiationsMap = QHash; 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 Indirections; + using Indirections = QVector; 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 AbstractMetaArgumentList; -typedef QVector AbstractMetaClassList; -typedef QVector AbstractMetaEnumList; -typedef QVector AbstractMetaEnumValueList; -typedef QVector AbstractMetaFieldList; -typedef QVector AbstractMetaFunctionList; -typedef QVector AbstractMetaTypeList; -typedef QVector AbstractMetaTypeCList; +using AbstractMetaArgumentList = QVector; +using AbstractMetaClassList = QVector; +using AbstractMetaEnumList = QVector; +using AbstractMetaEnumValueList = QVector; +using AbstractMetaFieldList = QVector; +using AbstractMetaFunctionList = QVector; +using AbstractMetaTypeList = QVector; +using AbstractMetaTypeCList = QVector; #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 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 CursorClassHash; - typedef QHash CursorTypedefHash; - typedef QHash TypeInfoHash; + using CursorClassHash = QHash; + using CursorTypedefHash = QHash; + using TypeInfoHash = QHash; explicit BuilderPrivate(BaseVisitor *bv) : m_baseVisitor(bv), m_model(new CodeModel) { @@ -645,11 +645,9 @@ static inline CXCursor definitionFromTypeRef(const CXCursor &typeRefCursor) template // ArgumentModelItem, VariableModelItem void BuilderPrivate::qualifyTypeDef(const CXCursor &typeRefCursor, const QSharedPointer &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 Snippet; + using Snippet = QPair; Snippet getCodeSnippet(const CXCursor &cursor); private: - typedef QHash FileBufferCache; + using FileBufferCache = QHash; FileBufferCache m_fileBufferCache; }; @@ -56,8 +56,8 @@ private: class BaseVisitor { Q_DISABLE_COPY(BaseVisitor) public: - typedef QVector Diagnostics; - typedef SourceFileCache::Snippet CodeSnippet; + using Diagnostics = QVector; + 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 SourceRange; +using SourceRange =QPair; SourceLocation getCursorLocation(const CXCursor &cursor); CXString getFileNameFromLocation(const CXSourceLocation &location); @@ -100,7 +100,7 @@ CXDiagnosticSeverity maxSeverity(const QVector &ds); // Parse a template argument list "a,e>" and invoke a handler // with each match (level and string). Return begin and end of the list. -typedef std::function TemplateArgumentHandler; +using TemplateArgumentHandler = std::function; QPair 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 Dependencies; +using Dependencies = QVector; #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 > Edges; - typedef QSet::const_iterator EdgeIterator; + using Edges = QVector >; Edges edges; @@ -50,11 +49,10 @@ struct Graph::GraphPrivate void dfsVisit(int node, Graph::Indexes &result, QVector &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 HeaderPaths; +using HeaderPaths = QList; #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 IncludeList; +using IncludeList = QVector; #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 static QSharedPointer findModelItem(const QVector > &list, const QString &name) { - typedef typename QVector >::const_iterator It; - const It it = std::find_if(list.begin(), list.end(), ModelItemNamePredicate(name)); - return it != list.end() ? *it : QSharedPointer(); + const auto it = std::find_if(list.cbegin(), list.cend(), ModelItemNamePredicate(name)); + return it != list.cend() ? *it : QSharedPointer(); } // --------------------------------------------------------------------------- @@ -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 Indirections; + using Indirections = QVector; 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 ArgumentList; -typedef QVector ClassList; -typedef QVector ItemList; -typedef QVector EnumList; -typedef QVector EnumeratorList; -typedef QVector FileList; -typedef QVector FunctionList; -typedef QVector NamespaceList; -typedef QVector ScopeList; -typedef QVector TemplateParameterList; -typedef QVector TypeDefList; -typedef QVector VariableList; -typedef QVector MemberList; +using ArgumentList = QVector; +using ClassList = QVector; +using ItemList = QVector; +using EnumList = QVector; +using EnumeratorList = QVector; +using FileList = QVector; +using FunctionList = QVector; +using NamespaceList = QVector; +using ScopeList = QVector; +using TemplateParameterList = QVector; +using TypeDefList = QVector; +using VariableList = QVector; +using MemberList = QVector; #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 ApiVersion; -typedef QVector ApiVersions; +using ApiVersion =QPair; +using ApiVersions = QVector; Q_GLOBAL_STATIC(ApiVersions, apiVersions) @@ -85,7 +85,7 @@ struct IntTypeNormalizationEntry QString replacement; }; -typedef QVector IntTypeNormalizationEntries; +using IntTypeNormalizationEntries = QVector; 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 TypeEntryList; -typedef QMap TemplateEntryMap; +using TypeEntryList = QVector; +using TemplateEntryMap =QMap; template 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 TypeEntryMultiMap; -typedef QMultiMapConstIteratorRange TypeEntryMultiMapConstIteratorRange; +using TypeEntryMultiMap = QMultiMap; +using TypeEntryMultiMapConstIteratorRange = QMultiMapConstIteratorRange; -typedef QMap TypeEntryMap; -typedef QMap TypedefEntryMap; +using TypeEntryMap = QMap; +using TypedefEntryMap = QMap; -typedef QVector ContainerTypeEntryList; +using ContainerTypeEntryList = QVector; using NamespaceTypeEntryList = QVector; -typedef QVector PrimitiveTypeEntryList; +using PrimitiveTypeEntryList = QVector; #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 ArgumentMap; +using ArgumentMap = QMap; class TemplateInstance; @@ -1225,7 +1225,7 @@ public: enum TypeFlag { Deprecated = 0x4 }; - typedef QFlags 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 TargetToNativeConversions; + using TargetToNativeConversions = QVector; 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; using AddedFunctionList = QVector; -typedef QVector CodeSnipList; -typedef QVector DocModificationList; -typedef QVector FieldModificationList; -typedef QVector FunctionModificationList; +using CodeSnipList = QVector; +using DocModificationList = QVector; +using FieldModificationList = QVector; +using FunctionModificationList = QVector; #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 OptionDescription; - typedef QVector OptionDescriptions; + using OptionDescription = QPair; + using OptionDescriptions = QVector; /// Optiosn used around the generator code enum Option { @@ -414,8 +414,8 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options) -typedef QSharedPointer GeneratorPtr; -typedef QVector Generators; +using GeneratorPtr = QSharedPointer; +using Generators = QVector; #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 CommandArgumentMap; +using CommandArgumentMap = QMap; -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 TocMap; + using TocMap = QMap; 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 TableRow; + using TableRow = QList; class Table : public QList { 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 CppGenerator::filterGroupedOperatorFunctions(c uint queryIn) { // ( func_name, num_args ) => func_list - typedef QMap, AbstractMetaFunctionList> ResultMap; - ResultMap results; + QMap, AbstractMetaFunctionList> results; const AbstractMetaClass::OperatorQueryOptions query(queryIn); const AbstractMetaFunctionList &funcs = metaClass->operatorOverloads(query); for (AbstractMetaFunction *func : funcs) { @@ -237,7 +236,7 @@ QVector CppGenerator::filterGroupedOperatorFunctions(c } QVector 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 FunctionGroupMap; -typedef FunctionGroupMap::const_iterator FunctionGroupMapIt; +using FunctionGroupMap = QMap; // 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 >::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 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 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 OverloadDataList; +using OverloadDataList = QVector; class OverloadData { public: - typedef QVector MetaFunctionList; + using MetaFunctionList = QVector; 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 StringPair; +using StringPair = QPair; 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 > ExtendedConverterData; + using ExtendedConverterData = QHash >; /// 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 ArgumentVarReplacementPair; - typedef QVector ArgumentVarReplacementList; - ArgumentVarReplacementList getArgumentReplacement(const AbstractMetaFunction *func, + using ArgumentVarReplacementPair = QPair; + using ArgumentVarReplacementList = QVector; + 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 AbstractMetaTypeCache; + using AbstractMetaTypeCache = QHash; 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 RefCountMap; +using RefCountMap = std::unordered_multimap ; /// Linked list of SbkBaseWrapper pointers using ChildrenList = std::set; @@ -198,7 +198,7 @@ private: class BaseAccumulatorVisitor : public HierarchyVisitor { public: - typedef std::vector Result; + using Result = std::vector; 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 WrapperMap; +using WrapperMap = std::unordered_map; class Graph { public: - typedef std::vector NodeList; - typedef std::unordered_map Edges; + using NodeList = std::vector; + using Edges = std::unordered_map; 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 ConvertersMap; +using ConvertersMap = std::unordered_map; 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 ToCppConversion; -typedef std::vector ToCppConversionVector; +using ToCppConversion = std::pair; +using ToCppConversionVector = std::vector; /** * \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 /// This hash maps module objects to arrays of Python types. -typedef std::unordered_map ModuleTypesMap; +using ModuleTypesMap = std::unordered_map ; /// This hash maps module objects to arrays of converters. -typedef std::unordered_map ModuleConvertersMap; +using ModuleConvertersMap = std::unordered_map; /// 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 // Test wrapping of a typedef -typedef std::vector MyArrayInt; +using MyArrayInt = std::vector; LIBMINIMAL_API bool arrayFuncInt(std::vector a); LIBMINIMAL_API bool arrayFuncIntTypedef(MyArrayInt a); @@ -43,7 +43,7 @@ LIBMINIMAL_API std::vector 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 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 PointList; + using PointList = std::list; 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; template class LIBSAMPLE_API TemplateBase; #endif -typedef TemplateBase ValueIdentity; -typedef TemplateBase ValueDuplicator; +using ValueIdentity = TemplateBase; +using ValueDuplicator = TemplateBase; 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 PointList; + using PointList = std::list; 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 -- cgit v1.2.3