Browse Source

Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.

--HG--
branch : minor
Alex Szpakowski 10 years ago
parent
commit
2f419c1c83
79 changed files with 602 additions and 567 deletions
  1. 1 0
      CMakeLists.txt
  2. 6 12
      platform/xcode/liblove.xcodeproj/project.pbxproj
  3. 1 6
      src/common/Variant.cpp
  4. 0 1
      src/common/Variant.h
  5. 20 113
      src/common/runtime.cpp
  6. 37 26
      src/common/runtime.h
  7. 215 0
      src/common/types.cpp
  8. 7 83
      src/common/types.h
  9. 2 2
      src/common/wrap_Data.cpp
  10. 10 10
      src/modules/audio/wrap_Audio.cpp
  11. 3 3
      src/modules/audio/wrap_Source.cpp
  12. 8 8
      src/modules/event/sdl/Event.cpp
  13. 1 1
      src/modules/event/wrap_Event.cpp
  14. 2 2
      src/modules/filesystem/wrap_DroppedFile.cpp
  15. 5 5
      src/modules/filesystem/wrap_File.cpp
  16. 2 2
      src/modules/filesystem/wrap_FileData.cpp
  17. 10 10
      src/modules/filesystem/wrap_Filesystem.cpp
  18. 11 11
      src/modules/font/wrap_Font.cpp
  19. 2 2
      src/modules/font/wrap_GlyphData.cpp
  20. 3 3
      src/modules/font/wrap_Rasterizer.cpp
  21. 4 4
      src/modules/graphics/opengl/wrap_Canvas.cpp
  22. 2 2
      src/modules/graphics/opengl/wrap_Font.cpp
  23. 32 32
      src/modules/graphics/opengl/wrap_Graphics.cpp
  24. 4 10
      src/modules/graphics/opengl/wrap_Image.cpp
  25. 4 4
      src/modules/graphics/opengl/wrap_Mesh.cpp
  26. 8 8
      src/modules/graphics/opengl/wrap_ParticleSystem.cpp
  27. 3 3
      src/modules/graphics/opengl/wrap_Shader.cpp
  28. 8 8
      src/modules/graphics/opengl/wrap_SpriteBatch.cpp
  29. 0 2
      src/modules/graphics/opengl/wrap_SpriteBatch.h
  30. 3 3
      src/modules/graphics/opengl/wrap_Text.cpp
  31. 2 2
      src/modules/graphics/wrap_Quad.cpp
  32. 1 1
      src/modules/graphics/wrap_Texture.cpp
  33. 2 2
      src/modules/image/wrap_CompressedData.cpp
  34. 4 4
      src/modules/image/wrap_Image.cpp
  35. 3 3
      src/modules/image/wrap_ImageData.cpp
  36. 2 2
      src/modules/joystick/wrap_Joystick.cpp
  37. 2 2
      src/modules/joystick/wrap_JoystickModule.cpp
  38. 1 1
      src/modules/keyboard/wrap_Keyboard.cpp
  39. 3 3
      src/modules/math/wrap_BezierCurve.cpp
  40. 3 3
      src/modules/math/wrap_Math.cpp
  41. 2 2
      src/modules/math/wrap_RandomGenerator.cpp
  42. 2 2
      src/modules/mouse/wrap_Cursor.cpp
  43. 6 6
      src/modules/mouse/wrap_Mouse.cpp
  44. 2 2
      src/modules/physics/box2d/Body.cpp
  45. 4 4
      src/modules/physics/box2d/Physics.cpp
  46. 10 10
      src/modules/physics/box2d/World.cpp
  47. 4 4
      src/modules/physics/box2d/wrap_Body.cpp
  48. 3 3
      src/modules/physics/box2d/wrap_ChainShape.cpp
  49. 2 2
      src/modules/physics/box2d/wrap_CircleShape.cpp
  50. 5 5
      src/modules/physics/box2d/wrap_Contact.cpp
  51. 2 2
      src/modules/physics/box2d/wrap_DistanceJoint.cpp
  52. 2 2
      src/modules/physics/box2d/wrap_EdgeShape.cpp
  53. 9 9
      src/modules/physics/box2d/wrap_Fixture.cpp
  54. 2 2
      src/modules/physics/box2d/wrap_FrictionJoint.cpp
  55. 2 2
      src/modules/physics/box2d/wrap_GearJoint.cpp
  56. 16 16
      src/modules/physics/box2d/wrap_Joint.cpp
  57. 2 2
      src/modules/physics/box2d/wrap_MotorJoint.cpp
  58. 2 2
      src/modules/physics/box2d/wrap_MouseJoint.cpp
  59. 42 42
      src/modules/physics/box2d/wrap_Physics.cpp
  60. 2 2
      src/modules/physics/box2d/wrap_PolygonShape.cpp
  61. 2 2
      src/modules/physics/box2d/wrap_PrismaticJoint.cpp
  62. 2 2
      src/modules/physics/box2d/wrap_PulleyJoint.cpp
  63. 2 2
      src/modules/physics/box2d/wrap_RevoluteJoint.cpp
  64. 2 2
      src/modules/physics/box2d/wrap_RopeJoint.cpp
  65. 2 2
      src/modules/physics/box2d/wrap_Shape.cpp
  66. 2 2
      src/modules/physics/box2d/wrap_WeldJoint.cpp
  67. 2 2
      src/modules/physics/box2d/wrap_WheelJoint.cpp
  68. 3 3
      src/modules/physics/box2d/wrap_World.cpp
  69. 2 2
      src/modules/sound/wrap_Decoder.cpp
  70. 4 4
      src/modules/sound/wrap_Sound.cpp
  71. 2 2
      src/modules/sound/wrap_SoundData.cpp
  72. 1 1
      src/modules/system/wrap_System.cpp
  73. 1 1
      src/modules/thread/LuaThread.cpp
  74. 2 2
      src/modules/thread/wrap_Channel.cpp
  75. 2 2
      src/modules/thread/wrap_LuaThread.cpp
  76. 8 8
      src/modules/thread/wrap_ThreadModule.cpp
  77. 1 1
      src/modules/timer/wrap_Timer.cpp
  78. 1 1
      src/modules/touch/wrap_Touch.cpp
  79. 3 6
      src/modules/window/wrap_Window.cpp

+ 1 - 0
CMakeLists.txt

@@ -102,6 +102,7 @@ set(LOVE_SRC_COMMON
 	src/common/runtime.cpp
 	src/common/runtime.cpp
 	src/common/runtime.h
 	src/common/runtime.h
 	src/common/StringMap.h
 	src/common/StringMap.h
+	src/common/types.cpp
 	src/common/types.h
 	src/common/types.h
 	src/common/utf8.cpp
 	src/common/utf8.cpp
 	src/common/utf8.h
 	src/common/utf8.h

+ 6 - 12
platform/xcode/liblove.xcodeproj/project.pbxproj

@@ -846,6 +846,8 @@
 		FA620A351AA2F8DB005DB4C2 /* wrap_Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */; };
 		FA620A351AA2F8DB005DB4C2 /* wrap_Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */; };
 		FA620A361AA2F8DB005DB4C2 /* wrap_Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */; };
 		FA620A361AA2F8DB005DB4C2 /* wrap_Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */; };
 		FA620A371AA2F8DB005DB4C2 /* wrap_Texture.h in Headers */ = {isa = PBXBuildFile; fileRef = FA620A311AA2F8DB005DB4C2 /* wrap_Texture.h */; };
 		FA620A371AA2F8DB005DB4C2 /* wrap_Texture.h in Headers */ = {isa = PBXBuildFile; fileRef = FA620A311AA2F8DB005DB4C2 /* wrap_Texture.h */; };
+		FA620A3A1AA305F6005DB4C2 /* types.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA620A391AA305F6005DB4C2 /* types.cpp */; };
+		FA620A3B1AA305F6005DB4C2 /* types.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA620A391AA305F6005DB4C2 /* types.cpp */; };
 		FA8951A21AA2EDF300EC385A /* wrap_Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA8951A01AA2EDF300EC385A /* wrap_Event.cpp */; };
 		FA8951A21AA2EDF300EC385A /* wrap_Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA8951A01AA2EDF300EC385A /* wrap_Event.cpp */; };
 		FA8951A31AA2EDF300EC385A /* wrap_Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA8951A01AA2EDF300EC385A /* wrap_Event.cpp */; };
 		FA8951A31AA2EDF300EC385A /* wrap_Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA8951A01AA2EDF300EC385A /* wrap_Event.cpp */; };
 		FA8951A41AA2EDF300EC385A /* wrap_Event.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8951A11AA2EDF300EC385A /* wrap_Event.h */; };
 		FA8951A41AA2EDF300EC385A /* wrap_Event.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8951A11AA2EDF300EC385A /* wrap_Event.h */; };
@@ -1480,6 +1482,7 @@
 		FA620A2F1AA2F8DB005DB4C2 /* wrap_Quad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Quad.h; sourceTree = "<group>"; };
 		FA620A2F1AA2F8DB005DB4C2 /* wrap_Quad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Quad.h; sourceTree = "<group>"; };
 		FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Texture.cpp; sourceTree = "<group>"; };
 		FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Texture.cpp; sourceTree = "<group>"; };
 		FA620A311AA2F8DB005DB4C2 /* wrap_Texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Texture.h; sourceTree = "<group>"; };
 		FA620A311AA2F8DB005DB4C2 /* wrap_Texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Texture.h; sourceTree = "<group>"; };
+		FA620A391AA305F6005DB4C2 /* types.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = types.cpp; sourceTree = "<group>"; };
 		FA8951A01AA2EDF300EC385A /* wrap_Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Event.cpp; sourceTree = "<group>"; };
 		FA8951A01AA2EDF300EC385A /* wrap_Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Event.cpp; sourceTree = "<group>"; };
 		FA8951A11AA2EDF300EC385A /* wrap_Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Event.h; sourceTree = "<group>"; };
 		FA8951A11AA2EDF300EC385A /* wrap_Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Event.h; sourceTree = "<group>"; };
 		FA9B4A0716E1578300074F42 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = /Library/Frameworks/SDL2.framework; sourceTree = "<absolute>"; };
 		FA9B4A0716E1578300074F42 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = /Library/Frameworks/SDL2.framework; sourceTree = "<absolute>"; };
@@ -1601,6 +1604,7 @@
 				FA0B790E1A958E3B000E1D17 /* runtime.cpp */,
 				FA0B790E1A958E3B000E1D17 /* runtime.cpp */,
 				FA0B790F1A958E3B000E1D17 /* runtime.h */,
 				FA0B790F1A958E3B000E1D17 /* runtime.h */,
 				FA0B79101A958E3B000E1D17 /* StringMap.h */,
 				FA0B79101A958E3B000E1D17 /* StringMap.h */,
+				FA620A391AA305F6005DB4C2 /* types.cpp */,
 				FA0B79111A958E3B000E1D17 /* types.h */,
 				FA0B79111A958E3B000E1D17 /* types.h */,
 				FA0B79121A958E3B000E1D17 /* utf8.cpp */,
 				FA0B79121A958E3B000E1D17 /* utf8.cpp */,
 				FA0B79131A958E3B000E1D17 /* utf8.h */,
 				FA0B79131A958E3B000E1D17 /* utf8.h */,
@@ -3352,6 +3356,7 @@
 				FA0B7A591A958EA3000E1D17 /* b2StackAllocator.cpp in Sources */,
 				FA0B7A591A958EA3000E1D17 /* b2StackAllocator.cpp in Sources */,
 				FA0B7E3D1A95902C000E1D17 /* wrap_Body.cpp in Sources */,
 				FA0B7E3D1A95902C000E1D17 /* wrap_Body.cpp in Sources */,
 				FA0B7D7A1A95902C000E1D17 /* Quad.cpp in Sources */,
 				FA0B7D7A1A95902C000E1D17 /* Quad.cpp in Sources */,
+				FA620A3B1AA305F6005DB4C2 /* types.cpp in Sources */,
 				FA0B7DD41A95902C000E1D17 /* BezierCurve.cpp in Sources */,
 				FA0B7DD41A95902C000E1D17 /* BezierCurve.cpp in Sources */,
 				FA0B7E7C1A95902C000E1D17 /* wrap_World.cpp in Sources */,
 				FA0B7E7C1A95902C000E1D17 /* wrap_World.cpp in Sources */,
 				FA0B7B0C1A958EA3000E1D17 /* tcp.c in Sources */,
 				FA0B7B0C1A958EA3000E1D17 /* tcp.c in Sources */,
@@ -3630,6 +3635,7 @@
 				FA0B7B1B1A958EA3000E1D17 /* usocket.c in Sources */,
 				FA0B7B1B1A958EA3000E1D17 /* usocket.c in Sources */,
 				FA0B7E3C1A95902C000E1D17 /* wrap_Body.cpp in Sources */,
 				FA0B7E3C1A95902C000E1D17 /* wrap_Body.cpp in Sources */,
 				FA0B7D791A95902C000E1D17 /* Quad.cpp in Sources */,
 				FA0B7D791A95902C000E1D17 /* Quad.cpp in Sources */,
+				FA620A3A1AA305F6005DB4C2 /* types.cpp in Sources */,
 				FA0B7DD31A95902C000E1D17 /* BezierCurve.cpp in Sources */,
 				FA0B7DD31A95902C000E1D17 /* BezierCurve.cpp in Sources */,
 				FA0B7E7B1A95902C000E1D17 /* wrap_World.cpp in Sources */,
 				FA0B7E7B1A95902C000E1D17 /* wrap_World.cpp in Sources */,
 				FA0B7B281A958EA3000E1D17 /* simplexnoise1234.cpp in Sources */,
 				FA0B7B281A958EA3000E1D17 /* simplexnoise1234.cpp in Sources */,
@@ -3988,10 +3994,6 @@
 				);
 				);
 				INFOPLIST_FILE = "macosx/liblove-macosx.plist";
 				INFOPLIST_FILE = "macosx/liblove-macosx.plist";
 				LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)";
 				LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)";
-				LIBRARY_SEARCH_PATHS = (
-					"$(inherited)",
-					"$(PROJECT_DIR)/ios/libraries/SDL2",
-				);
 				OTHER_LDFLAGS = (
 				OTHER_LDFLAGS = (
 					"-undefined",
 					"-undefined",
 					dynamic_lookup,
 					dynamic_lookup,
@@ -4024,10 +4026,6 @@
 				);
 				);
 				INFOPLIST_FILE = "macosx/liblove-macosx.plist";
 				INFOPLIST_FILE = "macosx/liblove-macosx.plist";
 				LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)";
 				LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)";
-				LIBRARY_SEARCH_PATHS = (
-					"$(inherited)",
-					"$(PROJECT_DIR)/ios/libraries/SDL2",
-				);
 				OTHER_LDFLAGS = (
 				OTHER_LDFLAGS = (
 					"-undefined",
 					"-undefined",
 					dynamic_lookup,
 					dynamic_lookup,
@@ -4061,10 +4059,6 @@
 				);
 				);
 				INFOPLIST_FILE = "macosx/liblove-macosx.plist";
 				INFOPLIST_FILE = "macosx/liblove-macosx.plist";
 				LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)";
 				LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)";
-				LIBRARY_SEARCH_PATHS = (
-					"$(inherited)",
-					"$(PROJECT_DIR)/ios/libraries/SDL2",
-				);
 				OTHER_LDFLAGS = (
 				OTHER_LDFLAGS = (
 					"-undefined",
 					"-undefined",
 					dynamic_lookup,
 					dynamic_lookup,

+ 1 - 6
src/common/Variant.cpp

@@ -101,7 +101,6 @@ Variant::Variant(love::Type udatatype, void *userdata)
 	if (udatatype != INVALID_ID)
 	if (udatatype != INVALID_ID)
 	{
 	{
 		Proxy *p = (Proxy *) userdata;
 		Proxy *p = (Proxy *) userdata;
-		flags = p->flags;
 		data.userdata = p->object;
 		data.userdata = p->object;
 		p->object->retain();
 		p->object->retain();
 	}
 	}
@@ -223,11 +222,7 @@ void Variant::toLua(lua_State *L)
 		break;
 		break;
 	case FUSERDATA:
 	case FUSERDATA:
 		if (udatatype != INVALID_ID)
 		if (udatatype != INVALID_ID)
-		{
-			const char *name = NULL;
-			love::types.find(udatatype, name);
-			luax_pushtype(L, name, flags, (love::Object *) data.userdata);
-		}
+			luax_pushtype(L, udatatype, (love::Object *) data.userdata);
 		else
 		else
 			lua_pushlightuserdata(L, data.userdata);
 			lua_pushlightuserdata(L, data.userdata);
 		// I know this is not the same
 		// I know this is not the same

+ 0 - 1
src/common/Variant.h

@@ -76,7 +76,6 @@ public:
 
 
 private:
 private:
 	love::Type udatatype;
 	love::Type udatatype;
-	bits flags;
 
 
 }; // Variant
 }; // Variant
 } // love
 } // love

+ 20 - 113
src/common/runtime.cpp

@@ -56,7 +56,7 @@ static int w__typeOf(lua_State *L)
 {
 {
 	Proxy *p = (Proxy *)lua_touserdata(L, 1);
 	Proxy *p = (Proxy *)lua_touserdata(L, 1);
 	Type t = luax_type(L, 2);
 	Type t = luax_type(L, 2);
-	luax_pushboolean(L, p->flags[t]);
+	luax_pushboolean(L, typeFlags[p->type][t]);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -207,7 +207,7 @@ int luax_register_module(lua_State *L, const WrappedModule &m)
 
 
 	Proxy *p = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
 	Proxy *p = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
 	p->object = m.module;
 	p->object = m.module;
-	p->flags = m.flags;
+	p->type = m.type;
 
 
 	luaL_newmetatable(L, m.module->getName());
 	luaL_newmetatable(L, m.module->getName());
 	lua_pushvalue(L, -1);
 	lua_pushvalue(L, -1);
@@ -254,12 +254,12 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name)
 	return 0;
 	return 0;
 }
 }
 
 
-int luax_register_type(lua_State *L, const char *tname, const luaL_Reg *f)
+int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f)
 {
 {
 	// Verify that this type name has a matching Type ID and type name mapping.
 	// Verify that this type name has a matching Type ID and type name mapping.
-	love::Type ltype;
-	if (!love::getType(tname, ltype))
-		printf("Missing type entry for type name: %s\n", tname);
+	const char *tname = "Invalid";
+	if (!love::getType(type, tname))
+		printf("Missing type name entry for type ID %d\n", type);
 
 
 	// Get the place for storing and re-using instantiated love types.
 	// Get the place for storing and re-using instantiated love types.
 	luax_getregistry(L, REGISTRY_TYPES);
 	luax_getregistry(L, REGISTRY_TYPES);
@@ -374,20 +374,23 @@ int luax_register_searcher(lua_State *L, lua_CFunction f, int pos)
 	return 0;
 	return 0;
 }
 }
 
 
-void luax_rawnewtype(lua_State *L, const char *name, bits flags, love::Object *object)
+void luax_rawnewtype(lua_State *L, love::Type type, love::Object *object)
 {
 {
 	Proxy *u = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
 	Proxy *u = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
 
 
 	object->retain();
 	object->retain();
 
 
 	u->object = object;
 	u->object = object;
-	u->flags = flags;
+	u->type = type;
+
+	const char *name = "Invalid";
+	getType(type, name);
 
 
 	luaL_newmetatable(L, name);
 	luaL_newmetatable(L, name);
 	lua_setmetatable(L, -2);
 	lua_setmetatable(L, -2);
 }
 }
 
 
