Updated the new module changes to use more compile/link-time checking rather than runtime checking.

This commit is contained in:
Alex Szpakowski
2014-07-21 15:12:01 -03:00
parent 014b9a46e5
commit d52bab4221
30 changed files with 59 additions and 87 deletions
+9 -17
View File
@@ -60,11 +60,6 @@ namespace love
Module *Module::instances[] = {};
Module::Module()
: moduleType(M_INVALID)
{
}
Module::~Module()
{
ModuleRegistry &registry = registryInstance();
@@ -79,15 +74,14 @@ Module::~Module()
}
}
// Same deal with Module::getModuleType().
for (int i = 0; i < (int) M_MAX_ENUM; i++)
{
if (instances[i] == this)
instances[i] = nullptr;
}
freeEmptyRegistry();
if (instances[moduleType] == this)
instances[moduleType] = nullptr;
}
Module::ModuleType Module::getModuleType() const
{
return moduleType;
}
void Module::registerInstance(Module *instance)
@@ -108,12 +102,10 @@ void Module::registerInstance(Module *instance)
throw Exception("Module %s already registered!", instance->getName());
}
ModuleType moduletype = instance->getModuleType();
if (moduletype == M_INVALID)
throw love::Exception("Module %s has an invalid base module type.", instance->getName());
registry.insert(make_pair(name, instance));
ModuleType moduletype = instance->getModuleType();
if (instances[moduletype] != nullptr)
{
printf("Warning: overwriting module instance %s with new instance %s\n",