Browse Source

Rework internal module registration to happen in constructors.

Sasha Szpakowski 1 year ago
parent
commit
1e97e09b28
73 changed files with 154 additions and 248 deletions
  1. 4 1
      src/common/Module.cpp
  2. 8 10
      src/common/Module.h
  3. 0 3
      src/common/runtime.cpp
  4. 4 0
      src/modules/audio/Audio.cpp
  5. 4 3
      src/modules/audio/Audio.h
  6. 2 6
      src/modules/audio/null/Audio.cpp
  7. 0 3
      src/modules/audio/null/Audio.h
  8. 2 6
      src/modules/audio/openal/Audio.cpp
  9. 0 3
      src/modules/audio/openal/Audio.h
  10. 1 0
      src/modules/data/DataModule.cpp
  11. 0 4
      src/modules/data/DataModule.h
  12. 5 0
      src/modules/event/Event.cpp
  13. 4 3
      src/modules/event/Event.h
  14. 1 5
      src/modules/event/sdl/Event.cpp
  15. 0 3
      src/modules/event/sdl/Event.h
  16. 2 1
      src/modules/filesystem/Filesystem.cpp
  17. 4 4
      src/modules/filesystem/Filesystem.h
  18. 2 6
      src/modules/filesystem/physfs/Filesystem.cpp
  19. 0 3
      src/modules/filesystem/physfs/Filesystem.h
  20. 2 1
      src/modules/font/Font.cpp
  21. 3 4
      src/modules/font/Font.h
  22. 1 5
      src/modules/font/freetype/Font.cpp
  23. 0 3
      src/modules/font/freetype/Font.h
  24. 3 2
      src/modules/graphics/Graphics.cpp
  25. 1 4
      src/modules/graphics/Graphics.h
  26. 0 3
      src/modules/graphics/metal/Graphics.h
  27. 2 1
      src/modules/graphics/metal/Graphics.mm
  28. 2 6
      src/modules/graphics/opengl/Graphics.cpp
  29. 0 3
      src/modules/graphics/opengl/Graphics.h
  30. 1 5
      src/modules/graphics/vulkan/Graphics.cpp
  31. 0 1
      src/modules/graphics/vulkan/Graphics.h
  32. 1 5
      src/modules/image/Image.cpp
  33. 0 4
      src/modules/image/Image.h
  34. 6 3
      src/modules/joystick/JoystickModule.h
  35. 1 5
      src/modules/joystick/sdl/JoystickModule.cpp
  36. 0 3
      src/modules/joystick/sdl/JoystickModule.h
  37. 5 0
      src/modules/keyboard/Keyboard.cpp
  38. 4 3
      src/modules/keyboard/Keyboard.h
  39. 2 6
      src/modules/keyboard/sdl/Keyboard.cpp
  40. 0 3
      src/modules/keyboard/sdl/Keyboard.h
  41. 2 1
      src/modules/math/MathModule.cpp
  42. 0 11
      src/modules/math/MathModule.h
  43. 6 0
      src/modules/mouse/Mouse.h
  44. 2 6
      src/modules/mouse/sdl/Mouse.cpp
  45. 0 3
      src/modules/mouse/sdl/Mouse.h
  46. 2 6
      src/modules/physics/box2d/Physics.cpp
  47. 0 4
      src/modules/physics/box2d/Physics.h
  48. 5 0
      src/modules/sensor/Sensor.cpp
  49. 4 3
      src/modules/sensor/Sensor.h
  50. 2 6
      src/modules/sensor/sdl/Sensor.cpp
  51. 0 3
      src/modules/sensor/sdl/Sensor.h
  52. 5 0
      src/modules/sound/Sound.cpp
  53. 4 3
      src/modules/sound/Sound.h
  54. 1 5
      src/modules/sound/lullaby/Sound.cpp
  55. 0 3
      src/modules/sound/lullaby/Sound.h
  56. 2 1
      src/modules/system/System.cpp
  57. 1 4
      src/modules/system/System.h
  58. 1 5
      src/modules/system/sdl/System.cpp
  59. 0 3
      src/modules/system/sdl/System.h
  60. 5 5
      src/modules/thread/ThreadModule.cpp
  61. 1 4
      src/modules/thread/ThreadModule.h
  62. 2 1
      src/modules/timer/Timer.cpp
  63. 0 4
      src/modules/timer/Timer.h
  64. 6 3
      src/modules/touch/Touch.h
  65. 5 5
      src/modules/touch/sdl/Touch.cpp
  66. 1 3
      src/modules/touch/sdl/Touch.h
  67. 8 3
      src/modules/video/Video.h
  68. 1 5
      src/modules/video/theora/Video.cpp
  69. 0 3
      src/modules/video/theora/Video.h
  70. 5 0
      src/modules/window/Window.cpp
  71. 4 3
      src/modules/window/Window.h
  72. 2 6
      src/modules/window/sdl/Window.cpp
  73. 0 2
      src/modules/window/sdl/Window.h

+ 4 - 1
src/common/Module.cpp

@@ -62,9 +62,12 @@ namespace love
 love::Type Module::type("Module", &Object::type);
 love::Type Module::type("Module", &Object::type);
 Module *Module::instances[] = {};
 Module *Module::instances[] = {};
 
 
-Module::Module()
+Module::Module(Module::ModuleType moduleType, const char *name)
+	: moduleType(moduleType)
+	, name(name)
 {
 {
 	initDeprecation();
 	initDeprecation();
+	registerInstance(this);
 }
 }
 
 
 Module::~Module()
 Module::~Module()

+ 8 - 10
src/common/Module.h

@@ -62,13 +62,13 @@ public:
 		M_MAX_ENUM
 		M_MAX_ENUM
 	};
 	};
 
 
-	Module();
+	Module(ModuleType moduleType, const char *name);
 	virtual ~Module();
 	virtual ~Module();
 
 
     /**
     /**
      * Gets the base type of the module.
      * Gets the base type of the module.
      **/
      **/
-	virtual ModuleType getModuleType() const = 0;
+	ModuleType getModuleType() const { return moduleType; }
 
 
 	/**
 	/**
 	 * Gets the name of the module. This is used in case of errors
 	 * Gets the name of the module. This is used in case of errors
@@ -76,14 +76,7 @@ public:
 	 *
 	 *
 	 * @return The full name of the module, eg. love.graphics.opengl.
 	 * @return The full name of the module, eg. love.graphics.opengl.
 	 **/
 	 **/
