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
-5
View File
@@ -25,11 +25,6 @@ namespace love
namespace audio
{
Audio::Audio()
{
moduleType = M_AUDIO;
}
StringMap<Audio::DistanceModel, Audio::DISTANCE_MAX_ENUM>::Entry Audio::distanceModelEntries[] =
{
{"none", Audio::DISTANCE_NONE},
+3 -1
View File
@@ -64,9 +64,11 @@ public:
static bool getConstant(const char *in, DistanceModel &out);
static bool getConstant(DistanceModel in, const char *&out);
Audio();
virtual ~Audio() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_AUDIO; }
virtual Source *newSource(love::sound::Decoder *decoder) = 0;
virtual Source *newSource(love::sound::SoundData *soundData) = 0;
-1
View File
@@ -82,7 +82,6 @@ Message *Message::fromLua(lua_State *L, int n)
Event::Event()
{
moduleType = M_EVENT;
mutex = thread::newMutex();
}
+3
View File
@@ -58,6 +58,9 @@ public:
Event();
virtual ~Event();
// Implements Module.
virtual ModuleType getModuleType() const { return M_EVENT; }
void push(Message *msg);
bool poll(Message *&msg);
virtual void clear();
@@ -77,7 +77,6 @@ Filesystem::Filesystem()
, fused(false)
, fusedSet(false)
{
moduleType = M_FILESYSTEM;
}
Filesystem::~Filesystem()
@@ -80,6 +80,8 @@ public:
Filesystem();
virtual ~Filesystem();
// Implements Module.
virtual ModuleType getModuleType() const { return M_FILESYSTEM; }
const char *getName() const;
void init(const char *arg0);
+3 -1
View File
@@ -40,9 +40,11 @@ class Font : public Module
public:
Font() { moduleType = M_FONT; }
virtual ~Font() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_FONT; }
virtual Rasterizer *newRasterizer(Data *data, int size) = 0;
virtual Rasterizer *newRasterizer(love::image::ImageData *data, const std::string &glyphs) = 0;
virtual Rasterizer *newRasterizer(love::image::ImageData *data, uint32 *glyphs, int length) = 0;
-5
View File
@@ -25,11 +25,6 @@ namespace love
namespace graphics
{
Graphics::Graphics()
{
moduleType = M_GRAPHICS;
}
Graphics::~Graphics()
{
}
+3 -1
View File
@@ -120,9 +120,11 @@ public:
std::string device;
};
Graphics();
virtual ~Graphics();
// Implements Module.
virtual ModuleType getModuleType() const { return M_GRAPHICS; }
/**
* Sets the current graphics display viewport dimensions.
**/
+3 -1
View File
@@ -44,9 +44,11 @@ class Image : public Module
{
public:
Image() { moduleType = M_IMAGE; }
virtual ~Image() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_IMAGE; }
/**
* Creates new ImageData from FileData.
* @param data The FileData containing the encoded image data.
+3 -1
View File
@@ -34,9 +34,11 @@ class JoystickModule : public Module
{
public:
JoystickModule() { moduleType = M_JOYSTICK; }
virtual ~JoystickModule() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_JOYSTICK; }
/**
* Adds a connected Joystick device and opens it for use.
* Returns NULL if the Joystick could not be added.
-5
View File
@@ -27,11 +27,6 @@ namespace love
namespace keyboard
{
Keyboard::Keyboard()
{
moduleType = M_KEYBOARD;
}
bool Keyboard::getConstant(const char *in, Keyboard::Key &out)
{
return keys.find(in, out);
+3 -1
View File
@@ -244,9 +244,11 @@ public:
KEY_MAX_ENUM = 512
};
Keyboard();
virtual ~Keyboard() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_KEYBOARD; }
/**
* Sets whether repeat keypress events should be sent if a key is held down.
* Does not affect text input events.
-2
View File
@@ -87,8 +87,6 @@ Math Math::instance;
Math::Math()
: rng()
{
moduleType = M_MATH;
// prevent the runtime from free()-ing this
retain();
}
+6
View File
@@ -115,6 +115,12 @@ public:
**/
BezierCurve *newBezierCurve(const std::vector<Vector> &points);
// Implements Module.
virtual ModuleType getModuleType() const
{
return M_MATH;
}
virtual const char *getName() const
{
return "love.math";
-5
View File
@@ -25,11 +25,6 @@ namespace love
namespace mouse
{
Mouse::Mouse()
{
moduleType = M_MOUSE;
}
bool Mouse::getConstant(const char *in, Button &out)
{
return buttons.find(in, out);
+3 -1
View File
@@ -49,9 +49,11 @@ public:
BUTTON_MAX_ENUM
};
Mouse();
virtual ~Mouse() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_MOUSE; }
virtual Cursor *newCursor(love::image::ImageData *data, int hotx, int hoty) = 0;
virtual Cursor *getSystemCursor(Cursor::SystemCursor cursortype) = 0;
-5
View File
@@ -33,11 +33,6 @@ namespace box2d
int Physics::meter = Physics::DEFAULT_METER;
Physics::Physics()
{
moduleType = M_PHYSICS;
}
const char *Physics::getName() const
{
return "love.physics.box2d";
+1 -2
View File
@@ -61,10 +61,9 @@ public:
**/
static const int DEFAULT_METER = 30;
Physics();
// Implements Module.
const char *getName() const;
virtual ModuleType getModuleType() const { return M_PHYSICS; }
/**
* Creates a new World.
-5
View File
@@ -25,11 +25,6 @@ namespace love
namespace sound
{
Sound::Sound()
{
moduleType = M_SOUND;
}
Sound::~Sound()
{
}
+3 -1
View File
@@ -42,9 +42,11 @@ class Sound : public Module
public:
Sound();
virtual ~Sound();
// Implements Module.
virtual ModuleType getModuleType() const { return M_SOUND; }
/**
* Creates new SoundData from a decoder. Fully expands the
* encoded sound data into raw sound data. Not recommended
-5
View File
@@ -41,11 +41,6 @@ namespace love
namespace system
{
System::System()
{
moduleType = M_SYSTEM;
}
std::string System::getOS() const
{
#if defined(LOVE_MACOSX)
+3 -1
View File
@@ -48,9 +48,11 @@ public:
POWER_MAX_ENUM
};
System();
virtual ~System() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_SYSTEM; }
/**
* Gets the current operating system.
**/
-5
View File
@@ -25,11 +25,6 @@ namespace love
namespace thread
{
ThreadModule::ThreadModule()
{
moduleType = M_THREAD;
}
LuaThread *ThreadModule::newThread(const std::string &name, love::Data *data)
{
LuaThread *lt = new LuaThread(name, data);
+1 -1
View File
@@ -42,7 +42,6 @@ class ThreadModule : public love::Module
{
public:
ThreadModule();
virtual ~ThreadModule() {}
virtual LuaThread *newThread(const std::string &name, love::Data *data);
virtual Channel *newChannel();
@@ -50,6 +49,7 @@ public:
// Implements Module.
virtual const char *getName() const;
virtual ModuleType getModuleType() const { return M_THREAD; }
}; // ThreadModule
+3 -1
View File
@@ -33,9 +33,11 @@ class Timer : public Module
{
public:
Timer() { moduleType = M_TIMER; }
virtual ~Timer() {}
// Implements Module.
virtual ModuleType getModuleType() const { return M_TIMER; }
/**
* Measures the time between this call and the previous call,
* and updates internal values accordinly.
-5
View File
@@ -28,11 +28,6 @@ namespace window
Window *Window::singleton = nullptr;
Window::Window()
{
moduleType = M_WINDOW;
}
Window::~Window()
{
if (singleton == this)
+3 -1
View File
@@ -75,9 +75,11 @@ public:
int height;
};
Window();
virtual ~Window();
// Implements Module.
virtual ModuleType getModuleType() const { return M_WINDOW; }
virtual bool setWindow(int width = 800, int height = 600, WindowSettings *settings = nullptr) = 0;
virtual void getWindow(int &width, int &height, WindowSettings &settings) = 0;