From ddfbbd346b522703a5b6f8d274a7f79983e5f319 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 09:33:27 +0200 Subject: shiboken: Introduce nullptr Apply Fixits by Qt Creator with some amendments. Change-Id: Ie8300ddb834adb8b649324562f2c912a4e8cf4ce Reviewed-by: Christian Tismer --- .../shiboken2/ApiExtractor/abstractmetabuilder.cpp | 50 +++++++++++----------- .../shiboken2/ApiExtractor/abstractmetalang.cpp | 24 +++++------ sources/shiboken2/ApiExtractor/abstractmetalang.h | 8 ++-- sources/shiboken2/ApiExtractor/apiextractor.cpp | 2 +- .../shiboken2/ApiExtractor/parser/codemodel.cpp | 2 +- sources/shiboken2/ApiExtractor/qtdocparser.cpp | 2 +- .../ApiExtractor/tests/testabstractmetaclass.cpp | 2 +- .../ApiExtractor/tests/testconversionoperator.cpp | 2 +- .../ApiExtractor/tests/testconversionruletag.cpp | 6 +-- .../ApiExtractor/tests/testimplicitconversions.cpp | 2 +- .../ApiExtractor/tests/testreverseoperators.cpp | 6 +-- sources/shiboken2/ApiExtractor/typedatabase.cpp | 12 +++--- sources/shiboken2/ApiExtractor/typesystem.cpp | 10 ++--- sources/shiboken2/ApiExtractor/typesystem.h | 2 +- sources/shiboken2/ApiExtractor/typesystem_p.h | 2 +- sources/shiboken2/generator/generator.h | 2 +- .../shiboken2/generator/qtdoc/qtdocgenerator.cpp | 12 +++--- .../shiboken2/generator/shiboken2/cppgenerator.cpp | 14 +++--- .../shiboken2/generator/shiboken2/cppgenerator.h | 4 +- .../shiboken2/generator/shiboken2/overloaddata.cpp | 12 +++--- .../generator/shiboken2/shibokengenerator.cpp | 4 +- .../generator/shiboken2/shibokengenerator.h | 6 +-- sources/shiboken2/libshiboken/autodecref.h | 4 +- sources/shiboken2/libshiboken/basewrapper.cpp | 48 ++++++++++----------- sources/shiboken2/libshiboken/basewrapper_p.h | 6 +-- sources/shiboken2/libshiboken/bindingmanager.cpp | 8 ++-- sources/shiboken2/libshiboken/helper.cpp | 10 ++--- sources/shiboken2/libshiboken/pep384impl.cpp | 6 +-- sources/shiboken2/libshiboken/qapp_macro.cpp | 12 +++--- sources/shiboken2/libshiboken/sbkconverter.cpp | 16 +++---- sources/shiboken2/libshiboken/sbkconverter.h | 6 +-- sources/shiboken2/libshiboken/sbkconverter_p.h | 40 ++++++++--------- sources/shiboken2/libshiboken/sbkenum.cpp | 32 +++++++------- sources/shiboken2/libshiboken/sbkenum.h | 2 +- sources/shiboken2/libshiboken/sbkstring.cpp | 4 +- sources/shiboken2/libshiboken/sbkstring.h | 2 +- sources/shiboken2/libshiboken/shibokenbuffer.h | 2 +- sources/shiboken2/libshiboken/signature.cpp | 26 +++++------ sources/shiboken2/libshiboken/threadstatesaver.cpp | 2 +- sources/shiboken2/libshiboken/voidptr.cpp | 36 ++++++++-------- sources/shiboken2/tests/libother/otherderived.cpp | 2 +- .../tests/libother/othermultiplederived.cpp | 2 +- sources/shiboken2/tests/libsample/abstract.cpp | 2 +- sources/shiboken2/tests/libsample/abstract.h | 2 +- sources/shiboken2/tests/libsample/blackbox.cpp | 6 +-- sources/shiboken2/tests/libsample/derived.cpp | 4 +- sources/shiboken2/tests/libsample/expression.cpp | 12 +++--- sources/shiboken2/tests/libsample/functions.cpp | 6 +-- sources/shiboken2/tests/libsample/handle.h | 2 +- sources/shiboken2/tests/libsample/modifications.h | 2 +- sources/shiboken2/tests/libsample/objectmodel.h | 4 +- sources/shiboken2/tests/libsample/objecttype.cpp | 16 +++---- sources/shiboken2/tests/libsample/objecttype.h | 2 +- sources/shiboken2/tests/libsample/objectview.h | 2 +- sources/shiboken2/tests/libsample/overload.h | 2 +- sources/shiboken2/tests/libsample/photon.h | 2 +- sources/shiboken2/tests/libsample/protected.h | 6 +-- .../shiboken2/tests/libsample/samplenamespace.cpp | 2 +- .../shiboken2/tests/libsample/samplenamespace.h | 10 ++--- sources/shiboken2/tests/libsample/simplefile.cpp | 6 +-- sources/shiboken2/tests/libsample/sometime.h | 2 +- sources/shiboken2/tests/libsample/str.h | 4 +- .../shiboken2/tests/libsample/virtualmethods.cpp | 2 +- sources/shiboken2/tests/libsample/voidholder.h | 2 +- sources/shiboken2/tests/libsmart/smart.h | 6 +-- 65 files changed, 278 insertions(+), 278 deletions(-) diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index b1f3fd5fb..b1c3b9114 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -441,7 +441,7 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) ReportHandler::startProgress("Generating enum model (" + QByteArray::number(enums.size()) + ")..."); for (const EnumModelItem &item : enums) { - AbstractMetaEnum *metaEnum = traverseEnum(item, 0, QSet()); + AbstractMetaEnum *metaEnum = traverseEnum(item, nullptr, QSet()); if (metaEnum) { if (metaEnum->typeEntry()->generateCode()) m_globalEnums << metaEnum; @@ -742,14 +742,14 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseNamespace(const FileModel if (TypeDatabase::instance()->isClassRejected(namespaceName)) { m_rejectedClasses.insert(namespaceName, AbstractMetaBuilder::GenerationDisabled); - return 0; + return nullptr; } auto type = TypeDatabase::instance()->findNamespaceType(namespaceName, namespaceItem->fileName()); if (!type) { qCWarning(lcShiboken).noquote().nospace() << QStringLiteral("namespace '%1' does not have a type entry").arg(namespaceName); - return 0; + return nullptr; } // Continue populating namespace? @@ -861,7 +861,7 @@ AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem & if (typeEntry) typeEntry->setCodeGeneration(TypeEntry::GenerateNothing); m_rejectedEnums.insert(qualifiedName + rejectReason, AbstractMetaBuilder::GenerationDisabled); - return 0; + return nullptr; } const bool rejectionWarning = !enclosing @@ -984,14 +984,14 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseTypeDef(const FileModelIt if (ptype) { QString typeDefName = typeDef->type().qualifiedName()[0]; ptype->setReferencedTypeEntry(types->findPrimitiveType(typeDefName)); - return 0; + return nullptr; } // If we haven't specified anything for the typedef, then we don't care ComplexTypeEntry *type = types->findComplexType(fullClassName); if (!type) - return 0; + return nullptr; AbstractMetaClass *metaClass = new AbstractMetaClass; metaClass->setTypeDef(true); @@ -1053,7 +1053,7 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseClass(const FileModelItem } if (reason != AbstractMetaBuilder::NoReason) { m_rejectedClasses.insert(fullClassName, reason); - return 0; + return nullptr; } AbstractMetaClass *metaClass = new AbstractMetaClass; @@ -1185,16 +1185,16 @@ AbstractMetaField *AbstractMetaBuilderPrivate::traverseField(const VariableModel // Ignore friend decl. if (field->isFriend()) - return 0; + return nullptr; if (field->accessPolicy() == CodeModel::Private) - return 0; + return nullptr; QString rejectReason; if (TypeDatabase::instance()->isFieldRejected(className, fieldName, &rejectReason)) { m_rejectedFields.insert(qualifiedFieldSignatureWithType(className, field) + rejectReason, AbstractMetaBuilder::GenerationDisabled); - return 0; + return nullptr; } @@ -1213,12 +1213,12 @@ AbstractMetaField *AbstractMetaBuilderPrivate::traverseField(const VariableModel .arg(cls->name(), fieldName, type); } delete metaField; - return 0; + return nullptr; } metaField->setType(metaType); - AbstractMetaAttributes::Attributes attr = 0; + AbstractMetaAttributes::Attributes attr = nullptr; if (field->isStatic()) attr |= AbstractMetaAttributes::Static; @@ -1316,7 +1316,7 @@ AbstractMetaFunctionList AbstractMetaBuilderPrivate::classFunctionList(const Sco AbstractMetaClass::Attributes *constructorAttributes, AbstractMetaClass *currentClass) { - *constructorAttributes = 0; + *constructorAttributes = nullptr; AbstractMetaFunctionList result; const FunctionList &scopeFunctionList = scopeItem->functions(); result.reserve(scopeFunctionList.size()); @@ -1369,7 +1369,7 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem, if (metaClass->isNamespace()) *metaFunction += AbstractMetaAttributes::Static; - QPropertySpec *read = 0; + QPropertySpec *read = nullptr; if (!metaFunction->isSignal() && (read = metaClass->propertySpecForRead(metaFunction->name()))) { // Property reader must be in the form " name()" if (metaFunction->type() && (read->type() == metaFunction->type()->typeEntry()) && (metaFunction->arguments().size() == 0)) { @@ -1434,7 +1434,7 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem, } if (!metaFunction->ownerClass()) { delete metaFunction; - metaFunction = 0; + metaFunction = nullptr; } } @@ -1604,7 +1604,7 @@ void AbstractMetaBuilderPrivate::traverseEnums(const ScopeModelItem &scopeItem, AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFunctionPtr &addedFunc) { - return traverseFunction(addedFunc, 0); + return traverseFunction(addedFunc, nullptr); } AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFunctionPtr &addedFunc, @@ -1833,7 +1833,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio return nullptr; if (functionItem->isFriend()) - return 0; + return nullptr; const bool deprecated = functionItem->isDeprecated(); if (deprecated && m_skipDeprecated) { @@ -1957,7 +1957,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio } break; } - Q_ASSERT(metaType == 0); + Q_ASSERT(metaType == nullptr); const QString reason = msgUnmatchedParameterType(arg, i, errorMessage); qCWarning(lcShiboken, "%s", qPrintable(msgSkippingFunction(functionItem, originalQualifiedSignatureWithReturn, reason))); @@ -2073,7 +2073,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const AddedFunction: QString typeName = typeInfo.name; if (typeName == QLatin1String("void")) - return 0; + return nullptr; type = typeDb->findType(typeName); @@ -2134,7 +2134,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const AddedFunction: static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaClass, const QString& qualifiedName) { - const TypeEntry* type = 0; + const TypeEntry* type = nullptr; QStringList context = metaClass->qualifiedCppName().split(colonColon()); while (!type && !context.isEmpty()) { type = TypeDatabase::instance()->findType(context.join(colonColon()) + colonColon() + qualifiedName); @@ -2268,7 +2268,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo typeInfo.clearInstantiations(); } - const TypeEntry *type = 0; + const TypeEntry *type = nullptr; // 5. Try to find the type // 5.1 - Try first using the current scope @@ -2537,7 +2537,7 @@ AbstractMetaClass* AbstractMetaBuilderPrivate::findTemplateClass(const QString & if (info) *info = parsed; - AbstractMetaClass* templ = 0; + AbstractMetaClass *templ = nullptr; for (AbstractMetaClass *c : qAsConst(m_templates)) { if (c->typeEntry()->name() == qualifiedName) { templ = c; @@ -2555,7 +2555,7 @@ AbstractMetaClass* AbstractMetaBuilderPrivate::findTemplateClass(const QString & *baseContainerType = types->findContainerType(qualifiedName); } - return 0; + return nullptr; } AbstractMetaClassList AbstractMetaBuilderPrivate::getBaseClasses(const AbstractMetaClass *metaClass) const @@ -2563,7 +2563,7 @@ AbstractMetaClassList AbstractMetaBuilderPrivate::getBaseClasses(const AbstractM AbstractMetaClassList baseClasses; const QStringList &baseClassNames = metaClass->baseClassNames(); for (const QString& parent : baseClassNames) { - AbstractMetaClass* cls = 0; + AbstractMetaClass *cls = nullptr; if (parent.contains(QLatin1Char('<'))) cls = findTemplateClass(parent, metaClass); else @@ -2865,7 +2865,7 @@ static AbstractMetaFunction* findCopyCtor(AbstractMetaClass* cls) if (t == AbstractMetaFunction::CopyConstructorFunction || t == AbstractMetaFunction::AssignmentOperatorFunction) return f; } - return 0; + return nullptr; } void AbstractMetaBuilderPrivate::setupClonable(AbstractMetaClass *cls) diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index 7bcad504d..8b29c5477 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -198,9 +198,9 @@ AbstractMetaType *AbstractMetaType::copy() const cpy->setInstantiations(instantiations()); cpy->setArrayElementCount(arrayElementCount()); cpy->setOriginalTypeDescription(originalTypeDescription()); - cpy->setOriginalTemplateType(originalTemplateType() ? originalTemplateType()->copy() : 0); + cpy->setOriginalTemplateType(originalTemplateType() ? originalTemplateType()->copy() : nullptr); - cpy->setArrayElementType(arrayElementType() ? arrayElementType()->copy() : 0); + cpy->setArrayElementType(arrayElementType() ? arrayElementType()->copy() : nullptr); cpy->setTypeEntry(typeEntry()); @@ -519,7 +519,7 @@ bool AbstractMetaFunction::operator<(const AbstractMetaFunction &other) const */ AbstractMetaFunction::CompareResult AbstractMetaFunction::compareTo(const AbstractMetaFunction *other) const { - CompareResult result = 0; + CompareResult result = nullptr; // Enclosing class... if (ownerClass() == other->ownerClass()) @@ -1408,7 +1408,7 @@ AbstractMetaClass *AbstractMetaClass::extractInterface() if (!m_extractedInterface) { AbstractMetaClass *iface = new AbstractMetaClass; iface->setAttributes(attributes()); - iface->setBaseClass(0); + iface->setBaseClass(nullptr); iface->setTypeEntry(typeEntry()->designatedInterface()); @@ -1712,7 +1712,7 @@ QPropertySpec *AbstractMetaClass::propertySpecForRead(const QString &name) const for (int i = 0; i < m_propertySpecs.size(); ++i) if (name == m_propertySpecs.at(i)->read()) return m_propertySpecs.at(i); - return 0; + return nullptr; } QPropertySpec *AbstractMetaClass::propertySpecForWrite(const QString &name) const @@ -1720,7 +1720,7 @@ QPropertySpec *AbstractMetaClass::propertySpecForWrite(const QString &name) cons for (int i = 0; i < m_propertySpecs.size(); ++i) if (name == m_propertySpecs.at(i)->write()) return m_propertySpecs.at(i); - return 0; + return nullptr; } QPropertySpec *AbstractMetaClass::propertySpecForReset(const QString &name) const @@ -1729,7 +1729,7 @@ QPropertySpec *AbstractMetaClass::propertySpecForReset(const QString &name) cons if (name == m_propertySpecs.at(i)->reset()) return m_propertySpecs.at(i); } - return 0; + return nullptr; } typedef QHash AbstractMetaClassBaseTemplateInstantiationsMap; @@ -2263,7 +2263,7 @@ static void addExtraIncludeForType(AbstractMetaClass *metaClass, const AbstractM return; Q_ASSERT(metaClass); - const TypeEntry *entry = (type ? type->typeEntry() : 0); + const TypeEntry *entry = (type ? type->typeEntry() : nullptr); if (entry && entry->isComplex()) { const ComplexTypeEntry *centry = static_cast(entry); ComplexTypeEntry *class_entry = metaClass->typeEntry(); @@ -2589,7 +2589,7 @@ AbstractMetaEnum *AbstractMetaClass::findEnum(const AbstractMetaClassList &class qCWarning(lcShiboken).noquote().nospace() << QStringLiteral("AbstractMeta::findEnum(), unknown class '%1' in '%2'") .arg(className, entry->qualifiedCppName()); - return 0; + return nullptr; } return metaClass->findEnum(enumName); @@ -2626,7 +2626,7 @@ AbstractMetaClass *AbstractMetaClass::findClass(const AbstractMetaClassList &cla const QString &name) { if (name.isEmpty()) - return 0; + return nullptr; for (AbstractMetaClass *c : classes) { if (c->qualifiedCppName() == name) @@ -2643,7 +2643,7 @@ AbstractMetaClass *AbstractMetaClass::findClass(const AbstractMetaClassList &cla return c; } - return 0; + return nullptr; } AbstractMetaClass *AbstractMetaClass::findClass(const AbstractMetaClassList &classes, @@ -2653,7 +2653,7 @@ AbstractMetaClass *AbstractMetaClass::findClass(const AbstractMetaClassList &cla if (c->typeEntry() == typeEntry) return c; } - return 0; + return nullptr; } #ifndef QT_NO_DEBUG_STREAM diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index e8ec21f48..6480257c7 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -587,7 +587,7 @@ public: } void setType(AbstractMetaType *type) { - Q_ASSERT(m_type == 0); + Q_ASSERT(m_type == nullptr); m_type = type; } void replaceType(AbstractMetaType *type) @@ -896,7 +896,7 @@ public: } void setType(AbstractMetaType *type) { - Q_ASSERT(m_type == 0); + Q_ASSERT(m_type == nullptr); m_type = type; } @@ -1053,12 +1053,12 @@ public: * \return true if there is some modification to function signature */ bool hasSignatureModifications() const; - FunctionModificationList modifications(const AbstractMetaClass* implementor = 0) const; + FunctionModificationList modifications(const AbstractMetaClass* implementor = nullptr) const; /** * Return the argument name if there is a modification the renamed value will be returned */ - QString argumentName(int index, bool create = true, const AbstractMetaClass *cl = 0) const; + QString argumentName(int index, bool create = true, const AbstractMetaClass *cl = nullptr) const; void setPropertySpec(QPropertySpec *spec) { diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp index 44fb70089..bd3ea9f18 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp @@ -168,7 +168,7 @@ ContainerTypeEntryList ApiExtractor::containerTypes() const static const AbstractMetaEnum* findEnumOnClasses(AbstractMetaClassList metaClasses, const EnumTypeEntry* typeEntry) { - const AbstractMetaEnum* result = 0; + const AbstractMetaEnum *result = nullptr; for (const AbstractMetaClass* metaClass : qAsConst(metaClasses)) { const AbstractMetaEnumList &enums = metaClass->enums(); for (const AbstractMetaEnum *metaEnum : enums) { diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp index 7bb7e0a83..b022f0c60 100644 --- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp @@ -161,7 +161,7 @@ bool TypeInfo::isVoid() const TypeInfo TypeInfo::resolveType(TypeInfo const &__type, const ScopeModelItem &__scope) { CodeModel *__model = __scope->model(); - Q_ASSERT(__model != 0); + Q_ASSERT(__model != nullptr); return TypeInfo::resolveType(__model->findItem(__type.qualifiedName(), __scope), __type, __scope); } diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.cpp b/sources/shiboken2/ApiExtractor/qtdocparser.cpp index c5ee1743d..72fa67401 100644 --- a/sources/shiboken2/ApiExtractor/qtdocparser.cpp +++ b/sources/shiboken2/ApiExtractor/qtdocparser.cpp @@ -212,7 +212,7 @@ void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass) const AbstractMetaClass* context = metaClass->enclosingClass(); while(context) { - if (context->enclosingClass() == 0) + if (context->enclosingClass() == nullptr) break; context = context->enclosingClass(); } diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp index 8a6b59285..98b493c67 100644 --- a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp @@ -134,7 +134,7 @@ public: const AbstractMetaClass *f = AbstractMetaClass::findClass(classes, QLatin1String("F")); QVERIFY(f); - AbstractMetaClass* no_class = 0; + AbstractMetaClass* no_class = nullptr; QCOMPARE(a->baseClass(), no_class); QCOMPARE(b->baseClass(), a); diff --git a/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp b/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp index 67865d3aa..142c783a4 100644 --- a/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testconversionoperator.cpp @@ -64,7 +64,7 @@ void TestConversionOperator::testConversionOperator() QCOMPARE(classC->functions().count(), 3); QCOMPARE(classA->externalConversionOperators().count(), 2); - AbstractMetaFunction* convOp = 0; + AbstractMetaFunction *convOp = nullptr; for (AbstractMetaFunction *func : classB->functions()) { if (func->isConversionOperator()) { convOp = func; diff --git a/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp b/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp index 8c662d76b..aa2bec5d6 100644 --- a/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testconversionruletag.cpp @@ -119,7 +119,7 @@ void TestConversionRuleTag::testConversionRuleTagReplace() QVERIFY(toNative); QCOMPARE(toNative->sourceTypeName(), QLatin1String("TargetNone")); QVERIFY(toNative->isCustomType()); - QCOMPARE(toNative->sourceType(), (const TypeEntry*)0); + QCOMPARE(toNative->sourceType(), nullptr); QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("%IN == Target_None")); QCOMPARE(toNative->conversion().simplified(), QLatin1String("DoThat(); DoSomething(); %OUT = A();")); @@ -138,7 +138,7 @@ void TestConversionRuleTag::testConversionRuleTagReplace() QVERIFY(toNative); QCOMPARE(toNative->sourceTypeName(), QLatin1String("String")); QVERIFY(toNative->isCustomType()); - QCOMPARE(toNative->sourceType(), (const TypeEntry*)0); + QCOMPARE(toNative->sourceType(), nullptr); QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("String_Check(%IN)")); QCOMPARE(toNative->conversion().trimmed(), QLatin1String("%OUT = new A(String_AsString(%IN), String_GetSize(%IN));")); } @@ -183,7 +183,7 @@ if (!TargetDateTimeAPI) TargetDateTime_IMPORT;\n\ QVERIFY(toNative); QCOMPARE(toNative->sourceTypeName(), QLatin1String("TargetDate")); QVERIFY(toNative->isCustomType()); - QCOMPARE(toNative->sourceType(), (const TypeEntry*)0); + QCOMPARE(toNative->sourceType(), nullptr); QCOMPARE(toNative->sourceTypeCheck(), QLatin1String("TargetDate_Check(%IN)")); QCOMPARE(toNative->conversion().trimmed(), QLatin1String("if (!TargetDateTimeAPI) TargetDateTime_IMPORT;\n%OUT = new Date(TargetDate_Day(%IN), TargetDate_Month(%IN), TargetDate_Year(%IN));")); diff --git a/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp index 7b3616daa..26fb148d5 100644 --- a/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testimplicitconversions.cpp @@ -151,7 +151,7 @@ void TestImplicitConversions::testWithExternalConversionOperator() AbstractMetaFunctionList externalConvOps = classA->externalConversionOperators(); QCOMPARE(externalConvOps.count(), 1); - const AbstractMetaFunction* convOp = 0; + const AbstractMetaFunction *convOp = nullptr; for (const AbstractMetaFunction *func : classB->functions()) { if (func->isConversionOperator()) convOp = func; diff --git a/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp b/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp index 2ea95595e..dc4801e18 100644 --- a/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testreverseoperators.cpp @@ -51,7 +51,7 @@ void TestReverseOperators::testReverseSum() QVERIFY(classA); QCOMPARE(classA->functions().count(), 4); - const AbstractMetaFunction* reverseOp = 0; + const AbstractMetaFunction* reverseOp = nullptr; const AbstractMetaFunction* normalOp = 0; for (const AbstractMetaFunction *func : classA->functions()) { if (func->name() == QLatin1String("operator+")) { @@ -100,8 +100,8 @@ void TestReverseOperators::testReverseSumWithAmbiguity() QVERIFY(classB); QCOMPARE(classB->functions().count(), 4); - const AbstractMetaFunction* reverseOp = 0; - const AbstractMetaFunction* normalOp = 0; + const AbstractMetaFunction *reverseOp = nullptr; + const AbstractMetaFunction *normalOp = nullptr; for (const AbstractMetaFunction *func : classB->functions()) { if (func->name() == QLatin1String("operator+")) { if (func->isReverseOperator()) diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 6a5e8d8ba..279be9dc0 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -68,7 +68,7 @@ TypeDatabase::~TypeDatabase() TypeDatabase* TypeDatabase::instance(bool newInstance) { - static TypeDatabase* db = 0; + static TypeDatabase *db = nullptr; if (!db || newInstance) { if (db) delete db; @@ -163,7 +163,7 @@ ContainerTypeEntry* TypeDatabase::findContainerType(const QString &name) const TypeEntry* type_entry = findType(template_name); if (type_entry && type_entry->isContainer()) return static_cast(type_entry); - return 0; + return nullptr; } static bool inline useType(const TypeEntry *t) @@ -179,7 +179,7 @@ FunctionTypeEntry* TypeDatabase::findFunctionType(const QString& name) const if (entry->type() == TypeEntry::FunctionType && useType(entry)) return static_cast(entry); } - return 0; + return nullptr; } void TypeDatabase::addTypeSystemType(const TypeSystemTypeEntry *e) @@ -598,7 +598,7 @@ PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString& name) const } } - return 0; + return nullptr; } ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const @@ -608,7 +608,7 @@ ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) const if (entry->isComplex() && useType(entry)) return static_cast(entry); } - return 0; + return nullptr; } ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const @@ -618,7 +618,7 @@ ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) const if (entry && entry->isObject() && useType(entry)) return static_cast(entry); } - return 0; + return nullptr; } NamespaceTypeEntryList TypeDatabase::findNamespaceTypes(const QString& name) const diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp index b4c94695d..d90e68175 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.cpp +++ b/sources/shiboken2/ApiExtractor/typesystem.cpp @@ -698,7 +698,7 @@ bool Handler::endElement(const QStringRef &localName) if (m_currentDroppedEntryDepth == 1) { m_current = m_currentDroppedEntry->parent; delete m_currentDroppedEntry; - m_currentDroppedEntry = 0; + m_currentDroppedEntry = nullptr; m_currentDroppedEntryDepth = 0; } else { --m_currentDroppedEntryDepth; @@ -785,7 +785,7 @@ bool Handler::endElement(const QStringRef &localName) case StackElement::EnumTypeEntry: m_current->entry->setDocModification(m_contextStack.top()->docModifications); m_contextStack.top()->docModifications = DocModificationList(); - m_currentEnum = 0; + m_currentEnum = nullptr; break; case StackElement::Template: m_database->addTemplate(m_current->value.templateEntry); @@ -2807,7 +2807,7 @@ bool Handler::startElement(const QXmlStreamReader &reader) return false; } - StackElement topElement = !m_current ? StackElement(0) : *m_current; + StackElement topElement = !m_current ? StackElement(nullptr) : *m_current; element->entry = topElement.entry; switch (element->type) { @@ -3003,7 +3003,7 @@ QString PrimitiveTypeEntry::targetLangApiName() const PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedTypeEntry() const { if (!m_referencedTypeEntry) - return 0; + return nullptr; PrimitiveTypeEntry *baseReferencedTypeEntry = m_referencedTypeEntry->basicReferencedTypeEntry(); return baseReferencedTypeEntry ? baseReferencedTypeEntry : m_referencedTypeEntry; @@ -3926,7 +3926,7 @@ struct CustomConversion::CustomConversionPrivate struct CustomConversion::TargetToNativeConversion::TargetToNativeConversionPrivate { TargetToNativeConversionPrivate() - : sourceType(0) + : sourceType(nullptr) { } const TypeEntry* sourceType; diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h index d95fad340..485dc981a 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.h +++ b/sources/shiboken2/ApiExtractor/typesystem.h @@ -770,7 +770,7 @@ public: virtual InterfaceTypeEntry *designatedInterface() const { - return 0; + return nullptr; } void setCustomConstructor(const CustomFunction &func) diff --git a/sources/shiboken2/ApiExtractor/typesystem_p.h b/sources/shiboken2/ApiExtractor/typesystem_p.h index 8a8fcb359..5b8b93cee 100644 --- a/sources/shiboken2/ApiExtractor/typesystem_p.h +++ b/sources/shiboken2/ApiExtractor/typesystem_p.h @@ -114,7 +114,7 @@ class StackElement ArgumentModifiers = 0xff000000 }; - StackElement(StackElement *p) : entry(0), type(None), parent(p) { } + StackElement(StackElement *p) : entry(nullptr), type(None), parent(p) { } TypeEntry* entry; ElementType type; diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index 1642752be..9d4201bc5 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -149,7 +149,7 @@ class GeneratorContext { public: GeneratorContext() = default; GeneratorContext(AbstractMetaClass *metaClass, - const AbstractMetaType *preciseType = 0, + const AbstractMetaType *preciseType = nullptr, bool forSmartPointer = false) : m_metaClass(metaClass), m_preciseClassType(preciseType), diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index 6abfde7c9..8d6c5903b 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -427,7 +427,7 @@ QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName) const { const QStringRef currentClass = m_context.splitRef(QLatin1Char('.')).constLast(); - const AbstractMetaClass* metaClass = 0; + const AbstractMetaClass *metaClass = nullptr; const AbstractMetaClassList &classes = m_generator->classes(); for (const AbstractMetaClass *cls : classes) { if (cls->name() == currentClass) { @@ -444,7 +444,7 @@ QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName) const funcList.append(func); } - const AbstractMetaClass* implementingClass = 0; + const AbstractMetaClass *implementingClass = nullptr; for (const AbstractMetaFunction *func : qAsConst(funcList)) { implementingClass = func->implementingClass(); if (implementingClass->name() == currentClass) @@ -1503,7 +1503,7 @@ static QString getFuncName(const AbstractMetaFunction* cppFunc) { return result; } -QtDocGenerator::QtDocGenerator() : m_docParser(0) +QtDocGenerator::QtDocGenerator() : m_docParser(nullptr) { } @@ -1656,8 +1656,8 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex "--------------------\n\n" << ".. _More:\n"; - writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, metaClass, 0); - if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, metaClass, 0)) + writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, metaClass, nullptr); + if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, metaClass, nullptr)) writeFormattedText(s, documentation, metaClass); if (!metaClass->isNamespace()) @@ -1679,7 +1679,7 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex writeFunction(s, metaClass, func); } - writeInjectDocumentation(s, TypeSystem::DocModificationAppend, metaClass, 0); + writeInjectDocumentation(s, TypeSystem::DocModificationAppend, metaClass, nullptr); } void QtDocGenerator::writeFunctionList(QTextStream& s, const AbstractMetaClass* cppClass) diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 73e1a7c3e..a37606923 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -1426,7 +1426,7 @@ void CppGenerator::writeConverterFunctions(QTextStream &s, const AbstractMetaCla pc << INDENT << getFullTypeNameWithoutModifiers(sourceType) << " cppIn"; writeMinimalConstructorExpression(pc, sourceType); pc << ';' << endl; - writeToCppConversion(pc, sourceType, 0, QLatin1String("pyIn"), QLatin1String("cppIn")); + writeToCppConversion(pc, sourceType, nullptr, QLatin1String("pyIn"), QLatin1String("cppIn")); pc << ';'; toCppConv.append(QLatin1String("cppIn")); } else if (!isWrapperType(sourceType)) { @@ -2265,7 +2265,7 @@ const AbstractMetaType *CppGenerator::getArgumentType(const AbstractMetaFunction if (argPos < 0 || argPos > func->arguments().size()) { qCWarning(lcShiboken).noquote().nospace() << QStringLiteral("Argument index for function '%1' out of range.").arg(func->signature()); - return 0; + return nullptr; } const AbstractMetaType *argType = nullptr; @@ -2600,7 +2600,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(QTextStream &s, const Ov || od->nextOverloadData().size() != 1 || od->overloads().size() != od->nextOverloadData().constFirst()->overloads().size()) { overloadData = od; - od = 0; + od = nullptr; } else { od = od->nextOverloadData().constFirst(); } @@ -3065,7 +3065,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction *func, int argIndex, const AbstractMetaClass **wrappedClass) { - *wrappedClass = 0; + *wrappedClass = nullptr; QString pyArgName; if (argIndex == -1) { pyArgName = QLatin1String("self"); @@ -4872,7 +4872,7 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEn s << "#endif" << endl << endl; s << INDENT << "cppResult = " << CPP_SELF_VAR << " " << cppOpName << " cppArg;" << endl; s << INDENT << "return "; - writeToPythonConversion(s, flagsType, 0, QLatin1String("cppResult")); + writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult")); s << ';' << endl; s << '}' << endl << endl; } @@ -4900,7 +4900,7 @@ void CppGenerator::writeFlagsUnaryOperator(QTextStream &s, const AbstractMetaEnu if (boolResult) s << "PyBool_FromLong(cppResult)"; else - writeToPythonConversion(s, flagsType, 0, QLatin1String("cppResult")); + writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult")); s << ';' << endl; s << '}' << endl << endl; } @@ -5479,7 +5479,7 @@ bool CppGenerator::finishGeneration() // Initialize smart pointer types. const QVector &smartPtrs = instantiatedSmartPointers(); for (const AbstractMetaType *metaType : smartPtrs) { - GeneratorContext context(0, metaType, true); + GeneratorContext context(nullptr, metaType, true); QString initFunctionName = getInitFunctionName(context); s_classInitDecl << "void init_" << initFunctionName << "(PyObject *module);" << endl; QString defineStr = QLatin1String("init_") + initFunctionName; diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h index 44a04653a..9a4a02093 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.h +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h @@ -117,7 +117,7 @@ private: */ void writeArgumentConversion(QTextStream &s, const AbstractMetaType *argType, const QString &argName, const QString &pyArgName, - const AbstractMetaClass *context = 0, + const AbstractMetaClass *context = nullptr, const QString &defaultValue = QString(), bool castArgumentAsUnused = false); @@ -138,7 +138,7 @@ private: const AbstractMetaType *type, const QString &pyIn, const QString &cppOut, - const AbstractMetaClass *context = 0, + const AbstractMetaClass *context = nullptr, const QString &defaultValue = QString()); /// Writes the conversion rule for arguments of regular and virtual methods. diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index 89c73576e..5c3d7d0b8 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -254,7 +254,7 @@ void OverloadData::sortNextOverloads() // be called. In the case of primitive types, list must come before list. if (instantiation->isPrimitive() && (signedIntegerPrimitives.contains(instantiation->name()))) { for (const QString &primitive : qAsConst(nonIntegerPrimitives)) - sortData.mapType(getImplicitConversionTypeName(ov->argType(), instantiation, 0, primitive)); + sortData.mapType(getImplicitConversionTypeName(ov->argType(), instantiation, nullptr, primitive)); } else { const AbstractMetaFunctionList &funcs = m_generator->implicitConversions(instantiation); for (const AbstractMetaFunction *function : funcs) @@ -346,7 +346,7 @@ void OverloadData::sortNextOverloads() if (instantiation->isPrimitive() && (signedIntegerPrimitives.contains(instantiation->name()))) { for (const QString &primitive : qAsConst(nonIntegerPrimitives)) { - QString convertibleTypeName = getImplicitConversionTypeName(ov->argType(), instantiation, 0, primitive); + QString convertibleTypeName = getImplicitConversionTypeName(ov->argType(), instantiation, nullptr, primitive); if (!graph.containsEdge(targetTypeId, sortData.map[convertibleTypeName])) // Avoid cyclic dependency. graph.addEdge(sortData.map[convertibleTypeName], targetTypeId); } @@ -467,8 +467,8 @@ void OverloadData::sortNextOverloads() * */ OverloadData::OverloadData(const AbstractMetaFunctionList &overloads, const ShibokenGenerator *generator) - : m_minArgs(256), m_maxArgs(0), m_argPos(-1), m_argType(0), - m_headOverloadData(this), m_previousOverloadData(0), m_generator(generator) + : m_minArgs(256), m_maxArgs(0), m_argPos(-1), m_argType(nullptr), + m_headOverloadData(this), m_previousOverloadData(nullptr), m_generator(generator) { for (const AbstractMetaFunction *func : overloads) { m_overloads.append(func); @@ -658,7 +658,7 @@ const AbstractMetaFunction *OverloadData::referenceFunction() const const AbstractMetaArgument *OverloadData::argument(const AbstractMetaFunction *func) const { if (isHeadOverloadData() || !m_overloads.contains(func)) - return 0; + return nullptr; int argPos = 0; int removed = 0; @@ -757,7 +757,7 @@ const AbstractMetaFunction *OverloadData::getFunctionWithDefaultValue() const if (!ShibokenGenerator::getDefaultValue(func, func->arguments().at(m_argPos + removedArgs)).isEmpty()) return func; } - return 0; + return nullptr; } QVector OverloadData::invalidArgumentLengths() const diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 9ed175af4..693576444 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -340,7 +340,7 @@ void ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumLi static const AbstractMetaClass *getProperEnclosingClass(const AbstractMetaClass *metaClass) { if (!metaClass) - return 0; + return nullptr; if (metaClass->typeEntry()->codeGeneration() != TypeEntry::GenerateForSubclass) return metaClass; @@ -1252,7 +1252,7 @@ QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry *type, bool gene QString ShibokenGenerator::guessCPythonCheckFunction(const QString &type, AbstractMetaType **metaType) { - *metaType = 0; + *metaType = nullptr; if (type == QLatin1String("PyTypeObject")) return QLatin1String("PyType_Check"); diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index fe6a1dc37..02231f1a0 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -118,7 +118,7 @@ protected: const QVector & codeSnips, TypeSystem::CodeSnipPosition position, TypeSystem::Language language, - const AbstractMetaClass *context = 0); + const AbstractMetaClass *context = nullptr); /// Write user's custom code snippets at function level. void writeCodeSnips(QTextStream &s, const QVector & codeSnips, @@ -312,8 +312,8 @@ protected: QString cpythonIsConvertibleFunction(const AbstractMetaArgument *metaArg, bool genericNumberType = false); QString cpythonToCppConversionFunction(const AbstractMetaClass *metaClass); - QString cpythonToCppConversionFunction(const AbstractMetaType *type, const AbstractMetaClass *context = 0); - QString cpythonToPythonConversionFunction(const AbstractMetaType *type, const AbstractMetaClass *context = 0); + QString cpythonToCppConversionFunction(const AbstractMetaType *type, const AbstractMetaClass *context = nullptr); + QString cpythonToPythonConversionFunction(const AbstractMetaType *type, const AbstractMetaClass *context = nullptr); QString cpythonToPythonConversionFunction(const AbstractMetaClass *metaClass); QString cpythonToPythonConversionFunction(const TypeEntry *type); diff --git a/sources/shiboken2/libshiboken/autodecref.h b/sources/shiboken2/libshiboken/autodecref.h index b2f5a6325..d3353b1e4 100644 --- a/sources/shiboken2/libshiboken/autodecref.h +++ b/sources/shiboken2/libshiboken/autodecref.h @@ -75,14 +75,14 @@ public: Py_XDECREF(m_pyObj); } - inline bool isNull() const { return m_pyObj == 0; } + inline bool isNull() const { return m_pyObj == nullptr; } /// Returns the pointer of the Python object being held. inline PyObject *object() { return m_pyObj; } inline operator PyObject *() { return m_pyObj; } #ifndef Py_LIMITED_API inline operator PyTupleObject *() { return reinterpret_cast(m_pyObj); } #endif - inline operator bool() const { return m_pyObj != 0; } + inline operator bool() const { return m_pyObj != nullptr; } inline PyObject *operator->() { return m_pyObj; } template diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index a12d95982..db7d0ad84 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -93,7 +93,7 @@ static PyType_Slot SbkObjectType_Type_slots[] = { {Py_tp_getset, (void *)SbkObjectType_Type_getsetlist}, {Py_tp_new, (void *)SbkObjectTypeTpNew}, {Py_tp_free, (void *)PyObject_GC_Del}, - {0, 0} + {0, nullptr} }; static PyType_Spec SbkObjectType_Type_spec = { "Shiboken.ObjectType", @@ -211,14 +211,14 @@ static PyObject *SbkObjectGetDict(PyObject *pObj, void *) if (!obj->ob_dict) obj->ob_dict = PyDict_New(); if (!obj->ob_dict) - return 0; + return nullptr; Py_INCREF(obj->ob_dict); return obj->ob_dict; } static PyGetSetDef SbkObjectGetSetList[] = { - {const_cast("__dict__"), SbkObjectGetDict, 0, 0, 0}, - {0, 0, 0, 0, 0} // Sentinel + {const_cast("__dict__"), SbkObjectGetDict, nullptr, nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel }; static int SbkObject_traverse(PyObject *self, visitproc visit, void *arg) @@ -267,7 +267,7 @@ static PyType_Slot SbkObject_Type_slots[] = { // unsupported: {Py_tp_weaklistoffset, (void *)offsetof(SbkObject, weakreflist)}, {Py_tp_getset, (void *)SbkObjectGetSetList}, // unsupported: {Py_tp_dictoffset, (void *)offsetof(SbkObject, ob_dict)}, - {0, 0} + {0, nullptr} }; static PyType_Spec SbkObject_Type_spec = { "Shiboken.Object", @@ -377,7 +377,7 @@ void SbkDeallocQAppWrapper(PyObject *pyObj) { SbkDeallocWrapper(pyObj); // PYSIDE-571: make sure to create a singleton deleted qApp. - MakeSingletonQAppWrapper(NULL); + MakeSingletonQAppWrapper(nullptr); } void SbkDeallocWrapperWithPrivateDtor(PyObject *self) @@ -431,7 +431,7 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k &name, &PyTuple_Type, &pyBases, &PyDict_Type, &dict)) - return NULL; + return nullptr; for (int i=0, i_max=PyTuple_GET_SIZE(pyBases); i < i_max; i++) { PyObject *baseType = PyTuple_GET_ITEM(pyBases, i); @@ -452,7 +452,7 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k newfunc type_new = reinterpret_cast(PyType_Type.tp_new); SbkObjectType *newType = reinterpret_cast(type_new(metatype, args, kwds)); if (!newType) - return 0; + return nullptr; Shiboken::ObjectType::initPrivateData(newType); SbkObjectTypePrivate *sotp = PepType_SOTP(newType); @@ -543,7 +543,7 @@ PyObject *SbkQAppTpNew(PyTypeObject *subtype, PyObject *, PyObject *) } #endif auto self = reinterpret_cast(MakeSingletonQAppWrapper(subtype)); - return self == 0 ? 0 : _setupNew(self, subtype); + return self == nullptr ? nullptr : _setupNew(self, subtype); } void @@ -622,7 +622,7 @@ bool importModule(const char *moduleName, PyTypeObject *** cppApiPtr) #ifdef IS_PY3K if (PyCapsule_CheckExact(cppApi)) - *cppApiPtr = reinterpret_cast(PyCapsule_GetPointer(cppApi, 0)); + *cppApiPtr = reinterpret_cast(PyCapsule_GetPointer(cppApi, nullptr)); #else // Python 2.6 doesn't have PyCapsule API, so let's keep usign PyCObject on all Python 2.x if (PyCObject_Check(cppApi)) @@ -766,7 +766,7 @@ bool canCallConstructor(PyTypeObject *myType, PyTypeObject *ctorType) bool hasCast(SbkObjectType *type) { - return PepType_SOTP(type)->mi_specialcast != 0; + return PepType_SOTP(type)->mi_specialcast != nullptr; } void *cast(SbkObjectType *sourceType, SbkObject *obj, PyTypeObject *targetType) @@ -1007,7 +1007,7 @@ void callCppDestructors(SbkObject *pyObj) } delete[] pyObj->d->cptr; - pyObj->d->cptr = 0; + pyObj->d->cptr = nullptr; pyObj->d->validCppObject = false; } @@ -1155,7 +1155,7 @@ void *cppPointer(SbkObject *pyObj, PyTypeObject *desiredType) idx = getTypeIndexOnHierarchy(type, desiredType); if (pyObj->d->cptr) return pyObj->d->cptr[idx]; - return 0; + return nullptr; } std::vector cppPointers(SbkObject *pyObj) @@ -1175,7 +1175,7 @@ bool setCppPointer(SbkObject *sbkObj, PyTypeObject *desiredType, void *cptr) if (PepType_SOTP(type)->is_multicpp) idx = getTypeIndexOnHierarchy(type, desiredType); - const bool alreadyInitialized = sbkObj->d->cptr[idx] != 0; + const bool alreadyInitialized = sbkObj->d->cptr[idx] != nullptr; if (alreadyInitialized) PyErr_SetString(PyExc_RuntimeError, "You can't initialize an object twice!"); else @@ -1249,11 +1249,11 @@ SbkObject *findColocatedChild(SbkObject *wrapper, return wrapper; if (!(wrapper->d && wrapper->d->cptr)) - return 0; + return nullptr; ParentInfo *pInfo = wrapper->d->parentInfo; if (!pInfo) - return 0; + return nullptr; ChildrenList &children = pInfo->children; @@ -1267,7 +1267,7 @@ SbkObject *findColocatedChild(SbkObject *wrapper, return findColocatedChild(child, instanceType); } } - return 0; + return nullptr; } PyObject *newObject(SbkObjectType *instanceType, @@ -1286,7 +1286,7 @@ PyObject *newObject(SbkObjectType *instanceType, bool shouldCreate = true; bool shouldRegister = true; - SbkObject *self = 0; + SbkObject *self = nullptr; // Some logic to ensure that colocated child field does not overwrite the parent if (BindingManager::instance().hasWrapper(cptr)) { @@ -1313,7 +1313,7 @@ PyObject *newObject(SbkObjectType *instanceType, } if (shouldCreate) { - self = reinterpret_cast(SbkObjectTpNew(reinterpret_cast(instanceType), 0, 0)); + self = reinterpret_cast(SbkObjectTpNew(reinterpret_cast(instanceType), nullptr, nullptr)); self->d->cptr[0] = cptr; self->d->hasOwnership = hasOwnership; self->d->validCppObject = 1; @@ -1328,7 +1328,7 @@ PyObject *newObject(SbkObjectType *instanceType, void destroy(SbkObject *self) { - destroy(self, 0); + destroy(self, nullptr); } void destroy(SbkObject *self, void *cppData) @@ -1369,7 +1369,7 @@ void destroy(SbkObject *self, void *cppData) // the cpp object instance was deleted delete[] self->d->cptr; - self->d->cptr = 0; + self->d->cptr = nullptr; } // After this point the object can be death do not use the self pointer bellow @@ -1393,7 +1393,7 @@ void removeParent(SbkObject *child, bool giveOwnershipBack, bool keepReference) oldBrothers.erase(iChild); - pInfo->parent = 0; + pInfo->parent = nullptr; // This will keep the wrapper reference, will wait for wrapper destruction to remove that if (keepReference && @@ -1427,7 +1427,7 @@ void setParent(PyObject *parent, PyObject *child) * follows the sequence protocol. */ if (PySequence_Check(child) && !Object::checkType(child)) { - Shiboken::AutoDecRef seq(PySequence_Fast(child, 0)); + Shiboken::AutoDecRef seq(PySequence_Fast(child, nullptr)); for (Py_ssize_t i = 0, max = PySequence_Size(seq); i < max; ++i) setParent(parent, PySequence_Fast_GET_ITEM(seq.object(), i)); return; @@ -1492,7 +1492,7 @@ void deallocData(SbkObject *self, bool cleanup) // Remove from BindingManager Shiboken::BindingManager::instance().releaseWrapper(self); delete[] self->d->cptr; - self->d->cptr = 0; + self->d->cptr = nullptr; // delete self->d; PYSIDE-205: wrong! } delete self->d; // PYSIDE-205: always delete d. diff --git a/sources/shiboken2/libshiboken/basewrapper_p.h b/sources/shiboken2/libshiboken/basewrapper_p.h index feba6561e..d119c7ec6 100644 --- a/sources/shiboken2/libshiboken/basewrapper_p.h +++ b/sources/shiboken2/libshiboken/basewrapper_p.h @@ -67,7 +67,7 @@ using ChildrenList = std::set; struct ParentInfo { /// Default ctor. - ParentInfo() : parent(0), hasWrapperRef(false) {} + ParentInfo() : parent(nullptr), hasWrapperRef(false) {} /// Pointer to parent object. SbkObject *parent; /// List of object children. @@ -105,9 +105,9 @@ struct SbkObjectPrivate ~SbkObjectPrivate() { delete parentInfo; - parentInfo = 0; + parentInfo = nullptr; delete referredObjects; - referredObjects = 0; + referredObjects = nullptr; } }; diff --git a/sources/shiboken2/libshiboken/bindingmanager.cpp b/sources/shiboken2/libshiboken/bindingmanager.cpp index c526d9b2e..92451a153 100644 --- a/sources/shiboken2/libshiboken/bindingmanager.cpp +++ b/sources/shiboken2/libshiboken/bindingmanager.cpp @@ -155,7 +155,7 @@ bool BindingManager::BindingManagerPrivate::releaseWrapper(void *cptr, SbkObject // Returns true if the correct wrapper is found and released. // If wrapper argument is NULL, no such check is performed. WrapperMap::iterator iter = wrapperMapper.find(cptr); - if (iter != wrapperMapper.end() && (wrapper == 0 || iter->second == wrapper)) { + if (iter != wrapperMapper.end() && (wrapper == nullptr || iter->second == wrapper)) { wrapperMapper.erase(iter); return true; } @@ -268,7 +268,7 @@ SbkObject *BindingManager::retrieveWrapper(const void *cptr) { WrapperMap::iterator iter = m_d->wrapperMapper.find(cptr); if (iter == m_d->wrapperMapper.end()) - return 0; + return nullptr; return iter->second; } @@ -278,7 +278,7 @@ PyObject *BindingManager::getOverride(const void *cptr, const char *methodName) // The refcount can be 0 if the object is dieing and someone called // a virtual method from the destructor if (!wrapper || reinterpret_cast(wrapper)->ob_refcnt == 0) - return 0; + return nullptr; if (wrapper->ob_dict) { PyObject *method = PyDict_GetItemString(wrapper->ob_dict, methodName); @@ -312,7 +312,7 @@ PyObject *BindingManager::getOverride(const void *cptr, const char *methodName) Py_XDECREF(method); Py_DECREF(pyMethodName); - return 0; + return nullptr; } void BindingManager::addClassInheritance(SbkObjectType *parent, SbkObjectType *child) diff --git a/sources/shiboken2/libshiboken/helper.cpp b/sources/shiboken2/libshiboken/helper.cpp index 1a2dc7ab9..85ae2b133 100644 --- a/sources/shiboken2/libshiboken/helper.cpp +++ b/sources/shiboken2/libshiboken/helper.cpp @@ -60,7 +60,7 @@ bool listToArgcArgv(PyObject *argList, int *argc, char ***argv, const char *defa defaultAppName = "PySideApplication"; // Check all items - Shiboken::AutoDecRef args(PySequence_Fast(argList, 0)); + Shiboken::AutoDecRef args(PySequence_Fast(argList, nullptr)); int numArgs = int(PySequence_Fast_GET_SIZE(argList)); for (int i = 0; i < numArgs; ++i) { PyObject *item = PyList_GET_ITEM(args.object(), i); @@ -83,7 +83,7 @@ bool listToArgcArgv(PyObject *argList, int *argc, char ***argv, const char *defa } else { for (int i = 0; i < numArgs; ++i) { PyObject *item = PyList_GET_ITEM(args.object(), i); - char *string = 0; + char *string = nullptr; if (Shiboken::String::check(item)) { string = strdup(Shiboken::String::toCString(item)); } @@ -98,7 +98,7 @@ int *sequenceToIntArray(PyObject *obj, bool zeroTerminated) { AutoDecRef seq(PySequence_Fast(obj, "Sequence of ints expected")); if (seq.isNull()) - return 0; + return nullptr; Py_ssize_t size = PySequence_Fast_GET_SIZE(seq.object()); int *array = new int[size + (zeroTerminated ? 1 : 0)]; @@ -108,7 +108,7 @@ int *sequenceToIntArray(PyObject *obj, bool zeroTerminated) if (!PyInt_Check(item)) { PyErr_SetString(PyExc_TypeError, "Sequence of ints expected"); delete[] array; - return 0; + return nullptr; } else { array[i] = PyInt_AsLong(item); } @@ -133,7 +133,7 @@ int warning(PyObject *category, int stacklevel, const char *format, ...) #endif // check the necessary memory - int size = vsnprintf(NULL, 0, format, args) + 1; + int size = vsnprintf(nullptr, 0, format, args) + 1; auto message = new char[size]; int result = 0; if (message) { diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index ac0328b6b..8a2930fc8 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -74,11 +74,11 @@ dummy_func(PyObject *self, PyObject *args) static struct PyMethodDef probe_methoddef[] = { {"dummy", dummy_func, METH_NOARGS}, - {0} + {nullptr} }; static PyGetSetDef probe_getseters[] = { - {0} /* Sentinel */ + {nullptr} /* Sentinel */ }; #define probe_tp_call make_dummy(1) @@ -110,7 +110,7 @@ static PyType_Slot typeprobe_slots[] = { {Py_tp_new, probe_tp_new}, {Py_tp_free, probe_tp_free}, {Py_tp_is_gc, probe_tp_is_gc}, - {0, 0} + {0, nullptr} }; static PyType_Spec typeprobe_spec = { probe_tp_name, diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp index ea9cf0c86..cab205970 100644 --- a/sources/shiboken2/libshiboken/qapp_macro.cpp +++ b/sources/shiboken2/libshiboken/qapp_macro.cpp @@ -87,9 +87,9 @@ static SbkObject _Py_ChameleonQAppWrapper_Struct = { BRACE_CLOSE }; -static PyObject *qApp_var = NULL; +static PyObject *qApp_var = nullptr; static PyObject *qApp_content = (PyObject *)&_Py_ChameleonQAppWrapper_Struct; -static PyObject *qApp_moduledicts[5] = {0, 0, 0, 0, 0}; +static PyObject *qApp_moduledicts[5] = {nullptr, nullptr, nullptr, nullptr, nullptr}; static int qApp_var_ref = 0; static int qApp_content_ref = 0; @@ -120,17 +120,17 @@ reset_qApp_var(void) PyObject * MakeSingletonQAppWrapper(PyTypeObject *type) { - if (type == NULL) + if (type == nullptr) type = Py_NONE_TYPE; if (!(type == Py_NONE_TYPE || Py_TYPE(qApp_content) == Py_NONE_TYPE)) { const char *res_name = PepType_GetNameStr(Py_TYPE(qApp_content)); const char *type_name = PepType_GetNameStr(type); PyErr_Format(PyExc_RuntimeError, "Please destroy the %s singleton before" " creating a new %s instance.", res_name, type_name); - return NULL; + return nullptr; } if (reset_qApp_var() < 0) - return NULL; + return nullptr; // always know the max of the refs if (Py_REFCNT(qApp_var) > qApp_var_ref) qApp_var_ref = Py_REFCNT(qApp_var); @@ -201,7 +201,7 @@ setup_qApp_var(PyObject *module) Py_NONE_TYPE->tp_as_number = &none_as_number; #endif qApp_var = Py_BuildValue("s", "qApp"); - if (qApp_var == NULL) + if (qApp_var == nullptr) return -1; // This is a borrowed reference qApp_moduledicts[0] = PyEval_GetBuiltins(); diff --git a/sources/shiboken2/libshiboken/sbkconverter.cpp b/sources/shiboken2/libshiboken/sbkconverter.cpp index 15afd5933..45551666a 100644 --- a/sources/shiboken2/libshiboken/sbkconverter.cpp +++ b/sources/shiboken2/libshiboken/sbkconverter.cpp @@ -143,7 +143,7 @@ SbkConverter *createConverter(SbkObjectType *type, SbkConverter *createConverter(PyTypeObject *type, CppToPythonFunc toPythonFunc) { - return createConverterObject(type, 0, 0, 0, toPythonFunc); + return createConverterObject(type, nullptr, nullptr, nullptr, toPythonFunc); } void deleteConverter(SbkConverter *converter) @@ -252,7 +252,7 @@ static inline PythonToCppFunc IsPythonToCppConvertible(const SbkConverter *conve if (PythonToCppFunc toCppFunc = c.first(pyIn)) return toCppFunc; } - return 0; + return nullptr; } PythonToCppFunc isPythonToCppValueConvertible(SbkObjectType *type, PyObject *pyIn) { @@ -307,7 +307,7 @@ void pythonToCppPointer(SbkObjectType *type, PyObject *pyIn, void *cppOut) assert(pyIn); assert(cppOut); *reinterpret_cast(cppOut) = pyIn == Py_None - ? 0 + ? nullptr : cppPointer(reinterpret_cast(type), reinterpret_cast(pyIn)); } @@ -317,7 +317,7 @@ void pythonToCppPointer(const SbkConverter *converter, PyObject *pyIn, void *cpp assert(pyIn); assert(cppOut); *reinterpret_cast(cppOut) = pyIn == Py_None - ? 0 + ? nullptr : cppPointer(reinterpret_cast(converter->pythonType), reinterpret_cast(pyIn)); } @@ -379,7 +379,7 @@ SbkConverter *getConverter(const char *typeName) return it->second; if (Py_VerboseFlag > 0) SbkDbg() << "Can't find type resolver for type '" << typeName << "'."; - return 0; + return nullptr; } SbkConverter *primitiveTypeConverter(int index) @@ -518,7 +518,7 @@ PyTypeObject *getPythonTypeObject(const SbkConverter *converter) { if (converter) return converter->pythonType; - return 0; + return nullptr; } PyTypeObject *getPythonTypeObject(const char *typeName) @@ -542,7 +542,7 @@ bool pythonTypeIsObjectType(const SbkConverter *converter) bool pythonTypeIsWrapperType(const SbkConverter *converter) { - return converter->pointerToPython != 0; + return converter->pointerToPython != nullptr; } SpecificConverter::SpecificConverter(const char *typeName) @@ -574,7 +574,7 @@ PyObject *SpecificConverter::toPython(const void *cppIn) default: PyErr_SetString(PyExc_RuntimeError, "tried to use invalid converter in 'C++ to Python' conversion"); } - return 0; + return nullptr; } void SpecificConverter::toCpp(PyObject *pyIn, void *cppOut) diff --git a/sources/shiboken2/libshiboken/sbkconverter.h b/sources/shiboken2/libshiboken/sbkconverter.h index 2d1735f2b..6c7a29300 100644 --- a/sources/shiboken2/libshiboken/sbkconverter.h +++ b/sources/shiboken2/libshiboken/sbkconverter.h @@ -151,7 +151,7 @@ LIBSHIBOKEN_API SbkConverter *createConverter(SbkObjectType *type, PythonToCppFunc toCppPointerConvFunc, IsConvertibleToCppFunc toCppPointerCheckFunc, CppToPythonFunc pointerToPythonFunc, - CppToPythonFunc copyToPythonFunc = 0); + CppToPythonFunc copyToPythonFunc = nullptr); /** * Creates a converter for a non wrapper type (primitive or container type). @@ -343,7 +343,7 @@ LIBSHIBOKEN_API bool pythonTypeIsWrapperType(const SbkConverter *converter); #define SBK_VOIDPTR_IDX 16 #define SBK_NULLPTR_T_IDX 17 -template SbkConverter *PrimitiveTypeConverter() { return 0; } +template SbkConverter *PrimitiveTypeConverter() { return nullptr; } template<> inline SbkConverter *PrimitiveTypeConverter() { return primitiveTypeConverter(SBK_PY_LONG_LONG_IDX); } template<> inline SbkConverter *PrimitiveTypeConverter() { return primitiveTypeConverter(SBK_BOOL_IDX_1); } template<> inline SbkConverter *PrimitiveTypeConverter() { return primitiveTypeConverter(SBK_CHAR_IDX); } @@ -371,7 +371,7 @@ template<> inline SbkConverter *PrimitiveTypeConverter() { retur * T isn't a C++ primitive type. * \see SpecialCastFunction */ -template PyTypeObject *SbkType() { return 0; } +template PyTypeObject *SbkType() { return nullptr; } // Below are the template specializations for C++ primitive types. template<> inline PyTypeObject *SbkType() { return &PyLong_Type; } diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h index aa90094af..84de2099a 100644 --- a/sources/shiboken2/libshiboken/sbkconverter_p.h +++ b/sources/shiboken2/libshiboken/sbkconverter_p.h @@ -112,11 +112,11 @@ struct SbkConverter template struct OverFlowCheckerBase { static void formatOverFlowMessage(const MaxLimitType &value, - const std::string *valueAsString = 0) + const std::string *valueAsString = nullptr) { std::ostringstream str; str << "libshiboken: Overflow: Value "; - if (valueAsString != 0 && !valueAsString->empty()) + if (valueAsString != nullptr && !valueAsString->empty()) str << *valueAsString; else str << value; @@ -261,27 +261,27 @@ struct IntPrimitive : TwoPrimitive double result = PyFloat_AS_DOUBLE(pyIn); // If cast to long directly it could overflow silently. if (OverFlowChecker::check(result, pyIn)) - PyErr_SetObject(PyExc_OverflowError, 0); + PyErr_SetObject(PyExc_OverflowError, nullptr); *reinterpret_cast(cppOut) = static_cast(result); } static PythonToCppFunc isConvertible(PyObject *pyIn) { if (PyFloat_Check(pyIn)) return toCpp; - return 0; + return nullptr; } static void otherToCpp(PyObject *pyIn, void *cppOut) { PY_LONG_LONG result = PyLong_AsLongLong(pyIn); if (OverFlowChecker::check(result, pyIn)) - PyErr_SetObject(PyExc_OverflowError, 0); + PyErr_SetObject(PyExc_OverflowError, nullptr); *reinterpret_cast(cppOut) = static_cast(result); } static PythonToCppFunc isOtherConvertible(PyObject *pyIn) { if (SbkNumber_Check(pyIn)) return otherToCpp; - return 0; + return nullptr; } }; template <> struct Primitive : IntPrimitive {}; @@ -322,7 +322,7 @@ struct Primitive : OnePrimitive { if (SbkNumber_Check(pyIn)) return toCpp; - return 0; + return nullptr; } }; @@ -339,7 +339,7 @@ struct Primitive : OnePrimitive if (PyLong_Check(pyIn)) { unsigned PY_LONG_LONG result = PyLong_AsUnsignedLongLong(pyIn); if (OverFlowChecker::check(result, pyIn)) - PyErr_SetObject(PyExc_OverflowError, 0); + PyErr_SetObject(PyExc_OverflowError, nullptr); *reinterpret_cast(cppOut) = result; } else { @@ -366,7 +366,7 @@ struct Primitive : OnePrimitive { if (SbkNumber_Check(pyIn)) return toCpp; - return 0; + return nullptr; } }; @@ -387,7 +387,7 @@ struct FloatPrimitive : TwoPrimitive { if (PyInt_Check(pyIn) || PyLong_Check(pyIn)) return toCpp; - return 0; + return nullptr; } static void otherToCpp(PyObject *pyIn, void *cppOut) { @@ -397,7 +397,7 @@ struct FloatPrimitive : TwoPrimitive { if (SbkNumber_Check(pyIn)) return otherToCpp; - return 0; + return nullptr; } }; template <> struct Primitive : FloatPrimitive {}; @@ -416,7 +416,7 @@ struct Primitive : OnePrimitive { if (SbkNumber_Check(pyIn)) return toCpp; - return 0; + return nullptr; } static void toCpp(PyObject *pyIn, void *cppOut) { @@ -437,20 +437,20 @@ struct CharPrimitive : IntPrimitive { if (Shiboken::String::checkChar(pyIn)) return toCpp; - return 0; + return nullptr; } static void otherToCpp(PyObject *pyIn, void *cppOut) { PY_LONG_LONG result = PyLong_AsLongLong(pyIn); if (OverFlowChecker::check(result, pyIn)) - PyErr_SetObject(PyExc_OverflowError, 0); + PyErr_SetObject(PyExc_OverflowError, nullptr); *reinterpret_cast(cppOut) = CHAR(result); } static PythonToCppFunc isOtherConvertible(PyObject *pyIn) { if (SbkNumber_Check(pyIn)) return otherToCpp; - return 0; + return nullptr; } static SbkConverter *createConverter() { @@ -484,13 +484,13 @@ struct Primitive : TwoPrimitive } static void toCpp(PyObject *, void *cppOut) { - *((const char **)cppOut) = 0; + *((const char **)cppOut) = nullptr; } static PythonToCppFunc isConvertible(PyObject *pyIn) { if (pyIn == Py_None) return toCpp; - return 0; + return nullptr; } static void otherToCpp(PyObject *pyIn, void *cppOut) { @@ -500,7 +500,7 @@ struct Primitive : TwoPrimitive { if (Shiboken::String::check(pyIn)) return otherToCpp; - return 0; + return nullptr; } }; @@ -519,7 +519,7 @@ struct Primitive : TwoPrimitive { if (pyIn == Py_None) return toCpp; - return 0; + return nullptr; } static void otherToCpp(PyObject *pyIn, void *cppOut) { @@ -529,7 +529,7 @@ struct Primitive : TwoPrimitive { if (Shiboken::String::check(pyIn)) return otherToCpp; - return 0; + return nullptr; } }; diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp index 75054ab71..78dba3c54 100644 --- a/sources/shiboken2/libshiboken/sbkenum.cpp +++ b/sources/shiboken2/libshiboken/sbkenum.cpp @@ -88,7 +88,7 @@ static PyObject *SbkEnumObject_name(PyObject *self, void *) { SbkEnumObject *enum_self = SBK_ENUM(self); - if (enum_self->ob_name == NULL) + if (enum_self->ob_name == nullptr) Py_RETURN_NONE; Py_INCREF(enum_self->ob_name); @@ -99,18 +99,18 @@ static PyObject *SbkEnum_tp_new(PyTypeObject *type, PyObject *args, PyObject *) { long itemValue = 0; if (!PyArg_ParseTuple(args, "|l:__new__", &itemValue)) - return 0; + return nullptr; SbkEnumObject *self = PyObject_New(SbkEnumObject, type); if (!self) - return 0; + return nullptr; self->ob_value = itemValue; PyObject *item = Shiboken::Enum::getEnumItemFromValue(type, itemValue); if (item) { - self->ob_name = SbkEnumObject_name(item, 0); + self->ob_name = SbkEnumObject_name(item, nullptr); Py_XDECREF(item); } else { - self->ob_name = 0; + self->ob_name = nullptr; } return reinterpret_cast(self); } @@ -256,7 +256,7 @@ static Py_hash_t enum_hash(PyObject *pyObj) static PyGetSetDef SbkEnumGetSetList[] = { {const_cast("name"), &SbkEnumObject_name, nullptr, nullptr, nullptr}, - {0, 0, 0, 0, 0} // Sentinel + {nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel }; static void SbkEnumTypeDealloc(PyObject *pyObj); @@ -286,7 +286,7 @@ static PyType_Slot SbkEnumType_Type_slots[] = { {Py_tp_alloc, (void *)PyType_GenericAlloc}, {Py_tp_new, (void *)SbkEnumTypeTpNew}, {Py_tp_free, (void *)PyObject_GC_Del}, - {0, 0} + {0, nullptr} }; static PyType_Spec SbkEnumType_Type_spec = { "Shiboken.EnumType", @@ -329,7 +329,7 @@ PyObject *SbkEnumTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *kwd newfunc type_new = reinterpret_cast(PyType_GetSlot(&PyType_Type, Py_tp_new)); auto newType = reinterpret_cast(type_new(metatype, args, kwds)); if (!newType) - return 0; + return nullptr; return reinterpret_cast(newType); } @@ -374,7 +374,7 @@ PyObject *getEnumItemFromValue(PyTypeObject *enumType, long itemValue) return value; } } - return 0; + return nullptr; } static PyTypeObject *createEnum(const char *fullName, const char *cppName, @@ -383,7 +383,7 @@ static PyTypeObject *createEnum(const char *fullName, const char *cppName, { PyTypeObject *enumType = newTypeWithName(fullName, cppName, flagsType); if (PyType_Ready(enumType) < 0) - return 0; + return nullptr; return enumType; } @@ -391,10 +391,10 @@ PyTypeObject *createGlobalEnum(PyObject *module, const char *name, const char *f { PyTypeObject *enumType = createEnum(fullName, cppName, name, flagsType); if (enumType && PyModule_AddObject(module, name, reinterpret_cast(enumType)) < 0) - return 0; + return nullptr; if (flagsType && PyModule_AddObject(module, PepType_GetNameStr(flagsType), reinterpret_cast(flagsType)) < 0) - return 0; + return nullptr; return enumType; } @@ -415,7 +415,7 @@ static PyObject *createEnumItem(PyTypeObject *enumType, const char *itemName, lo { PyObject *enumItem = newItem(enumType, itemValue, itemName); if (PyDict_SetItemString(enumType->tp_dict, itemName, enumItem) < 0) - return 0; + return nullptr; Py_DECREF(enumItem); return enumItem; } @@ -470,9 +470,9 @@ newItem(PyTypeObject *enumType, long itemValue, const char *itemName) enumObj = PyObject_New(SbkEnumObject, enumType); if (!enumObj) - return 0; + return nullptr; - enumObj->ob_name = itemName ? PyBytes_FromString(itemName) : 0; + enumObj->ob_name = itemName ? PyBytes_FromString(itemName) : nullptr; enumObj->ob_value = itemValue; if (newValue) { @@ -514,7 +514,7 @@ static PyType_Slot SbkNewType_slots[] = { {Py_tp_richcompare, (void *)enum_richcompare}, {Py_tp_hash, (void *)enum_hash}, {Py_tp_dealloc, (void *)object_dealloc}, - {0, 0} + {0, nullptr} }; static PyType_Spec SbkNewType_spec = { "missing Enum name", // to be inserted later diff --git a/sources/shiboken2/libshiboken/sbkenum.h b/sources/shiboken2/libshiboken/sbkenum.h index 199027836..759d72636 100644 --- a/sources/shiboken2/libshiboken/sbkenum.h +++ b/sources/shiboken2/libshiboken/sbkenum.h @@ -101,7 +101,7 @@ namespace Enum const char *itemName, long itemValue); LIBSHIBOKEN_API bool createScopedEnumItem(PyTypeObject *enumType, SbkObjectType *scope, const char *itemName, long itemValue); - LIBSHIBOKEN_API PyObject *newItem(PyTypeObject *enumType, long itemValue, const char *itemName = 0); + LIBSHIBOKEN_API PyObject *newItem(PyTypeObject *enumType, long itemValue, const char *itemName = nullptr); LIBSHIBOKEN_API PyTypeObject *newTypeWithName(const char *name, const char *cppName, PyTypeObject *numbers_fromFlag=nullptr); diff --git a/sources/shiboken2/libshiboken/sbkstring.cpp b/sources/shiboken2/libshiboken/sbkstring.cpp index d3c337524..9ba5be281 100644 --- a/sources/shiboken2/libshiboken/sbkstring.cpp +++ b/sources/shiboken2/libshiboken/sbkstring.cpp @@ -95,7 +95,7 @@ PyObject *fromCString(const char *value, int len) const char *toCString(PyObject *str, Py_ssize_t *len) { if (str == Py_None) - return NULL; + return nullptr; if (PyUnicode_Check(str)) { if (len) { // We need to encode the unicode string into utf8 to know the size of returned char *. @@ -119,7 +119,7 @@ const char *toCString(PyObject *str, Py_ssize_t *len) *len = PyBytes_GET_SIZE(str); return PyBytes_AS_STRING(str); } - return 0; + return nullptr; } bool concat(PyObject **val1, PyObject *val2) diff --git a/sources/shiboken2/libshiboken/sbkstring.h b/sources/shiboken2/libshiboken/sbkstring.h index ec674ee7b..7f434e1b9 100644 --- a/sources/shiboken2/libshiboken/sbkstring.h +++ b/sources/shiboken2/libshiboken/sbkstring.h @@ -59,7 +59,7 @@ namespace String LIBSHIBOKEN_API bool isConvertible(PyObject *obj); LIBSHIBOKEN_API PyObject *fromCString(const char *value); LIBSHIBOKEN_API PyObject *fromCString(const char *value, int len); - LIBSHIBOKEN_API const char *toCString(PyObject *str, Py_ssize_t *len = 0); + LIBSHIBOKEN_API const char *toCString(PyObject *str, Py_ssize_t *len = nullptr); LIBSHIBOKEN_API bool concat(PyObject **val1, PyObject *val2); LIBSHIBOKEN_API PyObject *fromFormat(const char *format, ...); LIBSHIBOKEN_API PyObject *fromStringAndSize(const char *str, Py_ssize_t size); diff --git a/sources/shiboken2/libshiboken/shibokenbuffer.h b/sources/shiboken2/libshiboken/shibokenbuffer.h index 8c41dad6c..dc9f8d89f 100644 --- a/sources/shiboken2/libshiboken/shibokenbuffer.h +++ b/sources/shiboken2/libshiboken/shibokenbuffer.h @@ -77,7 +77,7 @@ namespace Buffer * * If the \p pyObj is a non-contiguous buffer a Python error is set. */ - LIBSHIBOKEN_API void *getPointer(PyObject *pyObj, Py_ssize_t *size = 0); + LIBSHIBOKEN_API void *getPointer(PyObject *pyObj, Py_ssize_t *size = nullptr); } // namespace Buffer } // namespace Shiboken diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index 8f9c5a459..6d40ce42c 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -79,7 +79,7 @@ typedef struct safe_globals_struc { PyObject *make_helptext_func; } safe_globals_struc, *safe_globals; -static safe_globals pyside_globals = 0; +static safe_globals pyside_globals = nullptr; static PyObject *GetTypeKey(PyObject *ob); @@ -237,7 +237,7 @@ build_name_key_to_func(PyObject *obtype) PyTypeObject *type = reinterpret_cast(obtype); PyMethodDef *meth = type->tp_methods; - if (meth == 0) + if (meth == nullptr) return 0; Shiboken::AutoDecRef type_key(GetTypeKey(obtype)); @@ -661,11 +661,11 @@ add_more_getsets(PyTypeObject *type, PyGetSetDef *gsp, PyObject **old_descr) // // keep the original __doc__ functions -static PyObject *old_cf_doc_descr = 0; -static PyObject *old_sm_doc_descr = 0; -static PyObject *old_md_doc_descr = 0; -static PyObject *old_tp_doc_descr = 0; -static PyObject *old_wd_doc_descr = 0; +static PyObject *old_cf_doc_descr = nullptr; +static PyObject *old_sm_doc_descr = nullptr; +static PyObject *old_md_doc_descr = nullptr; +static PyObject *old_tp_doc_descr = nullptr; +static PyObject *old_wd_doc_descr = nullptr; static int handle_doc_in_progress = 0; @@ -737,35 +737,35 @@ static PyGetSetDef new_PyCFunction_getsets[] = { {const_cast("__doc__"), (getter)pyside_cf_get___doc__}, {const_cast("__signature__"), (getter)pyside_cf_get___signature__, (setter)pyside_set___signature__}, - {0} + {nullptr} }; static PyGetSetDef new_PyStaticMethod_getsets[] = { {const_cast("__doc__"), (getter)pyside_sm_get___doc__}, {const_cast("__signature__"), (getter)pyside_sm_get___signature__, (setter)pyside_set___signature__}, - {0} + {nullptr} }; static PyGetSetDef new_PyMethodDescr_getsets[] = { {const_cast("__doc__"), (getter)pyside_md_get___doc__}, {const_cast("__signature__"), (getter)pyside_md_get___signature__, (setter)pyside_set___signature__}, - {0} + {nullptr} }; static PyGetSetDef new_PyType_getsets[] = { {const_cast("__doc__"), (getter)pyside_tp_get___doc__}, {const_cast("__signature__"), (getter)pyside_tp_get___signature__, (setter)pyside_set___signature__}, - {0} + {nullptr} }; static PyGetSetDef new_PyWrapperDescr_getsets[] = { {const_cast("__doc__"), (getter)pyside_wd_get___doc__}, {const_cast("__signature__"), (getter)pyside_wd_get___signature__, (setter)pyside_set___signature__}, - {0} + {nullptr} }; //////////////////////////////////////////////////////////////////////////// @@ -1060,7 +1060,7 @@ _build_func_to_type(PyObject *obtype) PyObject *dict = type->tp_dict; PyMethodDef *meth = type->tp_methods; - if (meth == 0) + if (meth == nullptr) return 0; for (; meth->ml_name != nullptr; meth++) { diff --git a/sources/shiboken2/libshiboken/threadstatesaver.cpp b/sources/shiboken2/libshiboken/threadstatesaver.cpp index d64c01f86..0d19528f9 100644 --- a/sources/shiboken2/libshiboken/threadstatesaver.cpp +++ b/sources/shiboken2/libshiboken/threadstatesaver.cpp @@ -59,7 +59,7 @@ void ThreadStateSaver::restore() { if (m_threadState) { PyEval_RestoreThread(m_threadState); - m_threadState = 0; + m_threadState = nullptr; } } diff --git a/sources/shiboken2/libshiboken/voidptr.cpp b/sources/shiboken2/libshiboken/voidptr.cpp index 4d09adb0c..0dceefc29 100644 --- a/sources/shiboken2/libshiboken/voidptr.cpp +++ b/sources/shiboken2/libshiboken/voidptr.cpp @@ -63,8 +63,8 @@ PyObject *SbkVoidPtrObject_new(PyTypeObject *type, PyObject *args, PyObject *kwd PyObject *ob = type->tp_alloc(type, 0); SbkVoidPtrObject *self = reinterpret_cast(ob); - if (self != 0) { - self->cptr = 0; + if (self != nullptr) { + self->cptr = nullptr; self->size = -1; self->isWritable = false; } @@ -82,7 +82,7 @@ int SbkVoidPtrObject_init(PyObject *self, PyObject *args, PyObject *kwds) int isWritable = 0; SbkVoidPtrObject *sbkSelf = reinterpret_cast(self); - static const char *kwlist[] = {"address", "size", "writeable", 0}; + static const char *kwlist[] = {"address", "size", "writeable", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|ni", const_cast(kwlist), &addressObject, &size, &isWritable)) @@ -147,8 +147,8 @@ int SbkVoidPtrObject_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *SbkVoidPtrObject_richcmp(PyObject *obj1, PyObject *obj2, int op) { PyObject *result = Py_False; - void *cptr1 = 0; - void *cptr2 = 0; + void *cptr1 = nullptr; + void *cptr2 = nullptr; bool validObjects = true; if (SbkVoidPtr_Check(obj1)) @@ -197,7 +197,7 @@ PyObject *toBytes(PyObject *self, PyObject *args) static struct PyMethodDef SbkVoidPtrObject_methods[] = { {"toBytes", toBytes, METH_NOARGS}, - {0} + {nullptr} }; static Py_ssize_t SbkVoidPtrObject_length(PyObject *v) @@ -251,7 +251,7 @@ PyObject *SbkVoidPtrObject_str(PyObject *v) static int SbkVoidPtrObject_getbuffer(PyObject *obj, Py_buffer *view, int flags) { - if (view == NULL) + if (view == nullptr) return -1; SbkVoidPtrObject *sbkObject = reinterpret_cast(obj); @@ -273,18 +273,18 @@ static int SbkVoidPtrObject_getbuffer(PyObject *obj, Py_buffer *view, int flags) view->len = sbkObject->size; view->readonly = readonly; view->itemsize = 1; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) view->format = "B"; view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) view->shape = &(view->len); - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) view->strides = &(view->itemsize); - view->suboffsets = NULL; - view->internal = NULL; + view->suboffsets = nullptr; + view->internal = nullptr; return 0; } @@ -321,7 +321,7 @@ PyBufferProcs SbkVoidPtrObjectBufferProc = { static PyBufferProcs SbkVoidPtrObjectBufferProc = { (getbufferproc)SbkVoidPtrObject_getbuffer, // bf_getbuffer - (releasebufferproc)0 // bf_releasebuffer + (releasebufferproc)nullptr // bf_releasebuffer }; #endif @@ -337,7 +337,7 @@ static PyType_Slot SbkVoidPtrType_slots[] = { {Py_tp_new, (void *)SbkVoidPtrObject_new}, {Py_tp_dealloc, (void *)object_dealloc}, {Py_tp_methods, (void *)SbkVoidPtrObject_methods}, - {0, 0} + {0, nullptr} }; static PyType_Spec SbkVoidPtrType_spec = { "shiboken2.libshiboken.VoidPtr", @@ -416,7 +416,7 @@ static void VoidPtrToCpp(PyObject *pyIn, void *cppOut) static PythonToCppFunc VoidPtrToCppIsConvertible(PyObject *pyIn) { - return SbkVoidPtr_Check(pyIn) ? VoidPtrToCpp : 0; + return SbkVoidPtr_Check(pyIn) ? VoidPtrToCpp : nullptr; } static void SbkObjectToCpp(PyObject *pyIn, void *cppOut) @@ -427,7 +427,7 @@ static void SbkObjectToCpp(PyObject *pyIn, void *cppOut) static PythonToCppFunc SbkObjectToCppIsConvertible(PyObject *pyIn) { - return Shiboken::Object::checkType(pyIn) ? SbkObjectToCpp : 0; + return Shiboken::Object::checkType(pyIn) ? SbkObjectToCpp : nullptr; } static void PythonBufferToCpp(PyObject *pyIn, void *cppOut) @@ -453,14 +453,14 @@ static PythonToCppFunc PythonBufferToCppIsConvertible(PyObject *pyIn) // Bail out if the object can't provide a simple contiguous buffer. if (PyObject_GetBuffer(pyIn, &bufferView, PyBUF_SIMPLE) < 0) - return 0; + return nullptr; // Release the buffer. PyBuffer_Release(&bufferView); return PythonBufferToCpp; } - return 0; + return nullptr; } SbkConverter *createConverter() diff --git a/sources/shiboken2/tests/libother/otherderived.cpp b/sources/shiboken2/tests/libother/otherderived.cpp index 5b1714f2a..d23f6ad23 100644 --- a/sources/shiboken2/tests/libother/otherderived.cpp +++ b/sources/shiboken2/tests/libother/otherderived.cpp @@ -51,7 +51,7 @@ OtherDerived::pureVirtual() void* OtherDerived::pureVirtualReturningVoidPtr() { - return 0; + return nullptr; } void diff --git a/sources/shiboken2/tests/libother/othermultiplederived.cpp b/sources/shiboken2/tests/libother/othermultiplederived.cpp index 554df3c76..e7ee4f96d 100644 --- a/sources/shiboken2/tests/libother/othermultiplederived.cpp +++ b/sources/shiboken2/tests/libother/othermultiplederived.cpp @@ -45,6 +45,6 @@ Base1* OtherMultipleDerived::createObject(const std::string& objName) return new MDerived3; else if (objName == "OtherMultipleDerived") return new OtherMultipleDerived; - return 0; + return nullptr; } diff --git a/sources/shiboken2/tests/libsample/abstract.cpp b/sources/shiboken2/tests/libsample/abstract.cpp index c4900d0af..e60c792c4 100644 --- a/sources/shiboken2/tests/libsample/abstract.cpp +++ b/sources/shiboken2/tests/libsample/abstract.cpp @@ -38,7 +38,7 @@ Abstract::Abstract(int id) : m_id(id) { primitiveField = 123; valueTypeField = Point(12, 34); - objectTypeField = 0; + objectTypeField = nullptr; bitField = 0; } diff --git a/sources/shiboken2/tests/libsample/abstract.h b/sources/shiboken2/tests/libsample/abstract.h index 9e7cf5a29..09906f1ee 100644 --- a/sources/shiboken2/tests/libsample/abstract.h +++ b/sources/shiboken2/tests/libsample/abstract.h @@ -74,7 +74,7 @@ public: inline int id() { return m_id; } // factory method - inline static Abstract* createObject() { return 0; } + inline static Abstract* createObject() { return nullptr; } // method that receives an Object Type inline static int getObjectId(Abstract* obj) { return obj->id(); } diff --git a/sources/shiboken2/tests/libsample/blackbox.cpp b/sources/shiboken2/tests/libsample/blackbox.cpp index f3dd57e97..0546ba7c2 100644 --- a/sources/shiboken2/tests/libsample/blackbox.cpp +++ b/sources/shiboken2/tests/libsample/blackbox.cpp @@ -49,7 +49,7 @@ BlackBox::keepObjectType(ObjectType* object) m_ticket++; std::pair item(m_ticket, object); m_objects.insert(item); - object->setParent(0); + object->setParent(nullptr); return m_ticket; } @@ -63,7 +63,7 @@ BlackBox::retrieveObjectType(int ticket) m_objects.erase(it); return second; } - return 0; + return nullptr; } void @@ -93,7 +93,7 @@ BlackBox::retrievePoint(int ticket) m_points.erase(it); return second; } - return 0; + return nullptr; } void diff --git a/sources/shiboken2/tests/libsample/derived.cpp b/sources/shiboken2/tests/libsample/derived.cpp index 4fa3e4081..0dc026876 100644 --- a/sources/shiboken2/tests/libsample/derived.cpp +++ b/sources/shiboken2/tests/libsample/derived.cpp @@ -54,7 +54,7 @@ Derived::pureVirtual() void* Derived::pureVirtualReturningVoidPtr() { - return 0; + return nullptr; } void @@ -100,7 +100,7 @@ Derived::otherOverloaded(int a, double b) struct SecretClass : public Abstract { virtual void pureVirtual() {} - virtual void* pureVirtualReturningVoidPtr() { return 0; } + virtual void *pureVirtualReturningVoidPtr() { return nullptr; } virtual PrintFormat returnAnEnum() { return Short; } void hideFunction(HideType*){}; private: diff --git a/sources/shiboken2/tests/libsample/expression.cpp b/sources/shiboken2/tests/libsample/expression.cpp index a6051306e..0c255a659 100644 --- a/sources/shiboken2/tests/libsample/expression.cpp +++ b/sources/shiboken2/tests/libsample/expression.cpp @@ -30,18 +30,18 @@ #include "expression.h" #include -Expression::Expression() : m_value(0), m_operation(None), m_operand1(0), m_operand2(0) +Expression::Expression() : m_value(0), m_operation(None), m_operand1(nullptr), m_operand2(nullptr) { } -Expression::Expression(int number) : m_value(number), m_operation(None), m_operand1(0), m_operand2(0) +Expression::Expression(int number) : m_value(number), m_operation(None), m_operand1(nullptr), m_operand2(nullptr) { } Expression::Expression(const Expression& other) { - m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0; - m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0; + m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : nullptr; + m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : nullptr; m_value = other.m_value; m_operation = other.m_operation; } @@ -50,8 +50,8 @@ Expression& Expression::operator=(const Expression& other) { delete m_operand1; delete m_operand2; - m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0; - m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0; + m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : nullptr; + m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : nullptr; m_operation = other.m_operation; m_value = other.m_value; return *this; diff --git a/sources/shiboken2/tests/libsample/functions.cpp b/sources/shiboken2/tests/libsample/functions.cpp index 5cc9a1c67..288fa96ee 100644 --- a/sources/shiboken2/tests/libsample/functions.cpp +++ b/sources/shiboken2/tests/libsample/functions.cpp @@ -118,19 +118,19 @@ overloadedFunc(double val) char* returnNullPrimitivePointer() { - return 0; + return nullptr; } ObjectType* returnNullObjectTypePointer() { - return 0; + return nullptr; } Event* returnNullValueTypePointer() { - return 0; + return nullptr; } unsigned int diff --git a/sources/shiboken2/tests/libsample/handle.h b/sources/shiboken2/tests/libsample/handle.h index 400a0a3a6..18221c763 100644 --- a/sources/shiboken2/tests/libsample/handle.h +++ b/sources/shiboken2/tests/libsample/handle.h @@ -45,7 +45,7 @@ typedef OBJ* HANDLE; class LIBSAMPLE_API HandleHolder { public: - explicit HandleHolder(HANDLE ptr = 0) : m_handle(ptr) {} + explicit HandleHolder(HANDLE ptr = nullptr) : m_handle(ptr) {} explicit HandleHolder(Foo::HANDLE val): m_handle2(val) {} inline void set(HANDLE ptr) { HANDLE tmp; tmp = m_handle; m_handle = tmp; } diff --git a/sources/shiboken2/tests/libsample/modifications.h b/sources/shiboken2/tests/libsample/modifications.h index 035ec844e..fa32bdec3 100644 --- a/sources/shiboken2/tests/libsample/modifications.h +++ b/sources/shiboken2/tests/libsample/modifications.h @@ -117,7 +117,7 @@ public: double callDifferenceOfPointCoordinates(const Point* pt, bool* ok) { return differenceOfPointCoordinates(pt, ok); } // Sets an ObjectType in the argument and returns true. - bool nonConversionRuleForArgumentWithDefaultValue(ObjectType** object = 0); + bool nonConversionRuleForArgumentWithDefaultValue(ObjectType **object = nullptr); ObjectType* getObject() const { return m_object; } // Inject code with a %CONVERTTOPYTHON that receives an user's primitive type. diff --git a/sources/shiboken2/tests/libsample/objectmodel.h b/sources/shiboken2/tests/libsample/objectmodel.h index e15ce06a4..1890ac47f 100644 --- a/sources/shiboken2/tests/libsample/objectmodel.h +++ b/sources/shiboken2/tests/libsample/objectmodel.h @@ -35,8 +35,8 @@ class LIBSAMPLE_API ObjectModel : public ObjectType { public: - explicit ObjectModel(ObjectType* parent = 0) - : ObjectType(parent), m_data(0) + explicit ObjectModel(ObjectType *parent = nullptr) + : ObjectType(parent), m_data(nullptr) {} void setData(ObjectType* data); diff --git a/sources/shiboken2/tests/libsample/objecttype.cpp b/sources/shiboken2/tests/libsample/objecttype.cpp index f82b7cf0d..855c08611 100644 --- a/sources/shiboken2/tests/libsample/objecttype.cpp +++ b/sources/shiboken2/tests/libsample/objecttype.cpp @@ -35,7 +35,7 @@ using namespace std; -ObjectType::ObjectType(ObjectType* parent) : m_parent(0), m_layout(0), m_call_id(-1) +ObjectType::ObjectType(ObjectType* parent) : m_parent(nullptr), m_layout(nullptr), m_call_id(-1) { setParent(parent); } @@ -66,7 +66,7 @@ ObjectType::removeChild(ObjectType* child) ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child); if (child_iter != m_children.end()) { m_children.erase(child_iter); - child->m_parent = 0; + child->m_parent = nullptr; } } @@ -74,15 +74,15 @@ ObjectType* ObjectType::takeChild(ObjectType* child) { if (!child) - return 0; + return nullptr; ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child); if (child_iter != m_children.end()) { m_children.erase(child_iter); - child->m_parent = 0; + child->m_parent = nullptr; return child; } - return 0; + return nullptr; } ObjectType* @@ -101,7 +101,7 @@ ObjectType::findChild(const Str& name) if ((*child_iter)->objectName() == name) return *child_iter; } - return 0; + return nullptr; } void @@ -218,8 +218,8 @@ ObjectTypeLayout* ObjectType::takeLayout() { ObjectTypeLayout* l = layout(); if (!l) - return 0; - m_layout = 0; + return nullptr; + m_layout = nullptr; l->setParent(0); return l; } diff --git a/sources/shiboken2/tests/libsample/objecttype.h b/sources/shiboken2/tests/libsample/objecttype.h index ecd67b684..cb5823c5b 100644 --- a/sources/shiboken2/tests/libsample/objecttype.h +++ b/sources/shiboken2/tests/libsample/objecttype.h @@ -71,7 +71,7 @@ public: // ### Fixme: Use uintptr_t in C++ 11 typedef size_t Identifier; - explicit ObjectType(ObjectType* parent = 0); + explicit ObjectType(ObjectType *parent = nullptr); virtual ~ObjectType(); // factory method diff --git a/sources/shiboken2/tests/libsample/objectview.h b/sources/shiboken2/tests/libsample/objectview.h index 6a54057e9..b68d031e9 100644 --- a/sources/shiboken2/tests/libsample/objectview.h +++ b/sources/shiboken2/tests/libsample/objectview.h @@ -38,7 +38,7 @@ class ObjectModel; class LIBSAMPLE_API ObjectView : public ObjectType { public: - ObjectView(ObjectModel* model = 0, ObjectType* parent = 0) + ObjectView(ObjectModel *model = nullptr, ObjectType *parent = nullptr) : ObjectType(parent), m_model(model) {} diff --git a/sources/shiboken2/tests/libsample/overload.h b/sources/shiboken2/tests/libsample/overload.h index 6d0165619..aa2572d50 100644 --- a/sources/shiboken2/tests/libsample/overload.h +++ b/sources/shiboken2/tests/libsample/overload.h @@ -83,7 +83,7 @@ public: FunctionEnum wrapperIntIntOverloads(const Polygon& arg0, int arg1, int arg2) { return Function1; } // Similar to QImage constructor - FunctionEnum strBufferOverloads(const Str& arg0, const char* arg1 = 0, bool arg2 = true) { return Function0; } + FunctionEnum strBufferOverloads(const Str &arg0, const char *arg1 = nullptr, bool arg2 = true) { return Function0; } FunctionEnum strBufferOverloads(unsigned char* arg0, int arg1) { return Function1; } FunctionEnum strBufferOverloads() { return Function2; } diff --git a/sources/shiboken2/tests/libsample/photon.h b/sources/shiboken2/tests/libsample/photon.h index 2a32d511a..b9fc6532d 100644 --- a/sources/shiboken2/tests/libsample/photon.h +++ b/sources/shiboken2/tests/libsample/photon.h @@ -116,7 +116,7 @@ LIBSAMPLE_API int countValueDuplicators(const std::listm_descriptor = fopen(p->m_filename, "rb")) == 0) + if ((p->m_descriptor = fopen(p->m_filename, "rb")) == nullptr) return false; fseek(p->m_descriptor, 0, SEEK_END); @@ -88,7 +88,7 @@ SimpleFile::close() { if (p->m_descriptor) { fclose(p->m_descriptor); - p->m_descriptor = 0; + p->m_descriptor = nullptr; } } diff --git a/sources/shiboken2/tests/libsample/sometime.h b/sources/shiboken2/tests/libsample/sometime.h index 319cd7f8f..ef16efa29 100644 --- a/sources/shiboken2/tests/libsample/sometime.h +++ b/sources/shiboken2/tests/libsample/sometime.h @@ -70,7 +70,7 @@ public: NumArgs somethingCompletelyDifferent(); NumArgs somethingCompletelyDifferent(int h, int m, ImplicitConv ic = ImplicitConv::CtorThree, - ObjectType* type = 0); + ObjectType *type = nullptr); Str toString() const; bool operator==(const Time& other) const; diff --git a/sources/shiboken2/tests/libsample/str.h b/sources/shiboken2/tests/libsample/str.h index d3bcbaafc..4af00e5b6 100644 --- a/sources/shiboken2/tests/libsample/str.h +++ b/sources/shiboken2/tests/libsample/str.h @@ -49,7 +49,7 @@ public: char get_char(int pos) const; bool set_char(int pos, char ch); - int toInt(bool* ok = 0, int base = 10) const; + int toInt(bool *ok = nullptr, int base = 10) const; void show() const; @@ -73,6 +73,6 @@ LIBSAMPLE_API unsigned int strHash(const Str& str); typedef Str PStr; LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix); -LIBSAMPLE_API void duplicatePStr(PStr* pstr = 0); +LIBSAMPLE_API void duplicatePStr(PStr *pstr = nullptr); #endif // STR_H diff --git a/sources/shiboken2/tests/libsample/virtualmethods.cpp b/sources/shiboken2/tests/libsample/virtualmethods.cpp index 2d26bd7c8..294feca60 100644 --- a/sources/shiboken2/tests/libsample/virtualmethods.cpp +++ b/sources/shiboken2/tests/libsample/virtualmethods.cpp @@ -40,7 +40,7 @@ bool VirtualMethods::createStr(const char* text, Str*& ret) { if (!text) { - ret = 0; + ret = nullptr; return false; } diff --git a/sources/shiboken2/tests/libsample/voidholder.h b/sources/shiboken2/tests/libsample/voidholder.h index 23408fad8..367e99ddf 100644 --- a/sources/shiboken2/tests/libsample/voidholder.h +++ b/sources/shiboken2/tests/libsample/voidholder.h @@ -34,7 +34,7 @@ class VoidHolder { public: - explicit VoidHolder(void* ptr = 0) : m_ptr(ptr) {} + explicit VoidHolder(void *ptr = nullptr) : m_ptr(ptr) {} ~VoidHolder() {} inline void* voidPointer() { return m_ptr; } inline static void* gimmeMeSomeVoidPointer() diff --git a/sources/shiboken2/tests/libsmart/smart.h b/sources/shiboken2/tests/libsmart/smart.h index 2e3c96406..3347b22c1 100644 --- a/sources/shiboken2/tests/libsmart/smart.h +++ b/sources/shiboken2/tests/libsmart/smart.h @@ -81,7 +81,7 @@ public: template class SharedPtr { public: - SharedPtr() : m_refData(0) { + SharedPtr() : m_refData(nullptr) { if (shouldPrint()) std::cout << "shared_ptr default constructor " << this << "\n"; } @@ -122,7 +122,7 @@ public: { if (m_refData) return m_refData->m_heldPtr; - return 0; + return nullptr; } int useCount() const @@ -147,7 +147,7 @@ public: { if (m_refData) return m_refData->m_heldPtr; - return 0; + return nullptr; } bool operator!() const -- cgit v1.2.3