diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 09:51:39 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 10:44:01 +0200 |
commit | e5595a4b3010b1bb4b6f80a0339271a7b26934de (patch) | |
tree | 332a63307284ad7957c3daa9e8cb7ba6daed158f /sources/shiboken2/ApiExtractor | |
parent | ddfbbd346b522703a5b6f8d274a7f79983e5f319 (diff) |
shiboken: Introduce auto
Apply Fixits by Qt Creator with some amendments.
Change-Id: Ib2be1012ef7e8a2ad0e6cd130371bf1e941c4264
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
7 files changed, 46 insertions, 47 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index b1c3b9114..90664ef32 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -883,7 +883,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem & return nullptr; } - AbstractMetaEnum *metaEnum = new AbstractMetaEnum; + auto *metaEnum = new AbstractMetaEnum; metaEnum->setEnumKind(enumItem->enumKind()); metaEnum->setSigned(enumItem->isSigned()); if (enumsDeclarations.contains(qualifiedName) @@ -891,7 +891,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem & metaEnum->setHasQEnumsDeclaration(true); } - EnumTypeEntry *enumTypeEntry = static_cast<EnumTypeEntry *>(typeEntry); + auto *enumTypeEntry = static_cast<EnumTypeEntry *>(typeEntry); metaEnum->setTypeEntry(enumTypeEntry); switch (enumItem->accessPolicy()) { case CodeModel::Public: @@ -914,7 +914,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem & const EnumeratorList &enums = enumItem->enumerators(); for (const EnumeratorModelItem &value : enums) { - AbstractMetaEnumValue *metaEnumValue = new AbstractMetaEnumValue; + auto *metaEnumValue = new AbstractMetaEnumValue; metaEnumValue->setName(value->name()); // Deciding the enum value... @@ -993,7 +993,7 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseTypeDef(const FileModelIt if (!type) return nullptr; - AbstractMetaClass *metaClass = new AbstractMetaClass; + auto *metaClass = new AbstractMetaClass; metaClass->setTypeDef(true); metaClass->setTypeEntry(type); metaClass->setBaseClassNames(QStringList(typeDef->type().toString())); @@ -1014,7 +1014,7 @@ void AbstractMetaBuilderPrivate::traverseTypesystemTypedefs() const auto &entries = TypeDatabase::instance()->typedefEntries(); for (auto it = entries.begin(), end = entries.end(); it != end; ++it) { TypedefEntry *te = it.value(); - AbstractMetaClass *metaClass = new AbstractMetaClass; + auto *metaClass = new AbstractMetaClass; metaClass->setTypeDef(true); metaClass->setTypeEntry(te->target()); metaClass->setBaseClassNames(QStringList(te->sourceType())); @@ -1056,7 +1056,7 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseClass(const FileModelItem return nullptr; } - AbstractMetaClass *metaClass = new AbstractMetaClass; + auto *metaClass = new AbstractMetaClass; metaClass->setTypeEntry(type); if (classItem->isFinal()) @@ -1198,7 +1198,7 @@ AbstractMetaField *AbstractMetaBuilderPrivate::traverseField(const VariableModel } - AbstractMetaField *metaField = new AbstractMetaField; + auto *metaField = new AbstractMetaField; metaField->setName(fieldName); metaField->setEnclosingClass(cls); @@ -1282,7 +1282,7 @@ void AbstractMetaBuilderPrivate::fixReturnTypeOfConversionOperator(AbstractMetaF if (!retType) return; - AbstractMetaType *metaType = new AbstractMetaType; + auto *metaType = new AbstractMetaType; metaType->setTypeEntry(retType); metaFunction->replaceType(metaType); } @@ -1610,7 +1610,7 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFunctionPtr &addedFunc, AbstractMetaClass *metaClass) { - AbstractMetaFunction *metaFunction = new AbstractMetaFunction(addedFunc); + auto *metaFunction = new AbstractMetaFunction(addedFunc); metaFunction->setType(translateType(addedFunc->returnType())); @@ -1619,7 +1619,7 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu for (int i = 0; i < args.count(); ++i) { const AddedFunction::TypeInfo& typeInfo = args.at(i).typeInfo; - AbstractMetaArgument *metaArg = new AbstractMetaArgument; + auto *metaArg = new AbstractMetaArgument; AbstractMetaType *type = translateType(typeInfo); if (Q_UNLIKELY(!type)) { qCWarning(lcShiboken, @@ -1842,7 +1842,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio return nullptr; } - AbstractMetaFunction *metaFunction = new AbstractMetaFunction; + auto *metaFunction = new AbstractMetaFunction; if (deprecated) *metaFunction += AbstractMetaAttributes::Deprecated; @@ -1968,7 +1968,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio return nullptr; } - AbstractMetaArgument *metaArgument = new AbstractMetaArgument; + auto *metaArgument = new AbstractMetaArgument; metaArgument->setType(metaType); metaArgument->setName(arg->name()); @@ -2115,7 +2115,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const AddedFunction: qFatal("%s", qPrintable(msg)); } - AbstractMetaType *metaType = new AbstractMetaType; + auto *metaType = new AbstractMetaType; metaType->setTypeEntry(type); metaType->setIndirections(typeInfo.indirections); if (typeInfo.isReference) @@ -2229,7 +2229,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo } for (int i = typeInfo.arrayElements().size() - 1; i >= 0; --i) { - AbstractMetaType *arrayType = new AbstractMetaType; + auto *arrayType = new AbstractMetaType; arrayType->setArrayElementType(elementType); const QString &arrayElement = typeInfo.arrayElements().at(i); if (!arrayElement.isEmpty()) { @@ -2319,7 +2319,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo // These are only implicit and should not appear in code... Q_ASSERT(!type->isInterface()); - AbstractMetaType *metaType = new AbstractMetaType; + auto *metaType = new AbstractMetaType; metaType->setTypeEntry(type); metaType->setIndirectionsV(typeInfo.indirectionsV()); metaType->setReferenceType(typeInfo.referenceType()); @@ -2601,7 +2601,7 @@ AbstractMetaType * returned->setOriginalTemplateType(metaType); if (returned->typeEntry()->isTemplateArgument()) { - const TemplateArgumentEntry* tae = static_cast<const TemplateArgumentEntry*>(returned->typeEntry()); + const auto *tae = static_cast<const TemplateArgumentEntry*>(returned->typeEntry()); // If the template is intantiated with void we special case this as rejecting the functions that use this // parameter from the instantiation. @@ -2683,7 +2683,7 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass, } if (t) { - AbstractMetaType *temporaryType = new AbstractMetaType; + auto *temporaryType = new AbstractMetaType; temporaryType->setTypeEntry(t); temporaryType->setConstant(i.isConstant()); temporaryType->setReferenceType(i.referenceType()); @@ -2835,7 +2835,7 @@ void AbstractMetaBuilderPrivate::parseQ_Property(AbstractMetaClass *metaClass, continue; } - QPropertySpec* spec = new QPropertySpec(type->typeEntry()); + auto *spec = new QPropertySpec(type->typeEntry()); spec->setName(propertyTokens.at(1).toString()); spec->setIndex(i); diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index 8b29c5477..acf01cce5 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -188,7 +188,7 @@ QString AbstractMetaType::fullName() const AbstractMetaType *AbstractMetaType::copy() const { - AbstractMetaType *cpy = new AbstractMetaType; + auto *cpy = new AbstractMetaType; cpy->setTypeUsagePattern(typeUsagePattern()); cpy->setConstant(isConstant()); @@ -427,7 +427,7 @@ void AbstractMetaArgument::assignMetaArgument(const AbstractMetaArgument &other) AbstractMetaArgument *AbstractMetaArgument::copy() const { - AbstractMetaArgument *copy = new AbstractMetaArgument; + auto *copy = new AbstractMetaArgument; copy->assignMetaArgument(*this); return copy; } @@ -587,7 +587,7 @@ AbstractMetaFunction::CompareResult AbstractMetaFunction::compareTo(const Abstra AbstractMetaFunction *AbstractMetaFunction::copy() const { - AbstractMetaFunction *cpy = new AbstractMetaFunction; + auto *cpy = new AbstractMetaFunction; cpy->assignMetaAttributes(*this); cpy->setName(name()); cpy->setOriginalName(originalName()); @@ -1406,7 +1406,7 @@ AbstractMetaClass *AbstractMetaClass::extractInterface() Q_ASSERT(typeEntry()->designatedInterface()); if (!m_extractedInterface) { - AbstractMetaClass *iface = new AbstractMetaClass; + auto *iface = new AbstractMetaClass; iface->setAttributes(attributes()); iface->setBaseClass(nullptr); @@ -1782,7 +1782,7 @@ AbstractMetaField::~AbstractMetaField() AbstractMetaField *AbstractMetaField::copy() const { - AbstractMetaField *returned = new AbstractMetaField; + auto *returned = new AbstractMetaField; returned->assignMetaVariable(*this); returned->assignMetaAttributes(*this); returned->setEnclosingClass(nullptr); @@ -1822,7 +1822,7 @@ static QString upCaseFirst(const QString &str) static AbstractMetaFunction *createXetter(const AbstractMetaField *g, const QString &name, AbstractMetaAttributes::Attributes type) { - AbstractMetaFunction *f = new AbstractMetaFunction; + auto *f = new AbstractMetaFunction; f->setName(name); f->setOriginalName(name); @@ -1880,7 +1880,7 @@ const AbstractMetaFunction *AbstractMetaField::setter() const QLatin1String("set") + upCaseFirst(name()), AbstractMetaAttributes::SetterFunction); AbstractMetaArgumentList arguments; - AbstractMetaArgument *argument = new AbstractMetaArgument; + auto *argument = new AbstractMetaArgument; argument->setType(type()->copy()); argument->setName(name()); arguments.append(argument); @@ -2000,7 +2000,7 @@ bool AbstractMetaClass::hasPrivateCopyConstructor() const void AbstractMetaClass::addDefaultConstructor() { - AbstractMetaFunction *f = new AbstractMetaFunction; + auto *f = new AbstractMetaFunction; f->setOriginalName(name()); f->setName(name()); f->setOwnerClass(this); @@ -2265,7 +2265,7 @@ static void addExtraIncludeForType(AbstractMetaClass *metaClass, const AbstractM Q_ASSERT(metaClass); const TypeEntry *entry = (type ? type->typeEntry() : nullptr); if (entry && entry->isComplex()) { - const ComplexTypeEntry *centry = static_cast<const ComplexTypeEntry *>(entry); + const auto *centry = static_cast<const ComplexTypeEntry *>(entry); ComplexTypeEntry *class_entry = metaClass->typeEntry(); if (class_entry && centry->include().isValid()) class_entry->addExtraInclude(centry->include()); diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp index e116f8b83..6303d09e5 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangparser.cpp @@ -119,7 +119,7 @@ QString BaseVisitor::getCodeSnippetString(const CXCursor &cursor) static CXChildVisitResult visitorCallback(CXCursor cursor, CXCursor /* parent */, CXClientData clientData) { - BaseVisitor *bv = reinterpret_cast<BaseVisitor *>(clientData); + auto *bv = reinterpret_cast<BaseVisitor *>(clientData); const CXSourceLocation location = clang_getCursorLocation(cursor); if (!bv->visitLocation(location)) diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.cpp b/sources/shiboken2/ApiExtractor/qtdocparser.cpp index 72fa67401..2e50470e4 100644 --- a/sources/shiboken2/ApiExtractor/qtdocparser.cpp +++ b/sources/shiboken2/ApiExtractor/qtdocparser.cpp @@ -54,7 +54,7 @@ static void formatFunctionArgTypeQuery(QTextStream &str, const AbstractMetaArgum case AbstractMetaType::FlagsPattern: { // Modify qualified name "QFlags<Qt::AlignmentFlag>" with name "Alignment" // to "Qt::Alignment" as seen by qdoc. - const FlagsTypeEntry *flagsEntry = static_cast<const FlagsTypeEntry *>(metaType->typeEntry()); + const auto *flagsEntry = static_cast<const FlagsTypeEntry *>(metaType->typeEntry()); QString name = flagsEntry->qualifiedCppName(); if (name.endsWith(QLatin1Char('>')) && name.startsWith(QLatin1String("QFlags<"))) { const int lastColon = name.lastIndexOf(QLatin1Char(':')); diff --git a/sources/shiboken2/ApiExtractor/tests/testutil.h b/sources/shiboken2/ApiExtractor/tests/testutil.h index c6ad19d7e..c8f446c14 100644 --- a/sources/shiboken2/ApiExtractor/tests/testutil.h +++ b/sources/shiboken2/ApiExtractor/tests/testutil.h @@ -69,7 +69,7 @@ namespace TestUtil arguments.append(QFile::encodeName(tempSource.fileName())); tempSource.write(cppCode, qint64(strlen(cppCode))); tempSource.close(); - AbstractMetaBuilder *builder = new AbstractMetaBuilder; + auto *builder = new AbstractMetaBuilder; if (!builder->build(arguments)) { delete builder; return Q_NULLPTR; diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 279be9dc0..06667caaf 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -351,7 +351,7 @@ TypeEntry *TypeDatabase::resolveTypeDefEntry(TypedefEntry *typedefEntry, return nullptr; } - ComplexTypeEntry *result = static_cast<ComplexTypeEntry *>(source->clone()); + auto *result = static_cast<ComplexTypeEntry *>(source->clone()); result->useAsTypedef(typedefEntry); typedefEntry->setSource(source); typedefEntry->setTarget(result); @@ -592,7 +592,7 @@ PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const const auto entries = findTypes(name); for (TypeEntry *entry : entries) { if (entry->isPrimitive()) { - PrimitiveTypeEntry *pe = static_cast<PrimitiveTypeEntry *>(entry); + auto *pe = static_cast<PrimitiveTypeEntry *>(entry); if (pe->preferredTargetLangType()) return pe; } diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp index d90e68175..dc3036671 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.cpp +++ b/sources/shiboken2/ApiExtractor/typesystem.cpp @@ -510,7 +510,7 @@ Handler::~Handler() = default; static QString readerFileName(const QXmlStreamReader &reader) { - const QFile *file = qobject_cast<const QFile *>(reader.device()); + const auto *file = qobject_cast<const QFile *>(reader.device()); return file != nullptr ? file->fileName() : QString(); } @@ -728,7 +728,7 @@ bool Handler::endElement(const QStringRef &localName) case StackElement::ValueTypeEntry: case StackElement::InterfaceTypeEntry: case StackElement::NamespaceTypeEntry: { - ComplexTypeEntry *centry = static_cast<ComplexTypeEntry *>(m_current->entry); + auto *centry = static_cast<ComplexTypeEntry *>(m_current->entry); centry->setAddedFunctions(m_contextStack.top()->addedFunctions); centry->setFunctionModifications(m_contextStack.top()->functionMods); centry->setFieldModifications(m_contextStack.top()->fieldMods); @@ -1148,8 +1148,7 @@ SmartPointerTypeEntry * return nullptr; } - SmartPointerTypeEntry *type = - new SmartPointerTypeEntry(name, getter, smartPointerType, refCountMethodName, since); + auto *type = new SmartPointerTypeEntry(name, getter, smartPointerType, refCountMethodName, since); applyCommonAttributes(type, attributes); return type; } @@ -1159,7 +1158,7 @@ PrimitiveTypeEntry * const QString &name, const QVersionNumber &since, QXmlStreamAttributes *attributes) { - PrimitiveTypeEntry *type = new PrimitiveTypeEntry(name, since); + auto *type = new PrimitiveTypeEntry(name, since); applyCommonAttributes(type, attributes); for (int i = attributes->size() - 1; i >= 0; --i) { const QStringRef name = attributes->at(i).qualifiedName(); @@ -1203,7 +1202,7 @@ ContainerTypeEntry * m_error = QLatin1String("there is no container of type ") + typeName.toString(); return nullptr; } - ContainerTypeEntry *type = new ContainerTypeEntry(name, containerType, since); + auto *type = new ContainerTypeEntry(name, containerType, since); applyCommonAttributes(type, attributes); return type; } @@ -1220,7 +1219,7 @@ EnumTypeEntry * scope = fullName.left(sep); name = fullName.right(fullName.size() - sep - 2); } - EnumTypeEntry *entry = new EnumTypeEntry(scope, name, since); + auto *entry = new EnumTypeEntry(scope, name, since); applyCommonAttributes(entry, attributes); entry->setTargetLangPackage(m_defaultPackage); @@ -1258,7 +1257,7 @@ ObjectTypeEntry * const QString &name, const QVersionNumber &since, QXmlStreamAttributes *attributes) { - ObjectTypeEntry *otype = new ObjectTypeEntry(name, since); + auto *otype = new ObjectTypeEntry(name, since); applyCommonAttributes(otype, attributes); QString targetLangName = name; bool generate = true; @@ -1331,7 +1330,7 @@ ValueTypeEntry * const QString &name, const QVersionNumber &since, QXmlStreamAttributes *attributes) { - ValueTypeEntry *typeEntry = new ValueTypeEntry(name, since); + auto *typeEntry = new ValueTypeEntry(name, since); applyCommonAttributes(typeEntry, attributes); const int defaultCtIndex = indexOfAttribute(*attributes, QStringViewLiteral("default-constructor")); @@ -1356,7 +1355,7 @@ FunctionTypeEntry * TypeEntry *existingType = m_database->findType(name); if (!existingType) { - FunctionTypeEntry *result = new FunctionTypeEntry(name, signature, since); + auto *result = new FunctionTypeEntry(name, signature, since); applyCommonAttributes(result, attributes); return result; } @@ -1367,7 +1366,7 @@ FunctionTypeEntry * return nullptr; } - FunctionTypeEntry *result = reinterpret_cast<FunctionTypeEntry *>(existingType); + auto *result = reinterpret_cast<FunctionTypeEntry *>(existingType); result->addSignature(signature); return result; } @@ -1626,7 +1625,7 @@ TypeSystemTypeEntry *Handler::parseRootElement(const QXmlStreamReader &, } } - TypeSystemTypeEntry *moduleEntry = + auto *moduleEntry = const_cast<TypeSystemTypeEntry *>(m_database->findTypeSystemType(m_defaultPackage)); const bool add = moduleEntry == nullptr; if (add) @@ -1768,7 +1767,7 @@ bool Handler::parseCustomConversion(const QXmlStreamReader &, } } - CustomConversion* customConversion = new CustomConversion(m_current->entry); + auto *customConversion = new CustomConversion(m_current->entry); customConversionsForReview.append(customConversion); return true; } @@ -2305,7 +2304,7 @@ CustomFunction * else if (name == QLatin1String("param-name")) paramName = attributes->takeAt(i).value().toString(); } - CustomFunction *func = new CustomFunction(functionName); + auto *func = new CustomFunction(functionName); func->paramName = paramName; return func; } @@ -2604,7 +2603,7 @@ bool Handler::startElement(const QXmlStreamReader &reader) return true; } - StackElement* element = new StackElement(m_current); + auto *element = new StackElement(m_current); element->type = elementType; if (element->type == StackElement::Root && m_generate == TypeEntry::GenerateAll) |