-void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *object)
+void luax_pushtype(lua_State *L, love::Type type, love::Object *object)
 {
 {
 	if (object == nullptr)
 	if (object == nullptr)
 	{
 	{
@@ -402,11 +405,11 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
 	if (!lua_istable(L, -1))
 	if (!lua_istable(L, -1))
 	{
 	{
 		lua_pop(L, 1);
 		lua_pop(L, 1);
-		return luax_rawnewtype(L, name, flags, object);
+		return luax_rawnewtype(L, type, object);
 	}
 	}
 
 
 	// Get the value of lovetypes[object] on the stack.
 	// Get the value of lovetypes[object] on the stack.
-	lua_pushlightuserdata(L, (void *) object);
+	lua_pushlightuserdata(L, object);
 	lua_gettable(L, -2);
 	lua_gettable(L, -2);
 
 
 	// If the Proxy userdata isn't in the instantiated types table yet, add it.
 	// If the Proxy userdata isn't in the instantiated types table yet, add it.
@@ -414,9 +417,9 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
 	{
 	{
 		lua_pop(L, 1);
 		lua_pop(L, 1);
 
 
-		luax_rawnewtype(L, name, flags, object);
+		luax_rawnewtype(L, type, object);
 
 
-		lua_pushlightuserdata(L, (void *) object);
+		lua_pushlightuserdata(L, object);
 		lua_pushvalue(L, -2);
 		lua_pushvalue(L, -2);
 
 
 		// lovetypes[object] = Proxy.
 		// lovetypes[object] = Proxy.
@@ -429,12 +432,13 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
 	// Keep the Proxy userdata on the stack.
 	// Keep the Proxy userdata on the stack.
 }
 }
 
 
-bool luax_istype(lua_State *L, int idx, love::bits type)
+bool luax_istype(lua_State *L, int idx, love::Type type)
 {
 {
 	if (lua_type(L, idx) != LUA_TUSERDATA)
 	if (lua_type(L, idx) != LUA_TUSERDATA)
 		return false;
 		return false;
 
 
-	return ((((Proxy *)lua_touserdata(L, idx))->flags & type) == type);
+	Proxy *p = (Proxy *) lua_touserdata(L, idx);
+	return typeFlags[p->type][type];
 }
 }
 
 
 int luax_getfunction(lua_State *L, const char *mod, const char *fn)
 int luax_getfunction(lua_State *L, const char *mod, const char *fn)
@@ -624,107 +628,10 @@ extern "C" int luax_typerror(lua_State *L, int narg, const char *tname)
 	return luaL_argerror(L, narg, msg);
 	return luaL_argerror(L, narg, msg);
 }
 }
 
 
-StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
-{
-	{"Invalid", INVALID_ID},
-
-	{"Object", OBJECT_ID},
-	{"Data", DATA_ID},
-	{"Module", MODULE_ID},
-
-	// Filesystem
-	{"File", FILESYSTEM_FILE_ID},
-	{"DroppedFile", FILESYSTEM_DROPPED_FILE_ID},
-	{"FileData", FILESYSTEM_FILE_DATA_ID},
-
-	// Font
-	{"GlyphData", FONT_GLYPH_DATA_ID},
-	{"Rasterizer", FONT_RASTERIZER_ID},
-
-	// Graphics
-	{"Drawable", GRAPHICS_DRAWABLE_ID},
-	{"Texture", GRAPHICS_TEXTURE_ID},
-	{"Image", GRAPHICS_IMAGE_ID},
-	{"Quad", GRAPHICS_QUAD_ID},
-	{"Font", GRAPHICS_FONT_ID},
-	{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
-	{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
-	{"Canvas", GRAPHICS_CANVAS_ID},
-	{"Shader", GRAPHICS_SHADER_ID},
-	{"Mesh", GRAPHICS_MESH_ID},
-	{"Text", GRAPHICS_TEXT_ID},
-
-	// Image
-	{"ImageData", IMAGE_IMAGE_DATA_ID},
-	{"CompressedData", IMAGE_COMPRESSED_DATA_ID},
-
-	// Joystick
-	{"Joystick", JOYSTICK_JOYSTICK_ID},
-
-	// Math
-	{"RandomGenerator", MATH_RANDOM_GENERATOR_ID},
-	{"BezierCurve", MATH_BEZIER_CURVE_ID},
-
-	// Audio
-	{"Source", AUDIO_SOURCE_ID},
-
-	// Sound
-	{"SoundData", SOUND_SOUND_DATA_ID},
-	{"Decoder", SOUND_DECODER_ID},
-
-	// Mouse
-	{"Cursor", MOUSE_CURSOR_ID},
-
-	// Physics
-	{"World", PHYSICS_WORLD_ID},
-	{"Contact", PHYSICS_CONTACT_ID},
-	{"Body", PHYSICS_BODY_ID},
-	{"Fixture", PHYSICS_FIXTURE_ID},
-	{"Shape", PHYSICS_SHAPE_ID},
-	{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
-	{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
-	{"EdgeShape", PHYSICS_EDGE_SHAPE_ID},
-	{"ChainShape", PHYSICS_CHAIN_SHAPE_ID},
-	{"Joint", PHYSICS_JOINT_ID},
-	{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
-	{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
-	{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
-	{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
-	{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
-	{"GearJoint", PHYSICS_GEAR_JOINT_ID},
-	{"FrictionJoint", PHYSICS_FRICTION_JOINT_ID},
-	{"WeldJoint", PHYSICS_WELD_JOINT_ID},
-	{"RopeJoint", PHYSICS_ROPE_JOINT_ID},
-	{"WheelJoint", PHYSICS_WHEEL_JOINT_ID},
-	{"MotorJoint", PHYSICS_MOTOR_JOINT_ID},
-
-	// Thread
-	{"Thread", THREAD_THREAD_ID},
-	{"Channel", THREAD_CHANNEL_ID},
-
-	// The modules themselves. Only add abstracted modules here.
-	{"filesystem", MODULE_FILESYSTEM_ID},
-	{"graphics", MODULE_GRAPHICS_ID},
-	{"image", MODULE_IMAGE_ID},
-	{"sound", MODULE_SOUND_ID},
-};
-
-StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
-
-bool getType(const char *in, love::Type &out)
-{
-	return types.find(in, out);
-}
-
-bool getType(love::Type in, const char *&out)
-{
-	return types.find(in, out);
-}
-
 Type luax_type(lua_State *L, int idx)
 Type luax_type(lua_State *L, int idx)
 {
 {
 	Type t = INVALID_ID;
 	Type t = INVALID_ID;
-	types.find(luaL_checkstring(L, idx), t);
+	getType(luaL_checkstring(L, idx), t);
 	return t;
 	return t;
 }
 }
 
 

+ 37 - 26
src/common/runtime.h

@@ -63,7 +63,7 @@ enum Registry
 struct Proxy
 struct Proxy
 {
 {
 	// Holds type information (see types.h).
 	// Holds type information (see types.h).
-	bits flags;
+	Type type;
 
 
 	// Pointer to the actual object.
 	// Pointer to the actual object.
 	Object *object;
 	Object *object;
@@ -80,15 +80,14 @@ struct WrappedModule
 	// The name for the table to put the functions in, without the 'love'-prefix.
 	// The name for the table to put the functions in, without the 'love'-prefix.
 	const char *name;
 	const char *name;
 
 
-	// The type flags of this module.
-	love::bits flags;
+	// The type of this module.
+	love::Type type;
 
 
 	// The functions of the module (last element {0,0}).
 	// The functions of the module (last element {0,0}).
 	const luaL_Reg *functions;
 	const luaL_Reg *functions;
 
 
 	// A list of functions which expose the types of the modules (last element 0).
 	// A list of functions which expose the types of the modules (last element 0).
 	const lua_CFunction *types;
 	const lua_CFunction *types;
-
 };
 };
 
 
 /**
 /**
@@ -241,11 +240,10 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name);
 
 
 /**
 /**
  * Register a new type.
  * Register a new type.
- * @param tname The name of the type. This must not conflict with other type names,
- * even from other modules.
+ * @param type The type.
  * @param f The list of member functions for the type.
  * @param f The list of member functions for the type.
  **/
  **/
-int luax_register_type(lua_State *L, const char *tname, const luaL_Reg *f = 0);
+int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f = 0);
 
 
 /**
 /**
  * Do a table.insert from C
  * Do a table.insert from C
@@ -271,10 +269,10 @@ int luax_register_searcher(lua_State *L, lua_CFunction f, int pos = -1);
  * NOTE: The object will be retained by Lua and released upon garbage collection.
  * NOTE: The object will be retained by Lua and released upon garbage collection.
  * @param L The Lua state.
  * @param L The Lua state.
  * @param name The name of the type. This must match the name used with luax_register_type.
  * @param name The name of the type. This must match the name used with luax_register_type.
- * @param flags The type information of the object.
+ * @param type The type information of the object.
  * @param object The pointer to the actual object.
  * @param object The pointer to the actual object.
  **/
  **/
-void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *object);
+void luax_pushtype(lua_State *L, const love::Type type, love::Object *object);
 
 
 /**
 /**
  * Creates a new Lua representation of the given object *without* checking if it
  * Creates a new Lua representation of the given object *without* checking if it
@@ -285,10 +283,10 @@ void luax_pushtype(lua_State *L, const char *name, bits flags, love::Object *obj
  * NOTE: The object will be retained by Lua and released upon garbage collection.
  * NOTE: The object will be retained by Lua and released upon garbage collection.
  * @param L The Lua state.
  * @param L The Lua state.
  * @param name The name of the type. This must match the name used with luax_register_type.
  * @param name The name of the type. This must match the name used with luax_register_type.
- * @param flags The type information of the object.
+ * @param type The type information of the object.
  * @param object The pointer to the actual object.
  * @param object The pointer to the actual object.
  **/
  **/
-void luax_rawnewtype(lua_State *L, const char *name, bits flags, love::Object *object);
+void luax_rawnewtype(lua_State *L, love::Type type, love::Object *object);
 
 
 /**
 /**
  * Checks whether the value at idx is a certain type.
  * Checks whether the value at idx is a certain type.
@@ -297,7 +295,7 @@ void luax_rawnewtype(lua_State *L, const char *name, bits flags, love::Object *o
  * @param type The type to check for.
  * @param type The type to check for.
  * @return True if the value is Proxy of the specified type, false otherwise.
  * @return True if the value is Proxy of the specified type, false otherwise.
  **/
  **/
-bool luax_istype(lua_State *L, int idx, love::bits type);
+bool luax_istype(lua_State *L, int idx, love::Type type);
 
 
 /**
 /**
  * Gets the function love.module.function and puts it on top of the stack (alone). If the
  * Gets the function love.module.function and puts it on top of the stack (alone). If the
@@ -399,32 +397,43 @@ extern "C" { // Also called from luasocket
  * @param type The type bit.
  * @param type The type bit.
  **/
  **/
 template <typename T>
 template <typename T>
-T *luax_checktype(lua_State *L, int idx, const char *name, love::bits type)
+T *luax_checktype(lua_State *L, int idx, love::Type type)
 {
 {
 	if (lua_type(L, idx) != LUA_TUSERDATA)
 	if (lua_type(L, idx) != LUA_TUSERDATA)
+	{
+		const char *name = "Invalid";
+		getType(type, name);
 		luax_typerror(L, idx, name);
 		luax_typerror(L, idx, name);
+	}
 
 
 	Proxy *u = (Proxy *)lua_touserdata(L, idx);
 	Proxy *u = (Proxy *)lua_touserdata(L, idx);
 
 
-	if ((u->flags & type) != type)
+	if (!typeFlags[u->type][type])
+	{
+		const char *name = "Invalid";
+		getType(type, name);
 		luax_typerror(L, idx, name);
 		luax_typerror(L, idx, name);
+	}
 
 
 	return (T *)u->object;
 	return (T *)u->object;
 }
 }
 
 
 template <typename T>
 template <typename T>
-T *luax_getmodule(lua_State *L, const char *k, love::bits type)
+T *luax_getmodule(lua_State *L, love::Type type)
 {
 {
+	const char *name = "Invalid";
+	getType(type, name);
+
 	luax_insistregistry(L, REGISTRY_MODULES);
 	luax_insistregistry(L, REGISTRY_MODULES);
-	lua_getfield(L, -1, k);
+	lua_getfield(L, -1, name);
 
 
 	if (!lua_isuserdata(L, -1))
 	if (!lua_isuserdata(L, -1))
-		luaL_error(L, "Tried to get nonexistant module %s.", k);
+		luaL_error(L, "Tried to get nonexistant module %s.", name);
 
 
 	Proxy *u = (Proxy *)lua_touserdata(L, -1);
 	Proxy *u = (Proxy *)lua_touserdata(L, -1);
 
 
-	if ((u->flags & type) != type)
-		luaL_error(L, "Incorrect module %s", k);
+	if (!typeFlags[u->type][type])
+		luaL_error(L, "Incorrect module %s", name);
 
 
 	lua_pop(L, 2);
 	lua_pop(L, 2);
 
 
@@ -432,10 +441,13 @@ T *luax_getmodule(lua_State *L, const char *k, love::bits type)
 }
 }
 
 
 template <typename T>
 template <typename T>
-T *luax_optmodule(lua_State *L, const char *k, love::bits type)
+T *luax_optmodule(lua_State *L, love::Type type)
 {
 {
+	const char *name = "Invalid";
+	getType(type, name);
+
 	luax_insistregistry(L, REGISTRY_MODULES);
 	luax_insistregistry(L, REGISTRY_MODULES);
-	lua_getfield(L, -1, k);
+	lua_getfield(L, -1, name);
 
 
 	if (!lua_isuserdata(L, -1))
 	if (!lua_isuserdata(L, -1))
 	{
 	{
@@ -445,8 +457,8 @@ T *luax_optmodule(lua_State *L, const char *k, love::bits type)
 
 
 	Proxy *u = (Proxy *)lua_touserdata(L, -1);
 	Proxy *u = (Proxy *)lua_touserdata(L, -1);
 
 
-	if ((u->flags & type) != type)
-		luaL_error(L, "Incorrect module %s", k);
+	if (!typeFlags[u->type][type])
+		luaL_error(L, "Incorrect module %s", name);
 	
 	
 	lua_pop(L, 2);
 	lua_pop(L, 2);
 	
 	
@@ -459,11 +471,10 @@ T *luax_optmodule(lua_State *L, const char *k, love::bits type)
  * luax_istype, then this can be safely used. Otherwise, use luax_checktype.
  * luax_istype, then this can be safely used. Otherwise, use luax_checktype.
  * @param L The Lua state.
  * @param L The Lua state.
  * @param idx The index on the stack.
  * @param idx The index on the stack.
- * @param name The name of the type.
- * @param type The type bit.
+ * @param type The type of the object.
  **/
  **/
 template <typename T>
 template <typename T>
-T *luax_totype(lua_State *L, int idx, const char * /* name */, love::bits /* type */)
+T *luax_totype(lua_State *L, int idx, love::Type /*type*/)
 {
 {
 	return (T *)(((Proxy *)lua_touserdata(L, idx))->object);
 	return (T *)(((Proxy *)lua_touserdata(L, idx))->object);
 }
 }

+ 215 - 0
src/common/types.cpp

@@ -0,0 +1,215 @@
+/**
+ * Copyright (c) 2006-2015 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "types.h"
+#include "StringMap.h"
+
+namespace love
+{
+
+static const TypeBits *createTypeFlags()
+{
+	static TypeBits b[TYPE_MAX_ENUM];
+	TypeBits one = TypeBits(1);
+
+	b[INVALID_ID] = one << INVALID_ID;
+
+	b[OBJECT_ID] = one << OBJECT_ID;
+	b[DATA_ID] = (one << DATA_ID) | b[OBJECT_ID];
+	b[MODULE_ID] = (one << MODULE_ID) | b[OBJECT_ID];
+
+	// Filesystem.
+	b[FILESYSTEM_FILE_ID] = (one << FILESYSTEM_FILE_ID) | b[OBJECT_ID];
+	b[FILESYSTEM_DROPPED_FILE_ID] = (one << FILESYSTEM_DROPPED_FILE_ID) | b[FILESYSTEM_FILE_ID];
+	b[FILESYSTEM_FILE_DATA_ID] = (one << FILESYSTEM_FILE_DATA_ID) | b[DATA_ID];
+
+	b[FONT_GLYPH_DATA_ID] = (one << FONT_GLYPH_DATA_ID) | b[DATA_ID];
+	b[FONT_RASTERIZER_ID] = (one << FONT_RASTERIZER_ID) | b[OBJECT_ID];
+
+	// Graphics.
+	b[GRAPHICS_DRAWABLE_ID] = (one << GRAPHICS_DRAWABLE_ID) | b[OBJECT_ID];
+	b[GRAPHICS_TEXTURE_ID] = (one << GRAPHICS_TEXTURE_ID) | b[GRAPHICS_DRAWABLE_ID];
+	b[GRAPHICS_IMAGE_ID] = (one << GRAPHICS_IMAGE_ID) | b[GRAPHICS_TEXTURE_ID];
+	b[GRAPHICS_QUAD_ID] = (one << GRAPHICS_QUAD_ID) | b[OBJECT_ID];
+	b[GRAPHICS_FONT_ID] = (one << GRAPHICS_FONT_ID) | b[OBJECT_ID];
+	b[GRAPHICS_PARTICLE_SYSTEM_ID] = (one << GRAPHICS_PARTICLE_SYSTEM_ID) | b[GRAPHICS_DRAWABLE_ID];
+	b[GRAPHICS_SPRITE_BATCH_ID] = (one << GRAPHICS_SPRITE_BATCH_ID) | b[GRAPHICS_DRAWABLE_ID];
+	b[GRAPHICS_CANVAS_ID] = (one << GRAPHICS_CANVAS_ID) | b[GRAPHICS_TEXTURE_ID];
+	b[GRAPHICS_SHADER_ID] = (one << GRAPHICS_SHADER_ID) | b[OBJECT_ID];
+	b[GRAPHICS_MESH_ID] = (one << GRAPHICS_MESH_ID) | b[GRAPHICS_DRAWABLE_ID];
+	b[GRAPHICS_TEXT_ID] = (one << GRAPHICS_TEXT_ID) | b[GRAPHICS_DRAWABLE_ID];
+
+	// Image.
+	b[IMAGE_IMAGE_DATA_ID] = (one << IMAGE_IMAGE_DATA_ID) | b[DATA_ID];
+	b[IMAGE_COMPRESSED_DATA_ID] = (one << IMAGE_COMPRESSED_DATA_ID) | b[DATA_ID];
+
+	// Joystick.
+	b[JOYSTICK_JOYSTICK_ID] = (one << JOYSTICK_JOYSTICK_ID) | b[OBJECT_ID];
+
+	// Math.
+	b[MATH_RANDOM_GENERATOR_ID] = (one << MATH_RANDOM_GENERATOR_ID) | b[OBJECT_ID];
+	b[MATH_BEZIER_CURVE_ID] = (one << MATH_BEZIER_CURVE_ID) | b[OBJECT_ID];
+
+	// Audio.
+	b[AUDIO_SOURCE_ID] = (one << AUDIO_SOURCE_ID) | b[OBJECT_ID];
+
+	// Sound.
+	b[SOUND_SOUND_DATA_ID] = (one << SOUND_SOUND_DATA_ID) | b[DATA_ID];
+	b[SOUND_DECODER_ID] = one << SOUND_DECODER_ID;
+
+	// Mouse.
+	b[MOUSE_CURSOR_ID] = (one << MOUSE_CURSOR_ID) | b[OBJECT_ID];
+
+	// Physics.
+	b[PHYSICS_WORLD_ID] = (one << PHYSICS_WORLD_ID) | b[OBJECT_ID];
+	b[PHYSICS_CONTACT_ID] = (one << PHYSICS_CONTACT_ID) | b[OBJECT_ID];
+	b[PHYSICS_BODY_ID] = (one << PHYSICS_BODY_ID) | b[OBJECT_ID];
+	b[PHYSICS_FIXTURE_ID] = (one << PHYSICS_FIXTURE_ID) | b[OBJECT_ID];
+	b[PHYSICS_SHAPE_ID] = (one << PHYSICS_SHAPE_ID) | b[OBJECT_ID];
+	b[PHYSICS_CIRCLE_SHAPE_ID] = (one << PHYSICS_CIRCLE_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
+	b[PHYSICS_POLYGON_SHAPE_ID] = (one << PHYSICS_POLYGON_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
+	b[PHYSICS_EDGE_SHAPE_ID] = (one << PHYSICS_EDGE_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
+	b[PHYSICS_CHAIN_SHAPE_ID] = (one << PHYSICS_CHAIN_SHAPE_ID) | b[PHYSICS_SHAPE_ID];
+	b[PHYSICS_JOINT_ID] = (one << PHYSICS_JOINT_ID) | b[OBJECT_ID];
+	b[PHYSICS_MOUSE_JOINT_ID] = (one << PHYSICS_MOUSE_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_DISTANCE_JOINT_ID] = (one << PHYSICS_DISTANCE_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_PRISMATIC_JOINT_ID] = (one << PHYSICS_PRISMATIC_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_REVOLUTE_JOINT_ID] = (one << PHYSICS_REVOLUTE_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_PULLEY_JOINT_ID] = (one << PHYSICS_PULLEY_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_GEAR_JOINT_ID] = (one << PHYSICS_GEAR_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_FRICTION_JOINT_ID] = (one << PHYSICS_FRICTION_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_WELD_JOINT_ID] = (one << PHYSICS_WELD_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_ROPE_JOINT_ID] = (one << PHYSICS_ROPE_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_WHEEL_JOINT_ID] = (one << PHYSICS_WHEEL_JOINT_ID) | b[PHYSICS_JOINT_ID];
+	b[PHYSICS_MOTOR_JOINT_ID] = (one << PHYSICS_MOTOR_JOINT_ID) | b[PHYSICS_JOINT_ID];
+
+	// Thread.
+	b[THREAD_THREAD_ID] = (one << THREAD_THREAD_ID) | b[OBJECT_ID];
+	b[THREAD_CHANNEL_ID] = (one << THREAD_CHANNEL_ID) | b[OBJECT_ID];
+
+	// Modules.
+	b[MODULE_FILESYSTEM_ID] = (one << MODULE_FILESYSTEM_ID) | b[MODULE_ID];
+	b[MODULE_GRAPHICS_ID] = (one << MODULE_GRAPHICS_ID) | b[MODULE_ID];
+	b[MODULE_IMAGE_ID] = (one << MODULE_IMAGE_ID) | b[MODULE_ID];
+	b[MODULE_SOUND_ID] = (one << MODULE_SOUND_ID) | b[MODULE_ID];
+
+	return b;
+}
+
+const TypeBits *typeFlags = createTypeFlags();
+
+StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
+{
+	{"Invalid", INVALID_ID},
+
+	{"Object", OBJECT_ID},
+	{"Data", DATA_ID},
+	{"Module", MODULE_ID},
+
+	// Filesystem
+	{"File", FILESYSTEM_FILE_ID},
+	{"DroppedFile", FILESYSTEM_DROPPED_FILE_ID},
+	{"FileData", FILESYSTEM_FILE_DATA_ID},
+
+	// Font
+	{"GlyphData", FONT_GLYPH_DATA_ID},
+	{"Rasterizer", FONT_RASTERIZER_ID},
+
+	// Graphics
+	{"Drawable", GRAPHICS_DRAWABLE_ID},
+	{"Texture", GRAPHICS_TEXTURE_ID},
+	{"Image", GRAPHICS_IMAGE_ID},
+	{"Quad", GRAPHICS_QUAD_ID},
+	{"Font", GRAPHICS_FONT_ID},
+	{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
+	{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
+	{"Canvas", GRAPHICS_CANVAS_ID},
+	{"Shader", GRAPHICS_SHADER_ID},
+	{"Mesh", GRAPHICS_MESH_ID},
+	{"Text", GRAPHICS_TEXT_ID},
+
+	// Image
+	{"ImageData", IMAGE_IMAGE_DATA_ID},
+	{"CompressedData", IMAGE_COMPRESSED_DATA_ID},
+
+	// Joystick
+	{"Joystick", JOYSTICK_JOYSTICK_ID},
+
+	// Math
+	{"RandomGenerator", MATH_RANDOM_GENERATOR_ID},
+	{"BezierCurve", MATH_BEZIER_CURVE_ID},
+
+	// Audio
+	{"Source", AUDIO_SOURCE_ID},
+
+	// Sound
+	{"SoundData", SOUND_SOUND_DATA_ID},
+	{"Decoder", SOUND_DECODER_ID},
+
+	// Mouse
+	{"Cursor", MOUSE_CURSOR_ID},
+
+	// Physics
+	{"World", PHYSICS_WORLD_ID},
+	{"Contact", PHYSICS_CONTACT_ID},
+	{"Body", PHYSICS_BODY_ID},
+	{"Fixture", PHYSICS_FIXTURE_ID},
+	{"Shape", PHYSICS_SHAPE_ID},
+	{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
+	{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
+	{"EdgeShape", PHYSICS_EDGE_SHAPE_ID},
+	{"ChainShape", PHYSICS_CHAIN_SHAPE_ID},
+	{"Joint", PHYSICS_JOINT_ID},
+	{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
+	{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
+	{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
+	{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
+	{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
+	{"GearJoint", PHYSICS_GEAR_JOINT_ID},
+	{"FrictionJoint", PHYSICS_FRICTION_JOINT_ID},
+	{"WeldJoint", PHYSICS_WELD_JOINT_ID},
+	{"RopeJoint", PHYSICS_ROPE_JOINT_ID},
+	{"WheelJoint", PHYSICS_WHEEL_JOINT_ID},
+	{"MotorJoint", PHYSICS_MOTOR_JOINT_ID},
+
+	// Thread
+	{"Thread", THREAD_THREAD_ID},
+	{"Channel", THREAD_CHANNEL_ID},
+
+	// The modules themselves. Only add abstracted modules here.
+	{"filesystem", MODULE_FILESYSTEM_ID},
+	{"graphics", MODULE_GRAPHICS_ID},
+	{"image", MODULE_IMAGE_ID},
+	{"sound", MODULE_SOUND_ID},
+};
+
+StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
+
+bool getType(const char *in, love::Type &out)
+{
+	return types.find(in, out);
+}
+
+bool getType(love::Type in, const char *&out)
+{
+	return types.find(in, out);
+}
+
+} // love

+ 7 - 83
src/common/types.h

@@ -115,91 +115,15 @@ enum Type
 	TYPE_MAX_ENUM
 	TYPE_MAX_ENUM
 };
 };
 
 
-typedef std::bitset<TYPE_MAX_ENUM> bits;
-
-const bits INVALID_T = bits(1) << INVALID_ID;
-
-const bits OBJECT_T = bits(1) << OBJECT_ID;
-const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
-const bits MODULE_T = (bits(1) << MODULE_ID) | OBJECT_T;
-
-// Filesystem.
-const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
-const bits FILESYSTEM_DROPPED_FILE_T = (bits(1) << FILESYSTEM_DROPPED_FILE_ID) | FILESYSTEM_FILE_T;
-const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;
-
-const bits FONT_GLYPH_DATA_T = (bits(1) << FONT_GLYPH_DATA_ID) | DATA_T;
-const bits FONT_RASTERIZER_T = (bits(1) << FONT_RASTERIZER_ID) | OBJECT_T;
-
-// Graphics.
-const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
-const bits GRAPHICS_TEXTURE_T = (bits(1) << GRAPHICS_TEXTURE_ID) | GRAPHICS_DRAWABLE_T;
-const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_TEXTURE_T;
-const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
-const bits GRAPHICS_FONT_T = (bits(1) << GRAPHICS_FONT_ID) | OBJECT_T;
-const bits GRAPHICS_PARTICLE_SYSTEM_T = (bits(1) << GRAPHICS_PARTICLE_SYSTEM_ID) | GRAPHICS_DRAWABLE_T;
-const bits GRAPHICS_SPRITE_BATCH_T = (bits(1) << GRAPHICS_SPRITE_BATCH_ID) | GRAPHICS_DRAWABLE_T;
-const bits GRAPHICS_CANVAS_T = (bits(1) << GRAPHICS_CANVAS_ID) | GRAPHICS_TEXTURE_T;
-const bits GRAPHICS_SHADER_T = (bits(1) << GRAPHICS_SHADER_ID) | OBJECT_T;
-const bits GRAPHICS_MESH_T = (bits(1) << GRAPHICS_MESH_ID) | GRAPHICS_DRAWABLE_T;
-const bits GRAPHICS_TEXT_T = (bits(1) << GRAPHICS_TEXT_ID) | GRAPHICS_DRAWABLE_T;
-
-// Image.
-const bits IMAGE_IMAGE_DATA_T = (bits(1) << IMAGE_IMAGE_DATA_ID) | DATA_T;
-const bits IMAGE_COMPRESSED_DATA_T = (bits(1) << IMAGE_COMPRESSED_DATA_ID) | DATA_T;
-
-// Joystick.
-const bits JOYSTICK_JOYSTICK_T = (bits(1) << JOYSTICK_JOYSTICK_ID) | OBJECT_T;
-
-// Math.
-const bits MATH_RANDOM_GENERATOR_T = (bits(1) << MATH_RANDOM_GENERATOR_ID) | OBJECT_T;
-const bits MATH_BEZIER_CURVE_T = (bits(1) << MATH_BEZIER_CURVE_ID) | OBJECT_T;
-
-// Audio.
-const bits AUDIO_SOURCE_T = (bits(1) << AUDIO_SOURCE_ID) | OBJECT_T;
-
-// Sound.
-const bits SOUND_SOUND_DATA_T = (bits(1) << SOUND_SOUND_DATA_ID) | DATA_T;
-const bits SOUND_DECODER_T = bits(1) << SOUND_DECODER_ID;
-
-// Mouse.
-const bits MOUSE_CURSOR_T = (bits(1) << MOUSE_CURSOR_ID) | OBJECT_T;
-
-// Physics.
-const bits PHYSICS_WORLD_T = (bits(1) << PHYSICS_WORLD_ID) | OBJECT_T;
-const bits PHYSICS_CONTACT_T = (bits(1) << PHYSICS_CONTACT_ID) | OBJECT_T;
-const bits PHYSICS_BODY_T = (bits(1) << PHYSICS_BODY_ID) | OBJECT_T;
-const bits PHYSICS_FIXTURE_T = (bits(1) << PHYSICS_FIXTURE_ID) | OBJECT_T;
-const bits PHYSICS_SHAPE_T = (bits(1) << PHYSICS_SHAPE_ID) | OBJECT_T;
-const bits PHYSICS_CIRCLE_SHAPE_T = (bits(1) << PHYSICS_CIRCLE_SHAPE_ID) | PHYSICS_SHAPE_T;
-const bits PHYSICS_POLYGON_SHAPE_T = (bits(1) << PHYSICS_POLYGON_SHAPE_ID) | PHYSICS_SHAPE_T;
-const bits PHYSICS_EDGE_SHAPE_T = (bits(1) << PHYSICS_EDGE_SHAPE_ID) | PHYSICS_SHAPE_T;
-const bits PHYSICS_CHAIN_SHAPE_T = (bits(1) << PHYSICS_CHAIN_SHAPE_ID) | PHYSICS_SHAPE_T;
-const bits PHYSICS_JOINT_T = (bits(1) << PHYSICS_JOINT_ID) | OBJECT_T;
-const bits PHYSICS_MOUSE_JOINT_T = (bits(1) << PHYSICS_MOUSE_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_DISTANCE_JOINT_T = (bits(1) << PHYSICS_DISTANCE_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_PRISMATIC_JOINT_T = (bits(1) << PHYSICS_PRISMATIC_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_REVOLUTE_JOINT_T = (bits(1) << PHYSICS_REVOLUTE_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_PULLEY_JOINT_T = (bits(1) << PHYSICS_PULLEY_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_GEAR_JOINT_T = (bits(1) << PHYSICS_GEAR_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_FRICTION_JOINT_T = (bits(1) << PHYSICS_FRICTION_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_WELD_JOINT_T = (bits(1) << PHYSICS_WELD_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_ROPE_JOINT_T = (bits(1) << PHYSICS_ROPE_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_WHEEL_JOINT_T = (bits(1) << PHYSICS_WHEEL_JOINT_ID) | PHYSICS_JOINT_T;
-const bits PHYSICS_MOTOR_JOINT_T = (bits(1) << PHYSICS_MOTOR_JOINT_ID) | PHYSICS_JOINT_T;
-
-// Thread.
-const bits THREAD_THREAD_T = (bits(1) << THREAD_THREAD_ID) | OBJECT_T;
-const bits THREAD_CHANNEL_T = (bits(1) << THREAD_CHANNEL_ID) | OBJECT_T;
-
-// Modules.
-const bits MODULE_FILESYSTEM_T = (bits(1) << MODULE_FILESYSTEM_ID) | MODULE_T;
-const bits MODULE_GRAPHICS_T = (bits(1) << MODULE_GRAPHICS_ID) | MODULE_T;
-const bits MODULE_IMAGE_T = (bits(1) << MODULE_IMAGE_ID) | MODULE_T;
-const bits MODULE_SOUND_T = (bits(1) << MODULE_SOUND_ID) | MODULE_T;
+typedef std::bitset<TYPE_MAX_ENUM> TypeBits;
+
+/**
+ * Array of length TYPE_MAX_ENUM containing the flags for each love Type.
+ **/
+extern const TypeBits *typeFlags;
 
 
 bool getType(const char *in, Type &out);
 bool getType(const char *in, Type &out);
-bool getType(Type in, const char  *&out);
+bool getType(Type in, const char *&out);
 
 
 } // love
 } // love
 
 

+ 2 - 2
src/common/wrap_Data.cpp

@@ -25,7 +25,7 @@ namespace love
 
 
 Data *luax_checkdata(lua_State *L, int idx)
 Data *luax_checkdata(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Data>(L, idx, "Data", DATA_T);
+	return luax_checktype<Data>(L, idx, DATA_ID);
 }
 }
 
 
 int w_Data_getString(lua_State *L)
 int w_Data_getString(lua_State *L)
@@ -59,7 +59,7 @@ const luaL_Reg w_Data_functions[] =
 
 
 int w_Data_open(lua_State *L)
 int w_Data_open(lua_State *L)
 {
 {
-	luax_register_type(L, "Data", w_Data_functions);
+	luax_register_type(L, DATA_ID, w_Data_functions);
 	return 0;
 	return 0;
 }
 }
 
 

+ 10 - 10
src/modules/audio/wrap_Audio.cpp

@@ -44,7 +44,7 @@ int w_getSourceCount(lua_State *L)
 
 
 int w_newSource(lua_State *L)
 int w_newSource(lua_State *L)
 {
 {
-	if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
+	if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
 		luax_convobj(L, 1, "sound", "newDecoder");
 		luax_convobj(L, 1, "sound", "newDecoder");
 
 
 	Source::Type stype = Source::TYPE_STREAM;
 	Source::Type stype = Source::TYPE_STREAM;
@@ -53,21 +53,21 @@ int w_newSource(lua_State *L)
 	if (stypestr && !Source::getConstant(stypestr, stype))
 	if (stypestr && !Source::getConstant(stypestr, stype))
 		return luaL_error(L, "Invalid source type: %s", stypestr);
 		return luaL_error(L, "Invalid source type: %s", stypestr);
 
 
-	if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_T))
+	if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_ID))
 		luax_convobj(L, 1, "sound", "newSoundData");
 		luax_convobj(L, 1, "sound", "newSoundData");
 
 
 	Source *t = 0;
 	Source *t = 0;
 
 
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
-		if (luax_istype(L, 1, SOUND_SOUND_DATA_T))
-			t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, "SoundData", SOUND_SOUND_DATA_T));
-		else if (luax_istype(L, 1, SOUND_DECODER_T))
-			t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, "Decoder", SOUND_DECODER_T));
+		if (luax_istype(L, 1, SOUND_SOUND_DATA_ID))
+			t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, SOUND_SOUND_DATA_ID));
+		else if (luax_istype(L, 1, SOUND_DECODER_ID))
+			t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, SOUND_DECODER_ID));
 	});
 	});
 
 
 	if (t)
 	if (t)
 	{
 	{
-		luax_pushtype(L, "Source", AUDIO_SOURCE_T, t);
+		luax_pushtype(L, AUDIO_SOURCE_ID, t);
 		t->release();
 		t->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -243,7 +243,7 @@ int w_getRecordedData(lua_State *L)
 		lua_pushnil(L);
 		lua_pushnil(L);
 	else
 	else
 	{
 	{
-		luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
+		luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
 		sd->release();
 		sd->release();
 	}
 	}
 	return 1;
 	return 1;
@@ -258,7 +258,7 @@ int w_stopRecording(lua_State *L)
 			lua_pushnil(L);
 			lua_pushnil(L);
 		else
 		else
 		{
 		{
-			luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
+			luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
 			sd->release();
 			sd->release();
 		}
 		}
 		return 1;
 		return 1;
@@ -369,7 +369,7 @@ extern "C" int luaopen_love_audio(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "audio";
 	w.name = "audio";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 3 - 3
src/modules/audio/wrap_Source.cpp

@@ -29,7 +29,7 @@ namespace audio
 
 
 Source *luax_checksource(lua_State *L, int idx)
 Source *luax_checksource(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
+	return luax_checktype<Source>(L, idx, AUDIO_SOURCE_ID);
 }
 }
 
 
 int w_Source_clone(lua_State *L)
 int w_Source_clone(lua_State *L)
@@ -37,7 +37,7 @@ int w_Source_clone(lua_State *L)
 	Source *t = luax_checksource(L, 1);
 	Source *t = luax_checksource(L, 1);
 	Source *clone = nullptr;
 	Source *clone = nullptr;
 	luax_catchexcept(L, [&](){ clone = t->clone(); });
 	luax_catchexcept(L, [&](){ clone = t->clone(); });
-	luax_pushtype(L, "Source", AUDIO_SOURCE_T, clone);
+	luax_pushtype(L, AUDIO_SOURCE_ID, clone);
 	clone->release();
 	clone->release();
 	return 1;
 	return 1;
 }
 }
