From 7186b8a88f9a5176bdadcab30b36e27fa26f17c8 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Thu, 13 Feb 2025 20:24:25 +0100 Subject: [PATCH] Base: Use isBad() instead of comparing types with == --- src/Base/BaseClass.cpp | 8 ++++---- src/Base/BaseClassPyImp.cpp | 2 +- src/Base/TypePyImp.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Base/BaseClass.cpp b/src/Base/BaseClass.cpp index 301cb5c33b..9e7978fd9a 100644 --- a/src/Base/BaseClass.cpp +++ b/src/Base/BaseClass.cpp @@ -56,11 +56,11 @@ BaseClass::~BaseClass() = default; void BaseClass::init() { - assert(BaseClass::classTypeId == Type::badType() && "don't init() twice!"); + assert(BaseClass::classTypeId.isBad() && "don't init() twice!"); /* Make sure superclass gets initialized before subclass. */ /*assert(strcmp(#_parentclass_), "inherited"));*/ /*Type parentType(Type::fromName(#_parentclass_));*/ - /*assert(parentType != Type::badType() && "you forgot init() on parentclass!");*/ + /*assert(!parentType.isBad() && "you forgot init() on parentclass!");*/ /* Set up entry in the type system. */ BaseClass::classTypeId = @@ -84,11 +84,11 @@ void BaseClass::initSubclass(Base::Type& toInit, Type::instantiationMethod method) { // don't init twice! - assert(toInit == Base::Type::badType()); + assert(toInit.isBad()); // get the parent class Base::Type parentType(Base::Type::fromName(ParentName)); // forgot init parent! - assert(parentType != Base::Type::badType()); + assert(!parentType.isBad()); // create the new type toInit = Base::Type::createType(parentType, ClassName, method); diff --git a/src/Base/BaseClassPyImp.cpp b/src/Base/BaseClassPyImp.cpp index d432672264..ac17bb9bc3 100644 --- a/src/Base/BaseClassPyImp.cpp +++ b/src/Base/BaseClassPyImp.cpp @@ -44,7 +44,7 @@ PyObject* BaseClassPy::isDerivedFrom(PyObject* args) } Base::Type type = Base::Type::fromName(name); - bool valid = (type != Base::Type::badType() && getBaseClassPtr()->isDerivedFrom(type)); + bool valid = (!type.isBad() && getBaseClassPtr()->isDerivedFrom(type)); return PyBool_FromLong(valid ? 1 : 0); } diff --git a/src/Base/TypePyImp.cpp b/src/Base/TypePyImp.cpp index c997bb69c4..bb7dd94f89 100644 --- a/src/Base/TypePyImp.cpp +++ b/src/Base/TypePyImp.cpp @@ -122,7 +122,7 @@ PyObject* TypePy::isDerivedFrom(PyObject* args) return nullptr; } while (false); - bool val = (type != Base::Type::badType() && getBaseTypePtr()->isDerivedFrom(type)); + bool val = (!type.isBad() && getBaseTypePtr()->isDerivedFrom(type)); return PyBool_FromLong(val ? 1 : 0); }