-	virtual const char *getName() const = 0;
-
-	/**
-	 * Add module to internal registry. To be used /only/ in
-	 * runtime.cpp:luax_register_module()
-	 * @param instance The module instance.
-	 */
-	static void registerInstance(Module *instance);
+	const char *getName() const { return name.c_str(); }
 
 
 	/**
 	/**
 	 * Retrieve module instance from internal registry. May return NULL
 	 * Retrieve module instance from internal registry. May return NULL
@@ -106,6 +99,11 @@ public:
 
 
 private:
 private:
 
 
+	static void registerInstance(Module *instance);
+
+	ModuleType moduleType;
+	std::string name;
+
 	static Module *instances[M_MAX_ENUM];
 	static Module *instances[M_MAX_ENUM];
 
 
 }; // Module
 }; // Module

+ 0 - 3
src/common/runtime.cpp

@@ -473,9 +473,6 @@ int luax_register_module(lua_State *L, const WrappedModule &m)
 	lua_setfield(L, -3, m.name); // love.graphics = table
 	lua_setfield(L, -3, m.name); // love.graphics = table
 	lua_remove(L, -2); // love
 	lua_remove(L, -2); // love
 
 
-	// Register module instance
-	Module::registerInstance(m.module);
-
 	return 1;
 	return 1;
 }
 }
 
 

+ 4 - 0
src/modules/audio/Audio.cpp

@@ -68,6 +68,10 @@ void showRecordingPermissionMissingDialog()
 #endif
 #endif
 }
 }
 
 
+Audio::Audio(const char *name)
+	: Module(M_AUDIO, name)
+{}
+
 bool Audio::setMixWithSystem(bool mix)
 bool Audio::setMixWithSystem(bool mix)
 {
 {
 #ifdef LOVE_IOS
 #ifdef LOVE_IOS

+ 4 - 3
src/modules/audio/Audio.h

@@ -101,9 +101,6 @@ public:
 
 
 	virtual ~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::Decoder *decoder) = 0;
 	virtual Source *newSource(love::sound::SoundData *soundData) = 0;
 	virtual Source *newSource(love::sound::SoundData *soundData) = 0;
 	virtual Source *newSource(int sampleRate, int bitDepth, int channels, int buffers) = 0;
 	virtual Source *newSource(int sampleRate, int bitDepth, int channels, int buffers) = 0;
@@ -312,6 +309,10 @@ public:
 	 */
 	 */
 	virtual void setPlaybackDevice(const char *name);
 	virtual void setPlaybackDevice(const char *name);
 
 
+protected:
+
+	Audio(const char *name);
+
 private:
 private:
 
 
 	static StringMap<DistanceModel, DISTANCE_MAX_ENUM>::Entry distanceModelEntries[];
 	static StringMap<DistanceModel, DISTANCE_MAX_ENUM>::Entry distanceModelEntries[];

+ 2 - 6
src/modules/audio/null/Audio.cpp

@@ -28,7 +28,8 @@ namespace null
 {
 {
 
 
 Audio::Audio()
 Audio::Audio()
-	: distanceModel(DISTANCE_NONE)
+	: love::audio::Audio("love.audio.null")
+	, distanceModel(DISTANCE_NONE)
 {
 {
 }
 }
 
 
@@ -36,11 +37,6 @@ Audio::~Audio()
 {
 {
 }
 }
 
 
-const char *Audio::getName() const
-{
-	return "love.audio.null";
-}
-
 love::audio::Source *Audio::newSource(love::sound::Decoder *)
 love::audio::Source *Audio::newSource(love::sound::Decoder *)
 {
 {
 	return new Source();
 	return new Source();

+ 0 - 3
src/modules/audio/null/Audio.h

@@ -41,9 +41,6 @@ public:
 	Audio();
 	Audio();
 	virtual ~Audio();
 	virtual ~Audio();
 
 
-	// Implements Module.
-	const char *getName() const;
-
 	// Implements Audio.
 	// Implements Audio.
 	love::audio::Source *newSource(love::sound::Decoder *decoder);
 	love::audio::Source *newSource(love::sound::Decoder *decoder);
 	love::audio::Source *newSource(love::sound::SoundData *soundData);
 	love::audio::Source *newSource(love::sound::SoundData *soundData);

+ 2 - 6
src/modules/audio/openal/Audio.cpp

@@ -106,7 +106,8 @@ static const char *getDeviceSpecifier(ALCdevice *device)
 }
 }
 
 
 Audio::Audio()
 Audio::Audio()
-	: device(nullptr)
+	: love::audio::Audio("love.audio.openal")
+	, device(nullptr)
 	, context(nullptr)
 	, context(nullptr)
 	, pool(nullptr)
 	, pool(nullptr)
 	, poolThread(nullptr)
 	, poolThread(nullptr)
@@ -256,11 +257,6 @@ Audio::~Audio()
 	alcCloseDevice(device);
 	alcCloseDevice(device);
 }
 }
 
 
-const char *Audio::getName() const
-{
-	return "love.audio.openal";
-}
-
 love::audio::Source *Audio::newSource(love::sound::Decoder *decoder)
 love::audio::Source *Audio::newSource(love::sound::Decoder *decoder)
 {
 {
 	return new Source(pool, decoder);
 	return new Source(pool, decoder);

+ 0 - 3
src/modules/audio/openal/Audio.h

@@ -78,9 +78,6 @@ public:
 	 **/
 	 **/
 	static ALenum getFormat(int bitDepth, int channels);
 	static ALenum getFormat(int bitDepth, int channels);
 
 
-	// Implements Module.
-	const char *getName() const;
-
 	// Implements Audio.
 	// Implements Audio.
 	love::audio::Source *newSource(love::sound::Decoder *decoder);
 	love::audio::Source *newSource(love::sound::Decoder *decoder);
 	love::audio::Source *newSource(love::sound::SoundData *soundData);
 	love::audio::Source *newSource(love::sound::SoundData *soundData);

+ 1 - 0
src/modules/data/DataModule.cpp

@@ -214,6 +214,7 @@ void hash(HashFunction::Function function, const char *input, uint64_t size, Has
 }
 }
 
 
 DataModule::DataModule()
 DataModule::DataModule()
+	: Module(M_DATA, "love.data")
 {
 {
 }
 }
 
 

+ 0 - 4
src/modules/data/DataModule.h

@@ -117,10 +117,6 @@ public:
 	DataModule();
 	DataModule();
 	virtual ~DataModule();
 	virtual ~DataModule();
 
 
-	// Implements Module.
-	ModuleType getModuleType() const override { return M_DATA; }
-	const char *getName() const override { return "love.data"; }
-
 	DataView *newDataView(Data *data, size_t offset, size_t size);
 	DataView *newDataView(Data *data, size_t offset, size_t size);
 	ByteData *newByteData(size_t size);
 	ByteData *newByteData(size_t size);
 	ByteData *newByteData(const void *d, size_t size);
 	ByteData *newByteData(const void *d, size_t size);

+ 5 - 0
src/modules/event/Event.cpp

@@ -38,6 +38,11 @@ Message::~Message()
 {
 {
 }
 }
 
 
+Event::Event(const char *name)
+	: Module(M_EVENT, name)
+{
+}
+
 Event::~Event()
 Event::~Event()
 {
 {
 }
 }

+ 4 - 3
src/modules/event/Event.h

@@ -54,10 +54,8 @@ public:
 class Event : public Module
 class Event : public Module
 {
 {
 public:
 public:
-	virtual ~Event();
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_EVENT; }
+	virtual ~Event();
 
 
 	void push(Message *msg);
 	void push(Message *msg);
 	bool poll(Message *&msg);
 	bool poll(Message *&msg);
@@ -67,6 +65,9 @@ public:
 	virtual Message *wait() = 0;
 	virtual Message *wait() = 0;
 
 
 protected:
 protected:
+
+	Event(const char *name);
+
 	love::thread::MutexRef mutex;
 	love::thread::MutexRef mutex;
 	std::queue<Message *> queue;
 	std::queue<Message *> queue;
 
 

+ 1 - 5
src/modules/event/sdl/Event.cpp

@@ -105,12 +105,8 @@ static int SDLCALL watchAppEvents(void * /*udata*/, SDL_Event *event)
 	return 1;
 	return 1;
 }
 }
 
 