@@ -406,7 +406,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_source(lua_State *L)
 extern "C" int luaopen_source(lua_State *L)
 {
 {
-	return luax_register_type(L, "Source", functions);
+	return luax_register_type(L, AUDIO_SOURCE_ID, functions);
 }
 }
 
 
 } // audio
 } // audio

+ 8 - 8
src/modules/event/sdl/Event.cpp

@@ -350,7 +350,7 @@ Message *Event::convert(const SDL_Event &e) const
 			{
 			{
 				Proxy proxy;
 				Proxy proxy;
 				proxy.object = new love::filesystem::DroppedFile(e.drop.file);
 				proxy.object = new love::filesystem::DroppedFile(e.drop.file);
-				proxy.flags = FILESYSTEM_DROPPED_FILE_T;
+				proxy.type = FILESYSTEM_DROPPED_FILE_ID;
 				vargs.push_back(new Variant(FILESYSTEM_DROPPED_FILE_ID, &proxy));
 				vargs.push_back(new Variant(FILESYSTEM_DROPPED_FILE_ID, &proxy));
 				msg = new Message("filedropped", vargs);
 				msg = new Message("filedropped", vargs);
 				proxy.object->release();
 				proxy.object->release();
@@ -400,7 +400,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 	{
 	{
 	case SDL_JOYBUTTONDOWN:
 	case SDL_JOYBUTTONDOWN:
 	case SDL_JOYBUTTONUP:
 	case SDL_JOYBUTTONUP:
-		proxy.flags = JOYSTICK_JOYSTICK_T;
+		proxy.type = JOYSTICK_JOYSTICK_ID;
 		proxy.object = joymodule->getJoystickFromID(e.jbutton.which);
 		proxy.object = joymodule->getJoystickFromID(e.jbutton.which);
 		if (!proxy.object)
 		if (!proxy.object)
 			break;
 			break;
@@ -413,7 +413,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 		break;
 		break;
 	case SDL_JOYAXISMOTION:
 	case SDL_JOYAXISMOTION:
 		{
 		{
-			proxy.flags = JOYSTICK_JOYSTICK_T;
+			proxy.type = JOYSTICK_JOYSTICK_ID;
 			proxy.object = joymodule->getJoystickFromID(e.jaxis.which);
 			proxy.object = joymodule->getJoystickFromID(e.jaxis.which);
 			if (!proxy.object)
 			if (!proxy.object)
 				break;
 				break;
@@ -429,7 +429,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 		if (!joystick::sdl::Joystick::getConstant(e.jhat.value, hat) || !joystick::Joystick::getConstant(hat, txt))
 		if (!joystick::sdl::Joystick::getConstant(e.jhat.value, hat) || !joystick::Joystick::getConstant(hat, txt))
 			break;
 			break;
 
 
-		proxy.flags = JOYSTICK_JOYSTICK_T;
+		proxy.type = JOYSTICK_JOYSTICK_ID;
 		proxy.object = joymodule->getJoystickFromID(e.jhat.which);
 		proxy.object = joymodule->getJoystickFromID(e.jhat.which);
 		if (!proxy.object)
 		if (!proxy.object)
 			break;
 			break;
@@ -447,7 +447,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 		if (!joystick::Joystick::getConstant(padbutton, txt))
 		if (!joystick::Joystick::getConstant(padbutton, txt))
 			break;
 			break;
 
 
-		proxy.flags = JOYSTICK_JOYSTICK_T;
+		proxy.type = JOYSTICK_JOYSTICK_ID;
 		proxy.object = joymodule->getJoystickFromID(e.cbutton.which);
 		proxy.object = joymodule->getJoystickFromID(e.cbutton.which);
 		if (!proxy.object)
 		if (!proxy.object)
 			break;
 			break;
@@ -463,7 +463,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 			if (!joystick::Joystick::getConstant(padaxis, txt))
 			if (!joystick::Joystick::getConstant(padaxis, txt))
 				break;
 				break;
 
 
-			proxy.flags = JOYSTICK_JOYSTICK_T;
+			proxy.type = JOYSTICK_JOYSTICK_ID;
 			proxy.object = joymodule->getJoystickFromID(e.caxis.which);
 			proxy.object = joymodule->getJoystickFromID(e.caxis.which);
 			if (!proxy.object)
 			if (!proxy.object)
 				break;
 				break;
@@ -479,7 +479,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 	case SDL_JOYDEVICEADDED:
 	case SDL_JOYDEVICEADDED:
 		// jdevice.which is the joystick device index.
 		// jdevice.which is the joystick device index.
 		proxy.object = joymodule->addJoystick(e.jdevice.which);
 		proxy.object = joymodule->addJoystick(e.jdevice.which);
-		proxy.flags = JOYSTICK_JOYSTICK_T;
+		proxy.type = JOYSTICK_JOYSTICK_ID;
 		if (proxy.object)
 		if (proxy.object)
 		{
 		{
 			vargs.push_back(new Variant(JOYSTICK_JOYSTICK_ID, (void *) &proxy));
 			vargs.push_back(new Variant(JOYSTICK_JOYSTICK_ID, (void *) &proxy));
@@ -489,7 +489,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 	case SDL_JOYDEVICEREMOVED:
 	case SDL_JOYDEVICEREMOVED:
 		// jdevice.which is the joystick instance ID now.
 		// jdevice.which is the joystick instance ID now.
 		proxy.object = joymodule->getJoystickFromID(e.jdevice.which);
 		proxy.object = joymodule->getJoystickFromID(e.jdevice.which);
-		proxy.flags = JOYSTICK_JOYSTICK_T;
+		proxy.type = JOYSTICK_JOYSTICK_ID;
 		if (proxy.object)
 		if (proxy.object)
 		{
 		{
 			joymodule->removeJoystick((joystick::Joystick *) proxy.object);
 			joymodule->removeJoystick((joystick::Joystick *) proxy.object);

+ 1 - 1
src/modules/event/wrap_Event.cpp

@@ -129,7 +129,7 @@ extern "C" int luaopen_love_event(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "event";
 	w.name = "event";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = 0;
 	w.types = 0;
 
 

+ 2 - 2
src/modules/filesystem/wrap_DroppedFile.cpp

@@ -28,7 +28,7 @@ namespace filesystem
 
 
 DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
 DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
 {
 {
-	return luax_checktype<DroppedFile>(L, idx, "DroppedFile", FILESYSTEM_DROPPED_FILE_T);
+	return luax_checktype<DroppedFile>(L, idx, FILESYSTEM_DROPPED_FILE_ID);
 }
 }
 
 
 static const luaL_Reg functions[] =
 static const luaL_Reg functions[] =
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_droppedfile(lua_State *L)
 extern "C" int luaopen_droppedfile(lua_State *L)
 {
 {
-	return luax_register_type(L, "DroppedFile", functions);
+	return luax_register_type(L, FILESYSTEM_DROPPED_FILE_ID, functions);
 }
 }
 
 
 } // filesystem
 } // filesystem

+ 5 - 5
src/modules/filesystem/wrap_File.cpp

@@ -43,7 +43,7 @@ int luax_ioError(lua_State *L, const char *fmt, ...)
 
 
 File *luax_checkfile(lua_State *L, int idx)
 File *luax_checkfile(lua_State *L, int idx)
 {
 {
-	return luax_checktype<File>(L, idx, "File", FILESYSTEM_FILE_T);
+	return luax_checktype<File>(L, idx, FILESYSTEM_FILE_ID);
 }
 }
 
 
 int w_File_getSize(lua_State *L)
 int w_File_getSize(lua_State *L)
@@ -149,11 +149,11 @@ int w_File_write(lua_State *L)
 			return luax_ioError(L, "%s", e.what());
 			return luax_ioError(L, "%s", e.what());
 		}
 		}
 	}
 	}
-	else if (luax_istype(L, 2, DATA_T))
+	else if (luax_istype(L, 2, DATA_ID))
 	{
 	{
 		try
 		try
 		{
 		{
-			love::Data *data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
+			love::Data *data = luax_totype<love::Data>(L, 2, DATA_ID);
 			result = file->write(data, luaL_optinteger(L, 3, data->getSize()));
 			result = file->write(data, luaL_optinteger(L, 3, data->getSize()));
 		}
 		}
 		catch (love::Exception &e)
 		catch (love::Exception &e)
@@ -228,7 +228,7 @@ int w_File_lines_i(lua_State *L)
 	int linesize = 0;
 	int linesize = 0;
 	bool newline = false;
 	bool newline = false;
 
 
-	File *file = luax_checktype<File>(L, lua_upvalueindex(1), "File", FILESYSTEM_FILE_T);
+	File *file = luax_checktype<File>(L, lua_upvalueindex(1), FILESYSTEM_FILE_ID);
 
 
 	// Only accept read mode at this point.
 	// Only accept read mode at this point.
 	if (file->getMode() != File::MODE_READ)
 	if (file->getMode() != File::MODE_READ)
@@ -436,7 +436,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_file(lua_State *L)
 extern "C" int luaopen_file(lua_State *L)
 {
 {
-	return luax_register_type(L, "File", functions);
+	return luax_register_type(L, FILESYSTEM_FILE_ID, functions);
 }
 }
 
 
 } // filesystem
 } // filesystem

+ 2 - 2
src/modules/filesystem/wrap_FileData.cpp

@@ -29,7 +29,7 @@ namespace filesystem
 
 
 FileData *luax_checkfiledata(lua_State *L, int idx)
 FileData *luax_checkfiledata(lua_State *L, int idx)
 {
 {
-	return luax_checktype<FileData>(L, idx, "FileData", FILESYSTEM_FILE_DATA_T);
+	return luax_checktype<FileData>(L, idx, FILESYSTEM_FILE_DATA_ID);
 }
 }
 
 
 int w_FileData_getFilename(lua_State *L)
 int w_FileData_getFilename(lua_State *L)
@@ -61,7 +61,7 @@ static const luaL_Reg w_FileData_functions[] =
 
 
 extern "C" int luaopen_filedata(lua_State *L)
 extern "C" int luaopen_filedata(lua_State *L)
 {
 {
-	return luax_register_type(L, "FileData", w_FileData_functions);
+	return luax_register_type(L, FILESYSTEM_FILE_DATA_ID, w_FileData_functions);
 }
 }
 
 
 } // filesystem
 } // filesystem

+ 10 - 10
src/modules/filesystem/wrap_Filesystem.cpp

@@ -150,7 +150,7 @@ int w_newFile(lua_State *L)
 		}
 		}
 	}
 	}
 
 
