Base: Use isBad() instead of comparing types with ==
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user