-const char *Event::getName() const
-{
-	return "love.event.sdl";
-}
-
 Event::Event()
 Event::Event()
+	: love::event::Event("love.event.sdl")
 {
 {
 	if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0)
 	if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0)
 		throw love::Exception("Could not initialize SDL events subsystem (%s)", SDL_GetError());
 		throw love::Exception("Could not initialize SDL events subsystem (%s)", SDL_GetError());

+ 0 - 3
src/modules/event/sdl/Event.h

@@ -42,9 +42,6 @@ class Event : public love::event::Event
 {
 {
 public:
 public:
 
 
-	// Implements Module.
-	const char *getName() const;
-
 	Event();
 	Event();
 	virtual ~Event();
 	virtual ~Event();
 
 

+ 2 - 1
src/modules/filesystem/Filesystem.cpp

@@ -45,7 +45,8 @@ namespace filesystem
 
 
 love::Type Filesystem::type("filesystem", &Module::type);
 love::Type Filesystem::type("filesystem", &Module::type);
 
 
-Filesystem::Filesystem()
+Filesystem::Filesystem(const char *name)
+	: Module(M_FILESYSTEM, name)
 {
 {
 }
 }
 
 

+ 4 - 4
src/modules/filesystem/Filesystem.h

@@ -108,12 +108,8 @@ public:
 
 
 	static love::Type type;
 	static love::Type type;
 
 
-	Filesystem();
 	virtual ~Filesystem();
 	virtual ~Filesystem();
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_FILESYSTEM; }
-
 	virtual void init(const char *arg0) = 0;
 	virtual void init(const char *arg0) = 0;
 
 
 	virtual void setFused(bool fused) = 0;
 	virtual void setFused(bool fused) = 0;
@@ -317,6 +313,10 @@ public:
 	STRINGMAP_CLASS_DECLARE(MountPermissions);
 	STRINGMAP_CLASS_DECLARE(MountPermissions);
 	STRINGMAP_CLASS_DECLARE(LoadMode);
 	STRINGMAP_CLASS_DECLARE(LoadMode);
 
 
+protected:
+
+	Filesystem(const char *name);
+
 private:
 private:
 
 
 	bool getRealPathType(const std::string &path, FileType &ftype) const;
 	bool getRealPathType(const std::string &path, FileType &ftype) const;

+ 2 - 6
src/modules/filesystem/physfs/Filesystem.cpp

@@ -107,7 +107,8 @@ static bool isAppCommonPath(Filesystem::CommonPath path)
 }
 }
 
 
 Filesystem::Filesystem()
 Filesystem::Filesystem()
-	: appendIdentityToPath(false)
+	: love::filesystem::Filesystem("love.filesystem.physfs")
+	, appendIdentityToPath(false)
 	, fused(false)
 	, fused(false)
 	, fusedSet(false)
 	, fusedSet(false)
 	, fullPaths()
 	, fullPaths()
@@ -128,11 +129,6 @@ Filesystem::~Filesystem()
 		PHYSFS_deinit();
 		PHYSFS_deinit();
 }
 }
 
 
-const char *Filesystem::getName() const
-{
-	return "love.filesystem.physfs";
-}
-
 void Filesystem::init(const char *arg0)
 void Filesystem::init(const char *arg0)
 {
 {
 #ifdef LOVE_ANDROID
 #ifdef LOVE_ANDROID

+ 0 - 3
src/modules/filesystem/physfs/Filesystem.h

@@ -43,9 +43,6 @@ public:
 	Filesystem();
 	Filesystem();
 	virtual ~Filesystem();
 	virtual ~Filesystem();
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	void init(const char *arg0) override;
 	void init(const char *arg0) override;
 
 
 	void setFused(bool fused) override;
 	void setFused(bool fused) override;

+ 2 - 1
src/modules/font/Font.cpp

@@ -34,7 +34,8 @@ namespace font
 // Default TrueType font, gzip-compressed.
 // Default TrueType font, gzip-compressed.
 #include "NotoSans-Regular.ttf.gzip.h"
 #include "NotoSans-Regular.ttf.gzip.h"
 
 
-Font::Font()
+Font::Font(const char *name)
+	: Module(M_FONT, name)
 {
 {
 	auto compressedbytes = (const char *) NotoSans_Regular_ttf_gzip;
 	auto compressedbytes = (const char *) NotoSans_Regular_ttf_gzip;
 	size_t compressedsize = NotoSans_Regular_ttf_gzip_len;
 	size_t compressedsize = NotoSans_Regular_ttf_gzip_len;

+ 3 - 4
src/modules/font/Font.h

@@ -43,7 +43,6 @@ class Font : public Module
 
 
 public:
 public:
 
 
-	Font();
 	virtual ~Font() {}
 	virtual ~Font() {}
 
 
 	virtual Rasterizer *newRasterizer(love::filesystem::FileData *data) = 0;
 	virtual Rasterizer *newRasterizer(love::filesystem::FileData *data) = 0;
@@ -58,9 +57,9 @@ public:
 	virtual GlyphData *newGlyphData(Rasterizer *r, const std::string &glyph);
 	virtual GlyphData *newGlyphData(Rasterizer *r, const std::string &glyph);
 	virtual GlyphData *newGlyphData(Rasterizer *r, uint32 glyph);
 	virtual GlyphData *newGlyphData(Rasterizer *r, uint32 glyph);
 
 
-	// Implement Module.
-	virtual ModuleType getModuleType() const { return M_FONT; }
-	virtual const char *getName() const = 0;
+protected:
+
+	Font(const char *name);
 
 
 private:
 private:
 
 

+ 1 - 5
src/modules/font/freetype/Font.cpp

@@ -36,6 +36,7 @@ namespace freetype
 {
 {
 
 
 Font::Font()
 Font::Font()
+	: love::font::Font("love.font.freetype")
 {
 {
 	if (FT_Init_FreeType(&library))
 	if (FT_Init_FreeType(&library))
 		throw love::Exception("TrueTypeFont Loading error: FT_Init_FreeType failed");
 		throw love::Exception("TrueTypeFont Loading error: FT_Init_FreeType failed");
@@ -66,11 +67,6 @@ Rasterizer *Font::newTrueTypeRasterizer(love::Data *data, int size, const font::
 	return new TrueTypeRasterizer(library, data, size, settings, defaultdpiscale);
 	return new TrueTypeRasterizer(library, data, size, settings, defaultdpiscale);
 }
 }
 
 
-const char *Font::getName() const
-{
-	return "love.font.freetype";
-}
-
 } // freetype
 } // freetype
 } // font
 } // font
 } // love
 } // love

+ 0 - 3
src/modules/font/freetype/Font.h

@@ -47,9 +47,6 @@ public:
 	Rasterizer *newRasterizer(love::filesystem::FileData *data) override;
 	Rasterizer *newRasterizer(love::filesystem::FileData *data) override;
 	Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, const font::TrueTypeRasterizer::Settings &settings) override;
 	Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, const font::TrueTypeRasterizer::Settings &settings) override;
 
 
