From 2c4e713114d01ca517bd8d8ee37ae30b3c41f955 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 29 Nov 2015 20:38:12 -0400 Subject: [PATCH] Imported some of the dynamiccore branch from love-experiments: - Type names for love's Lua objects are specified as an argument to luax_register_type, rather than being statically defined in an array. - luax_register_type takes a variable number of method array arguments, for registering superclass methods without copying them into the subclass' method array. Also removed most of the header declarations for wrapper functions. --- src/common/Variant.cpp | 4 +- src/common/runtime.cpp | 38 ++++--- src/common/runtime.h | 19 ++-- src/common/types.cpp | 99 ++----------------- src/common/types.h | 5 +- src/common/wrap_Data.cpp | 2 +- src/common/wrap_Data.h | 4 +- src/modules/audio/wrap_Audio.h | 23 ----- src/modules/audio/wrap_Source.cpp | 4 +- src/modules/audio/wrap_Source.h | 36 ------- src/modules/event/wrap_Event.cpp | 2 +- src/modules/event/wrap_Event.h | 7 -- src/modules/filesystem/wrap_DroppedFile.cpp | 24 +---- src/modules/filesystem/wrap_File.cpp | 4 +- src/modules/filesystem/wrap_File.h | 18 +--- src/modules/filesystem/wrap_FileData.cpp | 7 +- src/modules/filesystem/wrap_FileData.h | 2 - src/modules/filesystem/wrap_Filesystem.h | 37 ------- src/modules/font/wrap_GlyphData.cpp | 9 +- src/modules/font/wrap_GlyphData.h | 9 -- src/modules/font/wrap_Rasterizer.cpp | 4 +- src/modules/font/wrap_Rasterizer.h | 8 -- src/modules/graphics/opengl/wrap_Canvas.cpp | 13 +-- src/modules/graphics/opengl/wrap_Canvas.h | 4 - src/modules/graphics/opengl/wrap_Font.cpp | 4 +- src/modules/graphics/opengl/wrap_Font.h | 12 --- src/modules/graphics/opengl/wrap_Graphics.cpp | 7 ++ src/modules/graphics/opengl/wrap_Graphics.h | 80 --------------- src/modules/graphics/opengl/wrap_Image.cpp | 13 +-- src/modules/graphics/opengl/wrap_Image.h | 6 -- src/modules/graphics/opengl/wrap_Mesh.cpp | 4 +- src/modules/graphics/opengl/wrap_Mesh.h | 19 ---- .../graphics/opengl/wrap_ParticleSystem.cpp | 4 +- .../graphics/opengl/wrap_ParticleSystem.h | 60 ----------- src/modules/graphics/opengl/wrap_Shader.cpp | 4 +- src/modules/graphics/opengl/wrap_Shader.h | 8 -- .../graphics/opengl/wrap_SpriteBatch.cpp | 4 +- .../graphics/opengl/wrap_SpriteBatch.h | 13 --- src/modules/graphics/opengl/wrap_Text.cpp | 4 +- src/modules/graphics/opengl/wrap_Text.h | 9 -- src/modules/graphics/wrap_Quad.cpp | 4 +- src/modules/graphics/wrap_Quad.h | 2 - src/modules/graphics/wrap_Texture.cpp | 17 ++++ src/modules/graphics/wrap_Texture.h | 10 +- src/modules/image/magpie/Image.cpp | 18 ++-- .../image/wrap_CompressedImageData.cpp | 9 +- src/modules/image/wrap_CompressedImageData.h | 5 - src/modules/image/wrap_Image.h | 3 - src/modules/image/wrap_ImageData.cpp | 25 ++--- src/modules/image/wrap_ImageData.h | 8 -- src/modules/joystick/wrap_Joystick.cpp | 4 +- src/modules/joystick/wrap_Joystick.h | 17 ---- src/modules/joystick/wrap_JoystickModule.h | 5 - src/modules/keyboard/wrap_Keyboard.h | 9 -- src/modules/love/love.cpp | 4 + src/modules/math/wrap_BezierCurve.cpp | 4 +- src/modules/math/wrap_BezierCurve.h | 14 --- src/modules/math/wrap_CompressedData.cpp | 9 +- src/modules/math/wrap_CompressedData.h | 1 - src/modules/math/wrap_Math.h | 15 --- src/modules/math/wrap_RandomGenerator.cpp | 4 +- src/modules/math/wrap_RandomGenerator.h | 6 -- src/modules/mouse/wrap_Cursor.cpp | 4 +- src/modules/mouse/wrap_Cursor.h | 1 - src/modules/mouse/wrap_Mouse.h | 18 ---- src/modules/physics/box2d/wrap_Body.cpp | 4 +- src/modules/physics/box2d/wrap_Body.h | 58 ----------- src/modules/physics/box2d/wrap_ChainShape.cpp | 12 +-- src/modules/physics/box2d/wrap_ChainShape.h | 8 -- .../physics/box2d/wrap_CircleShape.cpp | 12 +-- src/modules/physics/box2d/wrap_CircleShape.h | 4 - src/modules/physics/box2d/wrap_Contact.cpp | 44 ++++----- src/modules/physics/box2d/wrap_Contact.h | 16 --- .../physics/box2d/wrap_DistanceJoint.cpp | 15 +-- .../physics/box2d/wrap_DistanceJoint.h | 6 -- src/modules/physics/box2d/wrap_EdgeShape.cpp | 12 +-- src/modules/physics/box2d/wrap_EdgeShape.h | 1 - src/modules/physics/box2d/wrap_Fixture.cpp | 4 +- src/modules/physics/box2d/wrap_Fixture.h | 27 ----- .../physics/box2d/wrap_FrictionJoint.cpp | 15 +-- .../physics/box2d/wrap_FrictionJoint.h | 4 - src/modules/physics/box2d/wrap_GearJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_GearJoint.h | 3 - src/modules/physics/box2d/wrap_Joint.cpp | 4 +- src/modules/physics/box2d/wrap_Joint.h | 12 +-- src/modules/physics/box2d/wrap_MotorJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_MotorJoint.h | 10 -- src/modules/physics/box2d/wrap_MouseJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_MouseJoint.h | 8 -- src/modules/physics/box2d/wrap_Physics.h | 22 ----- .../physics/box2d/wrap_PolygonShape.cpp | 12 +-- src/modules/physics/box2d/wrap_PolygonShape.h | 2 - .../physics/box2d/wrap_PrismaticJoint.cpp | 15 +-- .../physics/box2d/wrap_PrismaticJoint.h | 17 ---- .../physics/box2d/wrap_PulleyJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_PulleyJoint.h | 4 - .../physics/box2d/wrap_RevoluteJoint.cpp | 15 +-- .../physics/box2d/wrap_RevoluteJoint.h | 17 ---- src/modules/physics/box2d/wrap_RopeJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_RopeJoint.h | 1 - src/modules/physics/box2d/wrap_Shape.cpp | 4 +- src/modules/physics/box2d/wrap_Shape.h | 11 +-- src/modules/physics/box2d/wrap_WeldJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_WeldJoint.h | 6 -- src/modules/physics/box2d/wrap_WheelJoint.cpp | 15 +-- src/modules/physics/box2d/wrap_WheelJoint.h | 13 --- src/modules/physics/box2d/wrap_World.cpp | 4 +- src/modules/physics/box2d/wrap_World.h | 21 ---- src/modules/sound/wrap_Decoder.cpp | 4 +- src/modules/sound/wrap_Decoder.h | 4 - src/modules/sound/wrap_Sound.cpp | 40 ++++---- src/modules/sound/wrap_Sound.h | 2 - src/modules/sound/wrap_SoundData.cpp | 21 ++-- src/modules/sound/wrap_SoundData.h | 7 -- src/modules/system/wrap_System.h | 7 -- src/modules/thread/wrap_Channel.cpp | 5 +- src/modules/thread/wrap_Channel.h | 11 +-- src/modules/thread/wrap_LuaThread.cpp | 5 +- src/modules/thread/wrap_LuaThread.h | 5 - src/modules/thread/wrap_ThreadModule.cpp | 3 +- src/modules/thread/wrap_ThreadModule.h | 3 - src/modules/timer/wrap_Timer.h | 6 -- src/modules/touch/wrap_Touch.h | 3 - src/modules/window/wrap_Window.h | 28 ------ 124 files changed, 251 insertions(+), 1300 deletions(-) diff --git a/src/common/Variant.cpp b/src/common/Variant.cpp index 02303fcff..3d48017bb 100644 --- a/src/common/Variant.cpp +++ b/src/common/Variant.cpp @@ -24,8 +24,6 @@ namespace love { -extern StringMap types; - static love::Type extractudatatype(lua_State *L, int idx) { Type t = INVALID_ID; @@ -36,7 +34,7 @@ static love::Type extractudatatype(lua_State *L, int idx) lua_pushvalue(L, idx); int result = lua_pcall(L, 1, 1, 0); if (result == 0) - types.find(lua_tostring(L, -1), t); + getTypeName(lua_tostring(L, -1), t); if (result == 0 || result == LUA_ERRRUN) lua_pop(L, 1); return t; diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 728f4c30c..dca9bb2df 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -216,6 +216,8 @@ int luax_require(lua_State *L, const char *name) int luax_register_module(lua_State *L, const WrappedModule &m) { + love::addTypeName(m.type, m.name); + // Put a reference to the C++ module in Lua. luax_insistregistry(L, REGISTRY_MODULES); @@ -270,12 +272,9 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name) return 0; } -int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f, bool pushmetatable) +int luax_register_type(lua_State *L, love::Type type, const char *name, ...) { - // Verify that this type name has a matching Type ID and type name mapping. - const char *tname = "Invalid"; - if (!love::getType(type, tname)) - printf("Missing type name entry for type ID %d\n", type); + love::addTypeName(type, name); // Get the place for storing and re-using instantiated love types. luax_getregistry(L, REGISTRY_OBJECTS); @@ -302,7 +301,7 @@ int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f, bool pu else lua_pop(L, 1); - luaL_newmetatable(L, tname); + luaL_newmetatable(L, name); // m.__index = m lua_pushvalue(L, -1); @@ -317,12 +316,12 @@ int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f, bool pu lua_setfield(L, -2, "__eq"); // Add tostring function. - lua_pushstring(L, tname); + lua_pushstring(L, name); lua_pushcclosure(L, w__tostring, 1); lua_setfield(L, -2, "__tostring"); // Add type - lua_pushstring(L, tname); + lua_pushstring(L, name); lua_pushcclosure(L, w__type, 1); lua_setfield(L, -2, "type"); @@ -330,16 +329,25 @@ int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f, bool pu lua_pushcfunction(L, w__typeOf); lua_setfield(L, -2, "typeOf"); - if (f != nullptr) + va_list fs; + va_start(fs, name); + for (const luaL_Reg *f = va_arg(fs, const luaL_Reg *); f; f = va_arg(fs, const luaL_Reg *)) luax_setfuncs(L, f); - - if (pushmetatable) - return 1; // leave the metatable on the stack. + va_end(fs); lua_pop(L, 1); // Pops metatable. return 0; } +void luax_gettypemetatable(lua_State *L, love::Type type) +{ + const char *name = nullptr; + if (getTypeName(type, name)) + lua_getfield(L, LUA_REGISTRYINDEX, name); + else + lua_pushnil(L); +} + int luax_table_insert(lua_State *L, int tindex, int vindex, int pos) { if (tindex < 0) @@ -403,7 +411,7 @@ void luax_rawnewtype(lua_State *L, love::Type type, love::Object *object) u->type = type; const char *name = "Invalid"; - getType(type, name); + getTypeName(type, name); luaL_newmetatable(L, name); lua_setmetatable(L, -2); @@ -670,7 +678,7 @@ extern "C" int luax_typerror(lua_State *L, int narg, const char *tname) // Non-love userdata might have a type metamethod which doesn't // describe its type properly, so we only use it for love types. love::Type t; - if (!love::getType(argtname, t)) + if (!love::getTypeName(argtname, t)) argtname = 0; } } @@ -707,7 +715,7 @@ void luax_register(lua_State *L, const char *name, const luaL_Reg *l) Type luax_type(lua_State *L, int idx) { Type t = INVALID_ID; - getType(luaL_checkstring(L, idx), t); + getTypeName(luaL_checkstring(L, idx), t); return t; } diff --git a/src/common/runtime.h b/src/common/runtime.h index 6d7f8cde2..7d8b26538 100644 --- a/src/common/runtime.h +++ b/src/common/runtime.h @@ -247,10 +247,15 @@ int luax_preload(lua_State *L, lua_CFunction f, const char *name); /** * Register a new type. * @param type The type. - * @param f The list of member functions for the type. - * @param pushmetatable Whether to push the type's metatable to the stack. + * @param name The type's human-readable name + * @param ... The list of lists of member functions for the type. (of type luaL_Reg*) **/ -int luax_register_type(lua_State *L, love::Type type, const luaL_Reg *f = nullptr, bool pushmetatable = false); +int luax_register_type(lua_State *L, love::Type type, const char *name, ...); + +/** + * Pushes the metatable of the specified type onto the stack. +**/ +void luax_gettypemetatable(lua_State *L, love::Type type); /** * Do a table.insert from C @@ -434,7 +439,7 @@ T *luax_checktype(lua_State *L, int idx, love::Type type) if (lua_type(L, idx) != LUA_TUSERDATA) { const char *name = "Invalid"; - getType(type, name); + getTypeName(type, name); luax_typerror(L, idx, name); } @@ -443,7 +448,7 @@ T *luax_checktype(lua_State *L, int idx, love::Type type) if (!typeFlags[u->type][type]) { const char *name = "Invalid"; - getType(type, name); + getTypeName(type, name); luax_typerror(L, idx, name); } @@ -454,7 +459,7 @@ template T *luax_getmodule(lua_State *L, love::Type type) { const char *name = "Invalid"; - getType(type, name); + getTypeName(type, name); luax_insistregistry(L, REGISTRY_MODULES); lua_getfield(L, -1, name); @@ -476,7 +481,7 @@ template T *luax_optmodule(lua_State *L, love::Type type) { const char *name = "Invalid"; - getType(type, name); + getTypeName(type, name); luax_insistregistry(L, REGISTRY_MODULES); lua_getfield(L, -1, name); diff --git a/src/common/types.cpp b/src/common/types.cpp index 7fdf0f01c..073be65b6 100644 --- a/src/common/types.cpp +++ b/src/common/types.cpp @@ -116,102 +116,21 @@ static const TypeBits *createTypeFlags() const TypeBits *typeFlags = createTypeFlags(); -StringMap::Entry typeEntries[] = +static StringMap types(nullptr, 0); + +void addTypeName(Type type, const char *name) { - {"Invalid", INVALID_ID}, + const char *n; + if (!types.find(type, n)) + types.add(name, type); +} - {"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}, - {"CompressedImageData", IMAGE_COMPRESSED_IMAGE_DATA_ID}, - - // Joystick - {"Joystick", JOYSTICK_JOYSTICK_ID}, - - // Math - {"RandomGenerator", MATH_RANDOM_GENERATOR_ID}, - {"BezierCurve", MATH_BEZIER_CURVE_ID}, - {"CompressedData", MATH_COMPRESSED_DATA_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 types(typeEntries, sizeof(typeEntries)); - -static_assert((sizeof(typeEntries) / sizeof(typeEntries[0])) == TYPE_MAX_ENUM, "Type name array size doesn't match the total number of type IDs!"); - -bool getType(const char *in, love::Type &out) +bool getTypeName(const char *in, love::Type &out) { return types.find(in, out); } -bool getType(love::Type in, const char *&out) +bool getTypeName(love::Type in, const char *&out) { return types.find(in, out); } diff --git a/src/common/types.h b/src/common/types.h index 0e801bdd0..226f4f24d 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -123,8 +123,9 @@ typedef std::bitset TypeBits; **/ extern const TypeBits *typeFlags; -bool getType(const char *in, Type &out); -bool getType(Type in, const char *&out); +void addTypeName(Type type, const char *name); +bool getTypeName(const char *in, Type &out); +bool getTypeName(Type in, const char *&out); } // love diff --git a/src/common/wrap_Data.cpp b/src/common/wrap_Data.cpp index 646d09b77..6a18eb594 100644 --- a/src/common/wrap_Data.cpp +++ b/src/common/wrap_Data.cpp @@ -59,7 +59,7 @@ const luaL_Reg w_Data_functions[] = int w_Data_open(lua_State *L) { - luax_register_type(L, DATA_ID, w_Data_functions); + luax_register_type(L, DATA_ID, "Data", w_Data_functions, nullptr); return 0; } diff --git a/src/common/wrap_Data.h b/src/common/wrap_Data.h index 50c944fe4..46f61a62b 100644 --- a/src/common/wrap_Data.h +++ b/src/common/wrap_Data.h @@ -29,10 +29,8 @@ namespace love { Data *luax_checkdata(lua_State *L, int idx); -int w_Data_getString(lua_State *L); -int w_Data_getPointer(lua_State *L); -int w_Data_getSize(lua_State *L); int w_Data_open(lua_State *L); +extern const luaL_Reg w_Data_functions[]; } // love diff --git a/src/modules/audio/wrap_Audio.h b/src/modules/audio/wrap_Audio.h index 40dc807d9..5673d9b72 100644 --- a/src/modules/audio/wrap_Audio.h +++ b/src/modules/audio/wrap_Audio.h @@ -32,29 +32,6 @@ namespace love namespace audio { -int w_getSourceCount(lua_State *L); -int w_newSource(lua_State *L); -int w_play(lua_State *L); -int w_stop(lua_State *L); -int w_pause(lua_State *L); -int w_resume(lua_State *L); -int w_rewind(lua_State *L); -int w_setVolume(lua_State *L); -int w_getVolume(lua_State *L); -int w_setPosition(lua_State *L); -int w_getPosition(lua_State *L); -int w_setOrientation(lua_State *L); -int w_getOrientation(lua_State *L); -int w_setVelocity(lua_State *L); -int w_getVelocity(lua_State *L); -int w_setDopplerScale(lua_State *L); -int w_getDopplerScale(lua_State *L); -int w_record(lua_State *L); -int w_getRecordedData(lua_State *L); -int w_stopRecording(lua_State *L); -int w_canRecord(lua_State *L); -int w_setDistanceModel(lua_State *L); -int w_getDistanceModel(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State *L); } // audio diff --git a/src/modules/audio/wrap_Source.cpp b/src/modules/audio/wrap_Source.cpp index 77cb76595..ceb868635 100644 --- a/src/modules/audio/wrap_Source.cpp +++ b/src/modules/audio/wrap_Source.cpp @@ -370,7 +370,7 @@ int w_Source_getType(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Source_functions[] = { { "clone", w_Source_clone }, @@ -420,7 +420,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_source(lua_State *L) { - return luax_register_type(L, AUDIO_SOURCE_ID, functions); + return luax_register_type(L, AUDIO_SOURCE_ID, "Source", w_Source_functions, nullptr); } } // audio diff --git a/src/modules/audio/wrap_Source.h b/src/modules/audio/wrap_Source.h index 2ae79c953..c7b8514de 100644 --- a/src/modules/audio/wrap_Source.h +++ b/src/modules/audio/wrap_Source.h @@ -30,42 +30,6 @@ namespace audio { Source *luax_checksource(lua_State *L, int idx); -int w_Source_clone(lua_State *L); -int w_Source_play(lua_State *L); -int w_Source_stop(lua_State *L); -int w_Source_pause(lua_State *L); -int w_Source_resume(lua_State *L); -int w_Source_rewind(lua_State *L); -int w_Source_setPitch(lua_State *L); -int w_Source_getPitch(lua_State *L); -int w_Source_setVolume(lua_State *L); -int w_Source_getVolume(lua_State *L); -int w_Source_seek(lua_State *L); -int w_Source_tell(lua_State *L); -int w_Source_getDuration(lua_State *L); -int w_Source_setPosition(lua_State *L); -int w_Source_getPosition(lua_State *L); -int w_Source_setVelocity(lua_State *L); -int w_Source_getVelocity(lua_State *L); -int w_Source_setDirection(lua_State *L); -int w_Source_getDirection(lua_State *L); -int w_Source_setCone(lua_State *L); -int w_Source_getCone(lua_State *L); -int w_Source_setRelative(lua_State *L); -int w_Source_isRelative(lua_State *L); -int w_Source_setLooping(lua_State *L); -int w_Source_isLooping(lua_State *L); -int w_Source_isStopped(lua_State *L); -int w_Source_isPaused(lua_State *L); -int w_Source_isPlaying(lua_State *L); -int w_Source_setVolumeLimits(lua_State *L); -int w_Source_getVolumeLimits(lua_State *L); -int w_Source_setAttenuationDistances(lua_State *L); -int w_Source_getAttenuationDistances(lua_State *L); -int w_Source_setRolloff(lua_State *L); -int w_Source_getRolloff(lua_State *L); -int w_Source_getChannels(lua_State *L); -int w_Source_getType(lua_State *L); extern "C" int luaopen_source(lua_State *L); } // audio diff --git a/src/modules/event/wrap_Event.cpp b/src/modules/event/wrap_Event.cpp index 747417073..8f9af72c1 100644 --- a/src/modules/event/wrap_Event.cpp +++ b/src/modules/event/wrap_Event.cpp @@ -141,7 +141,7 @@ extern "C" int luaopen_love_event(lua_State *L) w.name = "event"; w.type = MODULE_ID; w.functions = functions; - w.types = 0; + w.types = nullptr; return luax_register_module(L, w); } diff --git a/src/modules/event/wrap_Event.h b/src/modules/event/wrap_Event.h index 05a25f7c1..ed0f8f7e3 100644 --- a/src/modules/event/wrap_Event.h +++ b/src/modules/event/wrap_Event.h @@ -30,13 +30,6 @@ namespace love namespace event { -int w_pump(lua_State *L); -int w_poll(lua_State *L); -int w_wait(lua_State *L); -int w_push(lua_State *L); -int w_clear(lua_State *L); -int w_quit(lua_State *L); - extern "C" LOVE_EXPORT int luaopen_love_event(lua_State *L); } // event diff --git a/src/modules/filesystem/wrap_DroppedFile.cpp b/src/modules/filesystem/wrap_DroppedFile.cpp index b38982558..dfd82c800 100644 --- a/src/modules/filesystem/wrap_DroppedFile.cpp +++ b/src/modules/filesystem/wrap_DroppedFile.cpp @@ -31,31 +31,9 @@ DroppedFile *luax_checkdroppedfile(lua_State *L, int idx) return luax_checktype(L, idx, FILESYSTEM_DROPPED_FILE_ID); } -static const luaL_Reg functions[] = -{ - // Inherits from File. - { "getSize", w_File_getSize }, - { "open", w_File_open }, - { "close", w_File_close }, - { "isOpen", w_File_isOpen }, - { "read", w_File_read }, - { "write", w_File_write }, - { "flush", w_File_flush }, - { "isEOF", w_File_isEOF }, - { "tell", w_File_tell }, - { "seek", w_File_seek }, - { "lines", w_File_lines }, - { "setBuffer", w_File_setBuffer }, - { "getBuffer", w_File_getBuffer }, - { "getMode", w_File_getMode }, - { "getFilename", w_File_getFilename }, - { "getExtension", w_File_getExtension }, - { 0, 0 } -}; - extern "C" int luaopen_droppedfile(lua_State *L) { - return luax_register_type(L, FILESYSTEM_DROPPED_FILE_ID, functions); + return luax_register_type(L, FILESYSTEM_DROPPED_FILE_ID, "DroppedFile", w_File_functions, nullptr); } } // filesystem diff --git a/src/modules/filesystem/wrap_File.cpp b/src/modules/filesystem/wrap_File.cpp index f8b0fe0fc..234fad738 100644 --- a/src/modules/filesystem/wrap_File.cpp +++ b/src/modules/filesystem/wrap_File.cpp @@ -413,7 +413,7 @@ int w_File_getExtension(lua_State *L) return 1; } -static const luaL_Reg functions[] = +const luaL_Reg w_File_functions[] = { { "getSize", w_File_getSize }, { "open", w_File_open }, @@ -436,7 +436,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_file(lua_State *L) { - return luax_register_type(L, FILESYSTEM_FILE_ID, functions); + return luax_register_type(L, FILESYSTEM_FILE_ID, "File", w_File_functions, nullptr); } } // filesystem diff --git a/src/modules/filesystem/wrap_File.h b/src/modules/filesystem/wrap_File.h index 50ee0f137..65bd21d3e 100644 --- a/src/modules/filesystem/wrap_File.h +++ b/src/modules/filesystem/wrap_File.h @@ -34,25 +34,11 @@ namespace filesystem int luax_ioError(lua_State *L, const char *fmt, ...); File *luax_checkfile(lua_State *L, int idx); -int w_File_getSize(lua_State *L); -int w_File_open(lua_State *L); -int w_File_close(lua_State *L); -int w_File_isOpen(lua_State *L); -int w_File_read(lua_State *L); -int w_File_write(lua_State *L); -int w_File_flush(lua_State *L); -int w_File_isEOF(lua_State *L); -int w_File_tell(lua_State *L); -int w_File_seek(lua_State *L); int w_File_lines_i(lua_State *L); -int w_File_lines(lua_State *L); -int w_File_setBuffer(lua_State *L); -int w_File_getBuffer(lua_State *L); -int w_File_getMode(lua_State *L); -int w_File_getFilename(lua_State *L); -int w_File_getExtension(lua_State *L); extern "C" int luaopen_file(lua_State *L); +extern const luaL_Reg w_File_functions[]; + } // filesystem } // love diff --git a/src/modules/filesystem/wrap_FileData.cpp b/src/modules/filesystem/wrap_FileData.cpp index 83a2af9e9..3e5086682 100644 --- a/src/modules/filesystem/wrap_FileData.cpp +++ b/src/modules/filesystem/wrap_FileData.cpp @@ -48,11 +48,6 @@ int w_FileData_getExtension(lua_State *L) static const luaL_Reg w_FileData_functions[] = { - // Data - { "getString", w_Data_getString }, - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { "getFilename", w_FileData_getFilename }, { "getExtension", w_FileData_getExtension }, @@ -61,7 +56,7 @@ static const luaL_Reg w_FileData_functions[] = extern "C" int luaopen_filedata(lua_State *L) { - return luax_register_type(L, FILESYSTEM_FILE_DATA_ID, w_FileData_functions); + return luax_register_type(L, FILESYSTEM_FILE_DATA_ID, "FileData", w_Data_functions, w_FileData_functions, nullptr); } } // filesystem diff --git a/src/modules/filesystem/wrap_FileData.h b/src/modules/filesystem/wrap_FileData.h index 703e4ce49..bbd382328 100644 --- a/src/modules/filesystem/wrap_FileData.h +++ b/src/modules/filesystem/wrap_FileData.h @@ -31,8 +31,6 @@ namespace filesystem { FileData *luax_checkfiledata(lua_State *L, int idx); -int w_FileData_getFilename(lua_State *L); -int w_FileData_getExtension(lua_State *L); extern "C" int luaopen_filedata(lua_State *L); } // filesystem diff --git a/src/modules/filesystem/wrap_Filesystem.h b/src/modules/filesystem/wrap_Filesystem.h index 38ffa0b6f..707d0dad2 100644 --- a/src/modules/filesystem/wrap_Filesystem.h +++ b/src/modules/filesystem/wrap_Filesystem.h @@ -40,43 +40,6 @@ namespace filesystem FileData *luax_getfiledata(lua_State *L, int idx); bool hack_setupWriteDirectory(); -int w_init(lua_State *L); -int w_setFused(lua_State *L); -int w_isFused(lua_State *L); -int w_setIdentity(lua_State *L); -int w_getIdentity(lua_State *L); -int w_setSource(lua_State *L); -int w_getSource(lua_State *L); -int w_mount(lua_State *L); -int w_unmount(lua_State *L); -int w_newFile(lua_State *L); -int w_newFileData(lua_State *L); -int w_getWorkingDirectory(lua_State *L); -int w_getUserDirectory(lua_State *L); -int w_getAppdataDirectory(lua_State *L); -int w_getSaveDirectory(lua_State *L); -int w_getSourceBaseDirectory(lua_State *L); -int w_getRealDirectory(lua_State *L); -int w_getExecutablePath(lua_State *L); -int w_isDirectory(lua_State *L); -int w_isFile(lua_State *L); -int w_createDirectory(lua_State *L); -int w_remove(lua_State *L); -int w_open(lua_State *L); -int w_close(lua_State *L); -int w_read(lua_State *L); -int w_write(lua_State *L); -int w_append(lua_State *L); -int w_getDirectoryItems(lua_State *L); -int w_lines(lua_State *L); -int w_load(lua_State *L); -int w_getLastModified(lua_State *L); -int w_getSize(lua_State *L); -int w_setSymlinksEnabled(lua_State *L); -int w_areSymlinksEnabled(lua_State *L); -int w_isSymlink(lua_State *L); -int w_getRequirePath(lua_State *L); -int w_setRequirePath(lua_State *L); int loader(lua_State *L); int extloader(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_filesystem(lua_State *L); diff --git a/src/modules/font/wrap_GlyphData.cpp b/src/modules/font/wrap_GlyphData.cpp index 494d9e5e0..9cd369f30 100644 --- a/src/modules/font/wrap_GlyphData.cpp +++ b/src/modules/font/wrap_GlyphData.cpp @@ -115,13 +115,8 @@ int w_GlyphData_getFormat(lua_State *L) return 1; } -static const luaL_Reg functions[] = +const luaL_Reg w_GlyphData_functions[] = { - // Data - { "getString", w_Data_getString }, - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { "getWidth", w_GlyphData_getWidth }, { "getHeight", w_GlyphData_getHeight }, { "getDimensions", w_GlyphData_getDimensions }, @@ -136,7 +131,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_glyphdata(lua_State *L) { - return luax_register_type(L, FONT_GLYPH_DATA_ID, functions); + return luax_register_type(L, FONT_GLYPH_DATA_ID, "GlyphData", w_Data_functions, w_GlyphData_functions, nullptr); } } // font diff --git a/src/modules/font/wrap_GlyphData.h b/src/modules/font/wrap_GlyphData.h index 3d485dc33..ce3b0c5ef 100644 --- a/src/modules/font/wrap_GlyphData.h +++ b/src/modules/font/wrap_GlyphData.h @@ -33,15 +33,6 @@ namespace font { GlyphData *luax_checkglyphdata(lua_State *L, int idx); -int w_GlyphData_getWidth(lua_State *L); -int w_GlyphData_getHeight(lua_State *L); -int w_GlyphData_getDimensions(lua_State *L); -int w_GlyphData_getGlyph(lua_State *L); -int w_GlyphData_getGlyphString(lua_State *L); -int w_GlyphData_getAdvance(lua_State *L); -int w_GlyphData_getBearing(lua_State *L); -int w_GlyphData_getBoundingBox(lua_State *L); -int w_GlyphData_getFormat(lua_State *L); extern "C" int luaopen_glyphdata(lua_State *L); } // font diff --git a/src/modules/font/wrap_Rasterizer.cpp b/src/modules/font/wrap_Rasterizer.cpp index 59a934954..7fa04d88c 100644 --- a/src/modules/font/wrap_Rasterizer.cpp +++ b/src/modules/font/wrap_Rasterizer.cpp @@ -124,7 +124,7 @@ int w_Rasterizer_hasGlyphs(lua_State *L) return 1; } -static const luaL_Reg functions[] = +const luaL_Reg w_Rasterizer_functions[] = { { "getHeight", w_Rasterizer_getHeight }, { "getAdvance", w_Rasterizer_getAdvance }, @@ -139,7 +139,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_rasterizer(lua_State *L) { - return luax_register_type(L, FONT_RASTERIZER_ID, functions); + return luax_register_type(L, FONT_RASTERIZER_ID, "Rasterizer", w_Rasterizer_functions, nullptr); } } // font diff --git a/src/modules/font/wrap_Rasterizer.h b/src/modules/font/wrap_Rasterizer.h index b8d6eae1f..9c132d188 100644 --- a/src/modules/font/wrap_Rasterizer.h +++ b/src/modules/font/wrap_Rasterizer.h @@ -31,14 +31,6 @@ namespace font { Rasterizer *luax_checkrasterizer(lua_State *L, int idx); -int w_Rasterizer_getHeight(lua_State *L); -int w_Rasterizer_getAdvance(lua_State *L); -int w_Rasterizer_getAscent(lua_State *L); -int w_Rasterizer_getDescent(lua_State *L); -int w_Rasterizer_getLineHeight(lua_State *L); -int w_Rasterizer_getGlyphData(lua_State *L); -int w_Rasterizer_getGlyphCount(lua_State *L); -int w_Rasterizer_hasGlyphs(lua_State *L); extern "C" int luaopen_rasterizer(lua_State *L); } // font diff --git a/src/modules/graphics/opengl/wrap_Canvas.cpp b/src/modules/graphics/opengl/wrap_Canvas.cpp index 004ee2f9a..7294d2650 100644 --- a/src/modules/graphics/opengl/wrap_Canvas.cpp +++ b/src/modules/graphics/opengl/wrap_Canvas.cpp @@ -101,17 +101,8 @@ int w_Canvas_getMSAA(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Canvas_functions[] = { - // From wrap_Texture. - { "getWidth", w_Texture_getWidth }, - { "getHeight", w_Texture_getHeight }, - { "getDimensions", w_Texture_getDimensions }, - { "setFilter", w_Texture_setFilter }, - { "getFilter", w_Texture_getFilter }, - { "setWrap", w_Texture_setWrap }, - { "getWrap", w_Texture_getWrap }, - { "renderTo", w_Canvas_renderTo }, { "newImageData", w_Canvas_newImageData }, { "getFormat", w_Canvas_getFormat }, @@ -121,7 +112,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_canvas(lua_State *L) { - return luax_register_type(L, GRAPHICS_CANVAS_ID, functions); + return luax_register_type(L, GRAPHICS_CANVAS_ID, "Canvas", w_Texture_functions, w_Canvas_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_Canvas.h b/src/modules/graphics/opengl/wrap_Canvas.h index 9eb0fbe19..9cb28ff50 100644 --- a/src/modules/graphics/opengl/wrap_Canvas.h +++ b/src/modules/graphics/opengl/wrap_Canvas.h @@ -35,10 +35,6 @@ namespace opengl //see Canvas.h Canvas *luax_checkcanvas(lua_State *L, int idx); -int w_Canvas_renderTo(lua_State *L); -int w_Canvas_newImageData(lua_State *L); -int w_Canvas_getFormat(lua_State *L); -int w_Canvas_getMSAA(lua_State *L); extern "C" int luaopen_canvas(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_Font.cpp b/src/modules/graphics/opengl/wrap_Font.cpp index 22836c842..d449925bb 100644 --- a/src/modules/graphics/opengl/wrap_Font.cpp +++ b/src/modules/graphics/opengl/wrap_Font.cpp @@ -184,7 +184,7 @@ int w_Font_setFallbacks(lua_State *L) return 0; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Font_functions[] = { { "getHeight", w_Font_getHeight }, { "getWidth", w_Font_getWidth }, @@ -203,7 +203,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_font(lua_State *L) { - return luax_register_type(L, GRAPHICS_FONT_ID, functions); + return luax_register_type(L, GRAPHICS_FONT_ID, "Font", w_Font_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_Font.h b/src/modules/graphics/opengl/wrap_Font.h index 172cc90ce..048960fe2 100644 --- a/src/modules/graphics/opengl/wrap_Font.h +++ b/src/modules/graphics/opengl/wrap_Font.h @@ -33,18 +33,6 @@ namespace opengl { Font *luax_checkfont(lua_State *L, int idx); -int w_Font_getHeight(lua_State *L); -int w_Font_getWidth(lua_State *L); -int w_Font_getWrap(lua_State *L); -int w_Font_setLineHeight(lua_State *L); -int w_Font_getLineHeight(lua_State *L); -int w_Font_setFilter(lua_State *L); -int w_Font_getFilter(lua_State *L); -int w_Font_getAscent(lua_State *L); -int w_Font_getDescent(lua_State *L); -int w_Font_getBaseline(lua_State *L); -int w_Font_hasGlyphs(lua_State *L); -int w_Font_setFallbacks(lua_State *L); extern "C" int luaopen_font(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index ac81e0486..3b7d331f6 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -1946,9 +1946,16 @@ static const luaL_Reg functions[] = { 0, 0 } }; +static int luaopen_drawable(lua_State *L) +{ + return luax_register_type(L, GRAPHICS_DRAWABLE_ID, "Drawable", nullptr); +} + // Types for this module. static const lua_CFunction types[] = { + luaopen_drawable, + luaopen_texture, luaopen_font, luaopen_image, luaopen_quad, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index c6e802ca0..a725c6316 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -41,86 +41,6 @@ namespace graphics namespace opengl { -int w_reset(lua_State *L); -int w_clear(lua_State *L); -int w_discard(lua_State *L); -int w_present(lua_State *L); -int w_isCreated(lua_State *L); -int w_isActive(lua_State *L); -int w_isGammaCorrect(lua_State *L); -int w_getWidth(lua_State *L); -int w_getHeight(lua_State *L); -int w_getDimensions(lua_State *L); -int w_setScissor(lua_State *L); -int w_intersectScissor(lua_State *L); -int w_getScissor(lua_State *L); -int w_stencil(lua_State *L); -int w_setStencilTest(lua_State *L); -int w_getStencilTest(lua_State *L); -int w_newImage(lua_State *L); -int w_newQuad(lua_State *L); -int w_newFont(lua_State *L); -int w_newImageFont(lua_State *L); -int w_newSpriteBatch(lua_State *L); -int w_newParticleSystem(lua_State *L); -int w_newCanvas(lua_State *L); -int w_newShader(lua_State *L); -int w_newMesh(lua_State *L); -int w_newText(lua_State *L); -int w_setColor(lua_State *L); -int w_getColor(lua_State *L); -int w_setBackgroundColor(lua_State *L); -int w_getBackgroundColor(lua_State *L); -int w_setNewFont(lua_State *L); -int w_setFont(lua_State *L); -int w_getFont(lua_State *L); -int w_setColorMask(lua_State *L); -int w_getColorMask(lua_State *L); -int w_setBlendMode(lua_State *L); -int w_getBlendMode(lua_State *L); -int w_setDefaultFilter(lua_State *L); -int w_getDefaultFilter(lua_State *L); -int w_setDefaultMipmapFilter(lua_State *L); -int w_getDefaultMipmapFilter(lua_State *L); -int w_setLineWidth(lua_State *L); -int w_setLineStyle(lua_State *L); -int w_setLineJoin(lua_State *L); -int w_getLineWidth(lua_State *L); -int w_getLineStyle(lua_State *L); -int w_getLineJoin(lua_State *L); -int w_setPointSize(lua_State *L); -int w_getPointSize(lua_State *L); -int w_setWireframe(lua_State *L); -int w_isWireframe(lua_State *L); -int w_newScreenshot(lua_State *L); -int w_setCanvas(lua_State *L); -int w_getCanvas(lua_State *L); -int w_setShader(lua_State *L); -int w_getShader(lua_State *L); -int w_setDefaultShaderCode(lua_State *L); -int w_getSupported(lua_State *L); -int w_getCanvasFormats(lua_State *L); -int w_getCompressedImageFormats(lua_State *L); -int w_getRendererInfo(lua_State *L); -int w_getSystemLimits(lua_State *L); -int w_getStats(lua_State *L); -int w_draw(lua_State *L); -int w_print(lua_State *L); -int w_printf(lua_State *L); -int w_points(lua_State *L); -int w_line(lua_State *L); -int w_rectangle(lua_State *L); -int w_circle(lua_State *L); -int w_ellipse(lua_State *L); -int w_arc(lua_State *L); -int w_polygon(lua_State *L); -int w_push(lua_State *L); -int w_pop(lua_State *L); -int w_rotate(lua_State *L); -int w_scale(lua_State *L); -int w_translate(lua_State *L); -int w_shear(lua_State *L); -int w_origin(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_Image.cpp b/src/modules/graphics/opengl/wrap_Image.cpp index 8a3a147fa..c14892b55 100644 --- a/src/modules/graphics/opengl/wrap_Image.cpp +++ b/src/modules/graphics/opengl/wrap_Image.cpp @@ -137,17 +137,8 @@ int w_Image_getFlags(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Image_functions[] = { - // From wrap_Texture. - { "getWidth", w_Texture_getWidth }, - { "getHeight", w_Texture_getHeight }, - { "getDimensions", w_Texture_getDimensions }, - { "setFilter", w_Texture_setFilter }, - { "getFilter", w_Texture_getFilter }, - { "setWrap", w_Texture_setWrap }, - { "getWrap", w_Texture_getWrap }, - { "setMipmapFilter", w_Image_setMipmapFilter }, { "getMipmapFilter", w_Image_getMipmapFilter }, { "isCompressed", w_Image_isCompressed }, @@ -159,7 +150,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_image(lua_State *L) { - return luax_register_type(L, GRAPHICS_IMAGE_ID, functions); + return luax_register_type(L, GRAPHICS_IMAGE_ID, "Image", w_Texture_functions, w_Image_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_Image.h b/src/modules/graphics/opengl/wrap_Image.h index edf8f7892..d58487980 100644 --- a/src/modules/graphics/opengl/wrap_Image.h +++ b/src/modules/graphics/opengl/wrap_Image.h @@ -34,12 +34,6 @@ namespace opengl { Image *luax_checkimage(lua_State *L, int idx); -int w_Image_setMipmapFilter(lua_State *L); -int w_Image_getMipmapFilter(lua_State *L); -int w_Image_isCompressed(lua_State *L); -int w_Image_refresh(lua_State *L); -int w_Image_getData(lua_State *L); -int w_Image_getFlags(lua_State *L); extern "C" int luaopen_image(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_Mesh.cpp b/src/modules/graphics/opengl/wrap_Mesh.cpp index b008b4078..d430c48b7 100644 --- a/src/modules/graphics/opengl/wrap_Mesh.cpp +++ b/src/modules/graphics/opengl/wrap_Mesh.cpp @@ -490,7 +490,7 @@ int w_Mesh_getDrawRange(lua_State *L) return 2; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Mesh_functions[] = { { "setVertices", w_Mesh_setVertices }, { "setVertex", w_Mesh_setVertex }, @@ -516,7 +516,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_mesh(lua_State *L) { - return luax_register_type(L, GRAPHICS_MESH_ID, functions); + return luax_register_type(L, GRAPHICS_MESH_ID, "Mesh", w_Mesh_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_Mesh.h b/src/modules/graphics/opengl/wrap_Mesh.h index fe8334a85..9a95bbd61 100644 --- a/src/modules/graphics/opengl/wrap_Mesh.h +++ b/src/modules/graphics/opengl/wrap_Mesh.h @@ -36,25 +36,6 @@ char *luax_writeAttributeData(lua_State *L, int startidx, Mesh::DataType type, i const char *luax_readAttributeData(lua_State *L, Mesh::DataType type, int components, const char *data); Mesh *luax_checkmesh(lua_State *L, int idx); -int w_Mesh_setVertices(lua_State *L); -int w_Mesh_setVertex(lua_State *L); -int w_Mesh_getVertex(lua_State *L); -int w_Mesh_setVertexAttribute(lua_State *L); -int w_Mesh_getVertexAttribute(lua_State *L); -int w_Mesh_getVertexCount(lua_State *L); -int w_Mesh_getVertexFormat(lua_State *L); -int w_Mesh_setAttributeEnabled(lua_State *L); -int w_Mesh_isAttributeEnabled(lua_State *L); -int w_Mesh_attachAttribute(lua_State *L); -int w_Mesh_flush(lua_State *L); -int w_Mesh_setVertexMap(lua_State *L); -int w_Mesh_getVertexMap(lua_State *L); -int w_Mesh_setTexture(lua_State *L); -int w_Mesh_getTexture(lua_State *L); -int w_Mesh_setDrawMode(lua_State *L); -int w_Mesh_getDrawMode(lua_State *L); -int w_Mesh_setDrawRange(lua_State *L); -int w_Mesh_getDrawRange(lua_State *L); extern "C" int luaopen_mesh(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp index 8c547b775..b1f1caa01 100644 --- a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp +++ b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp @@ -705,7 +705,7 @@ int w_ParticleSystem_update(lua_State *L) return 0; } -static const luaL_Reg functions[] = +static const luaL_Reg w_ParticleSystem_functions[] = { { "clone", w_ParticleSystem_clone }, { "setTexture", w_ParticleSystem_setTexture }, @@ -772,7 +772,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_particlesystem(lua_State *L) { - return luax_register_type(L, GRAPHICS_PARTICLE_SYSTEM_ID, functions); + return luax_register_type(L, GRAPHICS_PARTICLE_SYSTEM_ID, "ParticleSystem", w_ParticleSystem_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_ParticleSystem.h b/src/modules/graphics/opengl/wrap_ParticleSystem.h index ff7b9091d..fc25ad3e7 100644 --- a/src/modules/graphics/opengl/wrap_ParticleSystem.h +++ b/src/modules/graphics/opengl/wrap_ParticleSystem.h @@ -33,66 +33,6 @@ namespace opengl { ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx); -int w_ParticleSystem_clone(lua_State *L); -int w_ParticleSystem_setTexture(lua_State *L); -int w_ParticleSystem_getTexture(lua_State *L); -int w_ParticleSystem_setBufferSize(lua_State *L); -int w_ParticleSystem_getBufferSize(lua_State *L); -int w_ParticleSystem_setInsertMode(lua_State *L); -int w_ParticleSystem_getInsertMode(lua_State *L); -int w_ParticleSystem_setEmissionRate(lua_State *L); -int w_ParticleSystem_getEmissionRate(lua_State *L); -int w_ParticleSystem_setEmitterLifetime(lua_State *L); -int w_ParticleSystem_getEmitterLifetime(lua_State *L); -int w_ParticleSystem_setParticleLifetime(lua_State *L); -int w_ParticleSystem_getParticleLifetime(lua_State *L); -int w_ParticleSystem_setPosition(lua_State *L); -int w_ParticleSystem_getPosition(lua_State *L); -int w_ParticleSystem_moveTo(lua_State *L); -int w_ParticleSystem_setAreaSpread(lua_State *L); -int w_ParticleSystem_getAreaSpread(lua_State *L); -int w_ParticleSystem_setDirection(lua_State *L); -int w_ParticleSystem_getDirection(lua_State *L); -int w_ParticleSystem_setSpread(lua_State *L); -int w_ParticleSystem_getSpread(lua_State *L); -int w_ParticleSystem_setSpeed(lua_State *L); -int w_ParticleSystem_getSpeed(lua_State *L); -int w_ParticleSystem_setLinearAcceleration(lua_State *L); -int w_ParticleSystem_getLinearAcceleration(lua_State *L); -int w_ParticleSystem_setRadialAcceleration(lua_State *L); -int w_ParticleSystem_getRadialAcceleration(lua_State *L); -int w_ParticleSystem_setTangentialAcceleration(lua_State *L); -int w_ParticleSystem_getTangentialAcceleration(lua_State *L); -int w_ParticleSystem_setLinearDamping(lua_State *L); -int w_ParticleSystem_getLinearDamping(lua_State *L); -int w_ParticleSystem_setSizes(lua_State *L); -int w_ParticleSystem_getSizes(lua_State *L); -int w_ParticleSystem_setSizeVariation(lua_State *L); -int w_ParticleSystem_getSizeVariation(lua_State *L); -int w_ParticleSystem_setRotation(lua_State *L); -int w_ParticleSystem_getRotation(lua_State *L); -int w_ParticleSystem_setSpin(lua_State *L); -int w_ParticleSystem_getSpin(lua_State *L); -int w_ParticleSystem_setSpinVariation(lua_State *L); -int w_ParticleSystem_getSpinVariation(lua_State *L); -int w_ParticleSystem_setColors(lua_State *L); -int w_ParticleSystem_getColors(lua_State *L); -int w_ParticleSystem_setQuads(lua_State *L); -int w_ParticleSystem_getQuads(lua_State *L); -int w_ParticleSystem_setOffset(lua_State *L); -int w_ParticleSystem_getOffset(lua_State *L); -int w_ParticleSystem_setRelativeRotation(lua_State *L); -int w_ParticleSystem_hasRelativeRotation(lua_State *L); -int w_ParticleSystem_getCount(lua_State *L); -int w_ParticleSystem_start(lua_State *L); -int w_ParticleSystem_stop(lua_State *L); -int w_ParticleSystem_pause(lua_State *L); -int w_ParticleSystem_reset(lua_State *L); -int w_ParticleSystem_emit(lua_State *L); -int w_ParticleSystem_isActive(lua_State *L); -int w_ParticleSystem_isPaused(lua_State *L); -int w_ParticleSystem_isStopped(lua_State *L); -int w_ParticleSystem_update(lua_State *L); extern "C" int luaopen_particlesystem(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_Shader.cpp b/src/modules/graphics/opengl/wrap_Shader.cpp index ccd1d3345..21a33bf29 100644 --- a/src/modules/graphics/opengl/wrap_Shader.cpp +++ b/src/modules/graphics/opengl/wrap_Shader.cpp @@ -401,7 +401,7 @@ int w_Shader_getExternVariable(lua_State *L) return 3; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Shader_functions[] = { { "getWarnings", w_Shader_getWarnings }, { "sendInt", w_Shader_sendInt }, @@ -417,7 +417,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_shader(lua_State *L) { - return luax_register_type(L, GRAPHICS_SHADER_ID, functions); + return luax_register_type(L, GRAPHICS_SHADER_ID, "Shader", w_Shader_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_Shader.h b/src/modules/graphics/opengl/wrap_Shader.h index 8cc773835..ecd46ffdd 100644 --- a/src/modules/graphics/opengl/wrap_Shader.h +++ b/src/modules/graphics/opengl/wrap_Shader.h @@ -33,14 +33,6 @@ namespace opengl { Shader *luax_checkshader(lua_State *L, int idx); -int w_Shader_getWarnings(lua_State *L); -int w_Shader_sendInt(lua_State *L); -int w_Shader_sendFloat(lua_State *L); -int w_Shader_sendColor(lua_State *L); -int w_Shader_sendMatrix(lua_State *L); -int w_Shader_sendTexture(lua_State *L); -int w_Shader_send(lua_State *L); -int w_Shader_getExternVariable(lua_State *L); extern "C" int luaopen_shader(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index bde1cf428..3394e83ba 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -213,7 +213,7 @@ int w_SpriteBatch_attachAttribute(lua_State *L) return 0; } -static const luaL_Reg functions[] = +static const luaL_Reg w_SpriteBatch_functions[] = { { "add", w_SpriteBatch_add }, { "set", w_SpriteBatch_set }, @@ -232,7 +232,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_spritebatch(lua_State *L) { - return luax_register_type(L, GRAPHICS_SPRITE_BATCH_ID, functions); + return luax_register_type(L, GRAPHICS_SPRITE_BATCH_ID, "SpriteBatch", w_SpriteBatch_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.h b/src/modules/graphics/opengl/wrap_SpriteBatch.h index 3926b9ff3..dd36502a4 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.h +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.h @@ -32,19 +32,6 @@ namespace opengl { SpriteBatch *luax_checkspritebatch(lua_State *L, int idx); -int w_SpriteBatch_add(lua_State *L); -int w_SpriteBatch_set(lua_State *L); -int w_SpriteBatch_clear(lua_State *L); -int w_SpriteBatch_flush(lua_State *L); -int w_SpriteBatch_setTexture(lua_State *L); -int w_SpriteBatch_getTexture(lua_State *L); -int w_SpriteBatch_setColor(lua_State *L); -int w_SpriteBatch_getColor(lua_State *L); -int w_SpriteBatch_getCount(lua_State *L); -int w_SpriteBatch_setBufferSize(lua_State *L); -int w_SpriteBatch_getBufferSize(lua_State *L); -int w_SpriteBatch_attachAttribute(lua_State *L); - extern "C" int luaopen_spritebatch(lua_State *L); } // opengl diff --git a/src/modules/graphics/opengl/wrap_Text.cpp b/src/modules/graphics/opengl/wrap_Text.cpp index f69ce796e..ef7058f11 100644 --- a/src/modules/graphics/opengl/wrap_Text.cpp +++ b/src/modules/graphics/opengl/wrap_Text.cpp @@ -222,7 +222,7 @@ int w_Text_getHeight(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Text_functions[] = { { "set", w_Text_set }, { "setf", w_Text_setf }, @@ -238,7 +238,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_text(lua_State *L) { - return luax_register_type(L, GRAPHICS_TEXT_ID, functions); + return luax_register_type(L, GRAPHICS_TEXT_ID, "Text", w_Text_functions, nullptr); } } // opengl diff --git a/src/modules/graphics/opengl/wrap_Text.h b/src/modules/graphics/opengl/wrap_Text.h index 3f5fc433b..283fad76d 100644 --- a/src/modules/graphics/opengl/wrap_Text.h +++ b/src/modules/graphics/opengl/wrap_Text.h @@ -33,15 +33,6 @@ namespace opengl Text *luax_checktext(lua_State *L, int idx); void luax_checkcoloredstring(lua_State *L, int idx, std::vector &strings); -int w_Text_set(lua_State *L); -int w_Text_setf(lua_State *L); -int w_Text_add(lua_State *L); -int w_Text_addf(lua_State *L); -int w_Text_clear(lua_State *L); -int w_Text_setFont(lua_State *L); -int w_Text_getFont(lua_State *L); -int w_Text_getWidth(lua_State *L); -int w_Text_getHeight(lua_State *L); extern "C" int luaopen_text(lua_State *L); } // opengl diff --git a/src/modules/graphics/wrap_Quad.cpp b/src/modules/graphics/wrap_Quad.cpp index 095d03d78..e6525ac53 100644 --- a/src/modules/graphics/wrap_Quad.cpp +++ b/src/modules/graphics/wrap_Quad.cpp @@ -64,7 +64,7 @@ int w_Quad_getViewport(lua_State *L) return 4; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Quad_functions[] = { { "setViewport", w_Quad_setViewport }, { "getViewport", w_Quad_getViewport }, @@ -73,7 +73,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_quad(lua_State *L) { - return luax_register_type(L, GRAPHICS_QUAD_ID, functions); + return luax_register_type(L, GRAPHICS_QUAD_ID, "Quad", w_Quad_functions, nullptr); } } // graphics diff --git a/src/modules/graphics/wrap_Quad.h b/src/modules/graphics/wrap_Quad.h index 5cc6f9963..5ba4f3611 100644 --- a/src/modules/graphics/wrap_Quad.h +++ b/src/modules/graphics/wrap_Quad.h @@ -31,8 +31,6 @@ namespace graphics { Quad *luax_checkquad(lua_State *L, int idx); -int w_Quad_setViewport(lua_State *L); -int w_Quad_getViewport(lua_State *L); extern "C" int luaopen_quad(lua_State *L); } // graphics diff --git a/src/modules/graphics/wrap_Texture.cpp b/src/modules/graphics/wrap_Texture.cpp index a6a0e9543..bcd6107fb 100644 --- a/src/modules/graphics/wrap_Texture.cpp +++ b/src/modules/graphics/wrap_Texture.cpp @@ -125,5 +125,22 @@ int w_Texture_getWrap(lua_State *L) return 2; } +const luaL_Reg w_Texture_functions[] = +{ + { "getWidth", w_Texture_getWidth }, + { "getHeight", w_Texture_getHeight }, + { "getDimensions", w_Texture_getDimensions }, + { "setFilter", w_Texture_setFilter }, + { "getFilter", w_Texture_getFilter }, + { "setWrap", w_Texture_setWrap }, + { "getWrap", w_Texture_getWrap }, + { 0, 0 } +}; + +extern "C" int luaopen_texture(lua_State *L) +{ + return luax_register_type(L, GRAPHICS_TEXTURE_ID, "Texture", w_Texture_functions, nullptr); +} + } // graphics } // love diff --git a/src/modules/graphics/wrap_Texture.h b/src/modules/graphics/wrap_Texture.h index dd75da6ad..eea260254 100644 --- a/src/modules/graphics/wrap_Texture.h +++ b/src/modules/graphics/wrap_Texture.h @@ -30,13 +30,9 @@ namespace graphics { Texture *luax_checktexture(lua_State *L, int idx); -int w_Texture_getWidth(lua_State *L); -int w_Texture_getHeight(lua_State *L); -int w_Texture_getDimensions(lua_State *L); -int w_Texture_setFilter(lua_State *L); -int w_Texture_getFilter(lua_State *L); -int w_Texture_setWrap(lua_State *L); -int w_Texture_getWrap(lua_State *L); +extern "C" int luaopen_texture(lua_State *L); + +extern const luaL_Reg w_Texture_functions[]; } // graphics } // love diff --git a/src/modules/image/magpie/Image.cpp b/src/modules/image/magpie/Image.cpp index 575f04b92..399a5d987 100644 --- a/src/modules/image/magpie/Image.cpp +++ b/src/modules/image/magpie/Image.cpp @@ -41,14 +41,18 @@ namespace magpie Image::Image() { - formatHandlers.push_back(new PNGHandler); - formatHandlers.push_back(new STBHandler); + formatHandlers = { + new PNGHandler, + new STBHandler, + }; - compressedFormatHandlers.push_back(new DDSHandler); - compressedFormatHandlers.push_back(new PVRHandler); - compressedFormatHandlers.push_back(new KTXHandler); - compressedFormatHandlers.push_back(new PKMHandler); - compressedFormatHandlers.push_back(new ASTCHandler); + compressedFormatHandlers = { + new DDSHandler, + new PVRHandler, + new KTXHandler, + new PKMHandler, + new ASTCHandler, + }; } Image::~Image() diff --git a/src/modules/image/wrap_CompressedImageData.cpp b/src/modules/image/wrap_CompressedImageData.cpp index 5c2375ed3..a1ad8cd44 100644 --- a/src/modules/image/wrap_CompressedImageData.cpp +++ b/src/modules/image/wrap_CompressedImageData.cpp @@ -94,13 +94,8 @@ int w_CompressedImageData_getFormat(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_CompressedImageData_functions[] = { - // Data - { "getString", w_Data_getString }, - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { "getWidth", w_CompressedImageData_getWidth }, { "getHeight", w_CompressedImageData_getHeight }, { "getDimensions", w_CompressedImageData_getDimensions }, @@ -111,7 +106,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_compressedimagedata(lua_State *L) { - return luax_register_type(L, IMAGE_COMPRESSED_IMAGE_DATA_ID, functions); + return luax_register_type(L, IMAGE_COMPRESSED_IMAGE_DATA_ID, "CompressedImageData", w_Data_functions, w_CompressedImageData_functions, nullptr); } } // image diff --git a/src/modules/image/wrap_CompressedImageData.h b/src/modules/image/wrap_CompressedImageData.h index c56758121..2b7625036 100644 --- a/src/modules/image/wrap_CompressedImageData.h +++ b/src/modules/image/wrap_CompressedImageData.h @@ -31,11 +31,6 @@ namespace image { CompressedImageData *luax_checkcompressedimagedata(lua_State *L, int idx); -int w_CompressedImageData_getWidth(lua_State *L); -int w_CompressedImageData_getHeight(lua_State *L); -int w_CompressedImageData_getDimensions(lua_State *L); -int w_CompressedImageData_getMipmapCount(lua_State *L); -int w_CompressedImageData_getFormat(lua_State *L); extern "C" int luaopen_compressedimagedata(lua_State *L); } // image diff --git a/src/modules/image/wrap_Image.h b/src/modules/image/wrap_Image.h index 5b910a993..0a473cce7 100644 --- a/src/modules/image/wrap_Image.h +++ b/src/modules/image/wrap_Image.h @@ -31,9 +31,6 @@ namespace love namespace image { -int w_newImageData(lua_State *L); -int w_newCompressedData(lua_State *L); -int w_isCompressed(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_image(lua_State *L); } // image diff --git a/src/modules/image/wrap_ImageData.cpp b/src/modules/image/wrap_ImageData.cpp index 021287907..84f0a161d 100644 --- a/src/modules/image/wrap_ImageData.cpp +++ b/src/modules/image/wrap_ImageData.cpp @@ -279,7 +279,7 @@ struct FFI_ImageData static FFI_ImageData ffifuncs = { - [](Proxy *p) -> void // lockMutex + [](Proxy *p) // lockMutex { // We don't do any type-checking for the Proxy here since these functions // are always called from code which has already done type checking. @@ -287,20 +287,15 @@ static FFI_ImageData ffifuncs = i->getMutex()->lock(); }, - [](Proxy *p) -> void // unlockMutex + [](Proxy *p) // unlockMutex { ImageData *i = (ImageData *) p->object; i->getMutex()->unlock(); } }; -static const luaL_Reg functions[] = +static const luaL_Reg w_ImageData_functions[] = { - // Data - { "getString", w_Data_getString }, - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { "getWidth", w_ImageData_getWidth }, { "getHeight", w_ImageData_getHeight }, { "getDimensions", w_ImageData_getDimensions }, @@ -318,23 +313,23 @@ static const luaL_Reg functions[] = extern "C" int luaopen_imagedata(lua_State *L) { - // The last argument pushes the type's metatable onto the stack. - int ret = luax_register_type(L, IMAGE_IMAGE_DATA_ID, functions, true); + int ret = luax_register_type(L, IMAGE_IMAGE_DATA_ID, "ImageData", w_Data_functions, w_ImageData_functions, nullptr); + + luax_gettypemetatable(L, IMAGE_IMAGE_DATA_ID); // Load and execute ImageData.lua, sending the metatable and the ffi // functions struct pointer as arguments. - if (ret > 0) + if (lua_istable(L, -1)) { luaL_loadbuffer(L, imagedata_lua, sizeof(imagedata_lua), "ImageData.lua"); lua_pushvalue(L, -2); lua_pushlightuserdata(L, &ffifuncs); lua_call(L, 2, 0); - - // Pop the metatable. - lua_pop(L, 1); - ret--; } + // Pop the metatable. + lua_pop(L, 1); + return ret; } diff --git a/src/modules/image/wrap_ImageData.h b/src/modules/image/wrap_ImageData.h index a3865b668..94584dedb 100644 --- a/src/modules/image/wrap_ImageData.h +++ b/src/modules/image/wrap_ImageData.h @@ -31,14 +31,6 @@ namespace image { ImageData *luax_checkimagedata(lua_State *L, int idx); -int w_ImageData_getWidth(lua_State *L); -int w_ImageData_getHeight(lua_State *L); -int w_ImageData_getDimensions(lua_State *L); -int w_ImageData_getPixel(lua_State *L); -int w_ImageData_setPixel(lua_State *L); -int w_ImageData_mapPixel(lua_State *L); -int w_ImageData_paste(lua_State *L); -int w_ImageData_encode(lua_State *L); extern "C" int luaopen_imagedata(lua_State *L); } // image diff --git a/src/modules/joystick/wrap_Joystick.cpp b/src/modules/joystick/wrap_Joystick.cpp index d6e0c87fa..e69607e80 100644 --- a/src/modules/joystick/wrap_Joystick.cpp +++ b/src/modules/joystick/wrap_Joystick.cpp @@ -224,7 +224,7 @@ int w_Joystick_getVibration(lua_State *L) } // List of functions to wrap. -static const luaL_Reg functions[] = +static const luaL_Reg w_Joystick_functions[] = { { "isConnected", w_Joystick_isConnected }, { "getName", w_Joystick_getName }, @@ -255,7 +255,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_joystick(lua_State *L) { - return luax_register_type(L, JOYSTICK_JOYSTICK_ID, functions); + return luax_register_type(L, JOYSTICK_JOYSTICK_ID, "Joystick", w_Joystick_functions, nullptr); } } // joystick diff --git a/src/modules/joystick/wrap_Joystick.h b/src/modules/joystick/wrap_Joystick.h index 824de6d57..60746c3be 100644 --- a/src/modules/joystick/wrap_Joystick.h +++ b/src/modules/joystick/wrap_Joystick.h @@ -32,23 +32,6 @@ namespace joystick { Joystick *luax_checkjoystick(lua_State *L, int idx); -int w_Joystick_isConnected(lua_State *L); -int w_Joystick_getName(lua_State *L); -int w_Joystick_getID(lua_State *L); -int w_Joystick_getGUID(lua_State *L); -int w_Joystick_getAxisCount(lua_State *L); -int w_Joystick_getButtonCount(lua_State *L); -int w_Joystick_getHatCount(lua_State *L); -int w_Joystick_getAxis(lua_State *L); -int w_Joystick_getAxes(lua_State *L); -int w_Joystick_getHat(lua_State *L); -int w_Joystick_isDown(lua_State *L); -int w_Joystick_isGamepad(lua_State *L); -int w_Joystick_getGamepadAxis(lua_State *L); -int w_Joystick_isGamepadDown(lua_State *L); -int w_Joystick_isVibrationSupported(lua_State *L); -int w_Joystick_setVibration(lua_State *L); -int w_Joystick_getVibration(lua_State *L); extern "C" int luaopen_joystick(lua_State *L); } // joystick diff --git a/src/modules/joystick/wrap_JoystickModule.h b/src/modules/joystick/wrap_JoystickModule.h index 3bbd97fd4..03c4ee9de 100644 --- a/src/modules/joystick/wrap_JoystickModule.h +++ b/src/modules/joystick/wrap_JoystickModule.h @@ -31,13 +31,8 @@ namespace love namespace joystick { -int w_getJoysticks(lua_State *L); int w_getIndex(lua_State *L); -int w_getJoystickCount(lua_State *L); -int w_setGamepadMapping(lua_State *L); int w_getGamepadMapping(lua_State *L); -int w_loadGamepadMappings(lua_State *L); -int w_saveGamepadMappings(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_joystick(lua_State *L); } // joystick diff --git a/src/modules/keyboard/wrap_Keyboard.h b/src/modules/keyboard/wrap_Keyboard.h index 30f47117e..e99c42a4f 100644 --- a/src/modules/keyboard/wrap_Keyboard.h +++ b/src/modules/keyboard/wrap_Keyboard.h @@ -30,15 +30,6 @@ namespace love namespace keyboard { -int w_setKeyRepeat(lua_State *L); -int w_hasKeyRepeat(lua_State *L); -int w_isDown(lua_State *L); -int w_isScancodeDown(lua_State *L); -int w_getKeyFromScancode(lua_State *L); -int w_getScancodeFromKey(lua_State *L); -int w_setTextInput(lua_State *L); -int w_hasTextInput(lua_State *L); -int w_hasScreenKeyboard(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_keyboard(lua_State *L); } // keyboard diff --git a/src/modules/love/love.cpp b/src/modules/love/love.cpp index 25f21d66a..96f02bd9f 100644 --- a/src/modules/love/love.cpp +++ b/src/modules/love/love.cpp @@ -22,6 +22,7 @@ #include "common/config.h" #include "common/version.h" #include "common/runtime.h" +#include "common/wrap_Data.h" #include "love.h" @@ -319,6 +320,9 @@ int luaopen_love(lua_State *L) for (int i = 0; modules[i].name != nullptr; i++) love::luax_preload(L, modules[i].func, modules[i].name); + // Load "common" types. + love::w_Data_open(L); + #ifdef LOVE_ENABLE_LUASOCKET love::luasocket::__open(L); #endif diff --git a/src/modules/math/wrap_BezierCurve.cpp b/src/modules/math/wrap_BezierCurve.cpp index 76edfd419..d2f88a5d9 100644 --- a/src/modules/math/wrap_BezierCurve.cpp +++ b/src/modules/math/wrap_BezierCurve.cpp @@ -213,7 +213,7 @@ int w_BezierCurve_renderSegment(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_BezierCurve_functions[] = { {"getDegree", w_BezierCurve_getDegree}, {"getDerivative", w_BezierCurve_getDerivative}, @@ -234,7 +234,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_beziercurve(lua_State *L) { - return luax_register_type(L, MATH_BEZIER_CURVE_ID, functions); + return luax_register_type(L, MATH_BEZIER_CURVE_ID, "BezierCurve", w_BezierCurve_functions, nullptr); } } // math diff --git a/src/modules/math/wrap_BezierCurve.h b/src/modules/math/wrap_BezierCurve.h index e5aae3dae..8b2ba6f46 100644 --- a/src/modules/math/wrap_BezierCurve.h +++ b/src/modules/math/wrap_BezierCurve.h @@ -31,20 +31,6 @@ namespace math { BezierCurve *luax_checkbeziercurve(lua_State *L, int idx); -int w_BezierCurve_getDegree(lua_State *L); -int w_BezierCurve_getDerivative(lua_State *L); -int w_BezierCurve_getControlPoint(lua_State *L); -int w_BezierCurve_setControlPoint(lua_State *L); -int w_BezierCurve_insertControlPoint(lua_State *L); -int w_BezierCurve_removeControlPoint(lua_State *L); -int w_BezierCurve_getControlPointCount(lua_State *L); -int w_BezierCurve_translate(lua_State *L); -int w_BezierCurve_rotate(lua_State *L); -int w_BezierCurve_scale(lua_State *L); -int w_BezierCurve_evaluate(lua_State *L); -int w_BezierCurve_getSegment(lua_State *L); -int w_BezierCurve_render(lua_State *L); -int w_BezierCurve_renderSegment(lua_State *L); extern "C" int luaopen_beziercurve(lua_State *L); } // math diff --git a/src/modules/math/wrap_CompressedData.cpp b/src/modules/math/wrap_CompressedData.cpp index e9868d8e5..e60d7316e 100644 --- a/src/modules/math/wrap_CompressedData.cpp +++ b/src/modules/math/wrap_CompressedData.cpp @@ -44,13 +44,8 @@ int w_CompressedData_getFormat(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_CompressedData_functions[] = { - // Data - { "getString", w_Data_getString }, - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { "getFormat", w_CompressedData_getFormat }, { 0, 0 }, }; @@ -58,7 +53,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_compresseddata(lua_State *L) { - return luax_register_type(L, MATH_COMPRESSED_DATA_ID, functions); + return luax_register_type(L, MATH_COMPRESSED_DATA_ID, "CompressedData", w_Data_functions, w_CompressedData_functions, nullptr); } } // math diff --git a/src/modules/math/wrap_CompressedData.h b/src/modules/math/wrap_CompressedData.h index 00dd41bb7..b28402744 100644 --- a/src/modules/math/wrap_CompressedData.h +++ b/src/modules/math/wrap_CompressedData.h @@ -31,7 +31,6 @@ namespace math { CompressedData *luax_checkcompresseddata(lua_State *L, int idx); -int w_CompressedData_getFormat(lua_State *L); extern "C" int luaopen_compresseddata(lua_State *L); } // math diff --git a/src/modules/math/wrap_Math.h b/src/modules/math/wrap_Math.h index ccbb8aeec..b8a41155c 100644 --- a/src/modules/math/wrap_Math.h +++ b/src/modules/math/wrap_Math.h @@ -30,21 +30,6 @@ namespace love namespace math { -int w_random(lua_State *L); -int w_randomNormal(lua_State *L); -int w_setRandomSeed(lua_State *L); -int w_getRandomSeed(lua_State *L); -int w_setRandomState(lua_State *L); -int w_getRandomState(lua_State *L); -int w_newRandomGenerator(lua_State *L); -int w_newBezierCurve(lua_State *L); -int w_triangulate(lua_State *L); -int w_isConvex(lua_State *L); -int w_gammaToLinear(lua_State *L); -int w_linearToGamma(lua_State *L); -int w_noise(lua_State *L); -int w_compress(lua_State *L); -int w_decompress(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_math(lua_State *L); } // random diff --git a/src/modules/math/wrap_RandomGenerator.cpp b/src/modules/math/wrap_RandomGenerator.cpp index 4923c07a2..14dbc315c 100644 --- a/src/modules/math/wrap_RandomGenerator.cpp +++ b/src/modules/math/wrap_RandomGenerator.cpp @@ -135,7 +135,7 @@ int w_RandomGenerator_getState(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_RandomGenerator_functions[] = { { "random", w_RandomGenerator_random }, { "randomNormal", w_RandomGenerator_randomNormal }, @@ -148,7 +148,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_randomgenerator(lua_State *L) { - return luax_register_type(L, MATH_RANDOM_GENERATOR_ID, functions); + return luax_register_type(L, MATH_RANDOM_GENERATOR_ID, "RandomGenerator", w_RandomGenerator_functions, nullptr); } } // math diff --git a/src/modules/math/wrap_RandomGenerator.h b/src/modules/math/wrap_RandomGenerator.h index 3f84825a8..efbe733b4 100644 --- a/src/modules/math/wrap_RandomGenerator.h +++ b/src/modules/math/wrap_RandomGenerator.h @@ -36,12 +36,6 @@ RandomGenerator::Seed luax_checkrandomseed(lua_State *L, int idx); int luax_getrandom(lua_State *L, int startidx, double r); RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx); -int w_RandomGenerator_random(lua_State *L); -int w_RandomGenerator_randomNormal(lua_State *L); -int w_RandomGenerator_setSeed(lua_State *L); -int w_RandomGenerator_getSeed(lua_State *L); -int w_RandomGenerator_setState(lua_State *L); -int w_RandomGenerator_getState(lua_State *L); extern "C" int luaopen_randomgenerator(lua_State *L); } // math diff --git a/src/modules/mouse/wrap_Cursor.cpp b/src/modules/mouse/wrap_Cursor.cpp index b1ea65626..851b7c696 100644 --- a/src/modules/mouse/wrap_Cursor.cpp +++ b/src/modules/mouse/wrap_Cursor.cpp @@ -53,7 +53,7 @@ int w_Cursor_getType(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Cursor_functions[] = { { "getType", w_Cursor_getType }, { 0, 0 }, @@ -61,7 +61,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_cursor(lua_State *L) { - return luax_register_type(L, MOUSE_CURSOR_ID, functions); + return luax_register_type(L, MOUSE_CURSOR_ID, "Cursor", w_Cursor_functions, nullptr); } } // mouse diff --git a/src/modules/mouse/wrap_Cursor.h b/src/modules/mouse/wrap_Cursor.h index f189dce79..2ae04d62c 100644 --- a/src/modules/mouse/wrap_Cursor.h +++ b/src/modules/mouse/wrap_Cursor.h @@ -31,7 +31,6 @@ namespace mouse { Cursor *luax_checkcursor(lua_State *L, int idx); -int w_Cursor_getType(lua_State *L); extern "C" int luaopen_cursor(lua_State *L); } // mouse diff --git a/src/modules/mouse/wrap_Mouse.h b/src/modules/mouse/wrap_Mouse.h index 4963494b3..dff93b031 100644 --- a/src/modules/mouse/wrap_Mouse.h +++ b/src/modules/mouse/wrap_Mouse.h @@ -30,24 +30,6 @@ namespace love namespace mouse { -int w_newCursor(lua_State *L); -int w_getSystemCursor(lua_State *L); -int w_setCursor(lua_State *L); -int w_getCursor(lua_State *L); -int w_hasCursor(lua_State *L); -int w_getX(lua_State *L); -int w_getY(lua_State *L); -int w_getPosition(lua_State *L); -int w_setX(lua_State *L); -int w_setY(lua_State *L); -int w_setPosition(lua_State *L); -int w_isDown(lua_State *L); -int w_setVisible(lua_State *L); -int w_isVisible(lua_State *L); -int w_setGrabbed(lua_State *L); -int w_isGrabbed(lua_State *L); -int w_setRelativeMode(lua_State *L); -int w_getRelativeMode(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_mouse(lua_State *L); } // mouse diff --git a/src/modules/physics/box2d/wrap_Body.cpp b/src/modules/physics/box2d/wrap_Body.cpp index edd8dfea5..6eb42ce22 100644 --- a/src/modules/physics/box2d/wrap_Body.cpp +++ b/src/modules/physics/box2d/wrap_Body.cpp @@ -585,7 +585,7 @@ int w_Body_getUserData(lua_State *L) return t->getUserData(L); } -static const luaL_Reg functions[] = +static const luaL_Reg w_Body_functions[] = { { "getX", w_Body_getX }, { "getY", w_Body_getY }, @@ -650,7 +650,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_body(lua_State *L) { - return luax_register_type(L, PHYSICS_BODY_ID, functions); + return luax_register_type(L, PHYSICS_BODY_ID, "Body", w_Body_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_Body.h b/src/modules/physics/box2d/wrap_Body.h index fb28a3dc9..81b7e4ca5 100644 --- a/src/modules/physics/box2d/wrap_Body.h +++ b/src/modules/physics/box2d/wrap_Body.h @@ -33,64 +33,6 @@ namespace box2d { Body *luax_checkbody(lua_State *L, int idx); -int w_Body_getX(lua_State *L); -int w_Body_getY(lua_State *L); -int w_Body_getAngle(lua_State *L); -int w_Body_getPosition(lua_State *L); -int w_Body_getLinearVelocity(lua_State *L); -int w_Body_getWorldCenter(lua_State *L); -int w_Body_getLocalCenter(lua_State *L); -int w_Body_getAngularVelocity(lua_State *L); -int w_Body_getMass(lua_State *L); -int w_Body_getInertia(lua_State *L); -int w_Body_getMassData(lua_State *L); -int w_Body_getAngularDamping(lua_State *L); -int w_Body_getLinearDamping(lua_State *L); -int w_Body_getGravityScale(lua_State *L); -int w_Body_getType(lua_State *L); -int w_Body_applyLinearImpulse(lua_State *L); -int w_Body_applyAngularImpulse(lua_State *L); -int w_Body_applyTorque(lua_State *L); -int w_Body_applyForce(lua_State *L); -int w_Body_setX(lua_State *L); -int w_Body_setY(lua_State *L); -int w_Body_setLinearVelocity(lua_State *L); -int w_Body_setAngle(lua_State *L); -int w_Body_setAngularVelocity(lua_State *L); -int w_Body_setPosition(lua_State *L); -int w_Body_resetMassData(lua_State *L); -int w_Body_setMassData(lua_State *L); -int w_Body_setMass(lua_State *L); -int w_Body_setInertia(lua_State *L); -int w_Body_setAngularDamping(lua_State *L); -int w_Body_setLinearDamping(lua_State *L); -int w_Body_setGravityScale(lua_State *L); -int w_Body_setType(lua_State *L); -int w_Body_getWorldPoint(lua_State *L); -int w_Body_getWorldVector(lua_State *L); -int w_Body_getWorldPoints(lua_State *L); -int w_Body_getLocalPoint(lua_State *L); -int w_Body_getLocalVector(lua_State *L); -int w_Body_getLinearVelocityFromWorldPoint(lua_State *L); -int w_Body_getLinearVelocityFromLocalPoint(lua_State *L); -int w_Body_isBullet(lua_State *L); -int w_Body_setBullet(lua_State *L); -int w_Body_isActive(lua_State *L); -int w_Body_isAwake(lua_State *L); -int w_Body_setSleepingAllowed(lua_State *L); -int w_Body_isSleepingAllowed(lua_State *L); -int w_Body_setActive(lua_State *L); -int w_Body_setAwake(lua_State *L); -int w_Body_setFixedRotation(lua_State *L); -int w_Body_isFixedRotation(lua_State *L); -int w_Body_getWorld(lua_State *L); -int w_Body_getFixtureList(lua_State *L); -int w_Body_getJointList(lua_State *L); -int w_Body_getContactList(lua_State *L); -int w_Body_destroy(lua_State *L); -int w_Body_isDestroyed(lua_State *L); -int w_Body_setUserData(lua_State *L); -int w_Body_getUserData(lua_State *L); extern "C" int luaopen_body(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_ChainShape.cpp b/src/modules/physics/box2d/wrap_ChainShape.cpp index 952c4b11d..38e17fa85 100644 --- a/src/modules/physics/box2d/wrap_ChainShape.cpp +++ b/src/modules/physics/box2d/wrap_ChainShape.cpp @@ -98,7 +98,7 @@ int w_ChainShape_getPoints(lua_State *L) return count*2; } -static const luaL_Reg functions[] = +static const luaL_Reg w_ChainShape_functions[] = { { "setNextVertex", w_ChainShape_setNextVertex }, { "setPreviousVertex", w_ChainShape_setPreviousVertex }, @@ -106,20 +106,12 @@ static const luaL_Reg functions[] = { "getVertexCount", w_ChainShape_getVertexCount }, { "getPoint", w_ChainShape_getPoint }, { "getPoints", w_ChainShape_getPoints }, - // From Shape. - { "getType", w_Shape_getType }, - { "getRadius", w_Shape_getRadius }, - { "getChildCount", w_Shape_getChildCount }, - { "testPoint", w_Shape_testPoint }, - { "rayCast", w_Shape_rayCast }, - { "computeAABB", w_Shape_computeAABB }, - { "computeMass", w_Shape_computeMass }, { 0, 0 } }; extern "C" int luaopen_chainshape(lua_State *L) { - return luax_register_type(L, PHYSICS_CHAIN_SHAPE_ID, functions); + return luax_register_type(L, PHYSICS_CHAIN_SHAPE_ID, "ChainShape", w_Shape_functions, w_ChainShape_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_ChainShape.h b/src/modules/physics/box2d/wrap_ChainShape.h index 312730fcf..30e50e51e 100644 --- a/src/modules/physics/box2d/wrap_ChainShape.h +++ b/src/modules/physics/box2d/wrap_ChainShape.h @@ -34,14 +34,6 @@ namespace box2d { ChainShape *luax_checkchainshape(lua_State *L, int idx); - -int w_ChainShape_setNextVertex(lua_State *L); -int w_ChainShape_setPreviousVertex(lua_State *L); -int w_ChainShape_getChildEdge(lua_State *L); -int w_ChainShape_getVertexCount(lua_State *L); -int w_ChainShape_getPoint(lua_State *L); -int w_ChainShape_getPoints(lua_State *L); - extern "C" int luaopen_chainshape(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_CircleShape.cpp b/src/modules/physics/box2d/wrap_CircleShape.cpp index b3a027895..8e467eaa7 100644 --- a/src/modules/physics/box2d/wrap_CircleShape.cpp +++ b/src/modules/physics/box2d/wrap_CircleShape.cpp @@ -64,26 +64,18 @@ int w_CircleShape_setPoint(lua_State *L) return 0; } -static const luaL_Reg functions[] = +static const luaL_Reg w_CircleShape_functions[] = { { "getRadius", w_CircleShape_getRadius }, { "setRadius", w_CircleShape_setRadius }, { "getPoint", w_CircleShape_getPoint }, { "setPoint", w_CircleShape_setPoint }, - // From Shape. - { "getType", w_Shape_getType }, - { "getRadius", w_Shape_getRadius }, - { "getChildCount", w_Shape_getChildCount }, - { "testPoint", w_Shape_testPoint }, - { "rayCast", w_Shape_rayCast }, - { "computeAABB", w_Shape_computeAABB }, - { "computeMass", w_Shape_computeMass }, { 0, 0 } }; extern "C" int luaopen_circleshape(lua_State *L) { - return luax_register_type(L, PHYSICS_CIRCLE_SHAPE_ID, functions); + return luax_register_type(L, PHYSICS_CIRCLE_SHAPE_ID, "CircleShape", w_Shape_functions, w_CircleShape_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_CircleShape.h b/src/modules/physics/box2d/wrap_CircleShape.h index 61817332d..19cc87820 100644 --- a/src/modules/physics/box2d/wrap_CircleShape.h +++ b/src/modules/physics/box2d/wrap_CircleShape.h @@ -34,10 +34,6 @@ namespace box2d { CircleShape *luax_checkcircleshape(lua_State *L, int idx); -int w_CircleShape_getRadius(lua_State *L); -int w_CircleShape_setRadius(lua_State *L); -int w_CircleShape_getPoint(lua_State *L); -int w_CircleShape_setPoint(lua_State *L); extern "C" int luaopen_circleshape(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_Contact.cpp b/src/modules/physics/box2d/wrap_Contact.cpp index 4a3a7cef6..eb7e037c9 100644 --- a/src/modules/physics/box2d/wrap_Contact.cpp +++ b/src/modules/physics/box2d/wrap_Contact.cpp @@ -158,30 +158,30 @@ int w_Contact_isDestroyed(lua_State *L) return 1; } +static const luaL_Reg w_Contact_functions[] = +{ + { "getPositions", w_Contact_getPositions }, + { "getNormal", w_Contact_getNormal }, + { "getFriction", w_Contact_getFriction }, + { "getRestitution", w_Contact_getRestitution }, + { "isEnabled", w_Contact_isEnabled }, + { "isTouching", w_Contact_isTouching }, + { "setFriction", w_Contact_setFriction }, + { "setRestitution", w_Contact_setRestitution }, + { "setEnabled", w_Contact_setEnabled }, + { "resetFriction", w_Contact_resetFriction }, + { "resetRestitution", w_Contact_resetRestitution }, + { "setTangentSpeed", w_Contact_setTangentSpeed }, + { "getTangentSpeed", w_Contact_getTangentSpeed }, + { "getChildren", w_Contact_getChildren }, + { "getFixtures", w_Contact_getFixtures }, + { "isDestroyed", w_Contact_isDestroyed }, + { 0, 0 } +}; + extern "C" int luaopen_contact(lua_State *L) { - static const luaL_Reg functions[] = - { - { "getPositions", w_Contact_getPositions }, - { "getNormal", w_Contact_getNormal }, - { "getFriction", w_Contact_getFriction }, - { "getRestitution", w_Contact_getRestitution }, - { "isEnabled", w_Contact_isEnabled }, - { "isTouching", w_Contact_isTouching }, - { "setFriction", w_Contact_setFriction }, - { "setRestitution", w_Contact_setRestitution }, - { "setEnabled", w_Contact_setEnabled }, - { "resetFriction", w_Contact_resetFriction }, - { "resetRestitution", w_Contact_resetRestitution }, - { "setTangentSpeed", w_Contact_setTangentSpeed }, - { "getTangentSpeed", w_Contact_getTangentSpeed }, - { "getChildren", w_Contact_getChildren }, - { "getFixtures", w_Contact_getFixtures }, - { "isDestroyed", w_Contact_isDestroyed }, - { 0, 0 } - }; - - return luax_register_type(L, PHYSICS_CONTACT_ID, functions); + return luax_register_type(L, PHYSICS_CONTACT_ID, "Contact", w_Contact_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_Contact.h b/src/modules/physics/box2d/wrap_Contact.h index 602d57bcc..906e001aa 100644 --- a/src/modules/physics/box2d/wrap_Contact.h +++ b/src/modules/physics/box2d/wrap_Contact.h @@ -33,22 +33,6 @@ namespace box2d { Contact *luax_checkcontact(lua_State *L, int idx); -int w_Contact_getPositions(lua_State *L); -int w_Contact_getNormal(lua_State *L); -int w_Contact_getFriction(lua_State *L); -int w_Contact_getRestitution(lua_State *L); -int w_Contact_isEnabled(lua_State *L); -int w_Contact_isTouching(lua_State *L); -int w_Contact_setFriction(lua_State *L); -int w_Contact_setRestitution(lua_State *L); -int w_Contact_setEnabled(lua_State *L); -int w_Contact_resetFriction(lua_State *L); -int w_Contact_resetRestitution(lua_State *L); -int w_Contact_setTangentSpeed(lua_State *L); -int w_Contact_getTangentSpeed(lua_State *L); -int w_Contact_getChildren(lua_State *L); -int w_Contact_getFixtures(lua_State *L); -int w_Contact_isDestroyed(lua_State *L); extern "C" int luaopen_contact(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_DistanceJoint.cpp b/src/modules/physics/box2d/wrap_DistanceJoint.cpp index 5f06cdfc6..3fd5a8920 100644 --- a/src/modules/physics/box2d/wrap_DistanceJoint.cpp +++ b/src/modules/physics/box2d/wrap_DistanceJoint.cpp @@ -80,7 +80,7 @@ int w_DistanceJoint_getDampingRatio(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_DistanceJoint_functions[] = { { "setLength", w_DistanceJoint_setLength }, { "getLength", w_DistanceJoint_getLength }, @@ -88,23 +88,12 @@ static const luaL_Reg functions[] = { "getFrequency", w_DistanceJoint_getFrequency }, { "setDampingRatio", w_DistanceJoint_setDampingRatio }, { "getDampingRatio", w_DistanceJoint_getDampingRatio }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_distancejoint(lua_State *L) { - return luax_register_type(L, PHYSICS_DISTANCE_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_DISTANCE_JOINT_ID, "DistanceJoint", w_Joint_functions, w_DistanceJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_DistanceJoint.h b/src/modules/physics/box2d/wrap_DistanceJoint.h index 5b107faab..f1abdbeb0 100644 --- a/src/modules/physics/box2d/wrap_DistanceJoint.h +++ b/src/modules/physics/box2d/wrap_DistanceJoint.h @@ -34,12 +34,6 @@ namespace box2d { DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx); -int w_DistanceJoint_setLength(lua_State *L); -int w_DistanceJoint_getLength(lua_State *L); -int w_DistanceJoint_setFrequency(lua_State *L); -int w_DistanceJoint_getFrequency(lua_State *L); -int w_DistanceJoint_setDampingRatio(lua_State *L); -int w_DistanceJoint_getDampingRatio(lua_State *L); extern "C" int luaopen_distancejoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_EdgeShape.cpp b/src/modules/physics/box2d/wrap_EdgeShape.cpp index 9caafbdcd..84c7fa1ca 100644 --- a/src/modules/physics/box2d/wrap_EdgeShape.cpp +++ b/src/modules/physics/box2d/wrap_EdgeShape.cpp @@ -39,23 +39,15 @@ int w_EdgeShape_getPoints(lua_State *L) return t->getPoints(L); } -static const luaL_Reg functions[] = +static const luaL_Reg w_EdgeShape_functions[] = { { "getPoints", w_EdgeShape_getPoints }, - // From Shape. - { "getType", w_Shape_getType }, - { "getRadius", w_Shape_getRadius }, - { "getChildCount", w_Shape_getChildCount }, - { "testPoint", w_Shape_testPoint }, - { "rayCast", w_Shape_rayCast }, - { "computeAABB", w_Shape_computeAABB }, - { "computeMass", w_Shape_computeMass }, { 0, 0 } }; extern "C" int luaopen_edgeshape(lua_State *L) { - return luax_register_type(L, PHYSICS_EDGE_SHAPE_ID, functions); + return luax_register_type(L, PHYSICS_EDGE_SHAPE_ID, "EdgeShape", w_Shape_functions, w_EdgeShape_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_EdgeShape.h b/src/modules/physics/box2d/wrap_EdgeShape.h index b77dd9bda..6a48b737b 100644 --- a/src/modules/physics/box2d/wrap_EdgeShape.h +++ b/src/modules/physics/box2d/wrap_EdgeShape.h @@ -34,7 +34,6 @@ namespace box2d { EdgeShape *luax_checkedgeshape(lua_State *L, int idx); -int w_EdgeShape_getPoints(lua_State *L); extern "C" int luaopen_edgeshape(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_Fixture.cpp b/src/modules/physics/box2d/wrap_Fixture.cpp index 1bd1b54eb..77965bab8 100644 --- a/src/modules/physics/box2d/wrap_Fixture.cpp +++ b/src/modules/physics/box2d/wrap_Fixture.cpp @@ -269,7 +269,7 @@ int w_Fixture_isDestroyed(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Fixture_functions[] = { { "getType", w_Fixture_getType }, { "setFriction", w_Fixture_setFriction }, @@ -303,7 +303,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_fixture(lua_State *L) { - return luax_register_type(L, PHYSICS_FIXTURE_ID, functions); + return luax_register_type(L, PHYSICS_FIXTURE_ID, "Fixture", w_Fixture_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_Fixture.h b/src/modules/physics/box2d/wrap_Fixture.h index 7c6f9a0fe..feb7703cf 100644 --- a/src/modules/physics/box2d/wrap_Fixture.h +++ b/src/modules/physics/box2d/wrap_Fixture.h @@ -34,33 +34,6 @@ namespace box2d { Fixture *luax_checkfixture(lua_State *L, int idx); -int w_Fixture_getType(lua_State *L); -int w_Fixture_setFriction(lua_State *L); -int w_Fixture_setRestitution(lua_State *L); -int w_Fixture_setDensity(lua_State *L); -int w_Fixture_setSensor(lua_State *L); -int w_Fixture_getFriction(lua_State *L); -int w_Fixture_getRestitution(lua_State *L); -int w_Fixture_getDensity(lua_State *L); -int w_Fixture_isSensor(lua_State *L); -int w_Fixture_getBody(lua_State *L); -int w_Fixture_getShape(lua_State *L); -int w_Fixture_testPoint(lua_State *L); -int w_Fixture_rayCast(lua_State *L); -int w_Fixture_setFilterData(lua_State *L); -int w_Fixture_getFilterData(lua_State *L); -int w_Fixture_setCategory(lua_State *L); -int w_Fixture_getCategory(lua_State *L); -int w_Fixture_setMask(lua_State *L); -int w_Fixture_getMask(lua_State *L); -int w_Fixture_setUserData(lua_State *L); -int w_Fixture_getUserData(lua_State *L); -int w_Fixture_getBoundingBox(lua_State *L); -int w_Fixture_getMassData(lua_State *L); -int w_Fixture_getGroupIndex(lua_State *L); -int w_Fixture_setGroupIndex(lua_State *L); -int w_Fixture_destroy(lua_State *L); -int w_Fixture_isDestroyed(lua_State *L); extern "C" int luaopen_fixture(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_FrictionJoint.cpp b/src/modules/physics/box2d/wrap_FrictionJoint.cpp index 44b007860..e04bf98de 100644 --- a/src/modules/physics/box2d/wrap_FrictionJoint.cpp +++ b/src/modules/physics/box2d/wrap_FrictionJoint.cpp @@ -66,29 +66,18 @@ int w_FrictionJoint_getMaxTorque(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_FrictionJoint_functions[] = { { "setMaxForce", w_FrictionJoint_setMaxForce }, { "getMaxForce", w_FrictionJoint_getMaxForce }, { "setMaxTorque", w_FrictionJoint_setMaxTorque }, { "getMaxTorque", w_FrictionJoint_getMaxTorque }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_frictionjoint(lua_State *L) { - return luax_register_type(L, PHYSICS_FRICTION_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_FRICTION_JOINT_ID, "FrictionJoint", w_Joint_functions, w_FrictionJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_FrictionJoint.h b/src/modules/physics/box2d/wrap_FrictionJoint.h index 3d8184f1f..f738d620b 100644 --- a/src/modules/physics/box2d/wrap_FrictionJoint.h +++ b/src/modules/physics/box2d/wrap_FrictionJoint.h @@ -34,10 +34,6 @@ namespace box2d { FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx); -int w_FrictionJoint_setMaxForce(lua_State *L); -int w_FrictionJoint_getMaxForce(lua_State *L); -int w_FrictionJoint_setMaxTorque(lua_State *L); -int w_FrictionJoint_getMaxTorque(lua_State *L); extern "C" int luaopen_frictionjoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_GearJoint.cpp b/src/modules/physics/box2d/wrap_GearJoint.cpp index 569be86cb..784c77ae2 100644 --- a/src/modules/physics/box2d/wrap_GearJoint.cpp +++ b/src/modules/physics/box2d/wrap_GearJoint.cpp @@ -67,28 +67,17 @@ int w_GearJoint_getJoints(lua_State *L) return 2; } -static const luaL_Reg functions[] = +static const luaL_Reg w_GearJoint_functions[] = { { "setRatio", w_GearJoint_setRatio }, { "getRatio", w_GearJoint_getRatio }, { "getJoints", w_GearJoint_getJoints }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_gearjoint(lua_State *L) { - return luax_register_type(L, PHYSICS_GEAR_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_GEAR_JOINT_ID, "GearJoint", w_Joint_functions, w_GearJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_GearJoint.h b/src/modules/physics/box2d/wrap_GearJoint.h index cf7ea97a3..a65a2fbab 100644 --- a/src/modules/physics/box2d/wrap_GearJoint.h +++ b/src/modules/physics/box2d/wrap_GearJoint.h @@ -34,9 +34,6 @@ namespace box2d { GearJoint *luax_checkgearjoint(lua_State *L, int idx); -int w_GearJoint_setRatio(lua_State *L); -int w_GearJoint_getRatio(lua_State *L); -int w_GearJoint_getJoints(lua_State *L); extern "C" int luaopen_gearjoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_Joint.cpp b/src/modules/physics/box2d/wrap_Joint.cpp index 249ac1bc2..47508cf52 100644 --- a/src/modules/physics/box2d/wrap_Joint.cpp +++ b/src/modules/physics/box2d/wrap_Joint.cpp @@ -154,7 +154,7 @@ int w_Joint_isDestroyed(lua_State *L) return 1; } -static const luaL_Reg functions[] = +const luaL_Reg w_Joint_functions[] = { { "getType", w_Joint_getType }, { "getBodies", w_Joint_getBodies }, @@ -171,7 +171,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_joint(lua_State *L) { - return luax_register_type(L, PHYSICS_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_JOINT_ID, "Joint", w_Joint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_Joint.h b/src/modules/physics/box2d/wrap_Joint.h index 4bdb44441..9f2bcb127 100644 --- a/src/modules/physics/box2d/wrap_Joint.h +++ b/src/modules/physics/box2d/wrap_Joint.h @@ -34,18 +34,10 @@ namespace box2d void luax_pushjoint(lua_State *L, Joint *j); Joint *luax_checkjoint(lua_State *L, int idx); -int w_Joint_getType(lua_State *L); -int w_Joint_getBodies(lua_State *L); -int w_Joint_getAnchors(lua_State *L); -int w_Joint_getReactionForce(lua_State *L); -int w_Joint_getReactionTorque(lua_State *L); -int w_Joint_getCollideConnected(lua_State *L); -int w_Joint_setUserData(lua_State *L); -int w_Joint_getUserData(lua_State *L); -int w_Joint_destroy(lua_State *L); -int w_Joint_isDestroyed(lua_State *L); extern "C" int luaopen_joint(lua_State *L); +extern const luaL_Reg w_Joint_functions[]; + } // box2d } // physics } // love diff --git a/src/modules/physics/box2d/wrap_MotorJoint.cpp b/src/modules/physics/box2d/wrap_MotorJoint.cpp index 40d60d217..1b85aa05d 100644 --- a/src/modules/physics/box2d/wrap_MotorJoint.cpp +++ b/src/modules/physics/box2d/wrap_MotorJoint.cpp @@ -110,7 +110,7 @@ int w_MotorJoint_getCorrectionFactor(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_MotorJoint_functions[] = { { "setLinearOffset", w_MotorJoint_setLinearOffset }, { "getLinearOffset", w_MotorJoint_getLinearOffset }, @@ -122,23 +122,12 @@ static const luaL_Reg functions[] = { "getMaxTorque", w_MotorJoint_getMaxTorque }, { "setCorrectionFactor", w_MotorJoint_setCorrectionFactor }, { "getCorrectionFactor", w_MotorJoint_getCorrectionFactor }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_motorjoint(lua_State *L) { - return luax_register_type(L, PHYSICS_MOTOR_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_MOTOR_JOINT_ID, "MotorJoint", w_Joint_functions, w_MotorJoint_functions, nullptr); } diff --git a/src/modules/physics/box2d/wrap_MotorJoint.h b/src/modules/physics/box2d/wrap_MotorJoint.h index c99df5572..2fdfe90a3 100644 --- a/src/modules/physics/box2d/wrap_MotorJoint.h +++ b/src/modules/physics/box2d/wrap_MotorJoint.h @@ -34,16 +34,6 @@ namespace box2d { MotorJoint *luax_checkmotorjoint(lua_State *L, int idx); -int w_MotorJoint_setLinearOffset(lua_State *L); -int w_MotorJoint_getLinearOffset(lua_State *L); -int w_MotorJoint_setAngularOffset(lua_State *L); -int w_MotorJoint_getAngularOffset(lua_State *L); -int w_MotorJoint_setMaxForce(lua_State *L); -int w_MotorJoint_getMaxForce(lua_State *L); -int w_MotorJoint_setMaxTorque(lua_State *L); -int w_MotorJoint_getMaxTorque(lua_State *L); -int w_MotorJoint_setCorrectionFactor(lua_State *L); -int w_MotorJoint_getCorrectionFactor(lua_State *L); extern "C" int luaopen_motorjoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_MouseJoint.cpp b/src/modules/physics/box2d/wrap_MouseJoint.cpp index 0e9338fc0..f28b15695 100644 --- a/src/modules/physics/box2d/wrap_MouseJoint.cpp +++ b/src/modules/physics/box2d/wrap_MouseJoint.cpp @@ -96,7 +96,7 @@ int w_MouseJoint_getDampingRatio(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_MouseJoint_functions[] = { { "setTarget", w_MouseJoint_setTarget }, { "getTarget", w_MouseJoint_getTarget }, @@ -106,23 +106,12 @@ static const luaL_Reg functions[] = { "getFrequency", w_MouseJoint_getFrequency }, { "setDampingRatio", w_MouseJoint_setDampingRatio }, { "getDampingRatio", w_MouseJoint_getDampingRatio }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_mousejoint(lua_State *L) { - return luax_register_type(L, PHYSICS_MOUSE_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_MOUSE_JOINT_ID, "MouseJoint", w_Joint_functions, w_MouseJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_MouseJoint.h b/src/modules/physics/box2d/wrap_MouseJoint.h index ca010df0f..4a9f78234 100644 --- a/src/modules/physics/box2d/wrap_MouseJoint.h +++ b/src/modules/physics/box2d/wrap_MouseJoint.h @@ -34,14 +34,6 @@ namespace box2d { MouseJoint *luax_checkmousejoint(lua_State *L, int idx); -int w_MouseJoint_setTarget(lua_State *L); -int w_MouseJoint_getTarget(lua_State *L); -int w_MouseJoint_setMaxForce(lua_State *L); -int w_MouseJoint_getMaxForce(lua_State *L); -int w_MouseJoint_setFrequency(lua_State *L); -int w_MouseJoint_getFrequency(lua_State *L); -int w_MouseJoint_setDampingRatio(lua_State *L); -int w_MouseJoint_getDampingRatio(lua_State *L); extern "C" int luaopen_mousejoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_Physics.h b/src/modules/physics/box2d/wrap_Physics.h index 8718131ee..e73a38c70 100644 --- a/src/modules/physics/box2d/wrap_Physics.h +++ b/src/modules/physics/box2d/wrap_Physics.h @@ -32,28 +32,6 @@ namespace physics namespace box2d { -int w_newWorld(lua_State *L); -int w_newBody(lua_State *L); -int w_newFixture(lua_State *L); -int w_newCircleShape(lua_State *L); -int w_newRectangleShape(lua_State *L); -int w_newPolygonShape(lua_State *L); -int w_newEdgeShape(lua_State *L); -int w_newChainShape(lua_State *L); -int w_newDistanceJoint(lua_State *L); -int w_newMouseJoint(lua_State *L); -int w_newRevoluteJoint(lua_State *L); -int w_newPrismaticJoint(lua_State *L); -int w_newPulleyJoint(lua_State *L); -int w_newGearJoint(lua_State *L); -int w_newFrictionJoint(lua_State *L); -int w_newWeldJoint(lua_State *L); -int w_newWheelJoint(lua_State *L); -int w_newRopeJoint(lua_State *L); -int w_newMotorJoint(lua_State *L); -int w_getDistance(lua_State *L); -int w_setMeter(lua_State *L); -int w_getMeter(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_physics(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_PolygonShape.cpp b/src/modules/physics/box2d/wrap_PolygonShape.cpp index b29ebd257..e30d93932 100644 --- a/src/modules/physics/box2d/wrap_PolygonShape.cpp +++ b/src/modules/physics/box2d/wrap_PolygonShape.cpp @@ -46,24 +46,16 @@ int w_PolygonShape_validate(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_PolygonShape_functions[] = { { "getPoints", w_PolygonShape_getPoints }, { "validate", w_PolygonShape_validate }, - // From Shape. - { "getType", w_Shape_getType }, - { "getRadius", w_Shape_getRadius }, - { "getChildCount", w_Shape_getChildCount }, - { "testPoint", w_Shape_testPoint }, - { "rayCast", w_Shape_rayCast }, - { "computeAABB", w_Shape_computeAABB }, - { "computeMass", w_Shape_computeMass }, { 0, 0 } }; extern "C" int luaopen_polygonshape(lua_State *L) { - return luax_register_type(L, PHYSICS_POLYGON_SHAPE_ID, functions); + return luax_register_type(L, PHYSICS_POLYGON_SHAPE_ID, "PolygonShape", w_Shape_functions, w_PolygonShape_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_PolygonShape.h b/src/modules/physics/box2d/wrap_PolygonShape.h index b3f1739f6..24686f7a8 100644 --- a/src/modules/physics/box2d/wrap_PolygonShape.h +++ b/src/modules/physics/box2d/wrap_PolygonShape.h @@ -34,8 +34,6 @@ namespace box2d { PolygonShape *luax_checkpolygonshape(lua_State *L, int idx); -int w_PolygonShape_getPoints(lua_State *L); -int w_PolygonShape_validate(lua_State *L); extern "C" int luaopen_polygonshape(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_PrismaticJoint.cpp b/src/modules/physics/box2d/wrap_PrismaticJoint.cpp index 44e9628eb..0f51c46c7 100644 --- a/src/modules/physics/box2d/wrap_PrismaticJoint.cpp +++ b/src/modules/physics/box2d/wrap_PrismaticJoint.cpp @@ -164,7 +164,7 @@ int w_PrismaticJoint_getLimits(lua_State *L) return t->getLimits(L); } -static const luaL_Reg functions[] = +static const luaL_Reg w_PrismaticJoint_functions[] = { { "getJointTranslation", w_PrismaticJoint_getJointTranslation }, { "getJointSpeed", w_PrismaticJoint_getJointSpeed }, @@ -183,23 +183,12 @@ static const luaL_Reg functions[] = { "getLowerLimit", w_PrismaticJoint_getLowerLimit }, { "getUpperLimit", w_PrismaticJoint_getUpperLimit }, { "getLimits", w_PrismaticJoint_getLimits }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_prismaticjoint(lua_State *L) { - return luax_register_type(L, PHYSICS_PRISMATIC_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_PRISMATIC_JOINT_ID, "PrismaticJoint", w_Joint_functions, w_PrismaticJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_PrismaticJoint.h b/src/modules/physics/box2d/wrap_PrismaticJoint.h index 2a24969ce..c2390c008 100644 --- a/src/modules/physics/box2d/wrap_PrismaticJoint.h +++ b/src/modules/physics/box2d/wrap_PrismaticJoint.h @@ -34,23 +34,6 @@ namespace box2d { PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx); -int w_PrismaticJoint_getJointTranslation(lua_State *L); -int w_PrismaticJoint_getJointSpeed(lua_State *L); -int w_PrismaticJoint_setMotorEnabled(lua_State *L); -int w_PrismaticJoint_isMotorEnabled(lua_State *L); -int w_PrismaticJoint_setMaxMotorForce(lua_State *L); -int w_PrismaticJoint_setMotorSpeed(lua_State *L); -int w_PrismaticJoint_getMotorSpeed(lua_State *L); -int w_PrismaticJoint_getMotorForce(lua_State *L); -int w_PrismaticJoint_getMaxMotorForce(lua_State *L); -int w_PrismaticJoint_setLimitsEnabled(lua_State *L); -int w_PrismaticJoint_hasLimitsEnabled(lua_State *L); -int w_PrismaticJoint_setUpperLimit(lua_State *L); -int w_PrismaticJoint_setLowerLimit(lua_State *L); -int w_PrismaticJoint_setLimits(lua_State *L); -int w_PrismaticJoint_getLowerLimit(lua_State *L); -int w_PrismaticJoint_getUpperLimit(lua_State *L); -int w_PrismaticJoint_getLimits(lua_State *L); extern "C" int luaopen_prismaticjoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_PulleyJoint.cpp b/src/modules/physics/box2d/wrap_PulleyJoint.cpp index 3a8c718f7..26f8f73d6 100644 --- a/src/modules/physics/box2d/wrap_PulleyJoint.cpp +++ b/src/modules/physics/box2d/wrap_PulleyJoint.cpp @@ -63,29 +63,18 @@ int w_PulleyJoint_getRatio(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_PulleyJoint_functions[] = { { "getGroundAnchors", w_PulleyJoint_getGroundAnchors }, { "getLengthA", w_PulleyJoint_getLengthA }, { "getLengthB", w_PulleyJoint_getLengthB }, { "getRatio", w_PulleyJoint_getRatio }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_pulleyjoint(lua_State *L) { - return luax_register_type(L, PHYSICS_PULLEY_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_PULLEY_JOINT_ID, "PulleyJoint", w_Joint_functions, w_PulleyJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_PulleyJoint.h b/src/modules/physics/box2d/wrap_PulleyJoint.h index cc997d7a4..9c07f91bd 100644 --- a/src/modules/physics/box2d/wrap_PulleyJoint.h +++ b/src/modules/physics/box2d/wrap_PulleyJoint.h @@ -34,10 +34,6 @@ namespace box2d { PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx); -int w_PulleyJoint_getGroundAnchors(lua_State *L); -int w_PulleyJoint_getLengthA(lua_State *L); -int w_PulleyJoint_getLengthB(lua_State *L); -int w_PulleyJoint_getRatio(lua_State *L); extern "C" int luaopen_pulleyjoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_RevoluteJoint.cpp b/src/modules/physics/box2d/wrap_RevoluteJoint.cpp index 75ad5914d..53791028a 100644 --- a/src/modules/physics/box2d/wrap_RevoluteJoint.cpp +++ b/src/modules/physics/box2d/wrap_RevoluteJoint.cpp @@ -164,7 +164,7 @@ int w_RevoluteJoint_getLimits(lua_State *L) return t->getLimits(L); } -static const luaL_Reg functions[] = +static const luaL_Reg w_RevoluteJoint_functions[] = { { "getJointAngle", w_RevoluteJoint_getJointAngle }, { "getJointSpeed", w_RevoluteJoint_getJointSpeed }, @@ -183,23 +183,12 @@ static const luaL_Reg functions[] = { "getLowerLimit", w_RevoluteJoint_getLowerLimit }, { "getUpperLimit", w_RevoluteJoint_getUpperLimit }, { "getLimits", w_RevoluteJoint_getLimits }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_revolutejoint(lua_State *L) { - return luax_register_type(L, PHYSICS_REVOLUTE_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_REVOLUTE_JOINT_ID, "RevoluteJoint", w_Joint_functions, w_RevoluteJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_RevoluteJoint.h b/src/modules/physics/box2d/wrap_RevoluteJoint.h index efbd26fe7..487516572 100644 --- a/src/modules/physics/box2d/wrap_RevoluteJoint.h +++ b/src/modules/physics/box2d/wrap_RevoluteJoint.h @@ -34,23 +34,6 @@ namespace box2d { RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx); -int w_RevoluteJoint_getJointAngle(lua_State *L); -int w_RevoluteJoint_getJointSpeed(lua_State *L); -int w_RevoluteJoint_setMotorEnabled(lua_State *L); -int w_RevoluteJoint_isMotorEnabled(lua_State *L); -int w_RevoluteJoint_setMaxMotorTorque(lua_State *L); -int w_RevoluteJoint_setMotorSpeed(lua_State *L); -int w_RevoluteJoint_getMotorSpeed(lua_State *L); -int w_RevoluteJoint_getMotorTorque(lua_State *L); -int w_RevoluteJoint_getMaxMotorTorque(lua_State *L); -int w_RevoluteJoint_setLimitsEnabled(lua_State *L); -int w_RevoluteJoint_hasLimitsEnabled(lua_State *L); -int w_RevoluteJoint_setUpperLimit(lua_State *L); -int w_RevoluteJoint_setLowerLimit(lua_State *L); -int w_RevoluteJoint_setLimits(lua_State *L); -int w_RevoluteJoint_getLowerLimit(lua_State *L); -int w_RevoluteJoint_getUpperLimit(lua_State *L); -int w_RevoluteJoint_getLimits(lua_State *L); extern "C" int luaopen_revolutejoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_RopeJoint.cpp b/src/modules/physics/box2d/wrap_RopeJoint.cpp index b9b9800d5..210637703 100644 --- a/src/modules/physics/box2d/wrap_RopeJoint.cpp +++ b/src/modules/physics/box2d/wrap_RopeJoint.cpp @@ -42,26 +42,15 @@ int w_RopeJoint_getMaxLength(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_RopeJoint_functions[] = { { "getMaxLength", w_RopeJoint_getMaxLength }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_ropejoint(lua_State *L) { - return luax_register_type(L, PHYSICS_ROPE_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_ROPE_JOINT_ID, "RopeJoint", w_Joint_functions, w_RopeJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_RopeJoint.h b/src/modules/physics/box2d/wrap_RopeJoint.h index f77b6c4f8..1c8e576e2 100644 --- a/src/modules/physics/box2d/wrap_RopeJoint.h +++ b/src/modules/physics/box2d/wrap_RopeJoint.h @@ -34,7 +34,6 @@ namespace box2d { RopeJoint *luax_checkropejoint(lua_State *L, int idx); -int w_RopeJoint_getMaxLength(lua_State *L); extern "C" int luaopen_ropejoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_Shape.cpp b/src/modules/physics/box2d/wrap_Shape.cpp index 0750d3e07..a036465f2 100644 --- a/src/modules/physics/box2d/wrap_Shape.cpp +++ b/src/modules/physics/box2d/wrap_Shape.cpp @@ -94,7 +94,7 @@ int w_Shape_computeMass(lua_State *L) return t->computeMass(L); } -static const luaL_Reg functions[] = +const luaL_Reg w_Shape_functions[] = { { "getType", w_Shape_getType }, { "getRadius", w_Shape_getRadius }, @@ -108,7 +108,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_shape(lua_State *L) { - return luax_register_type(L, PHYSICS_SHAPE_ID, functions); + return luax_register_type(L, PHYSICS_SHAPE_ID, "Shape", w_Shape_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_Shape.h b/src/modules/physics/box2d/wrap_Shape.h index 62cbc078d..456cbe3f2 100644 --- a/src/modules/physics/box2d/wrap_Shape.h +++ b/src/modules/physics/box2d/wrap_Shape.h @@ -34,17 +34,10 @@ namespace box2d { Shape *luax_checkshape(lua_State *L, int idx); -int w_Shape_getType(lua_State *L); -int w_Shape_getRadius(lua_State *L); - -int w_Shape_getChildCount(lua_State *L); -int w_Shape_testPoint(lua_State *L); -int w_Shape_rayCast(lua_State *L); -int w_Shape_computeAABB(lua_State *L); -int w_Shape_computeMass(lua_State *L); - extern "C" int luaopen_shape(lua_State *L); +extern const luaL_Reg w_Shape_functions[]; + } // box2d } // physics } // love diff --git a/src/modules/physics/box2d/wrap_WeldJoint.cpp b/src/modules/physics/box2d/wrap_WeldJoint.cpp index 056411bcb..56c61cd0b 100644 --- a/src/modules/physics/box2d/wrap_WeldJoint.cpp +++ b/src/modules/physics/box2d/wrap_WeldJoint.cpp @@ -65,29 +65,18 @@ int w_WeldJoint_getDampingRatio(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_WeldJoint_functions[] = { { "setFrequency", w_WeldJoint_setFrequency }, { "getFrequency", w_WeldJoint_getFrequency }, { "setDampingRatio", w_WeldJoint_setDampingRatio }, { "getDampingRatio", w_WeldJoint_getDampingRatio }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_weldjoint(lua_State *L) { - return luax_register_type(L, PHYSICS_WELD_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_WELD_JOINT_ID, "WeldJoint", w_Joint_functions, w_WeldJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_WeldJoint.h b/src/modules/physics/box2d/wrap_WeldJoint.h index 855888123..81aecf4d7 100644 --- a/src/modules/physics/box2d/wrap_WeldJoint.h +++ b/src/modules/physics/box2d/wrap_WeldJoint.h @@ -34,12 +34,6 @@ namespace box2d { WeldJoint *luax_checkweldjoint(lua_State *L, int idx); - -int w_WeldJoint_setFrequency(lua_State *L); -int w_WeldJoint_getFrequency(lua_State *L); -int w_WeldJoint_setDampingRatio(lua_State *L); -int w_WeldJoint_getDampingRatio(lua_State *L); - extern "C" int luaopen_weldjoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_WheelJoint.cpp b/src/modules/physics/box2d/wrap_WheelJoint.cpp index d8691898e..ce642f035 100644 --- a/src/modules/physics/box2d/wrap_WheelJoint.cpp +++ b/src/modules/physics/box2d/wrap_WheelJoint.cpp @@ -132,7 +132,7 @@ int w_WheelJoint_getSpringDampingRatio(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_WheelJoint_functions[] = { { "getJointTranslation", w_WheelJoint_getJointTranslation }, { "getJointSpeed", w_WheelJoint_getJointSpeed }, @@ -147,23 +147,12 @@ static const luaL_Reg functions[] = { "getSpringFrequency", w_WheelJoint_getSpringFrequency }, { "setSpringDampingRatio", w_WheelJoint_setSpringDampingRatio }, { "getSpringDampingRatio", w_WheelJoint_getSpringDampingRatio }, - // From Joint. - { "getType", w_Joint_getType }, - { "getBodies", w_Joint_getBodies }, - { "getAnchors", w_Joint_getAnchors }, - { "getReactionForce", w_Joint_getReactionForce }, - { "getReactionTorque", w_Joint_getReactionTorque }, - { "getCollideConnected", w_Joint_getCollideConnected }, - { "setUserData", w_Joint_setUserData }, - { "getUserData", w_Joint_getUserData }, - { "destroy", w_Joint_destroy }, - { "isDestroyed", w_Joint_isDestroyed }, { 0, 0 } }; extern "C" int luaopen_wheeljoint(lua_State *L) { - return luax_register_type(L, PHYSICS_WHEEL_JOINT_ID, functions); + return luax_register_type(L, PHYSICS_WHEEL_JOINT_ID, "WheelJoint", w_Joint_functions, w_WheelJoint_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_WheelJoint.h b/src/modules/physics/box2d/wrap_WheelJoint.h index 4a3fe60ce..1320dac20 100644 --- a/src/modules/physics/box2d/wrap_WheelJoint.h +++ b/src/modules/physics/box2d/wrap_WheelJoint.h @@ -34,19 +34,6 @@ namespace box2d { WheelJoint *luax_checkwheeljoint(lua_State *L, int idx); -int w_WheelJoint_getJointTranslation(lua_State *L); -int w_WheelJoint_getJointSpeed(lua_State *L); -int w_WheelJoint_setMotorEnabled(lua_State *L); -int w_WheelJoint_isMotorEnabled(lua_State *L); -int w_WheelJoint_setMotorSpeed(lua_State *L); -int w_WheelJoint_getMotorSpeed(lua_State *L); -int w_WheelJoint_setMaxMotorTorque(lua_State *L); -int w_WheelJoint_getMaxMotorTorque(lua_State *L); -int w_WheelJoint_getMotorTorque(lua_State *L); -int w_WheelJoint_setSpringFrequency(lua_State *L); -int w_WheelJoint_getSpringFrequency(lua_State *L); -int w_WheelJoint_setSpringDampingRatio(lua_State *L); -int w_WheelJoint_getSpringDampingRatio(lua_State *L); extern "C" int luaopen_wheeljoint(lua_State *L); } // box2d diff --git a/src/modules/physics/box2d/wrap_World.cpp b/src/modules/physics/box2d/wrap_World.cpp index a0c86082e..8f436672f 100644 --- a/src/modules/physics/box2d/wrap_World.cpp +++ b/src/modules/physics/box2d/wrap_World.cpp @@ -199,7 +199,7 @@ int w_World_isDestroyed(lua_State *L) } -static const luaL_Reg functions[] = +static const luaL_Reg w_World_functions[] = { { "update", w_World_update }, { "setCallbacks", w_World_setCallbacks }, @@ -227,7 +227,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_world(lua_State *L) { - return luax_register_type(L, PHYSICS_WORLD_ID, functions); + return luax_register_type(L, PHYSICS_WORLD_ID, "World", w_World_functions, nullptr); } } // box2d diff --git a/src/modules/physics/box2d/wrap_World.h b/src/modules/physics/box2d/wrap_World.h index c09dff7a1..3714eac96 100644 --- a/src/modules/physics/box2d/wrap_World.h +++ b/src/modules/physics/box2d/wrap_World.h @@ -35,27 +35,6 @@ namespace box2d { World *luax_checkworld(lua_State *L, int idx); -int w_World_update(lua_State *L); -int w_World_setCallbacks(lua_State *L); -int w_World_getCallbacks(lua_State *L); -int w_World_setContactFilter(lua_State *L); -int w_World_getContactFilter(lua_State *L); -int w_World_setGravity(lua_State *L); -int w_World_getGravity(lua_State *L); -int w_World_translateOrigin(lua_State *L); -int w_World_setSleepingAllowed(lua_State *L); -int w_World_isSleepingAllowed(lua_State *L); -int w_World_isLocked(lua_State *L); -int w_World_getBodyCount(lua_State *L); -int w_World_getJointCount(lua_State *L); -int w_World_getContactCount(lua_State *L); -int w_World_getBodyList(lua_State *L); -int w_World_getJointList(lua_State *L); -int w_World_getContactList(lua_State *L); -int w_World_queryBoundingBox(lua_State *L); -int w_World_rayCast(lua_State *L); -int w_World_destroy(lua_State *L); -int w_World_isDestroyed(lua_State *L); extern "C" int luaopen_world(lua_State *L); } // box2d diff --git a/src/modules/sound/wrap_Decoder.cpp b/src/modules/sound/wrap_Decoder.cpp index af8398fb4..9a542775c 100644 --- a/src/modules/sound/wrap_Decoder.cpp +++ b/src/modules/sound/wrap_Decoder.cpp @@ -58,7 +58,7 @@ int w_Decoder_getDuration(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_Decoder_functions[] = { { "getChannels", w_Decoder_getChannels }, { "getBitDepth", w_Decoder_getBitDepth }, @@ -69,7 +69,7 @@ static const luaL_Reg functions[] = extern "C" int luaopen_decoder(lua_State *L) { - return luax_register_type(L, SOUND_DECODER_ID, functions); + return luax_register_type(L, SOUND_DECODER_ID, "Decoder", w_Decoder_functions, nullptr); } } // sound diff --git a/src/modules/sound/wrap_Decoder.h b/src/modules/sound/wrap_Decoder.h index d0db3fc09..ccd2f5682 100644 --- a/src/modules/sound/wrap_Decoder.h +++ b/src/modules/sound/wrap_Decoder.h @@ -31,10 +31,6 @@ namespace sound { Decoder *luax_checkdecoder(lua_State *L, int idx); -int w_Decoder_getChannels(lua_State *L); -int w_Decoder_getBitDepth(lua_State *L); -int w_Decoder_getSampleRate(lua_State *L); -int w_Decoder_getDuration(lua_State *L); extern "C" int luaopen_decoder(lua_State *L); } // sound diff --git a/src/modules/sound/wrap_Sound.cpp b/src/modules/sound/wrap_Sound.cpp index 6f43343b4..044896fc5 100644 --- a/src/modules/sound/wrap_Sound.cpp +++ b/src/modules/sound/wrap_Sound.cpp @@ -32,6 +32,25 @@ namespace sound #define instance() (Module::getInstance(Module::M_SOUND)) +int w_newDecoder(lua_State *L) +{ + love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1); + int bufferSize = (int) luaL_optnumber(L, 2, Decoder::DEFAULT_BUFFER_SIZE); + + Decoder *t = nullptr; + luax_catchexcept(L, + [&]() { t = instance()->newDecoder(data, bufferSize); }, + [&](bool) { data->release(); } + ); + + if (t == nullptr) + return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str()); + + luax_pushtype(L, SOUND_DECODER_ID, t); + t->release(); + return 1; +} + int w_newSoundData(lua_State *L) { SoundData *t = 0; @@ -63,30 +82,11 @@ int w_newSoundData(lua_State *L) return 1; } -int w_newDecoder(lua_State *L) -{ - love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1); - int bufferSize = (int) luaL_optnumber(L, 2, Decoder::DEFAULT_BUFFER_SIZE); - - Decoder *t = nullptr; - luax_catchexcept(L, - [&]() { t = instance()->newDecoder(data, bufferSize); }, - [&](bool) { data->release(); } - ); - - if (t == nullptr) - return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str()); - - luax_pushtype(L, SOUND_DECODER_ID, t); - t->release(); - return 1; -} - // List of functions to wrap. static const luaL_Reg functions[] = { - { "newSoundData", w_newSoundData }, { "newDecoder", w_newDecoder }, + { "newSoundData", w_newSoundData }, { 0, 0 } }; diff --git a/src/modules/sound/wrap_Sound.h b/src/modules/sound/wrap_Sound.h index 39efb5006..0beae99d1 100644 --- a/src/modules/sound/wrap_Sound.h +++ b/src/modules/sound/wrap_Sound.h @@ -32,8 +32,6 @@ namespace love namespace sound { -int w_newSoundData(lua_State *L); -int w_newDecoder(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_sound(lua_State *L); } // sound diff --git a/src/modules/sound/wrap_SoundData.cpp b/src/modules/sound/wrap_SoundData.cpp index b4fc7b7ad..6ac4e0148 100644 --- a/src/modules/sound/wrap_SoundData.cpp +++ b/src/modules/sound/wrap_SoundData.cpp @@ -96,13 +96,8 @@ int w_SoundData_getSample(lua_State *L) return 1; } -static const luaL_Reg functions[] = +static const luaL_Reg w_SoundData_functions[] = { - // Data - { "getString", w_Data_getString }, - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { "getChannels", w_SoundData_getChannels }, { "getBitDepth", w_SoundData_getBitDepth }, { "getSampleRate", w_SoundData_getSampleRate }, @@ -115,21 +110,21 @@ static const luaL_Reg functions[] = extern "C" int luaopen_sounddata(lua_State *L) { - // The last argument pushes the type's metatable onto the stack. - int ret = luax_register_type(L, SOUND_SOUND_DATA_ID, functions, true); + int ret = luax_register_type(L, SOUND_SOUND_DATA_ID, "SoundData", w_Data_functions, w_SoundData_functions, nullptr); + + luax_gettypemetatable(L, SOUND_SOUND_DATA_ID); // Load and execute SoundData.lua, sending the metatable as an argument. - if (ret > 0) + if (lua_istable(L, -1)) { luaL_loadbuffer(L, sounddata_lua, sizeof(sounddata_lua), "SoundData.lua"); lua_pushvalue(L, -2); lua_call(L, 1, 0); - - // Pop the metatable. - lua_pop(L, 1); - ret--; } + // Pop the metatable. + lua_pop(L, 1); + return ret; } diff --git a/src/modules/sound/wrap_SoundData.h b/src/modules/sound/wrap_SoundData.h index c22ac0b32..9b1f3d80b 100644 --- a/src/modules/sound/wrap_SoundData.h +++ b/src/modules/sound/wrap_SoundData.h @@ -31,13 +31,6 @@ namespace sound { SoundData *luax_checksounddata(lua_State *L, int idx); -int w_SoundData_getChannels(lua_State *L); -int w_SoundData_getBitDepth(lua_State *L); -int w_SoundData_getSampleRate(lua_State *L); -int w_SoundData_getSampleCount(lua_State *L); -int w_SoundData_getDuration(lua_State *L); -int w_SoundData_setSample(lua_State *L); -int w_SoundData_getSample(lua_State *L); extern "C" int luaopen_sounddata(lua_State *L); } // sound diff --git a/src/modules/system/wrap_System.h b/src/modules/system/wrap_System.h index 2fe6438f5..c9eb968fd 100644 --- a/src/modules/system/wrap_System.h +++ b/src/modules/system/wrap_System.h @@ -30,13 +30,6 @@ namespace love namespace system { -int w_getOS(lua_State *L); -int w_getProcessorCount(lua_State *L); -int w_setClipboardText(lua_State *L); -int w_getClipboardText(lua_State *L); -int w_getPowerInfo(lua_State *L); -int w_openURL(lua_State *L); -int w_vibrate(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_system(lua_State *L); } // system diff --git a/src/modules/thread/wrap_Channel.cpp b/src/modules/thread/wrap_Channel.cpp index 002af7166..0885e319b 100644 --- a/src/modules/thread/wrap_Channel.cpp +++ b/src/modules/thread/wrap_Channel.cpp @@ -144,7 +144,8 @@ int w_Channel_performAtomic(lua_State *L) return lua_gettop(L) - 1; } -static const luaL_Reg type_functions[] = { +static const luaL_Reg w_Channel_functions[] = +{ { "push", w_Channel_push }, { "supply", w_Channel_supply }, { "pop", w_Channel_pop }, @@ -158,7 +159,7 @@ static const luaL_Reg type_functions[] = { extern "C" int luaopen_channel(lua_State *L) { - return luax_register_type(L, THREAD_CHANNEL_ID, type_functions); + return luax_register_type(L, THREAD_CHANNEL_ID, "Channel", w_Channel_functions, nullptr); } } // thread diff --git a/src/modules/thread/wrap_Channel.h b/src/modules/thread/wrap_Channel.h index 2a4b2c899..1e7e90a1c 100644 --- a/src/modules/thread/wrap_Channel.h +++ b/src/modules/thread/wrap_Channel.h @@ -28,17 +28,10 @@ namespace love { namespace thread { -Channel *luax_checkchannel(lua_State *L, int idx); -int w_Channel_push(lua_State *L); -int w_Channel_supply(lua_State *L); -int w_Channel_pop(lua_State *L); -int w_Channel_demand(lua_State *L); -int w_Channel_peek(lua_State *L); -int w_Channel_getCount(lua_State *L); -int w_Channel_clear(lua_State *L); -int w_Channel_performAtomic(lua_State *L); +Channel *luax_checkchannel(lua_State *L, int idx); extern "C" int luaopen_channel(lua_State *L); + } // thread } // love diff --git a/src/modules/thread/wrap_LuaThread.cpp b/src/modules/thread/wrap_LuaThread.cpp index 15a290615..ee2e4d6a0 100644 --- a/src/modules/thread/wrap_LuaThread.cpp +++ b/src/modules/thread/wrap_LuaThread.cpp @@ -81,7 +81,8 @@ int w_Thread_isRunning(lua_State *L) return 1; } -static const luaL_Reg type_functions[] = { +static const luaL_Reg w_Thread_functions[] = +{ { "start", w_Thread_start }, { "wait", w_Thread_wait }, { "getError", w_Thread_getError }, @@ -91,7 +92,7 @@ static const luaL_Reg type_functions[] = { extern "C" int luaopen_thread(lua_State *L) { - return luax_register_type(L, THREAD_THREAD_ID, type_functions); + return luax_register_type(L, THREAD_THREAD_ID, "Thread", w_Thread_functions, nullptr); } } // thread diff --git a/src/modules/thread/wrap_LuaThread.h b/src/modules/thread/wrap_LuaThread.h index 09474c542..6c74d8219 100644 --- a/src/modules/thread/wrap_LuaThread.h +++ b/src/modules/thread/wrap_LuaThread.h @@ -30,11 +30,6 @@ namespace thread { LuaThread *luax_checkthread(lua_State *L, int idx); -int w_Thread_start(lua_State *L); -int w_Thread_wait(lua_State *L); -int w_Thread_getError(lua_State *L); -int w_Thread_isRunning(lua_State *L); - extern "C" int luaopen_thread(lua_State *L); } // thread diff --git a/src/modules/thread/wrap_ThreadModule.cpp b/src/modules/thread/wrap_ThreadModule.cpp index ce7576227..0736188d3 100644 --- a/src/modules/thread/wrap_ThreadModule.cpp +++ b/src/modules/thread/wrap_ThreadModule.cpp @@ -99,7 +99,8 @@ int w_getChannel(lua_State *L) } // List of functions to wrap. -static const luaL_Reg module_functions[] = { +static const luaL_Reg module_functions[] = +{ { "newThread", w_newThread }, { "newChannel", w_newChannel }, { "getChannel", w_getChannel }, diff --git a/src/modules/thread/wrap_ThreadModule.h b/src/modules/thread/wrap_ThreadModule.h index f2298ba8b..d608f6f2f 100644 --- a/src/modules/thread/wrap_ThreadModule.h +++ b/src/modules/thread/wrap_ThreadModule.h @@ -29,9 +29,6 @@ namespace love { namespace thread { -int w_newThread(lua_State *L); -int w_newChannel(lua_State *L); -int w_getChannel(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_thread(lua_State * L); diff --git a/src/modules/timer/wrap_Timer.h b/src/modules/timer/wrap_Timer.h index a3ef01640..f01eef48b 100644 --- a/src/modules/timer/wrap_Timer.h +++ b/src/modules/timer/wrap_Timer.h @@ -30,12 +30,6 @@ namespace love namespace timer { -int w_step(lua_State *L); -int w_getDelta(lua_State *L); -int w_getFPS(lua_State *L); -int w_getAverageDelta(lua_State *L); -int w_sleep(lua_State *L); -int w_getTime(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_timer(lua_State *L); } // timer diff --git a/src/modules/touch/wrap_Touch.h b/src/modules/touch/wrap_Touch.h index 161a4b1f6..bd1a6e3c0 100644 --- a/src/modules/touch/wrap_Touch.h +++ b/src/modules/touch/wrap_Touch.h @@ -32,9 +32,6 @@ namespace touch { int64 luax_checktouchid(lua_State *L, int idx); -int w_getTouches(lua_State *L); -int w_getPosition(lua_State *L); -int w_getPressure(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_touch(lua_State *L); } // touch diff --git a/src/modules/window/wrap_Window.h b/src/modules/window/wrap_Window.h index 361184ca3..859091280 100644 --- a/src/modules/window/wrap_Window.h +++ b/src/modules/window/wrap_Window.h @@ -29,34 +29,6 @@ namespace love namespace window { -int w_getDisplayCount(lua_State *L); -int w_getDisplayName(lua_State *L); -int w_setMode(lua_State *L); -int w_getMode(lua_State *L); -int w_getFullscreenModes(lua_State *L); -int w_setFullscreen(lua_State *L); -int w_getFullscreen(lua_State *L); -int w_isOpen(lua_State *L); -int w_close(lua_State *L); -int w_getDesktopDimensions(lua_State *L); -int w_setPosition(lua_State *L); -int w_getPosition(lua_State *L); -int w_setIcon(lua_State *L); -int w_getIcon(lua_State *L); -int w_setDisplaySleepEnabled(lua_State *L); -int w_isDisplaySleepEnabled(lua_State *L); -int w_setTitle(lua_State *L); -int w_getTitle(lua_State *L); -int w_hasFocus(lua_State *L); -int w_hasMouseFocus(lua_State *L); -int w_isVisible(lua_State *L); -int w_getPixelScale(lua_State *L); -int w_toPixels(lua_State *L); -int w_fromPixels(lua_State *L); -int w_minimize(lua_State *L); -int w_maximize(lua_State *L); -int w_showMessageBox(lua_State *L); -int w_requestAttention(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_window(lua_State *L); } // window