-	luax_pushtype(L, "File", FILESYSTEM_FILE_T, t);
+	luax_pushtype(L, FILESYSTEM_FILE_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -165,12 +165,12 @@ FileData *luax_getfiledata(lua_State *L, int idx)
 		const char *filename = luaL_checkstring(L, idx);
 		const char *filename = luaL_checkstring(L, idx);
 		file = instance()->newFile(filename);
 		file = instance()->newFile(filename);
 	}
 	}
-	else if (luax_istype(L, idx, FILESYSTEM_FILE_T))
+	else if (luax_istype(L, idx, FILESYSTEM_FILE_ID))
 	{
 	{
 		file = luax_checkfile(L, idx);
 		file = luax_checkfile(L, idx);
 		file->retain();
 		file->retain();
 	}
 	}
-	else if (luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
+	else if (luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
 	{
 	{
 		data = luax_checkfiledata(L, idx);
 		data = luax_checkfiledata(L, idx);
 		data->retain();
 		data->retain();
@@ -203,7 +203,7 @@ int w_newFileData(lua_State *L)
 			luax_convobj(L, 1, "filesystem", "newFile");
 			luax_convobj(L, 1, "filesystem", "newFile");
 
 
 		// Get FileData from the File.
 		// Get FileData from the File.
-		if (luax_istype(L, 1, FILESYSTEM_FILE_T))
+		if (luax_istype(L, 1, FILESYSTEM_FILE_ID))
 		{
 		{
 			File *file = luax_checkfile(L, 1);
 			File *file = luax_checkfile(L, 1);
 
 
@@ -216,7 +216,7 @@ int w_newFileData(lua_State *L)
 			{
 			{
 				return luax_ioError(L, "%s", e.what());
 				return luax_ioError(L, "%s", e.what());
 			}
 			}
-			luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, data);
+			luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, data);
 			data->release();
 			data->release();
 			return 1;
 			return 1;
 		}
 		}
@@ -248,7 +248,7 @@ int w_newFileData(lua_State *L)
 		return luaL_error(L, "Invalid FileData decoder: %s", decstr);
 		return luaL_error(L, "Invalid FileData decoder: %s", decstr);
 	}
 	}
 
 
-	luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, t);
+	luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -366,9 +366,9 @@ static int w_write_or_append(lua_State *L, File::Mode mode)
 	const char *input = 0;
 	const char *input = 0;
 	size_t len = 0;
 	size_t len = 0;
 
 
-	if (luax_istype(L, 2, DATA_T))
+	if (luax_istype(L, 2, DATA_ID))
 	{
 	{
-		love::Data *data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
+		love::Data *data = luax_totype<love::Data>(L, 2, DATA_ID);
 		input = (const char *) data->getData();
 		input = (const char *) data->getData();
 		len = data->getSize();
 		len = data->getSize();
 	}
 	}
@@ -428,7 +428,7 @@ int w_lines(lua_State *L)
 			return luaL_error(L, "Could not open file.");
 			return luaL_error(L, "Could not open file.");
 		}
 		}
 
 
-		luax_pushtype(L, "File", FILESYSTEM_FILE_T, file);
+		luax_pushtype(L, FILESYSTEM_FILE_ID, file);
 		file->release();
 		file->release();
 	}
 	}
 	else
 	else
@@ -731,7 +731,7 @@ extern "C" int luaopen_love_filesystem(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "filesystem";
 	w.name = "filesystem";
-	w.flags = MODULE_FILESYSTEM_T;
+	w.type = MODULE_FILESYSTEM_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 11 - 11
src/modules/font/wrap_Font.cpp

@@ -52,7 +52,7 @@ int w_newRasterizer(lua_State *L)
 			[&]() { d->release(); }
 			[&]() { d->release(); }
 		);
 		);
 
 
-		luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
+		luax_pushtype(L, FONT_RASTERIZER_ID, t);
 		t->release();
 		t->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -82,7 +82,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
 	{
 	{
 		love::Data *d = nullptr;
 		love::Data *d = nullptr;
 
 
-		if (luax_istype(L, 1, DATA_T))
+		if (luax_istype(L, 1, DATA_ID))
 			d = luax_checkdata(L, 1);
 			d = luax_checkdata(L, 1);
 		else
 		else
 			d = filesystem::luax_getfiledata(L, 1);
 			d = filesystem::luax_getfiledata(L, 1);
@@ -95,14 +95,14 @@ int w_newTrueTypeRasterizer(lua_State *L)
 		);
 		);
 	}
 	}
 
 
-	luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
+	luax_pushtype(L, FONT_RASTERIZER_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
 
 
 static void convimagedata(lua_State *L, int idx)
 static void convimagedata(lua_State *L, int idx)
 {
 {
-	if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_T) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
+	if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_ID) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
 		luax_convobj(L, idx, "image", "newImageData");
 		luax_convobj(L, idx, "image", "newImageData");
 }
 }
 
 
@@ -120,7 +120,7 @@ int w_newBMFontRasterizer(lua_State *L)
 			lua_rawgeti(L, 2, i);
 			lua_rawgeti(L, 2, i);
 
 
 			convimagedata(L, -1);
 			convimagedata(L, -1);
-			image::ImageData *id = luax_checktype<image::ImageData>(L, -1, "ImageData", IMAGE_IMAGE_DATA_T);
+			image::ImageData *id = luax_checktype<image::ImageData>(L, -1, IMAGE_IMAGE_DATA_ID);
 			images.push_back(id);
 			images.push_back(id);
 			id->retain();
 			id->retain();
 
 
@@ -132,7 +132,7 @@ int w_newBMFontRasterizer(lua_State *L)
 		for (int i = 2; i <= lua_gettop(L); i++)
 		for (int i = 2; i <= lua_gettop(L); i++)
 		{
 		{
 			convimagedata(L, i);
 			convimagedata(L, i);
-			image::ImageData *id = luax_checktype<image::ImageData>(L, i, "ImageData", IMAGE_IMAGE_DATA_T);
+			image::ImageData *id = luax_checktype<image::ImageData>(L, i, IMAGE_IMAGE_DATA_ID);
 			images.push_back(id);
 			images.push_back(id);
 			id->retain();
 			id->retain();
 		}
 		}
@@ -143,7 +143,7 @@ int w_newBMFontRasterizer(lua_State *L)
 		[&]() { d->release(); for (auto id : images) id->release(); }
 		[&]() { d->release(); for (auto id : images) id->release(); }
 	);
 	);
 
 
-	luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
+	luax_pushtype(L, FONT_RASTERIZER_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -154,12 +154,12 @@ int w_newImageRasterizer(lua_State *L)
 
 
 	convimagedata(L, 1);
 	convimagedata(L, 1);
 
 
-	image::ImageData *d = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
+	image::ImageData *d = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
 	std::string glyphs = luax_checkstring(L, 2);
 	std::string glyphs = luax_checkstring(L, 2);
 
 
 	luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs); });
 	luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs); });
 
 
-	luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
+	luax_pushtype(L, FONT_RASTERIZER_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -181,7 +181,7 @@ int w_newGlyphData(lua_State *L)
 		t = instance()->newGlyphData(r, g);
 		t = instance()->newGlyphData(r, g);
 	}
 	}
 
 
-	luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
+	luax_pushtype(L, FONT_GLYPH_DATA_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -217,7 +217,7 @@ extern "C" int luaopen_love_font(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "font";
 	w.name = "font";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 2 - 2
src/modules/font/wrap_GlyphData.cpp

@@ -27,7 +27,7 @@ namespace font
 
 
 GlyphData *luax_checkglyphdata(lua_State *L, int idx)
 GlyphData *luax_checkglyphdata(lua_State *L, int idx)
 {
 {
-	return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
+	return luax_checktype<GlyphData>(L, idx, FONT_GLYPH_DATA_ID);
 }
 }
 
 
 int w_GlyphData_getWidth(lua_State *L)
 int w_GlyphData_getWidth(lua_State *L)
@@ -136,7 +136,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_glyphdata(lua_State *L)
 extern "C" int luaopen_glyphdata(lua_State *L)
 {
 {
-	return luax_register_type(L, "GlyphData", functions);
+	return luax_register_type(L, FONT_GLYPH_DATA_ID, functions);
 }
 }
 
 
 } // font
 } // font

+ 3 - 3
src/modules/font/wrap_Rasterizer.cpp

@@ -29,7 +29,7 @@ namespace font
 
 
 Rasterizer *luax_checkrasterizer(lua_State *L, int idx)
 Rasterizer *luax_checkrasterizer(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
+	return luax_checktype<Rasterizer>(L, idx, FONT_RASTERIZER_ID);
 }
 }
 
 
 int w_Rasterizer_getHeight(lua_State *L)
 int w_Rasterizer_getHeight(lua_State *L)
@@ -86,7 +86,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
 		}
 		}
 	});
 	});
 
 
-	luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, g);
+	luax_pushtype(L, FONT_GLYPH_DATA_ID, g);
 	g->release();
 	g->release();
 	return 1;
 	return 1;
 }
 }
@@ -139,7 +139,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_rasterizer(lua_State *L)
 extern "C" int luaopen_rasterizer(lua_State *L)
 {
 {
-	return luax_register_type(L, "Rasterizer", functions);
+	return luax_register_type(L, FONT_RASTERIZER_ID, functions);
 }
 }
 
 
 } // font
 } // font

+ 4 - 4
src/modules/graphics/opengl/wrap_Canvas.cpp

@@ -30,7 +30,7 @@ namespace opengl
 
 
 Canvas *luax_checkcanvas(lua_State *L, int idx)
 Canvas *luax_checkcanvas(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Canvas>(L, idx, "Canvas", GRAPHICS_CANVAS_T);
+	return luax_checktype<Canvas>(L, idx, GRAPHICS_CANVAS_ID);
 }
 }
 
 
 int w_Canvas_renderTo(lua_State *L)
 int w_Canvas_renderTo(lua_State *L)
@@ -65,7 +65,7 @@ int w_Canvas_renderTo(lua_State *L)
 int w_Canvas_newImageData(lua_State *L)
 int w_Canvas_newImageData(lua_State *L)
 {
 {
 	Canvas *canvas = luax_checkcanvas(L, 1);
 	Canvas *canvas = luax_checkcanvas(L, 1);
-	love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
+	love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
 	int x = luaL_optint(L, 2, 0);
 	int x = luaL_optint(L, 2, 0);
 	int y = luaL_optint(L, 3, 0);
 	int y = luaL_optint(L, 3, 0);
 	int w = luaL_optint(L, 4, canvas->getWidth());
 	int w = luaL_optint(L, 4, canvas->getWidth());
@@ -74,7 +74,7 @@ int w_Canvas_newImageData(lua_State *L)
 	love::image::ImageData *img = nullptr;
 	love::image::ImageData *img = nullptr;
 	luax_catchexcept(L, [&](){ img = canvas->newImageData(image, x, y, w, h); });
 	luax_catchexcept(L, [&](){ img = canvas->newImageData(image, x, y, w, h); });
 
 
-	luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
+	luax_pushtype(L, IMAGE_IMAGE_DATA_ID, img);
 	img->release();
 	img->release();
 	return 1;
 	return 1;
 }
 }
@@ -118,7 +118,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_canvas(lua_State *L)
 extern "C" int luaopen_canvas(lua_State *L)
 {
 {
-	return luax_register_type(L, "Canvas", functions);
+	return luax_register_type(L, GRAPHICS_CANVAS_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 2 - 2
src/modules/graphics/opengl/wrap_Font.cpp

@@ -30,7 +30,7 @@ namespace opengl
 
 
 Font *luax_checkfont(lua_State *L, int idx)
 Font *luax_checkfont(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
+	return luax_checktype<Font>(L, idx, GRAPHICS_FONT_ID);
 }
 }
 
 
 int w_Font_getHeight(lua_State *L)
 int w_Font_getHeight(lua_State *L)
@@ -186,7 +186,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_font(lua_State *L)
 extern "C" int luaopen_font(lua_State *L)
 {
 {
-	return luax_register_type(L, "Font", functions);
+	return luax_register_type(L, GRAPHICS_FONT_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 32 - 32
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -203,7 +203,7 @@ int w_newImage(lua_State *L)
 	bool releasedata = false;
 	bool releasedata = false;
 
 
 	// Convert to ImageData / CompressedData, if necessary.
 	// Convert to ImageData / CompressedData, if necessary.
-	if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
+	if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
 	{
 	{
 		love::image::Image *image = Module::getInstance<love::image::Image>(Module::M_IMAGE);
 		love::image::Image *image = Module::getInstance<love::image::Image>(Module::M_IMAGE);
 		if (image == nullptr)
 		if (image == nullptr)
@@ -229,10 +229,10 @@ int w_newImage(lua_State *L)
 		// Lua's GC won't release the image data, so we should do it ourselves.
 		// Lua's GC won't release the image data, so we should do it ourselves.
 		releasedata = true;
 		releasedata = true;
 	}
 	}
-	else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_T))
-		cdata = luax_checktype<love::image::CompressedData>(L, 1, "CompressedData", IMAGE_COMPRESSED_DATA_T);
+	else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_ID))
+		cdata = luax_checktype<love::image::CompressedData>(L, 1, IMAGE_COMPRESSED_DATA_ID);
 	else
 	else
-		data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
+		data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
 
 
 	if (!data && !cdata)
 	if (!data && !cdata)
 		return luaL_error(L, "Error creating image (could not load data.)");
 		return luaL_error(L, "Error creating image (could not load data.)");
@@ -258,7 +258,7 @@ int w_newImage(lua_State *L)
 		return luaL_error(L, "Could not load image.");
 		return luaL_error(L, "Could not load image.");
 
 
 	// Push the type.
 	// Push the type.
-	luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, image);
+	luax_pushtype(L, GRAPHICS_IMAGE_ID, image);
 	image->release();
 	image->release();
 	return 1;
 	return 1;
 }
 }
@@ -275,7 +275,7 @@ int w_newQuad(lua_State *L)
 	float sh = (float) luaL_checknumber(L, 6);
 	float sh = (float) luaL_checknumber(L, 6);
 
 
 	Quad *quad = instance()->newQuad(v, sw, sh);
 	Quad *quad = instance()->newQuad(v, sw, sh);
-	luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quad);
+	luax_pushtype(L, GRAPHICS_QUAD_ID, quad);
 	quad->release();
 	quad->release();
 	return 1;
 	return 1;
 }
 }
@@ -285,7 +285,7 @@ int w_newFont(lua_State *L)
 	Font *font = nullptr;
 	Font *font = nullptr;
 
 
 	// Convert to Rasterizer, if necessary.
 	// Convert to Rasterizer, if necessary.
-	if (!luax_istype(L, 1, FONT_RASTERIZER_T))
+	if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
 	{
 	{
 		std::vector<int> idxs;
 		std::vector<int> idxs;
 		for (int i = 0; i < lua_gettop(L); i++)
 		for (int i = 0; i < lua_gettop(L); i++)
@@ -294,14 +294,14 @@ int w_newFont(lua_State *L)
 		luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newRasterizer");
 		luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newRasterizer");
 	}
 	}
 
 
