diff --git a/src/Base/BaseClass.cpp b/src/Base/BaseClass.cpp index 9e7978fd9a..16c0ee8341 100644 --- a/src/Base/BaseClass.cpp +++ b/src/Base/BaseClass.cpp @@ -32,7 +32,7 @@ using namespace Base; -Type BaseClass::classTypeId = Base::Type::badType(); // NOLINT +Type BaseClass::classTypeId = Base::Type::BadType; //************************************************************************** @@ -63,8 +63,7 @@ void BaseClass::init() /*assert(!parentType.isBad() && "you forgot init() on parentclass!");*/ /* Set up entry in the type system. */ - BaseClass::classTypeId = - Type::createType(Type::badType(), "Base::BaseClass", BaseClass::create); + BaseClass::classTypeId = Type::createType(Type::BadType, "Base::BaseClass", BaseClass::create); } Type BaseClass::getClassTypeId() diff --git a/src/Base/BaseClass.h b/src/Base/BaseClass.h index 33d7ced2f2..3c3dced6d8 100644 --- a/src/Base/BaseClass.h +++ b/src/Base/BaseClass.h @@ -65,7 +65,7 @@ private: { \ return _class_::classTypeId; \ } \ - Base::Type _class_::classTypeId = Base::Type::badType(); \ + Base::Type _class_::classTypeId = Base::Type::BadType; \ void* _class_::create(void) \ { \ return new _class_(); \ @@ -99,7 +99,7 @@ private: { \ return _class_::classTypeId; \ } \ - Base::Type _class_::classTypeId = Base::Type::badType(); \ + Base::Type _class_::classTypeId = Base::Type::BadType; \ void* _class_::create(void) \ { \ return 0; \ diff --git a/src/Base/Type.cpp b/src/Base/Type.cpp index 421833305f..6a55ab669b 100644 --- a/src/Base/Type.cpp +++ b/src/Base/Type.cpp @@ -37,8 +37,8 @@ using namespace Base; struct Base::TypeData { TypeData(const char* theName, - const Type type = Type::badType(), - const Type theParent = Type::badType(), + const Type type = Type::BadType, + const Type theParent = Type::BadType, Type::instantiationMethod method = nullptr) : name(theName) , parent(theParent) @@ -56,6 +56,8 @@ std::map Type::typemap; std::vector Type::typedata; std::set Type::loadModuleSet; +const Type Type::BadType; + void* Type::createInstance() const { instantiationMethod method = typedata[index]->instMethod; @@ -77,7 +79,7 @@ void* Type::createInstanceByName(const char* TypeName, bool bLoadModule) // now the type should be in the type map Type type = fromName(TypeName); - if (type == badType()) { + if (type == BadType) { return nullptr; } @@ -117,13 +119,6 @@ std::string Type::getModuleName(const char* ClassName) : std::string(); } -Type Type::badType() -{ - Type bad; - bad.index = 0; - return bad; -} - Type Type::createType(const Type& parent, const char* name, instantiationMethod method) { @@ -167,7 +162,7 @@ Type Type::fromName(const char* name) return typedata[pos->second]->type; } - return Type::badType(); + return Type::BadType; } Type Type::fromKey(unsigned int key) @@ -176,7 +171,7 @@ Type Type::fromKey(unsigned int key) return typedata[key]->type; } - return Type::badType(); + return BadType; } const char* Type::getName() const @@ -198,7 +193,7 @@ bool Type::isDerivedFrom(const Type& type) const return true; } temp = temp.getParent(); - } while (temp != badType()); + } while (!temp.isBad()); return false; } @@ -233,5 +228,5 @@ Type Type::getTypeIfDerivedFrom(const char* name, const Type& parent, bool bLoad return type; } - return Type::badType(); + return BadType; } diff --git a/src/Base/Type.h b/src/Base/Type.h index fad31905db..b54455e566 100644 --- a/src/Base/Type.h +++ b/src/Base/Type.h @@ -126,7 +126,7 @@ public: bool operator>=(const Type& type) const; bool operator>(const Type& type) const; - static Type badType(); + static const Type BadType; static void init(); static void destruct(); diff --git a/src/Base/TypePyImp.cpp b/src/Base/TypePyImp.cpp index bb7dd94f89..7dc9336584 100644 --- a/src/Base/TypePyImp.cpp +++ b/src/Base/TypePyImp.cpp @@ -76,8 +76,7 @@ PyObject* TypePy::getBadType(PyObject* args) return nullptr; } - Base::Type type = Base::Type::badType(); - return new TypePy(new Base::Type(type)); + return new TypePy(new Base::Type(Base::Type::BadType)); } PyObject* TypePy::getParent(PyObject* args)