Base: Use constant for Type::BadType instead Type::badType()
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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; \
|
||||
|
||||
@@ -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<std::string, unsigned int> Type::typemap;
|
||||
std::vector<TypeData*> Type::typedata;
|
||||
std::set<std::string> 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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user