-	love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
+	love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
 
 
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		font = instance()->newFont(rasterizer, instance()->getDefaultFilter()); }
 		font = instance()->newFont(rasterizer, instance()->getDefaultFilter()); }
 	);
 	);
 
 
 	// Push the type.
 	// Push the type.
-	luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
+	luax_pushtype(L, GRAPHICS_FONT_ID, font);
 	font->release();
 	font->release();
 	return 1;
 	return 1;
 }
 }
@@ -312,32 +312,32 @@ int w_newImageFont(lua_State *L)
 	Texture::Filter filter = instance()->getDefaultFilter();
 	Texture::Filter filter = instance()->getDefaultFilter();
 
 
 	// Convert to ImageData if necessary.
 	// Convert to ImageData if necessary.
-	if (luax_istype(L, 1, GRAPHICS_IMAGE_T))
+	if (luax_istype(L, 1, GRAPHICS_IMAGE_ID))
 	{
 	{
-		Image *i = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
+		Image *i = luax_checktype<Image>(L, 1, GRAPHICS_IMAGE_ID);
 		filter = i->getFilter();
 		filter = i->getFilter();
 		love::image::ImageData *id = i->getImageData();
 		love::image::ImageData *id = i->getImageData();
 		if (!id)
 		if (!id)
 			return luaL_argerror(L, 1, "Image must not be compressed.");
 			return luaL_argerror(L, 1, "Image must not be compressed.");
-		luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id);
+		luax_pushtype(L, IMAGE_IMAGE_DATA_ID, id);
 		lua_replace(L, 1);
 		lua_replace(L, 1);
 	}
 	}
 
 
 	// Convert to Rasterizer if necessary.
 	// Convert to Rasterizer if necessary.
-	if (!luax_istype(L, 1, FONT_RASTERIZER_T))
+	if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
 	{
 	{
 		luaL_checkstring(L, 2);
 		luaL_checkstring(L, 2);
 		int idxs[] = {1, 2};
 		int idxs[] = {1, 2};
 		luax_convobj(L, idxs, 2, "font", "newImageRasterizer");
 		luax_convobj(L, idxs, 2, "font", "newImageRasterizer");
 	}
 	}
 
 
-	love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
+	love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
 
 
 	// Create the font.
 	// Create the font.
 	Font *font = instance()->newFont(rasterizer, filter);
 	Font *font = instance()->newFont(rasterizer, filter);
 
 
 	// Push the type.
 	// Push the type.
-	luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
+	luax_pushtype(L, GRAPHICS_FONT_ID, font);
 	font->release();
 	font->release();
 	return 1;
 	return 1;
 }
 }
@@ -359,7 +359,7 @@ int w_newSpriteBatch(lua_State *L)
 		[&](){ t = instance()->newSpriteBatch(texture, size, usage); }
 		[&](){ t = instance()->newSpriteBatch(texture, size, usage); }
 	);
 	);
 
 
-	luax_pushtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, t);
+	luax_pushtype(L, GRAPHICS_SPRITE_BATCH_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -376,7 +376,7 @@ int w_newParticleSystem(lua_State *L)
 		[&](){ t = instance()->newParticleSystem(texture, int(size)); }
 		[&](){ t = instance()->newParticleSystem(texture, int(size)); }
 	);
 	);
 
 
-	luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
+	luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -401,7 +401,7 @@ int w_newCanvas(lua_State *L)
 	if (canvas == nullptr)
 	if (canvas == nullptr)
 		return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
 		return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
 
 
-	luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, canvas);
+	luax_pushtype(L, GRAPHICS_CANVAS_ID, canvas);
 	canvas->release();
 	canvas->release();
 	return 1;
 	return 1;
 }
 }
@@ -492,7 +492,7 @@ int w_newShader(lua_State *L)
 	try
 	try
 	{
 	{
 		Shader *shader = instance()->newShader(source);
 		Shader *shader = instance()->newShader(source);
-		luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
+		luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
 		shader->release();
 		shader->release();
 	}
 	}
 	catch (love::Exception &e)
 	catch (love::Exception &e)
@@ -585,7 +585,7 @@ int w_newMesh(lua_State *L)
 	if (tex)
 	if (tex)
 		t->setTexture(tex);
 		t->setTexture(tex);
 
 
-	luax_pushtype(L, "Mesh", GRAPHICS_MESH_T, t);
+	luax_pushtype(L, GRAPHICS_MESH_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -603,7 +603,7 @@ int w_newText(lua_State *L)
 		luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
 		luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
 	}
 	}
 
 
-	luax_pushtype(L, "Text", GRAPHICS_TEXT_T, t);
+	luax_pushtype(L, GRAPHICS_TEXT_ID, t);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -682,14 +682,14 @@ int w_getBackgroundColor(lua_State *L)
 int w_setNewFont(lua_State *L)
 int w_setNewFont(lua_State *L)
 {
 {
 	int ret = w_newFont(L);
 	int ret = w_newFont(L);
-	Font *font = luax_checktype<Font>(L, -1, "Font", GRAPHICS_FONT_T);
+	Font *font = luax_checktype<Font>(L, -1, GRAPHICS_FONT_ID);
 	instance()->setFont(font);
 	instance()->setFont(font);
 	return ret;
 	return ret;
 }
 }
 
 
 int w_setFont(lua_State *L)
 int w_setFont(lua_State *L)
 {
 {
-	Font *font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
+	Font *font = luax_checktype<Font>(L, 1, GRAPHICS_FONT_ID);
 	instance()->setFont(font);
 	instance()->setFont(font);
 	return 0;
 	return 0;
 }
 }
@@ -699,7 +699,7 @@ int w_getFont(lua_State *L)
 	Font *f = nullptr;
 	Font *f = nullptr;
 	luax_catchexcept(L, [&](){ f = instance()->getFont(); });
 	luax_catchexcept(L, [&](){ f = instance()->getFont(); });
 
 
-	luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
+	luax_pushtype(L, GRAPHICS_FONT_ID, f);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -913,13 +913,13 @@ int w_isWireframe(lua_State *L)
 
 
 int w_newScreenshot(lua_State *L)
 int w_newScreenshot(lua_State *L)
 {
 {
-	love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
+	love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
 	bool copyAlpha = luax_optboolean(L, 1, false);
 	bool copyAlpha = luax_optboolean(L, 1, false);
 	love::image::ImageData *i = 0;
 	love::image::ImageData *i = 0;
 
 
 	luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
 	luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
 
 
-	luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
+	luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
 	i->release();
 	i->release();
 	return 1;
 	return 1;
 }
 }
@@ -971,7 +971,7 @@ int w_getCanvas(lua_State *L)
 
 
 	for (Canvas *c : canvases)
 	for (Canvas *c : canvases)
 	{
 	{
-		luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
+		luax_pushtype(L, GRAPHICS_CANVAS_ID, c);
 		n++;
 		n++;
 	}
 	}
 
 
@@ -1001,7 +1001,7 @@ int w_getShader(lua_State *L)
 {
 {
 	Shader *shader = instance()->getShader();
 	Shader *shader = instance()->getShader();
 	if (shader)
 	if (shader)
-		luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
+		luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
 	else
 	else
 		lua_pushnil(L);
 		lua_pushnil(L);
 
 
@@ -1172,10 +1172,10 @@ int w_draw(lua_State *L)
 	Quad *quad = nullptr;
 	Quad *quad = nullptr;
 	int startidx = 2;
 	int startidx = 2;
 
 
-	if (luax_istype(L, 2, GRAPHICS_QUAD_T))
+	if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
 	{
 	{
 		texture = luax_checktexture(L, 1);
 		texture = luax_checktexture(L, 1);
-		quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
+		quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
 		startidx = 3;
 		startidx = 3;
 	}
 	}
 	else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
 	else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
@@ -1184,7 +1184,7 @@ int w_draw(lua_State *L)
 	}
 	}
 	else
 	else
 	{
 	{
-		drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
+		drawable = luax_checktype<Drawable>(L, 1, GRAPHICS_DRAWABLE_ID);
 		startidx = 2;
 		startidx = 2;
 	}
 	}
 
 
@@ -1595,7 +1595,7 @@ extern "C" int luaopen_love_graphics(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "graphics";
 	w.name = "graphics";
-	w.flags = MODULE_GRAPHICS_T;
+	w.type = MODULE_GRAPHICS_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 4 - 10
src/modules/graphics/opengl/wrap_Image.cpp

@@ -30,7 +30,7 @@ namespace opengl
 
 
 Image *luax_checkimage(lua_State *L, int idx)
 Image *luax_checkimage(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
+	return luax_checktype<Image>(L, idx, GRAPHICS_IMAGE_ID);
 }
 }
 
 
 int w_Image_setMipmapFilter(lua_State *L)
 int w_Image_setMipmapFilter(lua_State *L)
@@ -96,18 +96,12 @@ int w_Image_getData(lua_State *L)
 	if (i->isCompressed())
 	if (i->isCompressed())
 	{
 	{
 		love::image::CompressedData *t = i->getCompressedData();
 		love::image::CompressedData *t = i->getCompressedData();
-		if (t)
-			luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
-		else
-			lua_pushnil(L);
+		luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
 	}
 	}
 	else
 	else
 	{
 	{
 		love::image::ImageData *t = i->getImageData();
 		love::image::ImageData *t = i->getImageData();
-		if (t)
-			luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
-		else
-			lua_pushnil(L);
+		luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
 	}
 	}
 
 
 	return 1;
 	return 1;
@@ -134,7 +128,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_image(lua_State *L)
 extern "C" int luaopen_image(lua_State *L)
 {
 {
-	return luax_register_type(L, "Image", functions);
+	return luax_register_type(L, GRAPHICS_IMAGE_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 4 - 4
src/modules/graphics/opengl/wrap_Mesh.cpp

@@ -36,7 +36,7 @@ namespace opengl
 
 
 Mesh *luax_checkmesh(lua_State *L, int idx)
 Mesh *luax_checkmesh(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Mesh>(L, idx, "Mesh", GRAPHICS_MESH_T);
+	return luax_checktype<Mesh>(L, idx, GRAPHICS_MESH_ID);
 }
 }
 
 
 int w_Mesh_setVertex(lua_State *L)
 int w_Mesh_setVertex(lua_State *L)
@@ -265,9 +265,9 @@ int w_Mesh_getTexture(lua_State *L)
 
 
 	// FIXME: big hack right here.
 	// FIXME: big hack right here.
 	if (typeid(*tex) == typeid(Image))
 	if (typeid(*tex) == typeid(Image))
-		luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
+		luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
 	else if (typeid(*tex) == typeid(Canvas))
 	else if (typeid(*tex) == typeid(Canvas))
-		luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
+		luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
 	else
 	else
 		return luaL_error(L, "Unable to determine texture type.");
 		return luaL_error(L, "Unable to determine texture type.");
 
 
@@ -368,7 +368,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_mesh(lua_State *L)
 extern "C" int luaopen_mesh(lua_State *L)
 {
 {
-	return luax_register_type(L, "Mesh", functions);
+	return luax_register_type(L, GRAPHICS_MESH_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 8 - 8
src/modules/graphics/opengl/wrap_ParticleSystem.cpp

@@ -41,7 +41,7 @@ namespace opengl
 
 
 ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx)
 ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx)
 {
 {
-	return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T);
+	return luax_checktype<ParticleSystem>(L, idx, GRAPHICS_PARTICLE_SYSTEM_ID);
 }
 }
 
 
 int w_ParticleSystem_clone(lua_State *L)
 int w_ParticleSystem_clone(lua_State *L)
@@ -51,7 +51,7 @@ int w_ParticleSystem_clone(lua_State *L)
 	ParticleSystem *clone = nullptr;
 	ParticleSystem *clone = nullptr;
 	luax_catchexcept(L, [&](){ clone = t->clone(); });
 	luax_catchexcept(L, [&](){ clone = t->clone(); });
 
 
-	luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, clone);
+	luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, clone);
 	clone->release();
 	clone->release();
 	return 1;
 	return 1;
 }
 }
@@ -71,9 +71,9 @@ int w_ParticleSystem_getTexture(lua_State *L)
 
 
 	// FIXME: big hack right here.
 	// FIXME: big hack right here.
 	if (typeid(*tex) == typeid(Image))
 	if (typeid(*tex) == typeid(Image))
-		luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
+		luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
 	else if (typeid(*tex) == typeid(Canvas))
 	else if (typeid(*tex) == typeid(Canvas))
-		luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
+		luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
 	else
 	else
 		return luaL_error(L, "Unable to determine texture type.");
 		return luaL_error(L, "Unable to determine texture type.");
 
 
@@ -596,7 +596,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
 		{
 		{
 			lua_rawgeti(L, 2, i);
 			lua_rawgeti(L, 2, i);
 
 
-			Quad *q = luax_checktype<Quad>(L, -1, "Quad", GRAPHICS_QUAD_T);
+			Quad *q = luax_checktype<Quad>(L, -1, GRAPHICS_QUAD_ID);
 			quads.push_back(q);
 			quads.push_back(q);
 
 
 			lua_pop(L, 1);
 			lua_pop(L, 1);
@@ -606,7 +606,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
 	{
 	{
 		for (int i = 2; i <= lua_gettop(L); i++)
 		for (int i = 2; i <= lua_gettop(L); i++)
 		{
 		{
-			Quad *q = luax_checktype<Quad>(L, i, "Quad", GRAPHICS_QUAD_T);
+			Quad *q = luax_checktype<Quad>(L, i, GRAPHICS_QUAD_ID);
 			quads.push_back(q);
 			quads.push_back(q);
 		}
 		}
 	}
 	}
@@ -624,7 +624,7 @@ int w_ParticleSystem_getQuads(lua_State *L)
 
 
 	for (int i = 0; i < (int) quads.size(); i++)
 	for (int i = 0; i < (int) quads.size(); i++)
 	{
 	{
-		luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]);
+		luax_pushtype(L, GRAPHICS_QUAD_ID, quads[i]);
 		lua_rawseti(L, -2, i + 1);
 		lua_rawseti(L, -2, i + 1);
 	}
 	}
 
 
@@ -784,7 +784,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_particlesystem(lua_State *L)
 extern "C" int luaopen_particlesystem(lua_State *L)
 {
 {
-	return luax_register_type(L, "ParticleSystem", functions);
+	return luax_register_type(L, GRAPHICS_PARTICLE_SYSTEM_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 3 - 3
src/modules/graphics/opengl/wrap_Shader.cpp

@@ -32,7 +32,7 @@ namespace opengl
 
 
 Shader *luax_checkshader(lua_State *L, int idx)
 Shader *luax_checkshader(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Shader>(L, idx, "Shader", GRAPHICS_SHADER_T);
+	return luax_checktype<Shader>(L, idx, GRAPHICS_SHADER_ID);
 }
 }
 
 
 int w_Shader_getWarnings(lua_State *L)
 int w_Shader_getWarnings(lua_State *L)
@@ -308,7 +308,7 @@ int w_Shader_send(lua_State *L)
 		// Texture (Image or Canvas).
 		// Texture (Image or Canvas).
 		p = (Proxy *) lua_touserdata(L, 3);
 		p = (Proxy *) lua_touserdata(L, 3);
 
 
-		if (p->flags[GRAPHICS_TEXTURE_ID])
+		if (typeFlags[p->type][GRAPHICS_TEXT_ID])
 			return w_Shader_sendTexture(L);
 			return w_Shader_sendTexture(L);
 
 
 		break;
 		break;
@@ -381,7 +381,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_shader(lua_State *L)
 extern "C" int luaopen_shader(lua_State *L)
 {
 {
-	return luax_register_type(L, "Shader", functions);
+	return luax_register_type(L, GRAPHICS_SHADER_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 8 - 8
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -36,7 +36,7 @@ namespace opengl
 
 
 SpriteBatch *luax_checkspritebatch(lua_State *L, int idx)
 SpriteBatch *luax_checkspritebatch(lua_State *L, int idx)
 {
 {
-	return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
+	return luax_checktype<SpriteBatch>(L, idx, GRAPHICS_SPRITE_BATCH_ID);
 }
 }
 
 
 int w_SpriteBatch_add(lua_State *L)
 int w_SpriteBatch_add(lua_State *L)
@@ -45,9 +45,9 @@ int w_SpriteBatch_add(lua_State *L)
 	Quad *quad = nullptr;
 	Quad *quad = nullptr;
 	int startidx = 2;
 	int startidx = 2;
 
 
-	if (luax_istype(L, 2, GRAPHICS_QUAD_T))
+	if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
 	{
 	{
-		quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
+		quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
 		startidx = 3;
 		startidx = 3;
 	}
 	}
 	else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
 	else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
@@ -83,9 +83,9 @@ int w_SpriteBatch_set(lua_State *L)
 	Quad *quad = nullptr;
 	Quad *quad = nullptr;
 	int startidx = 3;
 	int startidx = 3;
 
 
-	if (luax_istype(L, 3, GRAPHICS_QUAD_T))
+	if (luax_istype(L, 3, GRAPHICS_QUAD_ID))
 	{
 	{
-		quad = luax_totype<Quad>(L, 3, "Quad", GRAPHICS_QUAD_T);
+		quad = luax_totype<Quad>(L, 3, GRAPHICS_QUAD_ID);
 		startidx = 4;
 		startidx = 4;
 	}
 	}
 	else if (lua_isnil(L, 3) && !lua_isnoneornil(L, 4))
 	else if (lua_isnil(L, 3) && !lua_isnoneornil(L, 4))
@@ -140,9 +140,9 @@ int w_SpriteBatch_getTexture(lua_State *L)
 
 
 	// FIXME: big hack right here.
 	// FIXME: big hack right here.
 	if (typeid(*tex) == typeid(Image))
 	if (typeid(*tex) == typeid(Image))
-		luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
+		luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
 	else if (typeid(*tex) == typeid(Canvas))
 	else if (typeid(*tex) == typeid(Canvas))
-		luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
+		luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
 	else
 	else
 		return luaL_error(L, "Unable to determine texture type.");
 		return luaL_error(L, "Unable to determine texture type.");
 
 
@@ -241,7 +241,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_spritebatch(lua_State *L)
 extern "C" int luaopen_spritebatch(lua_State *L)
 {
 {
-	return luax_register_type(L, "SpriteBatch", functions);
+	return luax_register_type(L, GRAPHICS_SPRITE_BATCH_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 0 - 2
src/modules/graphics/opengl/wrap_SpriteBatch.h

@@ -33,9 +33,7 @@ namespace opengl
 
 
 SpriteBatch *luax_checkspritebatch(lua_State *L, int idx);
 SpriteBatch *luax_checkspritebatch(lua_State *L, int idx);
 int w_SpriteBatch_add(lua_State *L);
 int w_SpriteBatch_add(lua_State *L);
-int w_SpriteBatch_addg(lua_State *L);
 int w_SpriteBatch_set(lua_State *L);
 int w_SpriteBatch_set(lua_State *L);
-int w_SpriteBatch_setg(lua_State *L);
 int w_SpriteBatch_clear(lua_State *L);
 int w_SpriteBatch_clear(lua_State *L);
 int w_SpriteBatch_flush(lua_State *L);
 int w_SpriteBatch_flush(lua_State *L);
 int w_SpriteBatch_setTexture(lua_State *L);
 int w_SpriteBatch_setTexture(lua_State *L);

+ 3 - 3
src/modules/graphics/opengl/wrap_Text.cpp

@@ -29,7 +29,7 @@ namespace opengl
 
 
 Text *luax_checktext(lua_State *L, int idx)
 Text *luax_checktext(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Text>(L, idx, "Text", GRAPHICS_TEXT_T);
+	return luax_checktype<Text>(L, idx, GRAPHICS_TEXT_ID);
 }
 }
 
 
 int w_Text_set(lua_State *L)
 int w_Text_set(lua_State *L)
@@ -139,7 +139,7 @@ int w_Text_getFont(lua_State *L)
 {
 {
 	Text *t = luax_checktext(L, 1);
 	Text *t = luax_checktext(L, 1);
 	Font *f = t->getFont();
 	Font *f = t->getFont();
-	luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
+	luax_pushtype(L, GRAPHICS_FONT_ID, f);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -172,7 +172,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_text(lua_State *L)
 extern "C" int luaopen_text(lua_State *L)
 {
 {
-	return luax_register_type(L, "Text", functions);
+	return luax_register_type(L, GRAPHICS_TEXT_ID, functions);
 }
 }
 
 
 } // opengl
 } // opengl

+ 2 - 2
src/modules/graphics/wrap_Quad.cpp

@@ -28,7 +28,7 @@ namespace graphics
 
 
 Quad *luax_checkquad(lua_State *L, int idx)
 Quad *luax_checkquad(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
+	return luax_checktype<Quad>(L, idx, GRAPHICS_QUAD_ID);
 }
 }
 
 
 int w_Quad_setViewport(lua_State *L)
 int w_Quad_setViewport(lua_State *L)
@@ -73,7 +73,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_quad(lua_State *L)
 extern "C" int luaopen_quad(lua_State *L)
 {
 {
-	return luax_register_type(L, "Quad", functions);
+	return luax_register_type(L, GRAPHICS_QUAD_ID, functions);
 }
 }
 
 
 } // graphics
 } // graphics

+ 1 - 1
src/modules/graphics/wrap_Texture.cpp

@@ -27,7 +27,7 @@ namespace graphics
 
 
 Texture *luax_checktexture(lua_State *L, int idx)
 Texture *luax_checktexture(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Texture>(L, idx, "Texture", GRAPHICS_TEXTURE_T);
+	return luax_checktype<Texture>(L, idx, GRAPHICS_TEXTURE_ID);
 }
 }
 
 
 int w_Texture_getWidth(lua_State *L)
 int w_Texture_getWidth(lua_State *L)

+ 2 - 2
src/modules/image/wrap_CompressedData.cpp

@@ -28,7 +28,7 @@ namespace image
 
 
 CompressedData *luax_checkcompresseddata(lua_State *L, int idx)
 CompressedData *luax_checkcompresseddata(lua_State *L, int idx)
 {
 {
-	return luax_checktype<CompressedData>(L, idx, "CompressedData", IMAGE_COMPRESSED_DATA_T);
+	return luax_checktype<CompressedData>(L, idx, IMAGE_COMPRESSED_DATA_ID);
 }
 }
 
 
 int w_CompressedData_getWidth(lua_State *L)
 int w_CompressedData_getWidth(lua_State *L)
@@ -111,7 +111,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_compresseddata(lua_State *L)
 extern "C" int luaopen_compresseddata(lua_State *L)
 {
 {
-	return luax_register_type(L, "CompressedData", functions);
+	return luax_register_type(L, IMAGE_COMPRESSED_DATA_ID, functions);
 }
 }
 
 
 } // image
 } // image

+ 4 - 4
src/modules/image/wrap_Image.cpp

@@ -47,7 +47,7 @@ int w_newImageData(lua_State *L)
 		ImageData *t = nullptr;
 		ImageData *t = nullptr;
 		luax_catchexcept(L, [&](){ t = instance()->newImageData(w, h); });
 		luax_catchexcept(L, [&](){ t = instance()->newImageData(w, h); });
 
 
-		luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
+		luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
 		t->release();
 		t->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -61,7 +61,7 @@ int w_newImageData(lua_State *L)
 		[&]() { data->release(); }
 		[&]() { data->release(); }
 	);
 	);
 
 