-	// Implement Module
-	const char *getName() const override;
-
 private:
 private:
 
 
 	// FreeType library
 	// FreeType library

+ 3 - 2
src/modules/graphics/Graphics.cpp

@@ -180,8 +180,9 @@ Graphics::DisplayState::DisplayState()
 	defaultSamplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_LINEAR;
 	defaultSamplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_LINEAR;
 }
 }
 
 
-Graphics::Graphics()
-	: width(0)
+Graphics::Graphics(const char *name)
+	: Module(M_GRAPHICS, name)
+	, width(0)
 	, height(0)
 	, height(0)
 	, pixelWidth(0)
 	, pixelWidth(0)
 	, pixelHeight(0)
 	, pixelHeight(0)

+ 1 - 4
src/modules/graphics/Graphics.h

@@ -451,12 +451,9 @@ public:
 		}
 		}
 	};
 	};
 
 
-	Graphics();
+	Graphics(const char *name);
 	virtual ~Graphics();
 	virtual ~Graphics();
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_GRAPHICS; }
-
 	virtual Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) = 0;
 	virtual Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) = 0;
 
 
 	Quad *newQuad(Quad::Viewport v, double sw, double sh);
 	Quad *newQuad(Quad::Viewport v, double sw, double sh);

+ 0 - 3
src/modules/graphics/metal/Graphics.h

@@ -60,9 +60,6 @@ public:
 	Graphics();
 	Graphics();
 	virtual ~Graphics();
 	virtual ~Graphics();
 
 
-	// Implements Module.
-	const char *getName() const override { return "love.graphics.metal"; }
-
 	love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
 	love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
 	love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
 	love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
 
 

+ 2 - 1
src/modules/graphics/metal/Graphics.mm

@@ -263,7 +263,8 @@ struct DefaultVertexAttributes
 Graphics *Graphics::graphicsInstance = nullptr;
 Graphics *Graphics::graphicsInstance = nullptr;
 
 
 Graphics::Graphics()
 Graphics::Graphics()
-	: device(nil)
+	: love::graphics::Graphics("love.graphics.metal")
+	, device(nil)
 	, commandQueue(nil)
 	, commandQueue(nil)
 	, commandBuffer(nil)
 	, commandBuffer(nil)
 	, renderEncoder(nil)
 	, renderEncoder(nil)

+ 2 - 6
src/modules/graphics/opengl/Graphics.cpp

@@ -106,7 +106,8 @@ love::graphics::Graphics *createInstance()
 }
 }
 
 
 Graphics::Graphics()
 Graphics::Graphics()
-	: windowHasStencil(false)
+	: love::graphics::Graphics("love.graphics.opengl")
+	, windowHasStencil(false)
 	, mainVAO(0)
 	, mainVAO(0)
 	, internalBackbufferFBO(0)
 	, internalBackbufferFBO(0)
 	, requestedBackbufferMSAA(0)
 	, requestedBackbufferMSAA(0)
@@ -147,11 +148,6 @@ Graphics::~Graphics()
 	delete[] bufferMapMemory;
 	delete[] bufferMapMemory;
 }
 }
 
 
