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 /sources/shiboken2/generator | |
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>
Diffstat (limited to 'sources/shiboken2/generator')
8 files changed, 23 insertions, 27 deletions
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. |