-	luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
+	luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -76,7 +76,7 @@ int w_newCompressedData(lua_State *L)
 		[&]() { data->release(); }
 		[&]() { data->release(); }
 	);
 	);
 
 
-	luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
+	luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -120,7 +120,7 @@ extern "C" int luaopen_love_image(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "image";
 	w.name = "image";
-	w.flags = MODULE_IMAGE_T;
+	w.type = MODULE_IMAGE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 3 - 3
src/modules/image/wrap_ImageData.cpp

@@ -30,7 +30,7 @@ namespace image
 
 
 ImageData *luax_checkimagedata(lua_State *L, int idx)
 ImageData *luax_checkimagedata(lua_State *L, int idx)
 {
 {
-	return luax_checktype<ImageData>(L, idx, "ImageData", IMAGE_IMAGE_DATA_T);
+	return luax_checktype<ImageData>(L, idx, IMAGE_IMAGE_DATA_ID);
 }
 }
 
 
 int w_ImageData_getWidth(lua_State *L)
 int w_ImageData_getWidth(lua_State *L)
@@ -245,7 +245,7 @@ int w_ImageData_encode(lua_State *L)
 
 
 	if (lua_isstring(L, 2))
 	if (lua_isstring(L, 2))
 		luax_convobj(L, 2, "filesystem", "newFile");
 		luax_convobj(L, 2, "filesystem", "newFile");
-	love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T);
+	love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 2, FILESYSTEM_FILE_ID);
 
 
 	if (lua_isnoneornil(L, 3))
 	if (lua_isnoneornil(L, 3))
 	{
 	{
@@ -285,7 +285,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_imagedata(lua_State *L)
 extern "C" int luaopen_imagedata(lua_State *L)
 {
 {
-	return luax_register_type(L, "ImageData", functions);
+	return luax_register_type(L, IMAGE_IMAGE_DATA_ID, functions);
 }
 }
 
 
 } // image
 } // image

+ 2 - 2
src/modules/joystick/wrap_Joystick.cpp

@@ -31,7 +31,7 @@ namespace joystick
 
 
 Joystick *luax_checkjoystick(lua_State *L, int idx)
 Joystick *luax_checkjoystick(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Joystick>(L, idx, "Joystick", JOYSTICK_JOYSTICK_T);
+	return luax_checktype<Joystick>(L, idx, JOYSTICK_JOYSTICK_ID);
 }
 }
 
 
 int w_Joystick_isConnected(lua_State *L)
 int w_Joystick_isConnected(lua_State *L)
@@ -255,7 +255,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_joystick(lua_State *L)
 extern "C" int luaopen_joystick(lua_State *L)
 {
 {
-	return luax_register_type(L, "Joystick", functions);
+	return luax_register_type(L, JOYSTICK_JOYSTICK_ID, functions);
 }
 }
 
 
 } // joystick
 } // joystick

+ 2 - 2
src/modules/joystick/wrap_JoystickModule.cpp

@@ -40,7 +40,7 @@ int w_getJoysticks(lua_State *L)
 	for (int i = 0; i < stickcount; i++)
 	for (int i = 0; i < stickcount; i++)
 	{
 	{
 		Joystick *stick = instance()->getJoystick(i);
 		Joystick *stick = instance()->getJoystick(i);
-		luax_pushtype(L, "Joystick", JOYSTICK_JOYSTICK_T, stick);
+		luax_pushtype(L, JOYSTICK_JOYSTICK_ID, stick);
 		lua_rawseti(L, -2, i + 1);
 		lua_rawseti(L, -2, i + 1);
 	}
 	}
 
 
@@ -254,7 +254,7 @@ extern "C" int luaopen_love_joystick(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "joystick";
 	w.name = "joystick";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 1 - 1
src/modules/keyboard/wrap_Keyboard.cpp

@@ -169,7 +169,7 @@ extern "C" int luaopen_love_keyboard(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "keyboard";
 	w.name = "keyboard";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = 0;
 	w.types = 0;
 
 

+ 3 - 3
src/modules/math/wrap_BezierCurve.cpp

@@ -30,7 +30,7 @@ namespace math
 
 
 BezierCurve *luax_checkbeziercurve(lua_State *L, int idx)
 BezierCurve *luax_checkbeziercurve(lua_State *L, int idx)
 {
 {
-	return luax_checktype<BezierCurve>(L, idx, "BezierCurve", MATH_BEZIER_CURVE_T);
+	return luax_checktype<BezierCurve>(L, idx, MATH_BEZIER_CURVE_ID);
 }
 }
 
 
 int w_BezierCurve_getDegree(lua_State *L)
 int w_BezierCurve_getDegree(lua_State *L)
@@ -44,7 +44,7 @@ int w_BezierCurve_getDerivative(lua_State *L)
 {
 {
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *deriv = new BezierCurve(curve->getDerivative());
 	BezierCurve *deriv = new BezierCurve(curve->getDerivative());
-	luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, deriv);
+	luax_pushtype(L, MATH_BEZIER_CURVE_ID, deriv);
 	deriv->release();
 	deriv->release();
 	return 1;
 	return 1;
 }
 }
@@ -183,7 +183,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_beziercurve(lua_State *L)
 extern "C" int luaopen_beziercurve(lua_State *L)
 {
 {
-	return luax_register_type(L, "BezierCurve", functions);
+	return luax_register_type(L, MATH_BEZIER_CURVE_ID, functions);
 }
 }
 
 
 } // math
 } // math

+ 3 - 3
src/modules/math/wrap_Math.cpp

@@ -100,7 +100,7 @@ int w_newRandomGenerator(lua_State *L)
 			return luaL_error(L, "%s", lua_tostring(L, -1));
 			return luaL_error(L, "%s", lua_tostring(L, -1));
 	}
 	}
 
 
-	luax_pushtype(L, "RandomGenerator", MATH_RANDOM_GENERATOR_T, t);
+	luax_pushtype(L, MATH_RANDOM_GENERATOR_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -139,7 +139,7 @@ int w_newBezierCurve(lua_State *L)
 	}
 	}
 
 
 	BezierCurve *curve = Math::instance.newBezierCurve(points);
 	BezierCurve *curve = Math::instance.newBezierCurve(points);
-	luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, curve);
+	luax_pushtype(L, MATH_BEZIER_CURVE_ID, curve);
 	curve->release();
 	curve->release();
 	return 1;
 	return 1;
 }
 }
@@ -384,7 +384,7 @@ extern "C" int luaopen_love_math(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = &Math::instance;
 	w.module = &Math::instance;
 	w.name = "math";
 	w.name = "math";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 2 - 2
src/modules/math/wrap_RandomGenerator.cpp

@@ -84,7 +84,7 @@ int luax_getrandom(lua_State *L, int startidx, double r)
 
 
 RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx)
 RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx)
 {
 {
-	return luax_checktype<RandomGenerator>(L, idx, "RandomGenerator", MATH_RANDOM_GENERATOR_T);
+	return luax_checktype<RandomGenerator>(L, idx, MATH_RANDOM_GENERATOR_ID);
 }
 }
 
 
 int w_RandomGenerator_random(lua_State *L)
 int w_RandomGenerator_random(lua_State *L)
@@ -148,7 +148,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_randomgenerator(lua_State *L)
 extern "C" int luaopen_randomgenerator(lua_State *L)
 {
 {
-	return luax_register_type(L, "RandomGenerator", functions);
+	return luax_register_type(L, MATH_RANDOM_GENERATOR_ID, functions);
 }
 }
 
 
 } // math
 } // math

+ 2 - 2
src/modules/mouse/wrap_Cursor.cpp

@@ -28,7 +28,7 @@ namespace mouse
 
 
 Cursor *luax_checkcursor(lua_State *L, int idx)
 Cursor *luax_checkcursor(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Cursor>(L, idx, "Cursor", MOUSE_CURSOR_T);
+	return luax_checktype<Cursor>(L, idx, MOUSE_CURSOR_ID);
 }
 }
 
 
 int w_Cursor_getType(lua_State *L)
 int w_Cursor_getType(lua_State *L)
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_cursor(lua_State *L)
 extern "C" int luaopen_cursor(lua_State *L)
 {
 {
-	return luax_register_type(L, "Cursor", functions);
+	return luax_register_type(L, MOUSE_CURSOR_ID, functions);
 }
 }
 
 
 } // mouse
 } // mouse

+ 6 - 6
src/modules/mouse/wrap_Mouse.cpp

@@ -36,16 +36,16 @@ int w_newCursor(lua_State *L)
 {
 {
 	Cursor *cursor = nullptr;
 	Cursor *cursor = nullptr;
 
 
-	if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
+	if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
 		luax_convobj(L, 1, "image", "newImageData");
 		luax_convobj(L, 1, "image", "newImageData");
 
 
-	love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
+	love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
 	int hotx = luaL_optint(L, 2, 0);
 	int hotx = luaL_optint(L, 2, 0);
 	int hoty = luaL_optint(L, 3, 0);
 	int hoty = luaL_optint(L, 3, 0);
 
 
 	luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
 	luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
 
 
-	luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
+	luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
 	cursor->release();
 	cursor->release();
 	return 1;
 	return 1;
 }
 }
@@ -61,7 +61,7 @@ int w_getSystemCursor(lua_State *L)
 	Cursor *cursor = 0;
 	Cursor *cursor = 0;
 	luax_catchexcept(L, [&](){ cursor = instance()->getSystemCursor(systemCursor); });
 	luax_catchexcept(L, [&](){ cursor = instance()->getSystemCursor(systemCursor); });
 
 
-	luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
+	luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -84,7 +84,7 @@ int w_getCursor(lua_State *L)
 	Cursor *cursor = instance()->getCursor();
 	Cursor *cursor = instance()->getCursor();
 
 
 	if (cursor)
 	if (cursor)
-		luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
+		luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
 	else
 	else
 		lua_pushnil(L);
 		lua_pushnil(L);
 
 
@@ -242,7 +242,7 @@ extern "C" int luaopen_love_mouse(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "mouse";
 	w.name = "mouse";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 2 - 2
src/modules/physics/box2d/Body.cpp

@@ -435,7 +435,7 @@ int Body::getFixtureList(lua_State *L) const
 		Fixture *fixture = (Fixture *)Memoizer::find(f);
 		Fixture *fixture = (Fixture *)Memoizer::find(f);
 		if (!fixture)
 		if (!fixture)
 			throw love::Exception("A fixture has escaped Memoizer!");
 			throw love::Exception("A fixture has escaped Memoizer!");
-		luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
+		luax_pushtype(L, PHYSICS_FIXTURE_ID, fixture);
 		lua_rawseti(L, -2, i);
 		lua_rawseti(L, -2, i);
 		i++;
 		i++;
 	}
 	}
@@ -483,7 +483,7 @@ int Body::getContactList(lua_State *L) const
 		else
 		else
 			contact->retain();
 			contact->retain();
 		
 		
-		luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
+		luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
 		contact->release();
 		contact->release();
 		lua_rawseti(L, -2, i);
 		lua_rawseti(L, -2, i);
 		i++;
 		i++;

+ 4 - 4
src/modules/physics/box2d/Physics.cpp

@@ -146,7 +146,7 @@ int Physics::newPolygonShape(lua_State *L)
 	}
 	}
 
 
 	PolygonShape *p = new PolygonShape(s);
 	PolygonShape *p = new PolygonShape(s);
-	luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, p);
+	luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, p);
 	p->release();
 	p->release();
 	return 1;
 	return 1;
 }
 }
@@ -208,7 +208,7 @@ int Physics::newChainShape(lua_State *L)
 	delete[] vecs;
 	delete[] vecs;
 
 
 	ChainShape *c = new ChainShape(s);
 	ChainShape *c = new ChainShape(s);
-	luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
+	luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, c);
 	c->release();
 	c->release();
 	return 1;
 	return 1;
 }
 }
@@ -281,8 +281,8 @@ Fixture *Physics::newFixture(Body *body, Shape *shape, float density)
 
 
 int Physics::getDistance(lua_State *L)
 int Physics::getDistance(lua_State *L)
 {
 {
-	Fixture *fixtureA = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
-	Fixture *fixtureB = luax_checktype<Fixture>(L, 2, "Fixture", PHYSICS_FIXTURE_T);
+	Fixture *fixtureA = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
+	Fixture *fixtureB = luax_checktype<Fixture>(L, 2, PHYSICS_FIXTURE_ID);
 	b2DistanceProxy pA, pB;
 	b2DistanceProxy pA, pB;
 	b2DistanceInput i;
 	b2DistanceInput i;
 	b2DistanceOutput o;
 	b2DistanceOutput o;

+ 10 - 10
src/modules/physics/box2d/World.cpp

@@ -57,7 +57,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
 		{
 		{
 			Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
 			Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
 			if (a != 0)
 			if (a != 0)
-				luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
+				luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
 			else
 			else
 				throw love::Exception("A fixture has escaped Memoizer!");
 				throw love::Exception("A fixture has escaped Memoizer!");
 		}
 		}
@@ -66,7 +66,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
 		{
 		{
 			Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
 			Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
 			if (b != 0)
 			if (b != 0)
-				luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
+				luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
 			else
 			else
 				throw love::Exception("A fixture has escaped Memoizer!");
 				throw love::Exception("A fixture has escaped Memoizer!");
 		}
 		}
@@ -77,7 +77,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
 		else
 		else
 			cobj->retain();
 			cobj->retain();
 
 
-		luax_pushtype(L, "Contact", (PHYSICS_CONTACT_T), cobj);
+		luax_pushtype(L, PHYSICS_CONTACT_ID, cobj);
 		cobj->release();
 		cobj->release();
 
 
 		int args = 3;
 		int args = 3;
@@ -128,8 +128,8 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b)
 	{
 	{
 		lua_State *L = ref->getL();
 		lua_State *L = ref->getL();
 		ref->push();
 		ref->push();
-		luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
-		luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
+		luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
+		luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
 		lua_call(L, 2, 1);
 		lua_call(L, 2, 1);
 		return luax_toboolean(L, -1);
 		return luax_toboolean(L, -1);
 	}
 	}
@@ -156,7 +156,7 @@ bool World::QueryCallback::ReportFixture(b2Fixture *fixture)
 		Fixture *f = (Fixture *)Memoizer::find(fixture);
 		Fixture *f = (Fixture *)Memoizer::find(fixture);
 		if (!f)
 		if (!f)
 			throw love::Exception("A fixture has escaped Memoizer!");
 			throw love::Exception("A fixture has escaped Memoizer!");
-		luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
+		luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
 		lua_call(L, 1, 1);
 		lua_call(L, 1, 1);
 		return luax_toboolean(L, -1);
 		return luax_toboolean(L, -1);
 	}
 	}
@@ -183,7 +183,7 @@ float32 World::RayCastCallback::ReportFixture(b2Fixture *fixture, const b2Vec2 &
 		Fixture *f = (Fixture *)Memoizer::find(fixture);
 		Fixture *f = (Fixture *)Memoizer::find(fixture);
 		if (!f)
 		if (!f)
 			throw love::Exception("A fixture has escaped Memoizer!");
 			throw love::Exception("A fixture has escaped Memoizer!");
-		luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
+		luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
 		b2Vec2 scaledPoint = Physics::scaleUp(point);
 		b2Vec2 scaledPoint = Physics::scaleUp(point);
 		lua_pushnumber(L, scaledPoint.x);
 		lua_pushnumber(L, scaledPoint.x);
 		lua_pushnumber(L, scaledPoint.y);
 		lua_pushnumber(L, scaledPoint.y);
@@ -431,7 +431,7 @@ int World::getBodyList(lua_State *L) const
 		Body *body = (Body *)Memoizer::find(b);
 		Body *body = (Body *)Memoizer::find(b);
 		if (!body)
 		if (!body)
 			throw love::Exception("A body has escaped Memoizer!");
 			throw love::Exception("A body has escaped Memoizer!");
-		luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
+		luax_pushtype(L, PHYSICS_BODY_ID, body);
 		lua_rawseti(L, -2, i);
 		lua_rawseti(L, -2, i);
 		i++;
 		i++;
 	}
 	}
@@ -449,7 +449,7 @@ int World::getJointList(lua_State *L) const
 		if (!j) break;
 		if (!j) break;
 		Joint *joint = (Joint *)Memoizer::find(j);
 		Joint *joint = (Joint *)Memoizer::find(j);
 		if (!joint) throw love::Exception("A joint has escaped Memoizer!");
 		if (!joint) throw love::Exception("A joint has escaped Memoizer!");
-		luax_pushtype(L, "Joint", PHYSICS_JOINT_T, joint);
+		luax_pushtype(L, PHYSICS_JOINT_ID, joint);
 		lua_rawseti(L, -2, i);
 		lua_rawseti(L, -2, i);
 		i++;
 		i++;
 	}
 	}
@@ -470,7 +470,7 @@ int World::getContactList(lua_State *L) const
 			contact = new Contact(c);
 			contact = new Contact(c);
 		else
 		else
 			contact->retain();
 			contact->retain();
-		luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
+		luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
 		contact->release();
 		contact->release();
 		lua_rawseti(L, -2, i);
 		lua_rawseti(L, -2, i);
 		i++;
 		i++;