-const char *Graphics::getName() const
-{
-	return "love.graphics.opengl";
-}
-
 love::graphics::StreamBuffer *Graphics::newStreamBuffer(BufferUsage type, size_t size)
 love::graphics::StreamBuffer *Graphics::newStreamBuffer(BufferUsage type, size_t size)
 {
 {
 	return CreateStreamBuffer(type, size);
 	return CreateStreamBuffer(type, size);

+ 0 - 3
src/modules/graphics/opengl/Graphics.h

@@ -56,9 +56,6 @@ public:
 	Graphics();
 	Graphics();
 	virtual ~Graphics();
 	virtual ~Graphics();
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
 	love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
 	love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
 	love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
 
 

+ 1 - 5
src/modules/graphics/vulkan/Graphics.cpp

@@ -60,11 +60,6 @@ static const std::vector<const char*> deviceExtensions = {
 
 
 constexpr uint32_t USAGES_POLL_INTERVAL = 5000;
 constexpr uint32_t USAGES_POLL_INTERVAL = 5000;
 
 
-const char *Graphics::getName() const
-{
-	return "love.graphics.vulkan";
-}
-
 VkDevice Graphics::getDevice() const
 VkDevice Graphics::getDevice() const
 {
 {
 	return device;
 	return device;
@@ -95,6 +90,7 @@ static void checkOptionalInstanceExtensions(OptionalInstanceExtensions& ext)
 }
 }
 
 
 Graphics::Graphics()
 Graphics::Graphics()
+	: love::graphics::Graphics("love.graphics.vulkan")
 {
 {
 	if (SDL_Vulkan_LoadLibrary(nullptr))
 	if (SDL_Vulkan_LoadLibrary(nullptr))
 		throw love::Exception("could not find vulkan");
 		throw love::Exception("could not find vulkan");

+ 0 - 1
src/modules/graphics/vulkan/Graphics.h

@@ -274,7 +274,6 @@ public:
 	~Graphics();
 	~Graphics();
 
 
 	// implementation for virtual functions
 	// implementation for virtual functions
-	const char *getName() const override;
 	love::graphics::Texture *newTexture(const love::graphics::Texture::Settings &settings, const love::graphics::Texture::Slices *data) override;
 	love::graphics::Texture *newTexture(const love::graphics::Texture::Settings &settings, const love::graphics::Texture::Slices *data) override;
 	love::graphics::Buffer *newBuffer(const love::graphics::Buffer::Settings &settings, const std::vector<love::graphics::Buffer::DataDeclaration>& format, const void *data, size_t size, size_t arraylength) override;
 	love::graphics::Buffer *newBuffer(const love::graphics::Buffer::Settings &settings, const std::vector<love::graphics::Buffer::DataDeclaration>& format, const void *data, size_t size, size_t arraylength) override;
 	graphics::GraphicsReadback *newReadbackInternal(ReadbackMethod method, love::graphics::Buffer *buffer, size_t offset, size_t size, data::ByteData *dest, size_t destoffset) override;
 	graphics::GraphicsReadback *newReadbackInternal(ReadbackMethod method, love::graphics::Buffer *buffer, size_t offset, size_t size, data::ByteData *dest, size_t destoffset) override;

+ 1 - 5
src/modules/image/Image.cpp

@@ -40,6 +40,7 @@ namespace image
 love::Type Image::type("image", &Module::type);
 love::Type Image::type("image", &Module::type);
 
 
 Image::Image()
 Image::Image()
+	: Module(M_IMAGE, "love.image.magpie")
 {
 {
 	using namespace magpie;
 	using namespace magpie;
 
 
@@ -65,11 +66,6 @@ Image::~Image()
 		handler->release();
 		handler->release();
 }
 }
 
 
-const char *Image::getName() const
-{
-	return "love.image.magpie";
-}
-
 love::image::ImageData *Image::newImageData(Data *data)
 love::image::ImageData *Image::newImageData(Data *data)
 {
 {
 	return new ImageData(data);
 	return new ImageData(data);

+ 0 - 4
src/modules/image/Image.h

@@ -52,10 +52,6 @@ public:
 	Image();
 	Image();
 	virtual ~Image();
 	virtual ~Image();
 
 
-	// Implements Module.
-	ModuleType getModuleType() const override { return M_IMAGE; }
-	const char *getName() const override;
-
 	/**
 	/**
 	 * Creates new ImageData from FileData.
 	 * Creates new ImageData from FileData.
 	 * @param data The FileData containing the encoded image data.
 	 * @param data The FileData containing the encoded image data.

+ 6 - 3
src/modules/joystick/JoystickModule.h

@@ -36,9 +36,6 @@ public:
 
 
 	virtual ~JoystickModule() {}
 	virtual ~JoystickModule() {}
 
 
-	// Implements Module.
-	ModuleType getModuleType() const override { return M_JOYSTICK; }
-
 	/**
 	/**
 	 * Adds a connected Joystick device and opens it for use.
 	 * Adds a connected Joystick device and opens it for use.
 	 * Returns NULL if the Joystick could not be added.
 	 * Returns NULL if the Joystick could not be added.
@@ -101,6 +98,12 @@ public:
 	 **/
 	 **/
 	virtual std::string getGamepadMappingString(const std::string &guid) const = 0;
 	virtual std::string getGamepadMappingString(const std::string &guid) const = 0;
 
 
+protected:
+
+	JoystickModule(const char *name)
+		: Module(M_JOYSTICK, name)
+	{}
+
 }; // JoystickModule
 }; // JoystickModule
 
 
 } // joystick
 } // joystick

+ 1 - 5
src/modules/joystick/sdl/JoystickModule.cpp

@@ -40,6 +40,7 @@ namespace sdl
 {
 {
 
 
 JoystickModule::JoystickModule()
 JoystickModule::JoystickModule()
+	: love::joystick::JoystickModule("love.joystick.sdl")
 {
 {
 	if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0)
 	if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0)
 		throw love::Exception("Could not initialize SDL joystick subsystem (%s)", SDL_GetError());
 		throw love::Exception("Could not initialize SDL joystick subsystem (%s)", SDL_GetError());
@@ -69,11 +70,6 @@ JoystickModule::~JoystickModule()
 	SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
 	SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
 }
 }
 
 
-const char *JoystickModule::getName() const
-{
-	return "love.joystick.sdl";
-}
-
 love::joystick::Joystick *JoystickModule::getJoystick(int joyindex)
 love::joystick::Joystick *JoystickModule::getJoystick(int joyindex)
 {
 {
 	if (joyindex < 0 || (size_t) joyindex >= activeSticks.size())
 	if (joyindex < 0 || (size_t) joyindex >= activeSticks.size())

+ 0 - 3
src/modules/joystick/sdl/JoystickModule.h

@@ -44,9 +44,6 @@ public:
 	JoystickModule();
 	JoystickModule();
 	virtual ~JoystickModule();
 	virtual ~JoystickModule();
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	// Implements JoystickModule.
 	// Implements JoystickModule.
 	love::joystick::Joystick *addJoystick(int deviceindex) override;
 	love::joystick::Joystick *addJoystick(int deviceindex) override;
 	void removeJoystick(love::joystick::Joystick *joystick) override;
 	void removeJoystick(love::joystick::Joystick *joystick) override;

+ 5 - 0
src/modules/keyboard/Keyboard.cpp

@@ -27,6 +27,11 @@ namespace love
 namespace keyboard
 namespace keyboard
 {
 {
 
 
+Keyboard::Keyboard(const char *name)
+	: Module(M_KEYBOARD, name)
+{
+}
+
 bool Keyboard::getConstant(const char *in, Key &out)
 bool Keyboard::getConstant(const char *in, Key &out)
 {
 {
 	return keys.find(in, out);
 	return keys.find(in, out);

+ 4 - 3
src/modules/keyboard/Keyboard.h

@@ -533,9 +533,6 @@ public:
 
 
 	virtual ~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.
 	 * Sets whether repeat keypress events should be sent if a key is held down.
 	 * Does not affect text input events.
 	 * Does not affect text input events.
@@ -614,6 +611,10 @@ public:
 	static bool getConstant(const char *in, ModifierKey &out);
 	static bool getConstant(const char *in, ModifierKey &out);
 	static bool getConstant(ModifierKey in, const char *&out);
 	static bool getConstant(ModifierKey in, const char *&out);
 
 
+protected:
+
+	Keyboard(const char *name);
+
 private:
 private:
 
 
 	static StringMap<Key, KEY_MAX_ENUM>::Entry keyEntries[];
 	static StringMap<Key, KEY_MAX_ENUM>::Entry keyEntries[];

+ 2 - 6
src/modules/keyboard/sdl/Keyboard.cpp

@@ -36,15 +36,11 @@ namespace sdl
 {
 {
 
 
 Keyboard::Keyboard()
 Keyboard::Keyboard()
-	: key_repeat(false)
+	: love::keyboard::Keyboard("love.keyboard.sdl")
+	, key_repeat(false)
 {
 {
 }
 }
 
 
-const char *Keyboard::getName() const
-{
-	return "love.keyboard.sdl";
-}
-
 void Keyboard::setKeyRepeat(bool enable)
 void Keyboard::setKeyRepeat(bool enable)
 {
 {
 	key_repeat = enable;
 	key_repeat = enable;

+ 0 - 3
src/modules/keyboard/sdl/Keyboard.h

@@ -41,9 +41,6 @@ public:
 
 
 	Keyboard();
 	Keyboard();
 
 
-	// Implements Module.
-	const char *getName() const;
-
 	void setKeyRepeat(bool enable);
 	void setKeyRepeat(bool enable);
 	bool hasKeyRepeat() const;
 	bool hasKeyRepeat() const;
 	bool isDown(const std::vector<Key> &keylist) const;
 	bool isDown(const std::vector<Key> &keylist) const;

+ 2 - 1
src/modules/math/MathModule.cpp

@@ -200,7 +200,8 @@ float linearToGamma(float c)
 }
 }
 
 
 Math::Math()
 Math::Math()
-	: rng()
+	: Module(M_MATH, "love.math")
+	, rng()
 {
 {
 	RandomGenerator::Seed seed;
 	RandomGenerator::Seed seed;
 	seed.b64 = (uint64) time(nullptr);
 	seed.b64 = (uint64) time(nullptr);

+ 0 - 11
src/modules/math/MathModule.h

@@ -118,17 +118,6 @@ public:
 	Transform *newTransform();
 	Transform *newTransform();
 	Transform *newTransform(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky);
 	Transform *newTransform(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky);
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const
-	{
-		return M_MATH;
-	}
-
-	virtual const char *getName() const
-	{
-		return "love.math";
-	}
-
 private:
 private:
 
 
 	RandomGenerator rng;
 	RandomGenerator rng;

+ 6 - 0
src/modules/mouse/Mouse.h

@@ -64,6 +64,12 @@ public:
 	virtual bool setRelativeMode(bool relative) = 0;
 	virtual bool setRelativeMode(bool relative) = 0;
 	virtual bool getRelativeMode() const = 0;
 	virtual bool getRelativeMode() const = 0;
 
 
+protected:
+
+	Mouse(const char *name)
+		: Module(M_MOUSE, name)
+	{}
+
 }; // Mouse
 }; // Mouse
 
 
 } // mouse
 } // mouse

+ 2 - 6
src/modules/mouse/sdl/Mouse.cpp

@@ -56,13 +56,9 @@ static void clampToWindow(double *x, double *y)
 		window->clampPositionInWindow(x, y);
 		window->clampPositionInWindow(x, y);
 }
 }
 
 
-const char *Mouse::getName() const
-{
-	return "love.mouse.sdl";
-}
-
 Mouse::Mouse()
 Mouse::Mouse()
-	: curCursor(nullptr)
+	: love::mouse::Mouse("love.mouse.sdl")
+	, curCursor(nullptr)
 {
 {
 	// SDL may need the video subsystem in order to clean up the cursor when
 	// SDL may need the video subsystem in order to clean up the cursor when
 	// quitting. Subsystems are reference-counted.
 	// quitting. Subsystems are reference-counted.

+ 0 - 3
src/modules/mouse/sdl/Mouse.h

@@ -39,9 +39,6 @@ class Mouse : public love::mouse::Mouse
 {
 {
 public:
 public:
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	Mouse();
 	Mouse();
 	virtual ~Mouse();
 	virtual ~Mouse();
 
 

+ 2 - 6
src/modules/physics/box2d/Physics.cpp

@@ -35,7 +35,8 @@ namespace box2d
 float Physics::meter = Physics::DEFAULT_METER;
 float Physics::meter = Physics::DEFAULT_METER;
 
 
 Physics::Physics()
 Physics::Physics()
-	: blockAllocator()
+	: Module(M_PHYSICS, "love.physics.box2d")
+	, blockAllocator()
 {
 {
 	meter = DEFAULT_METER;
 	meter = DEFAULT_METER;
 }
 }
@@ -44,11 +45,6 @@ Physics::~Physics()
 {
 {
 }
 }
 
 
-const char *Physics::getName() const
-{
-	return "love.physics.box2d";
-}
-
 World *Physics::newWorld(float gx, float gy, bool sleep)
 World *Physics::newWorld(float gx, float gy, bool sleep)
 {
 {
 	return new World(b2Vec2(gx, gy), sleep);
 	return new World(b2Vec2(gx, gy), sleep);

+ 0 - 4
src/modules/physics/box2d/Physics.h

@@ -65,10 +65,6 @@ public:
 	Physics();
 	Physics();
 	virtual ~Physics();
 	virtual ~Physics();
 
 
-	// Implements Module.
-	const char *getName() const;
-	virtual ModuleType getModuleType() const { return M_PHYSICS; }
-
 	/**
 	/**
 	 * Creates a new World.
 	 * Creates a new World.
 	 * @param gx Gravity along x-axis.
 	 * @param gx Gravity along x-axis.

+ 5 - 0
src/modules/sensor/Sensor.cpp

@@ -26,6 +26,11 @@ namespace love
 namespace sensor
 namespace sensor
 {
 {
 
 
+Sensor::Sensor(const char *name)
+	: Module(M_SENSOR, name)
+{
+}
+
 STRINGMAP_CLASS_BEGIN(Sensor, Sensor::SensorType, Sensor::SENSOR_MAX_ENUM, sensorType)
 STRINGMAP_CLASS_BEGIN(Sensor, Sensor::SensorType, Sensor::SENSOR_MAX_ENUM, sensorType)
 {
 {
 	{ "accelerometer", Sensor::SENSOR_ACCELEROMETER },
 	{ "accelerometer", Sensor::SENSOR_ACCELEROMETER },

+ 4 - 3
src/modules/sensor/Sensor.h

@@ -43,9 +43,6 @@ public:
 
 
 	virtual ~Sensor() {}
 	virtual ~Sensor() {}
 
 
-	// Implements Module.
-	ModuleType getModuleType() const override { return M_SENSOR; }
-
 	/**
 	/**
 	 * Check the availability of the sensor.
 	 * Check the availability of the sensor.
 	 **/
 	 **/
@@ -75,6 +72,10 @@ public:
 
 
 	STRINGMAP_CLASS_DECLARE(SensorType);
 	STRINGMAP_CLASS_DECLARE(SensorType);
 
 
+protected:
+
+	Sensor(const char *name);
+
 }; // Sensor
 }; // Sensor
 
 
 } // sensor
 } // sensor

+ 2 - 6
src/modules/sensor/sdl/Sensor.cpp

@@ -33,7 +33,8 @@ namespace sdl
 {
 {
 
 
 Sensor::Sensor()
 Sensor::Sensor()
-: sensors()
+	: love::sensor::Sensor("love.sensor.sdl")
+	, sensors()
 {
 {
 	if (SDL_InitSubSystem(SDL_INIT_SENSOR) < 0)
 	if (SDL_InitSubSystem(SDL_INIT_SENSOR) < 0)
 		throw love::Exception("Could not initialize SDL sensor subsystem (%s)", SDL_GetError());
 		throw love::Exception("Could not initialize SDL sensor subsystem (%s)", SDL_GetError());
@@ -44,11 +45,6 @@ Sensor::~Sensor()
 	SDL_QuitSubSystem(SDL_INIT_SENSOR);
 	SDL_QuitSubSystem(SDL_INIT_SENSOR);
 }
 }
 
 
-const char *Sensor::getName() const
-{
-	return "love.sensor.sdl";
-}
-
 bool Sensor::hasSensor(SensorType type)
 bool Sensor::hasSensor(SensorType type)
 {
 {
 	for (int i = 0; i < SDL_NumSensors(); i++)
 	for (int i = 0; i < SDL_NumSensors(); i++)

+ 0 - 3
src/modules/sensor/sdl/Sensor.h

@@ -43,9 +43,6 @@ public:
 	Sensor();
 	Sensor();
 	~Sensor() override;
 	~Sensor() override;
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	bool hasSensor(SensorType type) override;
 	bool hasSensor(SensorType type) override;
 	bool isEnabled(SensorType type) override;
 	bool isEnabled(SensorType type) override;
 	void setEnabled(SensorType type, bool enable) override;
 	void setEnabled(SensorType type, bool enable) override;

+ 5 - 0
src/modules/sound/Sound.cpp

@@ -27,6 +27,11 @@ namespace sound
 
 
 love::Type Sound::type("Sound", &Module::type);
 love::Type Sound::type("Sound", &Module::type);
 
 
+Sound::Sound(const char *name)
+	: Module(M_SOUND, name)
+{
+}
+
 Sound::~Sound()
 Sound::~Sound()
 {
 {
 }
 }

+ 4 - 3
src/modules/sound/Sound.h

@@ -46,9 +46,6 @@ public:
 
 
 	virtual ~Sound();
 	virtual ~Sound();
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_SOUND; }
-
 	/**
 	/**
 	 * Creates new SoundData from a decoder. Fully expands the
 	 * Creates new SoundData from a decoder. Fully expands the
 	 * encoded sound data into raw sound data. Not recommended
 	 * encoded sound data into raw sound data. Not recommended
@@ -89,6 +86,10 @@ public:
 	 **/
 	 **/
 	virtual Decoder *newDecoder(Stream *stream, int bufferSize) = 0;
 	virtual Decoder *newDecoder(Stream *stream, int bufferSize) = 0;
 
 
+protected:
+
+	Sound(const char *name);
+
 }; // Sound
 }; // Sound
 
 
 } // sound
 } // sound

+ 1 - 5
src/modules/sound/lullaby/Sound.cpp

@@ -59,6 +59,7 @@ namespace lullaby
 {
 {
 
 
 Sound::Sound()
 Sound::Sound()
+	: love::sound::Sound("love.sound.lullaby")
 {
 {
 }
 }
 
 
@@ -66,11 +67,6 @@ Sound::~Sound()
 {
 {
 }
 }
 
 
-const char *Sound::getName() const
-{
-	return "love.sound.lullaby";
-}
-
 sound::Decoder *Sound::newDecoder(Stream *stream, int bufferSize)
 sound::Decoder *Sound::newDecoder(Stream *stream, int bufferSize)
 {
 {
 	std::vector<DecoderImpl> possibleDecoders = {
 	std::vector<DecoderImpl> possibleDecoders = {

+ 0 - 3
src/modules/sound/lullaby/Sound.h

@@ -48,9 +48,6 @@ public:
 	Sound();
 	Sound();
 	virtual ~Sound();
 	virtual ~Sound();
 
 
-	/// @copydoc love::Module::getName
-	const char *getName() const override;
-
 	/// @copydoc love::sound::Sound::newDecoder
 	/// @copydoc love::sound::Sound::newDecoder
 	sound::Decoder *newDecoder(Stream *stream, int bufferSize) override;
 	sound::Decoder *newDecoder(Stream *stream, int bufferSize) override;
 
 

+ 2 - 1
src/modules/system/System.cpp

@@ -58,7 +58,8 @@ namespace love
 namespace system
 namespace system
 {
 {
 
 
-System::System()
+System::System(const char *name)
+	: Module(M_SYSTEM, name)
 {
 {
 }
 }
 
 

+ 1 - 4
src/modules/system/System.h

@@ -48,12 +48,9 @@ public:
 		POWER_MAX_ENUM
 		POWER_MAX_ENUM
 	};
 	};
 
 
-	System();
+	System(const char *name);
 	virtual ~System() {}
 	virtual ~System() {}
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_SYSTEM; }
-
 	/**
 	/**
 	 * Gets the current operating system.
 	 * Gets the current operating system.
 	 **/
 	 **/

+ 1 - 5
src/modules/system/sdl/System.cpp

@@ -39,14 +39,10 @@ namespace sdl
 {
 {
 
 
 System::System()
 System::System()
+	: love::system::System("love.system.sdl")
 {
 {
 }
 }
 
 
-const char *System::getName() const
-{
-	return "love.system.sdl";
-}
-
 int System::getProcessorCount() const
 int System::getProcessorCount() const
 {
 {
 	return SDL_GetCPUCount();
 	return SDL_GetCPUCount();

+ 0 - 3
src/modules/system/sdl/System.h

@@ -42,9 +42,6 @@ public:
 	System();
 	System();
 	virtual ~System() {}
 	virtual ~System() {}
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	int getProcessorCount() const override;
 	int getProcessorCount() const override;
 
 
 	void setClipboardText(const std::string &text) const override;
 	void setClipboardText(const std::string &text) const override;

+ 5 - 5
src/modules/thread/ThreadModule.cpp

@@ -25,6 +25,11 @@ namespace love
 namespace thread
 namespace thread
 {
 {
 
 
+ThreadModule::ThreadModule()
+	: love::Module(M_THREAD, "love.thread.sdl")
+{
+}
+
 LuaThread *ThreadModule::newThread(const std::string &name, love::Data *data)
 LuaThread *ThreadModule::newThread(const std::string &name, love::Data *data)
 {
 {
 	return new LuaThread(name, data);
 	return new LuaThread(name, data);
@@ -48,10 +53,5 @@ Channel *ThreadModule::getChannel(const std::string &name)
 	return c;
 	return c;
 }
 }
 
 
-const char *ThreadModule::getName() const
-{
-	return "love.thread.sdl";
-}
-
 } // thread
 } // thread
 } // love
 } // love

+ 1 - 4
src/modules/thread/ThreadModule.h

@@ -43,15 +43,12 @@ class ThreadModule : public love::Module
 {
 {
 public:
 public:
 
 
+	ThreadModule();
 	virtual ~ThreadModule() {}
 	virtual ~ThreadModule() {}
 	virtual LuaThread *newThread(const std::string &name, love::Data *data);
 	virtual LuaThread *newThread(const std::string &name, love::Data *data);
 	virtual Channel *newChannel();
 	virtual Channel *newChannel();
 	virtual Channel *getChannel(const std::string &name);
 	virtual Channel *getChannel(const std::string &name);
 
 
-	// Implements Module.
-	virtual const char *getName() const;
-	virtual ModuleType getModuleType() const { return M_THREAD; }
-
 private:
 private:
 
 
 	std::map<std::string, StrongRef<Channel>> namedChannels;
 	std::map<std::string, StrongRef<Channel>> namedChannels;

+ 2 - 1
src/modules/timer/Timer.cpp

@@ -43,7 +43,8 @@ namespace timer
 {
 {
 
 
 Timer::Timer()
 Timer::Timer()
-	: currTime(0)
+	: Module(M_TIMER, "love.timer")
+	, currTime(0)
 	, prevFpsUpdate(0)
 	, prevFpsUpdate(0)
 	, fps(0)
 	, fps(0)
 	, averageDelta(0)
 	, averageDelta(0)

+ 0 - 4
src/modules/timer/Timer.h

@@ -36,10 +36,6 @@ public:
 	Timer();
 	Timer();
 	virtual ~Timer() {}
 	virtual ~Timer() {}
 
 
-	// Implements Module.
-	ModuleType getModuleType() const override { return M_TIMER; }
-	const char *getName() const override { return "love.timer"; }
-
 	/**
 	/**
 	 * Measures the time between this call and the previous call,
 	 * Measures the time between this call and the previous call,
 	 * and updates internal values accordingly.
 	 * and updates internal values accordingly.

+ 6 - 3
src/modules/touch/Touch.h

@@ -51,9 +51,6 @@ public:
 
 
 	virtual ~Touch() {}
 	virtual ~Touch() {}
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_TOUCH; }
-
 	/**
 	/**
 	 * Gets all currently active touches.
 	 * Gets all currently active touches.
 	 **/
 	 **/
@@ -64,6 +61,12 @@ public:
 	 **/
 	 **/
 	virtual const TouchInfo &getTouch(int64 id) const = 0;
 	virtual const TouchInfo &getTouch(int64 id) const = 0;
 
 
+protected:
+
+	Touch(const char *name)
+		: Module(M_TOUCH, name)
+	{}
+
 }; // Touch
 }; // Touch
 
 
 } // touch
 } // touch

+ 5 - 5
src/modules/touch/sdl/Touch.cpp

@@ -33,6 +33,11 @@ namespace touch
 namespace sdl
 namespace sdl
 {
 {
 
 
+Touch::Touch()
+	: love::touch::Touch("love.touch.sdl")
+{
+}
+
 const std::vector<Touch::TouchInfo> &Touch::getTouches() const
 const std::vector<Touch::TouchInfo> &Touch::getTouches() const
 {
 {
 	return touches;
 	return touches;
@@ -49,11 +54,6 @@ const Touch::TouchInfo &Touch::getTouch(int64 id) const
 	throw love::Exception("Invalid active touch ID: %d", id);
 	throw love::Exception("Invalid active touch ID: %d", id);
 }
 }
 
 
-const char *Touch::getName() const
-{
-	return "love.touch.sdl";
-}
-
 void Touch::onEvent(Uint32 eventtype, const TouchInfo &info)
 void Touch::onEvent(Uint32 eventtype, const TouchInfo &info)
 {
 {
 	auto compare = [&](const TouchInfo &touch) -> bool
 	auto compare = [&](const TouchInfo &touch) -> bool

+ 1 - 3
src/modules/touch/sdl/Touch.h

@@ -38,14 +38,12 @@ class Touch : public love::touch::Touch
 {
 {
 public:
 public:
 
 
+	Touch();
 	virtual ~Touch() {}
 	virtual ~Touch() {}
 
 
 	const std::vector<TouchInfo> &getTouches() const override;
 	const std::vector<TouchInfo> &getTouches() const override;
 	const TouchInfo &getTouch(int64 id) const override;
 	const TouchInfo &getTouch(int64 id) const override;
 
 
-	// Implements Module.
-	const char *getName() const override;
-
 	// SDL has functions to query the state of touch presses, but unfortunately
 	// SDL has functions to query the state of touch presses, but unfortunately
 	// they are updated on a different thread in some backends, which causes
 	// they are updated on a different thread in some backends, which causes
 	// issues especially if the user is iterating through the current touches
 	// issues especially if the user is iterating through the current touches

+ 8 - 3
src/modules/video/Video.h

@@ -35,15 +35,20 @@ namespace video
 class Video : public Module
 class Video : public Module
 {
 {
 public:
 public:
-	virtual ~Video() {}
 
 
-	// Implements Module
-	virtual ModuleType getModuleType() const { return M_VIDEO; }
+	virtual ~Video() {}
 
 
 	/**
 	/**
 	 * Create a VideoStream representing video frames
 	 * Create a VideoStream representing video frames
 	 **/
 	 **/
 	virtual VideoStream *newVideoStream(love::filesystem::File *file) = 0;
 	virtual VideoStream *newVideoStream(love::filesystem::File *file) = 0;
+
+protected:
+
+	Video(const char *name)
+		: Module(M_VIDEO, name)
+	{}
+
 }; // Video
 }; // Video
 
 
 } // video
 } // video

+ 1 - 5
src/modules/video/theora/Video.cpp

@@ -34,6 +34,7 @@ namespace theora
 {
 {
 
 
 Video::Video()
 Video::Video()
+	: love::video::Video("love.video.theora")
 {
 {
 	workerThread = new Worker();
 	workerThread = new Worker();
 	workerThread->start();
 	workerThread->start();
@@ -51,11 +52,6 @@ VideoStream *Video::newVideoStream(love::filesystem::File *file)
 	return stream;
 	return stream;
 }
 }
 
 
-const char *Video::getName() const
-{
-	return "love.video.theora";
-}
-
 Worker::Worker()
 Worker::Worker()
 	: stopping(false)
 	: stopping(false)
 {
 {

+ 0 - 3
src/modules/video/theora/Video.h

@@ -46,9 +46,6 @@ public:
 	Video();
 	Video();
 	virtual ~Video();
 	virtual ~Video();
 
 
-	// Implements Module
-	virtual const char *getName() const;
-
 	VideoStream *newVideoStream(love::filesystem::File* file);
 	VideoStream *newVideoStream(love::filesystem::File* file);
 
 
 private:
 private:

+ 5 - 0
src/modules/window/Window.cpp

@@ -43,6 +43,11 @@ bool isHighDPIAllowed()
 	return highDPIAllowed;
 	return highDPIAllowed;
 }
 }
 
 
+Window::Window(const char *name)
+	: Module(M_WINDOW, name)
+{
+}
+
 Window::~Window()
 Window::~Window()
 {
 {
 }
 }

+ 4 - 3
src/modules/window/Window.h

@@ -131,9 +131,6 @@ public:
 
 
 	virtual ~Window();
 	virtual ~Window();
 
 
-	// Implements Module.
-	virtual ModuleType getModuleType() const { return M_WINDOW; }
-
 	virtual void setGraphics(graphics::Graphics *graphics) = 0;
 	virtual void setGraphics(graphics::Graphics *graphics) = 0;
 
 
 	virtual bool setWindow(int width = 800, int height = 600, WindowSettings *settings = nullptr) = 0;
 	virtual bool setWindow(int width = 800, int height = 600, WindowSettings *settings = nullptr) = 0;
@@ -239,6 +236,10 @@ public:
 	static bool getConstant(DisplayOrientation in, const char *&out);
 	static bool getConstant(DisplayOrientation in, const char *&out);
 	static std::vector<std::string> getConstants(DisplayOrientation);
 	static std::vector<std::string> getConstants(DisplayOrientation);
 
 
+protected:
+
+	Window(const char *name);
+
 private:
 private:
 
 
 	static StringMap<Setting, SETTING_MAX_ENUM>::Entry settingEntries[];
 	static StringMap<Setting, SETTING_MAX_ENUM>::Entry settingEntries[];

+ 2 - 6
src/modules/window/sdl/Window.cpp

@@ -88,7 +88,8 @@ namespace sdl
 {
 {
 
 
 Window::Window()
 Window::Window()
-	: open(false)
+	: love::window::Window("love.window.sdl")
+	, open(false)
 	, mouseGrabbed(false)
 	, mouseGrabbed(false)
 	, window(nullptr)
 	, window(nullptr)
 	, glcontext(nullptr)
 	, glcontext(nullptr)
@@ -1503,11 +1504,6 @@ void Window::requestAttention(bool continuous)
 	// TODO: Linux?
 	// TODO: Linux?
 }
 }
 
 
-const char *Window::getName() const
-{
-	return "love.window.sdl";
-}
-
 } // sdl
 } // sdl
 } // window
 } // window
 } // love
 } // love

+ 0 - 2
src/modules/window/sdl/Window.h

@@ -130,8 +130,6 @@ public:
 
 
 	void requestAttention(bool continuous) override;
 	void requestAttention(bool continuous) override;
 
 
-	const char *getName() const override;
-
 private:
 private:
 
 
 	struct ContextAttribs
 	struct ContextAttribs