+ 4 - 4
src/modules/physics/box2d/wrap_Body.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 Body *luax_checkbody(lua_State *L, int idx)
 Body *luax_checkbody(lua_State *L, int idx)
 {
 {
-	Body *b = luax_checktype<Body>(L, idx, "Body", PHYSICS_BODY_T);
+	Body *b = luax_checktype<Body>(L, idx, PHYSICS_BODY_ID);
 	if (b->body == 0)
 	if (b->body == 0)
 		luaL_error(L, "Attempt to use destroyed body.");
 		luaL_error(L, "Attempt to use destroyed body.");
 	return b;
 	return b;
@@ -526,7 +526,7 @@ int w_Body_getWorld(lua_State *L)
 {
 {
 	Body *t = luax_checkbody(L, 1);
 	Body *t = luax_checkbody(L, 1);
 	World *world = t->getWorld();
 	World *world = t->getWorld();
-	luax_pushtype(L, "World", PHYSICS_WORLD_T, world);
+	luax_pushtype(L, PHYSICS_WORLD_ID, world);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -566,7 +566,7 @@ int w_Body_destroy(lua_State *L)
 
 
 int w_Body_isDestroyed(lua_State *L)
 int w_Body_isDestroyed(lua_State *L)
 {
 {
-	Body *b = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
+	Body *b = luax_checktype<Body>(L, 1, PHYSICS_BODY_ID);
 	luax_pushboolean(L, b->body == nullptr);
 	luax_pushboolean(L, b->body == nullptr);
 	return 1;
 	return 1;
 }
 }
@@ -650,7 +650,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_body(lua_State *L)
 extern "C" int luaopen_body(lua_State *L)
 {
 {
-	return luax_register_type(L, "Body", functions);
+	return luax_register_type(L, PHYSICS_BODY_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 3 - 3
src/modules/physics/box2d/wrap_ChainShape.cpp

@@ -31,7 +31,7 @@ namespace box2d
 
 
 ChainShape *luax_checkchainshape(lua_State *L, int idx)
 ChainShape *luax_checkchainshape(lua_State *L, int idx)
 {
 {
-	return luax_checktype<ChainShape>(L, idx, "ChainShape", PHYSICS_CHAIN_SHAPE_T);
+	return luax_checktype<ChainShape>(L, idx, PHYSICS_CHAIN_SHAPE_ID);
 }
 }
 
 
 int w_ChainShape_setNextVertex(lua_State *L)
 int w_ChainShape_setNextVertex(lua_State *L)
@@ -65,7 +65,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
 	int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
 	int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
 	EdgeShape *e = 0;
 	EdgeShape *e = 0;
 	luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
 	luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
-	luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
+	luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, e);
 	e->release();
 	e->release();
 	return 1;
 	return 1;
 }
 }
@@ -127,7 +127,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_chainshape(lua_State *L)
 extern "C" int luaopen_chainshape(lua_State *L)
 {
 {
-	return luax_register_type(L, "ChainShape", functions);
+	return luax_register_type(L, PHYSICS_CHAIN_SHAPE_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_CircleShape.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 CircleShape *luax_checkcircleshape(lua_State *L, int idx)
 CircleShape *luax_checkcircleshape(lua_State *L, int idx)
 {
 {
-	return luax_checktype<CircleShape>(L, idx, "CircleShape", PHYSICS_CIRCLE_SHAPE_T);
+	return luax_checktype<CircleShape>(L, idx, PHYSICS_CIRCLE_SHAPE_ID);
 }
 }
 
 
 int w_CircleShape_getRadius(lua_State *L)
 int w_CircleShape_getRadius(lua_State *L)
@@ -83,7 +83,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_circleshape(lua_State *L)
 extern "C" int luaopen_circleshape(lua_State *L)
 {
 {
-	return luax_register_type(L, "CircleShape", functions);
+	return luax_register_type(L, PHYSICS_CIRCLE_SHAPE_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 5 - 5
src/modules/physics/box2d/wrap_Contact.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 Contact *luax_checkcontact(lua_State *L, int idx)
 Contact *luax_checkcontact(lua_State *L, int idx)
 {
 {
-	Contact *c = luax_checktype<Contact>(L, idx, "Contact", PHYSICS_CONTACT_T);
+	Contact *c = luax_checktype<Contact>(L, idx, PHYSICS_CONTACT_ID);
 	if (!c->isValid())
 	if (!c->isValid())
 		luaL_error(L, "Attempt to use destroyed contact.");
 		luaL_error(L, "Attempt to use destroyed contact.");
 	return c;
 	return c;
@@ -146,14 +146,14 @@ int w_Contact_getFixtures(lua_State *L)
 	Fixture *b = nullptr;
 	Fixture *b = nullptr;
 	luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
 	luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
 
 
-	luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
-	luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
+	luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
+	luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
 	return 2;
 	return 2;
 }
 }
 
 
 int w_Contact_isDestroyed(lua_State *L)
 int w_Contact_isDestroyed(lua_State *L)
 {
 {
-	Contact *c = luax_checktype<Contact>(L, 1, "Contact", PHYSICS_CONTACT_T);
+	Contact *c = luax_checktype<Contact>(L, 1, PHYSICS_CONTACT_ID);
 	luax_pushboolean(L, !c->isValid());
 	luax_pushboolean(L, !c->isValid());
 	return 1;
 	return 1;
 }
 }
@@ -181,7 +181,7 @@ extern "C" int luaopen_contact(lua_State *L)
 		{ 0, 0 }
 		{ 0, 0 }
 	};
 	};
 
 
-	return luax_register_type(L, "Contact", functions);
+	return luax_register_type(L, PHYSICS_CONTACT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_DistanceJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx)
 DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx)
 {
 {
-	DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T);
+	DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, PHYSICS_DISTANCE_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -104,7 +104,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_distancejoint(lua_State *L)
 extern "C" int luaopen_distancejoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "DistanceJoint", functions);
+	return luax_register_type(L, PHYSICS_DISTANCE_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_EdgeShape.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 EdgeShape *luax_checkedgeshape(lua_State *L, int idx)
 EdgeShape *luax_checkedgeshape(lua_State *L, int idx)
 {
 {
-	return luax_checktype<EdgeShape>(L, idx, "EdgeShape", PHYSICS_EDGE_SHAPE_T);
+	return luax_checktype<EdgeShape>(L, idx, PHYSICS_EDGE_SHAPE_ID);
 }
 }
 
 
 int w_EdgeShape_getPoints(lua_State *L)
 int w_EdgeShape_getPoints(lua_State *L)
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_edgeshape(lua_State *L)
 extern "C" int luaopen_edgeshape(lua_State *L)
 {
 {
-	return luax_register_type(L, "EdgeShape", functions);
+	return luax_register_type(L, PHYSICS_EDGE_SHAPE_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 9 - 9
src/modules/physics/box2d/wrap_Fixture.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 Fixture *luax_checkfixture(lua_State *L, int idx)
 Fixture *luax_checkfixture(lua_State *L, int idx)
 {
 {
-	Fixture *f = luax_checktype<Fixture>(L, idx, "Fixture", PHYSICS_FIXTURE_T);
+	Fixture *f = luax_checktype<Fixture>(L, idx, PHYSICS_FIXTURE_ID);
 	if (!f->isValid())
 	if (!f->isValid())
 		luaL_error(L, "Attempt to use destroyed fixture.");
 		luaL_error(L, "Attempt to use destroyed fixture.");
 	return f;
 	return f;
@@ -111,7 +111,7 @@ int w_Fixture_getBody(lua_State *L)
 	Body *body = t->getBody();
 	Body *body = t->getBody();
 	if (body == 0)
 	if (body == 0)
 		return 0;
 		return 0;
-	luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
+	luax_pushtype(L, PHYSICS_BODY_ID, body);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -124,19 +124,19 @@ int w_Fixture_getShape(lua_State *L)
 	switch (shape->getType())
 	switch (shape->getType())
 	{
 	{
 	case Shape::SHAPE_EDGE:
 	case Shape::SHAPE_EDGE:
-		luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
 		break;
 		break;
 	case Shape::SHAPE_CHAIN:
 	case Shape::SHAPE_CHAIN:
-		luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, shape);
 		break;
 		break;
 	case Shape::SHAPE_CIRCLE:
 	case Shape::SHAPE_CIRCLE:
-		luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
 		break;
 		break;
 	case Shape::SHAPE_POLYGON:
 	case Shape::SHAPE_POLYGON:
-		luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
 		break;
 		break;
 	default:
 	default:
-		luax_pushtype(L, "Shape", PHYSICS_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_SHAPE_ID, shape);
 		break;
 		break;
 	}
 	}
 	shape->release();
 	shape->release();
@@ -264,7 +264,7 @@ int w_Fixture_destroy(lua_State *L)
 
 
 int w_Fixture_isDestroyed(lua_State *L)
 int w_Fixture_isDestroyed(lua_State *L)
 {
 {
-	Fixture *f = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
+	Fixture *f = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
 	luax_pushboolean(L, !f->isValid());
 	luax_pushboolean(L, !f->isValid());
 	return 1;
 	return 1;
 }
 }
@@ -303,7 +303,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_fixture(lua_State *L)
 extern "C" int luaopen_fixture(lua_State *L)
 {
 {
-	return luax_register_type(L, "Fixture", functions);
+	return luax_register_type(L, PHYSICS_FIXTURE_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_FrictionJoint.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx)
 FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx)
 {
 {
-	FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, "FrictionJoint", PHYSICS_FRICTION_JOINT_T);
+	FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, PHYSICS_FRICTION_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_frictionjoint(lua_State *L)
 extern "C" int luaopen_frictionjoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "FrictionJoint", functions);
+	return luax_register_type(L, PHYSICS_FRICTION_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_GearJoint.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 GearJoint *luax_checkgearjoint(lua_State *L, int idx)
 GearJoint *luax_checkgearjoint(lua_State *L, int idx)
 {
 {
-	GearJoint *j = luax_checktype<GearJoint>(L, idx, "GearJoint", PHYSICS_GEAR_JOINT_T);
+	GearJoint *j = luax_checktype<GearJoint>(L, idx, PHYSICS_GEAR_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_gearjoint(lua_State *L)
 extern "C" int luaopen_gearjoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "GearJoint", functions);
+	return luax_register_type(L, PHYSICS_GEAR_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 16 - 16
src/modules/physics/box2d/wrap_Joint.cpp

@@ -38,27 +38,27 @@ void luax_pushjoint(lua_State *L, Joint *j)
 	switch (j->getType())
 	switch (j->getType())
 	{
 	{
 	case Joint::JOINT_DISTANCE:
 	case Joint::JOINT_DISTANCE:
-		return luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
 	case Joint::JOINT_REVOLUTE:
 	case Joint::JOINT_REVOLUTE:
-		return luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
 	case Joint::JOINT_PRISMATIC:
 	case Joint::JOINT_PRISMATIC:
-		return luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
 	case Joint::JOINT_MOUSE:
 	case Joint::JOINT_MOUSE:
-		return luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
 	case Joint::JOINT_PULLEY:
 	case Joint::JOINT_PULLEY:
-		return luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
 	case Joint::JOINT_GEAR:
 	case Joint::JOINT_GEAR:
-		return luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
 	case Joint::JOINT_FRICTION:
 	case Joint::JOINT_FRICTION:
-		return luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
 	case Joint::JOINT_WELD:
 	case Joint::JOINT_WELD:
-		return luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
 	case Joint::JOINT_WHEEL:
 	case Joint::JOINT_WHEEL:
-		return luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
 	case Joint::JOINT_ROPE:
 	case Joint::JOINT_ROPE:
-		return luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
 	case Joint::JOINT_MOTOR:
 	case Joint::JOINT_MOTOR:
-		return luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
+		return luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
 	default:
 	default:
 		return lua_pushnil(L);
 		return lua_pushnil(L);
 	}
 	}
@@ -66,7 +66,7 @@ void luax_pushjoint(lua_State *L, Joint *j)
 
 
 Joint *luax_checkjoint(lua_State *L, int idx)
 Joint *luax_checkjoint(lua_State *L, int idx)
 {
 {
-	Joint *t = luax_checktype<Joint>(L, idx, "Joint", PHYSICS_JOINT_T);
+	Joint *t = luax_checktype<Joint>(L, idx, PHYSICS_JOINT_ID);
 	if (!t->isValid())
 	if (!t->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return t;
 	return t;
@@ -92,8 +92,8 @@ int w_Joint_getBodies(lua_State *L)
 		b2 = t->getBodyB();
 		b2 = t->getBodyB();
 	});
 	});
 
 
-	luax_pushtype(L, "Body", PHYSICS_BODY_T, b1);
-	luax_pushtype(L, "Body", PHYSICS_BODY_T, b2);
+	luax_pushtype(L, PHYSICS_BODY_ID, b1);
+	luax_pushtype(L, PHYSICS_BODY_ID, b2);
 	return 2;
 	return 2;
 }
 }
 
 
@@ -149,7 +149,7 @@ int w_Joint_destroy(lua_State *L)
 
 
 int w_Joint_isDestroyed(lua_State *L)
 int w_Joint_isDestroyed(lua_State *L)
 {
 {
-	Joint *t = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
+	Joint *t = luax_checktype<Joint>(L, 1, PHYSICS_JOINT_ID);
 	luax_pushboolean(L, !t->isValid());
 	luax_pushboolean(L, !t->isValid());
 	return 1;
 	return 1;
 }
 }
@@ -171,7 +171,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_joint(lua_State *L)
 extern "C" int luaopen_joint(lua_State *L)
 {
 {
-	return luax_register_type(L, "Joint", functions);
+	return luax_register_type(L, PHYSICS_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_MotorJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
 MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
 {
 {
-	MotorJoint *j = luax_checktype<MotorJoint>(L, idx, "MotorJoint", PHYSICS_MOTOR_JOINT_T);
+	MotorJoint *j = luax_checktype<MotorJoint>(L, idx, PHYSICS_MOTOR_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -138,7 +138,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_motorjoint(lua_State *L)
 extern "C" int luaopen_motorjoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "MotorJoint", functions);
+	return luax_register_type(L, PHYSICS_MOTOR_JOINT_ID, functions);
 }
 }
 
 
 
 

+ 2 - 2
src/modules/physics/box2d/wrap_MouseJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 MouseJoint *luax_checkmousejoint(lua_State *L, int idx)
 MouseJoint *luax_checkmousejoint(lua_State *L, int idx)
 {
 {
-	MouseJoint *j = luax_checktype<MouseJoint>(L, idx, "MouseJoint", PHYSICS_MOUSE_JOINT_T);
+	MouseJoint *j = luax_checktype<MouseJoint>(L, idx, PHYSICS_MOUSE_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -122,7 +122,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_mousejoint(lua_State *L)
 extern "C" int luaopen_mousejoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "MouseJoint", functions);
+	return luax_register_type(L, PHYSICS_MOUSE_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 42 - 42
src/modules/physics/box2d/wrap_Physics.cpp

@@ -59,7 +59,7 @@ int w_newWorld(lua_State *L)
 
 
 	World *w;
 	World *w;
 	luax_catchexcept(L, [&](){ w = instance()->newWorld(gx, gy, sleep); });
 	luax_catchexcept(L, [&](){ w = instance()->newWorld(gx, gy, sleep); });
-	luax_pushtype(L, "World", PHYSICS_WORLD_T, w);
+	luax_pushtype(L, PHYSICS_WORLD_ID, w);
 	w->release();
 	w->release();
 
 
 	return 1;
 	return 1;
@@ -67,7 +67,7 @@ int w_newWorld(lua_State *L)
 
 
 int w_newBody(lua_State *L)
 int w_newBody(lua_State *L)
 {
 {
-	World *world = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
+	World *world = luax_checkworld(L, 1);
 	float x = (float)luaL_optnumber(L, 2, 0.0);
 	float x = (float)luaL_optnumber(L, 2, 0.0);
 	float y = (float)luaL_optnumber(L, 3, 0.0);
 	float y = (float)luaL_optnumber(L, 3, 0.0);
 
 
@@ -78,7 +78,7 @@ int w_newBody(lua_State *L)
 
 
 	Body *body;
 	Body *body;
 	luax_catchexcept(L, [&](){ body = instance()->newBody(world, x, y, btype); });
 	luax_catchexcept(L, [&](){ body = instance()->newBody(world, x, y, btype); });
-	luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
+	luax_pushtype(L, PHYSICS_BODY_ID, body);
 	body->release();
 	body->release();
 	return 1;
 	return 1;
 }
 }
@@ -90,7 +90,7 @@ int w_newFixture(lua_State *L)
 	float density = (float)luaL_optnumber(L, 3, 1.0f);
 	float density = (float)luaL_optnumber(L, 3, 1.0f);
 	Fixture *fixture;
 	Fixture *fixture;
 	luax_catchexcept(L, [&](){ fixture = instance()->newFixture(body, shape, density); });
 	luax_catchexcept(L, [&](){ fixture = instance()->newFixture(body, shape, density); });
-	luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
+	luax_pushtype(L, PHYSICS_FIXTURE_ID, fixture);
 	fixture->release();
 	fixture->release();
 	return 1;
 	return 1;
 }
 }
@@ -104,7 +104,7 @@ int w_newCircleShape(lua_State *L)
 		float radius = (float)luaL_checknumber(L, 1);
 		float radius = (float)luaL_checknumber(L, 1);
 		CircleShape *shape;
 		CircleShape *shape;
 		luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(radius); });
 		luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(radius); });
-		luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
 		shape->release();
 		shape->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -115,7 +115,7 @@ int w_newCircleShape(lua_State *L)
 		float radius = (float)luaL_checknumber(L, 3);
 		float radius = (float)luaL_checknumber(L, 3);
 		CircleShape *shape;
 		CircleShape *shape;
 		luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(x, y, radius); });
 		luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(x, y, radius); });
-		luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
 		shape->release();
 		shape->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -133,7 +133,7 @@ int w_newRectangleShape(lua_State *L)
 		float h = (float)luaL_checknumber(L, 2);
 		float h = (float)luaL_checknumber(L, 2);
 		PolygonShape *shape;
 		PolygonShape *shape;
 		luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(w, h); });
 		luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(w, h); });
-		luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
 		shape->release();
 		shape->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -146,7 +146,7 @@ int w_newRectangleShape(lua_State *L)
 		float angle = (float)luaL_optnumber(L, 5, 0);
 		float angle = (float)luaL_optnumber(L, 5, 0);
 		PolygonShape *shape;
 		PolygonShape *shape;
 		luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(x, y, w, h, angle); });
 		luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(x, y, w, h, angle); });
-		luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
+		luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
 		shape->release();
 		shape->release();
 		return 1;
 		return 1;
 	}
 	}
@@ -162,7 +162,7 @@ int w_newEdgeShape(lua_State *L)
 	float y2 = (float)luaL_checknumber(L, 4);
 	float y2 = (float)luaL_checknumber(L, 4);
 	EdgeShape *shape;
 	EdgeShape *shape;
 	luax_catchexcept(L, [&](){ shape = instance()->newEdgeShape(x1, y1, x2, y2); });
 	luax_catchexcept(L, [&](){ shape = instance()->newEdgeShape(x1, y1, x2, y2); });
-	luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
+	luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
 	shape->release();
 	shape->release();
 	return 1;
 	return 1;
 }
 }
@@ -183,8 +183,8 @@ int w_newChainShape(lua_State *L)
 
 
 int w_newDistanceJoint(lua_State *L)
 int w_newDistanceJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float x1 = (float)luaL_checknumber(L, 3);
 	float x1 = (float)luaL_checknumber(L, 3);
 	float y1 = (float)luaL_checknumber(L, 4);
 	float y1 = (float)luaL_checknumber(L, 4);
 	float x2 = (float)luaL_checknumber(L, 5);
 	float x2 = (float)luaL_checknumber(L, 5);
@@ -194,27 +194,27 @@ int w_newDistanceJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
 		j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
 	});
 	});
-	luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newMouseJoint(lua_State *L)
 int w_newMouseJoint(lua_State *L)
 {
 {
-	Body *body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
+	Body *body = luax_checkbody(L, 1);
 	float x = (float)luaL_checknumber(L, 2);
 	float x = (float)luaL_checknumber(L, 2);
 	float y = (float)luaL_checknumber(L, 3);
 	float y = (float)luaL_checknumber(L, 3);
 	MouseJoint *j;
 	MouseJoint *j;
 	luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
 	luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
-	luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newRevoluteJoint(lua_State *L)
 int w_newRevoluteJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float x = (float)luaL_checknumber(L, 3);
 	float x = (float)luaL_checknumber(L, 3);
 	float y = (float)luaL_checknumber(L, 4);
 	float y = (float)luaL_checknumber(L, 4);
 	bool collideConnected = luax_optboolean(L, 5, false);
 	bool collideConnected = luax_optboolean(L, 5, false);
@@ -222,15 +222,15 @@ int w_newRevoluteJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected);
 		j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected);
 	});
 	});
-	luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newPrismaticJoint(lua_State *L)
 int w_newPrismaticJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float xA = (float)luaL_checknumber(L, 3);
 	float xA = (float)luaL_checknumber(L, 3);
 	float yA = (float)luaL_checknumber(L, 4);
 	float yA = (float)luaL_checknumber(L, 4);
 	float xB, yB, ax, ay;
 	float xB, yB, ax, ay;
@@ -255,15 +255,15 @@ int w_newPrismaticJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
 		j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
 	});
 	});
-	luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newPulleyJoint(lua_State *L)
 int w_newPulleyJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float gx1 = (float)luaL_checknumber(L, 3);
 	float gx1 = (float)luaL_checknumber(L, 3);
 	float gy1 = (float)luaL_checknumber(L, 4);
 	float gy1 = (float)luaL_checknumber(L, 4);
 	float gx2 = (float)luaL_checknumber(L, 5);
 	float gx2 = (float)luaL_checknumber(L, 5);
@@ -279,15 +279,15 @@ int w_newPulleyJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected);
 		j = instance()->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected);
 	});
 	});
-	luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newGearJoint(lua_State *L)
 int w_newGearJoint(lua_State *L)
 {
 {
-	Joint *joint1 = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
-	Joint *joint2 = luax_checktype<Joint>(L, 2, "Joint", PHYSICS_JOINT_T);
+	Joint *joint1 = luax_checkjoint(L, 1);
+	Joint *joint2 = luax_checkjoint(L, 2);
 	float ratio = (float)luaL_optnumber(L, 3, 1.0);
 	float ratio = (float)luaL_optnumber(L, 3, 1.0);
 	bool collideConnected = luax_optboolean(L, 4, false);
 	bool collideConnected = luax_optboolean(L, 4, false);
 
 
@@ -295,15 +295,15 @@ int w_newGearJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
 		j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
 	});
 	});
-	luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newFrictionJoint(lua_State *L)
 int w_newFrictionJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float xA = (float)luaL_checknumber(L, 3);
 	float xA = (float)luaL_checknumber(L, 3);
 	float yA = (float)luaL_checknumber(L, 4);
 	float yA = (float)luaL_checknumber(L, 4);
 	float xB, yB;
 	float xB, yB;
@@ -324,15 +324,15 @@ int w_newFrictionJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
 		j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
 	});
 	});
-	luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newWeldJoint(lua_State *L)
 int w_newWeldJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float xA = (float)luaL_checknumber(L, 3);
 	float xA = (float)luaL_checknumber(L, 3);
 	float yA = (float)luaL_checknumber(L, 4);
 	float yA = (float)luaL_checknumber(L, 4);
 	float xB, yB;
 	float xB, yB;
@@ -353,15 +353,15 @@ int w_newWeldJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
 		j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
 	});
 	});
-	luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newWheelJoint(lua_State *L)
 int w_newWheelJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float xA = (float)luaL_checknumber(L, 3);
 	float xA = (float)luaL_checknumber(L, 3);
 	float yA = (float)luaL_checknumber(L, 4);
 	float yA = (float)luaL_checknumber(L, 4);
 	float xB, yB, ax, ay;
 	float xB, yB, ax, ay;
@@ -387,15 +387,15 @@ int w_newWheelJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
 		j = instance()->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
 	});
 	});
-	luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newRopeJoint(lua_State *L)
 int w_newRopeJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	float x1 = (float)luaL_checknumber(L, 3);
 	float x1 = (float)luaL_checknumber(L, 3);
 	float y1 = (float)luaL_checknumber(L, 4);
 	float y1 = (float)luaL_checknumber(L, 4);
 	float x2 = (float)luaL_checknumber(L, 5);
 	float x2 = (float)luaL_checknumber(L, 5);
@@ -406,15 +406,15 @@ int w_newRopeJoint(lua_State *L)
 	luax_catchexcept(L, [&]() {
 	luax_catchexcept(L, [&]() {
 		j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
 		j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
 	});
 	});
-	luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
 
 
 int w_newMotorJoint(lua_State *L)
 int w_newMotorJoint(lua_State *L)
 {
 {
-	Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
-	Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
+	Body *body1 = luax_checkbody(L, 1);
+	Body *body2 = luax_checkbody(L, 2);
 	MotorJoint *j = 0;
 	MotorJoint *j = 0;
 	if (!lua_isnoneornil(L, 3))
 	if (!lua_isnoneornil(L, 3))
 	{
 	{
@@ -427,7 +427,7 @@ int w_newMotorJoint(lua_State *L)
 	{
 	{
 		luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
 		luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
 	}
 	}
-	luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
+	luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
 	j->release();
 	j->release();
 	return 1;
 	return 1;
 }
 }
@@ -517,7 +517,7 @@ extern "C" int luaopen_love_physics(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "physics";
 	w.name = "physics";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 2 - 2
src/modules/physics/box2d/wrap_PolygonShape.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 PolygonShape *luax_checkpolygonshape(lua_State *L, int idx)
 PolygonShape *luax_checkpolygonshape(lua_State *L, int idx)
 {
 {
-	return luax_checktype<PolygonShape>(L, idx, "PolygonShape", PHYSICS_POLYGON_SHAPE_T);
+	return luax_checktype<PolygonShape>(L, idx, PHYSICS_POLYGON_SHAPE_ID);
 }
 }
 
 
 int w_PolygonShape_getPoints(lua_State *L)
 int w_PolygonShape_getPoints(lua_State *L)
@@ -63,7 +63,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_polygonshape(lua_State *L)
 extern "C" int luaopen_polygonshape(lua_State *L)
 {
 {
-	return luax_register_type(L, "PolygonShape", functions);
+	return luax_register_type(L, PHYSICS_POLYGON_SHAPE_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_PrismaticJoint.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx)
 PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx)
 {
 {
-	PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
+	PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, PHYSICS_PRISMATIC_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_prismaticjoint(lua_State *L)
 extern "C" int luaopen_prismaticjoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "PrismaticJoint", functions);
+	return luax_register_type(L, PHYSICS_PRISMATIC_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_PulleyJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx)
 PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx)
 {
 {
-	PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, "PulleyJoint", PHYSICS_PULLEY_JOINT_T);
+	PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, PHYSICS_PULLEY_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -85,7 +85,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_pulleyjoint(lua_State *L)
 extern "C" int luaopen_pulleyjoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "PulleyJoint", functions);
+	return luax_register_type(L, PHYSICS_PULLEY_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_RevoluteJoint.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx)
 RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx)
 {
 {
-	RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T);
+	RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, PHYSICS_REVOLUTE_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_revolutejoint(lua_State *L)
 extern "C" int luaopen_revolutejoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "RevoluteJoint", functions);
+	return luax_register_type(L, PHYSICS_REVOLUTE_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_RopeJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 RopeJoint *luax_checkropejoint(lua_State *L, int idx)
 RopeJoint *luax_checkropejoint(lua_State *L, int idx)
 {
 {
-	RopeJoint *j = luax_checktype<RopeJoint>(L, idx, "RopeJoint", PHYSICS_ROPE_JOINT_T);
+	RopeJoint *j = luax_checktype<RopeJoint>(L, idx, PHYSICS_ROPE_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_ropejoint(lua_State *L)
 extern "C" int luaopen_ropejoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "RopeJoint", functions);
+	return luax_register_type(L, PHYSICS_ROPE_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_Shape.cpp

@@ -30,7 +30,7 @@ namespace box2d
 
 
 Shape *luax_checkshape(lua_State *L, int idx)
 Shape *luax_checkshape(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Shape>(L, idx, "Shape", PHYSICS_SHAPE_T);
+	return luax_checktype<Shape>(L, idx, PHYSICS_SHAPE_ID);
 }
 }
 
 
 int w_Shape_getType(lua_State *L)
 int w_Shape_getType(lua_State *L)
@@ -108,7 +108,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_shape(lua_State *L)
 extern "C" int luaopen_shape(lua_State *L)
 {
 {
-	return luax_register_type(L, "Shape", functions);
+	return luax_register_type(L, PHYSICS_SHAPE_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_WeldJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
 WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
 {
 {
-	WeldJoint *j = luax_checktype<WeldJoint>(L, idx, "WeldJoint", PHYSICS_WELD_JOINT_T);
+	WeldJoint *j = luax_checktype<WeldJoint>(L, idx, PHYSICS_WELD_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -87,7 +87,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_weldjoint(lua_State *L)
 extern "C" int luaopen_weldjoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "WeldJoint", functions);
+	return luax_register_type(L, PHYSICS_WELD_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/physics/box2d/wrap_WheelJoint.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 WheelJoint *luax_checkwheeljoint(lua_State *L, int idx)
 WheelJoint *luax_checkwheeljoint(lua_State *L, int idx)
 {
 {
-	WheelJoint *j = luax_checktype<WheelJoint>(L, idx, "WheelJoint", PHYSICS_WHEEL_JOINT_T);
+	WheelJoint *j = luax_checktype<WheelJoint>(L, idx, PHYSICS_WHEEL_JOINT_ID);
 	if (!j->isValid())
 	if (!j->isValid())
 		luaL_error(L, "Attempt to use destroyed joint.");
 		luaL_error(L, "Attempt to use destroyed joint.");
 	return j;
 	return j;
@@ -163,7 +163,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_wheeljoint(lua_State *L)
 extern "C" int luaopen_wheeljoint(lua_State *L)
 {
 {
-	return luax_register_type(L, "WheelJoint", functions);
+	return luax_register_type(L, PHYSICS_WHEEL_JOINT_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 3 - 3
src/modules/physics/box2d/wrap_World.cpp

@@ -29,7 +29,7 @@ namespace box2d
 
 
 World *luax_checkworld(lua_State *L, int idx)
 World *luax_checkworld(lua_State *L, int idx)
 {
 {
-	World *w = luax_checktype<World>(L, idx, "World", PHYSICS_WORLD_T);
+	World *w = luax_checktype<World>(L, idx, PHYSICS_WORLD_ID);
 	if (!w->isValid())
 	if (!w->isValid())
 		luaL_error(L, "Attempt to use destroyed world.");
 		luaL_error(L, "Attempt to use destroyed world.");
 	return w;
 	return w;
@@ -191,7 +191,7 @@ int w_World_destroy(lua_State *L)
 
 
 int w_World_isDestroyed(lua_State *L)
 int w_World_isDestroyed(lua_State *L)
 {
 {
-	World *w = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
+	World *w = luax_checktype<World>(L, 1, PHYSICS_WORLD_ID);
 	luax_pushboolean(L, !w->isValid());
 	luax_pushboolean(L, !w->isValid());
 	return 1;
 	return 1;
 }
 }
@@ -225,7 +225,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_world(lua_State *L)
 extern "C" int luaopen_world(lua_State *L)
 {
 {
-	return luax_register_type(L, "World", functions);
+	return luax_register_type(L, PHYSICS_WORLD_ID, functions);
 }
 }
 
 
 } // box2d
 } // box2d

+ 2 - 2
src/modules/sound/wrap_Decoder.cpp

@@ -27,7 +27,7 @@ namespace sound
 
 
 Decoder *luax_checkdecoder(lua_State *L, int idx)
 Decoder *luax_checkdecoder(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
+	return luax_checktype<Decoder>(L, idx, SOUND_DECODER_ID);
 }
 }
 
 
 int w_Decoder_getChannels(lua_State *L)
 int w_Decoder_getChannels(lua_State *L)
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_decoder(lua_State *L)
 extern "C" int luaopen_decoder(lua_State *L)
 {
 {
-	return luax_register_type(L, "Decoder", functions);
+	return luax_register_type(L, SOUND_DECODER_ID, functions);
 }
 }
 
 
 } // sound
 } // sound

+ 4 - 4
src/modules/sound/wrap_Sound.cpp

@@ -49,7 +49,7 @@ int w_newSoundData(lua_State *L)
 	else
 	else
 	{
 	{
 		// Convert to Decoder, if necessary.
 		// Convert to Decoder, if necessary.
-		if (!luax_istype(L, 1, SOUND_DECODER_T))
+		if (!luax_istype(L, 1, SOUND_DECODER_ID))
 		{
 		{
 			w_newDecoder(L);
 			w_newDecoder(L);
 			lua_replace(L, 1);
 			lua_replace(L, 1);
@@ -58,7 +58,7 @@ int w_newSoundData(lua_State *L)
 		luax_catchexcept(L, [&](){ t = instance()->newSoundData(luax_checkdecoder(L, 1)); });
 		luax_catchexcept(L, [&](){ t = instance()->newSoundData(luax_checkdecoder(L, 1)); });
 	}
 	}
 
 
-	luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, t);
+	luax_pushtype(L, SOUND_SOUND_DATA_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -77,7 +77,7 @@ int w_newDecoder(lua_State *L)
 	if (t == nullptr)
 	if (t == nullptr)
 		return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str());
 		return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str());
 
 
-	luax_pushtype(L, "Decoder", SOUND_DECODER_T, t);
+	luax_pushtype(L, SOUND_DECODER_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -111,7 +111,7 @@ extern "C" int luaopen_love_sound(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "sound";
 	w.name = "sound";
-	w.flags = MODULE_SOUND_T;
+	w.type = MODULE_SOUND_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = types;
 	w.types = types;
 
 

+ 2 - 2
src/modules/sound/wrap_SoundData.cpp

@@ -29,7 +29,7 @@ namespace sound
 
 
 SoundData *luax_checksounddata(lua_State *L, int idx)
 SoundData *luax_checksounddata(lua_State *L, int idx)
 {
 {
-	return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
+	return luax_checktype<SoundData>(L, idx, SOUND_SOUND_DATA_ID);
 }
 }
 
 
 int w_SoundData_getChannels(lua_State *L)
 int w_SoundData_getChannels(lua_State *L)
@@ -105,7 +105,7 @@ static const luaL_Reg functions[] =
 
 
 extern "C" int luaopen_sounddata(lua_State *L)
 extern "C" int luaopen_sounddata(lua_State *L)
 {
 {
-	return luax_register_type(L, "SoundData", functions);
+	return luax_register_type(L, SOUND_SOUND_DATA_ID, functions);
 }
 }
 
 
 } // sound
 } // sound

+ 1 - 1
src/modules/system/wrap_System.cpp

@@ -110,7 +110,7 @@ extern "C" int luaopen_love_system(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "system";
 	w.name = "system";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = nullptr;
 	w.types = nullptr;
 
 

+ 1 - 1
src/modules/thread/LuaThread.cpp

@@ -109,7 +109,7 @@ void LuaThread::onError()
 		return;
 		return;
 
 
 	Proxy p;
 	Proxy p;
-	p.flags = THREAD_THREAD_T;
+	p.type = THREAD_THREAD_ID;
 	p.object = this;
 	p.object = this;
 
 
 	std::vector<StrongRef<Variant>> vargs = {
 	std::vector<StrongRef<Variant>> vargs = {

+ 2 - 2
src/modules/thread/wrap_Channel.cpp

@@ -40,7 +40,7 @@ void releaseVariant(Channel *c, Variant *v)
 
 
 Channel *luax_checkchannel(lua_State *L, int idx)
 Channel *luax_checkchannel(lua_State *L, int idx)
 {
 {
-	return luax_checktype<Channel>(L, idx, "Channel", THREAD_CHANNEL_T);
+	return luax_checktype<Channel>(L, idx, THREAD_CHANNEL_ID);
 }
 }
 
 
 int w_Channel_push(lua_State *L)
 int w_Channel_push(lua_State *L)
@@ -129,7 +129,7 @@ static const luaL_Reg type_functions[] = {
 
 
 extern "C" int luaopen_channel(lua_State *L)
 extern "C" int luaopen_channel(lua_State *L)
 {
 {
-	return luax_register_type(L, "Channel", type_functions);
+	return luax_register_type(L, THREAD_CHANNEL_ID, type_functions);
 }
 }
 }
 }
 }
 }

+ 2 - 2
src/modules/thread/wrap_LuaThread.cpp

@@ -27,7 +27,7 @@ namespace thread
 
 
 LuaThread *luax_checkthread(lua_State *L, int idx)
 LuaThread *luax_checkthread(lua_State *L, int idx)
 {
 {
-	return luax_checktype<LuaThread>(L, idx, "Thread", THREAD_THREAD_T);
+	return luax_checktype<LuaThread>(L, idx, THREAD_THREAD_ID);
 }
 }
 
 
 int w_Thread_start(lua_State *L)
 int w_Thread_start(lua_State *L)
@@ -91,7 +91,7 @@ static const luaL_Reg type_functions[] = {
 
 
 extern "C" int luaopen_thread(lua_State *L)
 extern "C" int luaopen_thread(lua_State *L)
 {
 {
-	return luax_register_type(L, "Thread", type_functions);
+	return luax_register_type(L, THREAD_THREAD_ID, type_functions);
 }
 }
 
 
 } // thread
 } // thread

+ 8 - 8
src/modules/thread/wrap_ThreadModule.cpp

@@ -61,22 +61,22 @@ int w_newThread(lua_State *L)
 		else
 		else
 			luax_convobj(L, 1, "filesystem", "newFileData");
 			luax_convobj(L, 1, "filesystem", "newFileData");
 	}
 	}
-	else if (luax_istype(L, 1, FILESYSTEM_FILE_T))
+	else if (luax_istype(L, 1, FILESYSTEM_FILE_ID))
 		luax_convobj(L, 1, "filesystem", "newFileData");
 		luax_convobj(L, 1, "filesystem", "newFileData");
 
 
-	if (luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
+	if (luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
 	{
 	{
-		love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
+		love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, FILESYSTEM_FILE_DATA_ID);
 		name = std::string("@") + fdata->getFilename();
 		name = std::string("@") + fdata->getFilename();
 		data = fdata;
 		data = fdata;
 	}
 	}
 	else
 	else
 	{
 	{
-		data = luax_checktype<love::Data>(L, 1, "Data", DATA_T);
+		data = luax_checktype<love::Data>(L, 1, DATA_ID);
 	}
 	}
 
 
 	LuaThread *t = instance()->newThread(name, data);
 	LuaThread *t = instance()->newThread(name, data);
-	luax_pushtype(L, "Thread", THREAD_THREAD_T, t);
+	luax_pushtype(L, THREAD_THREAD_ID, t);
 	t->release();
 	t->release();
 	return 1;
 	return 1;
 }
 }
@@ -84,7 +84,7 @@ int w_newThread(lua_State *L)
 int w_newChannel(lua_State *L)
 int w_newChannel(lua_State *L)
 {
 {
 	Channel *c = instance()->newChannel();
 	Channel *c = instance()->newChannel();
-	luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
+	luax_pushtype(L, THREAD_CHANNEL_ID, c);
 	c->release();
 	c->release();
 	return 1;
 	return 1;
 }
 }
@@ -93,7 +93,7 @@ int w_getChannel(lua_State *L)
 {
 {
 	std::string name = luax_checkstring(L, 1);
 	std::string name = luax_checkstring(L, 1);
 	Channel *c = instance()->getChannel(name);
 	Channel *c = instance()->getChannel(name);
-	luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
+	luax_pushtype(L, THREAD_CHANNEL_ID, c);
 	c->release();
 	c->release();
 	return 1;
 	return 1;
 }
 }
@@ -125,7 +125,7 @@ extern "C" int luaopen_love_thread(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "thread";
 	w.name = "thread";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = module_functions;
 	w.functions = module_functions;
 	w.types = types;
 	w.types = types;
 
 

+ 1 - 1
src/modules/timer/wrap_Timer.cpp

@@ -94,7 +94,7 @@ extern "C" int luaopen_love_timer(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "timer";
 	w.name = "timer";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = 0;
 	w.types = 0;
 
 

+ 1 - 1
src/modules/touch/wrap_Touch.cpp

@@ -90,7 +90,7 @@ extern "C" int luaopen_love_touch(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "touch";
 	w.name = "touch";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = nullptr;
 	w.types = nullptr;
 
 

+ 3 - 6
src/modules/window/wrap_Window.cpp

@@ -292,7 +292,7 @@ int w_getPosition(lua_State *L)
 
 
 int w_setIcon(lua_State *L)
 int w_setIcon(lua_State *L)
 {
 {
-	image::ImageData *i = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
+	image::ImageData *i = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
 	luax_pushboolean(L, instance()->setIcon(i));
 	luax_pushboolean(L, instance()->setIcon(i));
 	return 1;
 	return 1;
 }
 }
@@ -300,10 +300,7 @@ int w_setIcon(lua_State *L)
 int w_getIcon(lua_State *L)
 int w_getIcon(lua_State *L)
 {
 {
 	image::ImageData *i = instance()->getIcon();
 	image::ImageData *i = instance()->getIcon();
-	if (i)
-		luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
-	else
-		lua_pushnil(L);
+	luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -500,7 +497,7 @@ extern "C" int luaopen_love_window(lua_State *L)
 	WrappedModule w;
 	WrappedModule w;
 	w.module = instance;
 	w.module = instance;
 	w.name = "window";
 	w.name = "window";
-	w.flags = MODULE_T;
+	w.type = MODULE_ID;
 	w.functions = functions;
 	w.functions = functions;
 	w.types = 0;
 	w.types = 0;