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

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2015-03-01 18:32:41 -04:00
parent 3830a0969c
commit 2f419c1c83
79 changed files with 601 additions and 566 deletions
+10 -10
View File
@@ -44,7 +44,7 @@ int w_getSourceCount(lua_State *L)
int w_newSource(lua_State *L)
{
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
luax_convobj(L, 1, "sound", "newDecoder");
Source::Type stype = Source::TYPE_STREAM;
@@ -53,21 +53,21 @@ int w_newSource(lua_State *L)
if (stypestr && !Source::getConstant(stypestr, stype))
return luaL_error(L, "Invalid source type: %s", stypestr);
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_T))
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_ID))
luax_convobj(L, 1, "sound", "newSoundData");
Source *t = 0;
luax_catchexcept(L, [&]() {
if (luax_istype(L, 1, SOUND_SOUND_DATA_T))
t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, "SoundData", SOUND_SOUND_DATA_T));
else if (luax_istype(L, 1, SOUND_DECODER_T))
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, "Decoder", SOUND_DECODER_T));
if (luax_istype(L, 1, SOUND_SOUND_DATA_ID))
t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, SOUND_SOUND_DATA_ID));
else if (luax_istype(L, 1, SOUND_DECODER_ID))
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, SOUND_DECODER_ID));
});
if (t)
{
luax_pushtype(L, "Source", AUDIO_SOURCE_T, t);
luax_pushtype(L, AUDIO_SOURCE_ID, t);
t->release();
return 1;
}
@@ -243,7 +243,7 @@ int w_getRecordedData(lua_State *L)
lua_pushnil(L);
else
{
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
sd->release();
}
return 1;
@@ -258,7 +258,7 @@ int w_stopRecording(lua_State *L)
lua_pushnil(L);
else
{
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
sd->release();
}
return 1;
@@ -369,7 +369,7 @@ extern "C" int luaopen_love_audio(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "audio";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
+3 -3
View File
@@ -29,7 +29,7 @@ namespace audio
Source *luax_checksource(lua_State *L, int idx)
{
return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
return luax_checktype<Source>(L, idx, AUDIO_SOURCE_ID);
}
int w_Source_clone(lua_State *L)
@@ -37,7 +37,7 @@ int w_Source_clone(lua_State *L)
Source *t = luax_checksource(L, 1);
Source *clone = nullptr;
luax_catchexcept(L, [&](){ clone = t->clone(); });
luax_pushtype(L, "Source", AUDIO_SOURCE_T, clone);
luax_pushtype(L, AUDIO_SOURCE_ID, clone);
clone->release();
return 1;
}
@@ -406,7 +406,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_source(lua_State *L)
{
return luax_register_type(L, "Source", functions);
return luax_register_type(L, AUDIO_SOURCE_ID, functions);
}
} // audio
+8 -8
View File
@@ -350,7 +350,7 @@ Message *Event::convert(const SDL_Event &e) const
{
Proxy proxy;
proxy.object = new love::filesystem::DroppedFile(e.drop.file);
proxy.flags = FILESYSTEM_DROPPED_FILE_T;
proxy.type = FILESYSTEM_DROPPED_FILE_ID;
vargs.push_back(new Variant(FILESYSTEM_DROPPED_FILE_ID, &proxy));
msg = new Message("filedropped", vargs);
proxy.object->release();
@@ -400,7 +400,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
{
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
proxy.object = joymodule->getJoystickFromID(e.jbutton.which);
if (!proxy.object)
break;
@@ -413,7 +413,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
break;
case SDL_JOYAXISMOTION:
{
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
proxy.object = joymodule->getJoystickFromID(e.jaxis.which);
if (!proxy.object)
break;
@@ -429,7 +429,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
if (!joystick::sdl::Joystick::getConstant(e.jhat.value, hat) || !joystick::Joystick::getConstant(hat, txt))
break;
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
proxy.object = joymodule->getJoystickFromID(e.jhat.which);
if (!proxy.object)
break;
@@ -447,7 +447,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
if (!joystick::Joystick::getConstant(padbutton, txt))
break;
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
proxy.object = joymodule->getJoystickFromID(e.cbutton.which);
if (!proxy.object)
break;
@@ -463,7 +463,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
if (!joystick::Joystick::getConstant(padaxis, txt))
break;
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
proxy.object = joymodule->getJoystickFromID(e.caxis.which);
if (!proxy.object)
break;
@@ -479,7 +479,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
case SDL_JOYDEVICEADDED:
// jdevice.which is the joystick device index.
proxy.object = joymodule->addJoystick(e.jdevice.which);
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
if (proxy.object)
{
vargs.push_back(new Variant(JOYSTICK_JOYSTICK_ID, (void *) &proxy));
@@ -489,7 +489,7 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
case SDL_JOYDEVICEREMOVED:
// jdevice.which is the joystick instance ID now.
proxy.object = joymodule->getJoystickFromID(e.jdevice.which);
proxy.flags = JOYSTICK_JOYSTICK_T;
proxy.type = JOYSTICK_JOYSTICK_ID;
if (proxy.object)
{
joymodule->removeJoystick((joystick::Joystick *) proxy.object);
+1 -1
View File
@@ -129,7 +129,7 @@ extern "C" int luaopen_love_event(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "event";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = 0;
+2 -2
View File
@@ -28,7 +28,7 @@ namespace filesystem
DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
{
return luax_checktype<DroppedFile>(L, idx, "DroppedFile", FILESYSTEM_DROPPED_FILE_T);
return luax_checktype<DroppedFile>(L, idx, FILESYSTEM_DROPPED_FILE_ID);
}
static const luaL_Reg functions[] =
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_droppedfile(lua_State *L)
{
return luax_register_type(L, "DroppedFile", functions);
return luax_register_type(L, FILESYSTEM_DROPPED_FILE_ID, functions);
}
} // filesystem
+5 -5
View File
@@ -43,7 +43,7 @@ int luax_ioError(lua_State *L, const char *fmt, ...)
File *luax_checkfile(lua_State *L, int idx)
{
return luax_checktype<File>(L, idx, "File", FILESYSTEM_FILE_T);
return luax_checktype<File>(L, idx, FILESYSTEM_FILE_ID);
}
int w_File_getSize(lua_State *L)
@@ -149,11 +149,11 @@ int w_File_write(lua_State *L)
return luax_ioError(L, "%s", e.what());
}
}
else if (luax_istype(L, 2, DATA_T))
else if (luax_istype(L, 2, DATA_ID))
{
try
{
love::Data *data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
love::Data *data = luax_totype<love::Data>(L, 2, DATA_ID);
result = file->write(data, luaL_optinteger(L, 3, data->getSize()));
}
catch (love::Exception &e)
@@ -228,7 +228,7 @@ int w_File_lines_i(lua_State *L)
int linesize = 0;
bool newline = false;
File *file = luax_checktype<File>(L, lua_upvalueindex(1), "File", FILESYSTEM_FILE_T);
File *file = luax_checktype<File>(L, lua_upvalueindex(1), FILESYSTEM_FILE_ID);
// Only accept read mode at this point.
if (file->getMode() != File::MODE_READ)
@@ -436,7 +436,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_file(lua_State *L)
{
return luax_register_type(L, "File", functions);
return luax_register_type(L, FILESYSTEM_FILE_ID, functions);
}
} // filesystem
+2 -2
View File
@@ -29,7 +29,7 @@ namespace filesystem
FileData *luax_checkfiledata(lua_State *L, int idx)
{
return luax_checktype<FileData>(L, idx, "FileData", FILESYSTEM_FILE_DATA_T);
return luax_checktype<FileData>(L, idx, FILESYSTEM_FILE_DATA_ID);
}
int w_FileData_getFilename(lua_State *L)
@@ -61,7 +61,7 @@ static const luaL_Reg w_FileData_functions[] =
extern "C" int luaopen_filedata(lua_State *L)
{
return luax_register_type(L, "FileData", w_FileData_functions);
return luax_register_type(L, FILESYSTEM_FILE_DATA_ID, w_FileData_functions);
}
} // filesystem
+10 -10
View File
@@ -150,7 +150,7 @@ int w_newFile(lua_State *L)
}
}
luax_pushtype(L, "File", FILESYSTEM_FILE_T, t);
luax_pushtype(L, FILESYSTEM_FILE_ID, t);
t->release();
return 1;
}
@@ -165,12 +165,12 @@ FileData *luax_getfiledata(lua_State *L, int idx)
const char *filename = luaL_checkstring(L, idx);
file = instance()->newFile(filename);
}
else if (luax_istype(L, idx, FILESYSTEM_FILE_T))
else if (luax_istype(L, idx, FILESYSTEM_FILE_ID))
{
file = luax_checkfile(L, idx);
file->retain();
}
else if (luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
else if (luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
{
data = luax_checkfiledata(L, idx);
data->retain();
@@ -203,7 +203,7 @@ int w_newFileData(lua_State *L)
luax_convobj(L, 1, "filesystem", "newFile");
// Get FileData from the File.
if (luax_istype(L, 1, FILESYSTEM_FILE_T))
if (luax_istype(L, 1, FILESYSTEM_FILE_ID))
{
File *file = luax_checkfile(L, 1);
@@ -216,7 +216,7 @@ int w_newFileData(lua_State *L)
{
return luax_ioError(L, "%s", e.what());
}
luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, data);
luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, data);
data->release();
return 1;
}
@@ -248,7 +248,7 @@ int w_newFileData(lua_State *L)
return luaL_error(L, "Invalid FileData decoder: %s", decstr);
}
luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, t);
luax_pushtype(L, FILESYSTEM_FILE_DATA_ID, t);
t->release();
return 1;
}
@@ -366,9 +366,9 @@ static int w_write_or_append(lua_State *L, File::Mode mode)
const char *input = 0;
size_t len = 0;
if (luax_istype(L, 2, DATA_T))
if (luax_istype(L, 2, DATA_ID))
{
love::Data *data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
love::Data *data = luax_totype<love::Data>(L, 2, DATA_ID);
input = (const char *) data->getData();
len = data->getSize();
}
@@ -428,7 +428,7 @@ int w_lines(lua_State *L)
return luaL_error(L, "Could not open file.");
}
luax_pushtype(L, "File", FILESYSTEM_FILE_T, file);
luax_pushtype(L, FILESYSTEM_FILE_ID, file);
file->release();
}
else
@@ -731,7 +731,7 @@ extern "C" int luaopen_love_filesystem(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "filesystem";
w.flags = MODULE_FILESYSTEM_T;
w.type = MODULE_FILESYSTEM_ID;
w.functions = functions;
w.types = types;
+11 -11
View File
@@ -52,7 +52,7 @@ int w_newRasterizer(lua_State *L)
[&]() { d->release(); }
);
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
luax_pushtype(L, FONT_RASTERIZER_ID, t);
t->release();
return 1;
}
@@ -82,7 +82,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
{
love::Data *d = nullptr;
if (luax_istype(L, 1, DATA_T))
if (luax_istype(L, 1, DATA_ID))
d = luax_checkdata(L, 1);
else
d = filesystem::luax_getfiledata(L, 1);
@@ -95,14 +95,14 @@ int w_newTrueTypeRasterizer(lua_State *L)
);
}
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
luax_pushtype(L, FONT_RASTERIZER_ID, t);
t->release();
return 1;
}
static void convimagedata(lua_State *L, int idx)
{
if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_T) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_ID) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
luax_convobj(L, idx, "image", "newImageData");
}
@@ -120,7 +120,7 @@ int w_newBMFontRasterizer(lua_State *L)
lua_rawgeti(L, 2, i);
convimagedata(L, -1);
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, "ImageData", IMAGE_IMAGE_DATA_T);
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, IMAGE_IMAGE_DATA_ID);
images.push_back(id);
id->retain();
@@ -132,7 +132,7 @@ int w_newBMFontRasterizer(lua_State *L)
for (int i = 2; i <= lua_gettop(L); i++)
{
convimagedata(L, i);
image::ImageData *id = luax_checktype<image::ImageData>(L, i, "ImageData", IMAGE_IMAGE_DATA_T);
image::ImageData *id = luax_checktype<image::ImageData>(L, i, IMAGE_IMAGE_DATA_ID);
images.push_back(id);
id->retain();
}
@@ -143,7 +143,7 @@ int w_newBMFontRasterizer(lua_State *L)
[&]() { d->release(); for (auto id : images) id->release(); }
);
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
luax_pushtype(L, FONT_RASTERIZER_ID, t);
t->release();
return 1;
}
@@ -154,12 +154,12 @@ int w_newImageRasterizer(lua_State *L)
convimagedata(L, 1);
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
std::string glyphs = luax_checkstring(L, 2);
luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs); });
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
luax_pushtype(L, FONT_RASTERIZER_ID, t);
t->release();
return 1;
}
@@ -181,7 +181,7 @@ int w_newGlyphData(lua_State *L)
t = instance()->newGlyphData(r, g);
}
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
luax_pushtype(L, FONT_GLYPH_DATA_ID, t);
t->release();
return 1;
}
@@ -217,7 +217,7 @@ extern "C" int luaopen_love_font(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "font";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
+2 -2
View File
@@ -27,7 +27,7 @@ namespace font
GlyphData *luax_checkglyphdata(lua_State *L, int idx)
{
return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
return luax_checktype<GlyphData>(L, idx, FONT_GLYPH_DATA_ID);
}
int w_GlyphData_getWidth(lua_State *L)
@@ -136,7 +136,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_glyphdata(lua_State *L)
{
return luax_register_type(L, "GlyphData", functions);
return luax_register_type(L, FONT_GLYPH_DATA_ID, functions);
}
} // font
+3 -3
View File
@@ -29,7 +29,7 @@ namespace font
Rasterizer *luax_checkrasterizer(lua_State *L, int idx)
{
return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
return luax_checktype<Rasterizer>(L, idx, FONT_RASTERIZER_ID);
}
int w_Rasterizer_getHeight(lua_State *L)
@@ -86,7 +86,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
}
});
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, g);
luax_pushtype(L, FONT_GLYPH_DATA_ID, g);
g->release();
return 1;
}
@@ -139,7 +139,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_rasterizer(lua_State *L)
{
return luax_register_type(L, "Rasterizer", functions);
return luax_register_type(L, FONT_RASTERIZER_ID, functions);
}
} // font
+4 -4
View File
@@ -30,7 +30,7 @@ namespace opengl
Canvas *luax_checkcanvas(lua_State *L, int idx)
{
return luax_checktype<Canvas>(L, idx, "Canvas", GRAPHICS_CANVAS_T);
return luax_checktype<Canvas>(L, idx, GRAPHICS_CANVAS_ID);
}
int w_Canvas_renderTo(lua_State *L)
@@ -65,7 +65,7 @@ int w_Canvas_renderTo(lua_State *L)
int w_Canvas_newImageData(lua_State *L)
{
Canvas *canvas = luax_checkcanvas(L, 1);
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
int x = luaL_optint(L, 2, 0);
int y = luaL_optint(L, 3, 0);
int w = luaL_optint(L, 4, canvas->getWidth());
@@ -74,7 +74,7 @@ int w_Canvas_newImageData(lua_State *L)
love::image::ImageData *img = nullptr;
luax_catchexcept(L, [&](){ img = canvas->newImageData(image, x, y, w, h); });
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, img);
img->release();
return 1;
}
@@ -118,7 +118,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_canvas(lua_State *L)
{
return luax_register_type(L, "Canvas", functions);
return luax_register_type(L, GRAPHICS_CANVAS_ID, functions);
}
} // opengl
+2 -2
View File
@@ -30,7 +30,7 @@ namespace opengl
Font *luax_checkfont(lua_State *L, int idx)
{
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
return luax_checktype<Font>(L, idx, GRAPHICS_FONT_ID);
}
int w_Font_getHeight(lua_State *L)
@@ -186,7 +186,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_font(lua_State *L)
{
return luax_register_type(L, "Font", functions);
return luax_register_type(L, GRAPHICS_FONT_ID, functions);
}
} // opengl
+32 -32
View File
@@ -203,7 +203,7 @@ int w_newImage(lua_State *L)
bool releasedata = false;
// Convert to ImageData / CompressedData, if necessary.
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
{
love::image::Image *image = Module::getInstance<love::image::Image>(Module::M_IMAGE);
if (image == nullptr)
@@ -229,10 +229,10 @@ int w_newImage(lua_State *L)
// Lua's GC won't release the image data, so we should do it ourselves.
releasedata = true;
}
else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_T))
cdata = luax_checktype<love::image::CompressedData>(L, 1, "CompressedData", IMAGE_COMPRESSED_DATA_T);
else if (luax_istype(L, 1, IMAGE_COMPRESSED_DATA_ID))
cdata = luax_checktype<love::image::CompressedData>(L, 1, IMAGE_COMPRESSED_DATA_ID);
else
data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
if (!data && !cdata)
return luaL_error(L, "Error creating image (could not load data.)");
@@ -258,7 +258,7 @@ int w_newImage(lua_State *L)
return luaL_error(L, "Could not load image.");
// Push the type.
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, image);
luax_pushtype(L, GRAPHICS_IMAGE_ID, image);
image->release();
return 1;
}
@@ -275,7 +275,7 @@ int w_newQuad(lua_State *L)
float sh = (float) luaL_checknumber(L, 6);
Quad *quad = instance()->newQuad(v, sw, sh);
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quad);
luax_pushtype(L, GRAPHICS_QUAD_ID, quad);
quad->release();
return 1;
}
@@ -285,7 +285,7 @@ int w_newFont(lua_State *L)
Font *font = nullptr;
// Convert to Rasterizer, if necessary.
if (!luax_istype(L, 1, FONT_RASTERIZER_T))
if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
{
std::vector<int> idxs;
for (int i = 0; i < lua_gettop(L); i++)
@@ -294,14 +294,14 @@ int w_newFont(lua_State *L)
luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newRasterizer");
}
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
luax_catchexcept(L, [&]() {
font = instance()->newFont(rasterizer, instance()->getDefaultFilter()); }
);
// Push the type.
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
luax_pushtype(L, GRAPHICS_FONT_ID, font);
font->release();
return 1;
}
@@ -312,32 +312,32 @@ int w_newImageFont(lua_State *L)
Texture::Filter filter = instance()->getDefaultFilter();
// Convert to ImageData if necessary.
if (luax_istype(L, 1, GRAPHICS_IMAGE_T))
if (luax_istype(L, 1, GRAPHICS_IMAGE_ID))
{
Image *i = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
Image *i = luax_checktype<Image>(L, 1, GRAPHICS_IMAGE_ID);
filter = i->getFilter();
love::image::ImageData *id = i->getImageData();
if (!id)
return luaL_argerror(L, 1, "Image must not be compressed.");
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, id);
lua_replace(L, 1);
}
// Convert to Rasterizer if necessary.
if (!luax_istype(L, 1, FONT_RASTERIZER_T))
if (!luax_istype(L, 1, FONT_RASTERIZER_ID))
{
luaL_checkstring(L, 2);
int idxs[] = {1, 2};
luax_convobj(L, idxs, 2, "font", "newImageRasterizer");
}
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, FONT_RASTERIZER_ID);
// Create the font.
Font *font = instance()->newFont(rasterizer, filter);
// Push the type.
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
luax_pushtype(L, GRAPHICS_FONT_ID, font);
font->release();
return 1;
}
@@ -359,7 +359,7 @@ int w_newSpriteBatch(lua_State *L)
[&](){ t = instance()->newSpriteBatch(texture, size, usage); }
);
luax_pushtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, t);
luax_pushtype(L, GRAPHICS_SPRITE_BATCH_ID, t);
t->release();
return 1;
}
@@ -376,7 +376,7 @@ int w_newParticleSystem(lua_State *L)
[&](){ t = instance()->newParticleSystem(texture, int(size)); }
);
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, t);
t->release();
return 1;
}
@@ -401,7 +401,7 @@ int w_newCanvas(lua_State *L)
if (canvas == nullptr)
return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, canvas);
luax_pushtype(L, GRAPHICS_CANVAS_ID, canvas);
canvas->release();
return 1;
}
@@ -492,7 +492,7 @@ int w_newShader(lua_State *L)
try
{
Shader *shader = instance()->newShader(source);
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
shader->release();
}
catch (love::Exception &e)
@@ -585,7 +585,7 @@ int w_newMesh(lua_State *L)
if (tex)
t->setTexture(tex);
luax_pushtype(L, "Mesh", GRAPHICS_MESH_T, t);
luax_pushtype(L, GRAPHICS_MESH_ID, t);
t->release();
return 1;
}
@@ -603,7 +603,7 @@ int w_newText(lua_State *L)
luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
}
luax_pushtype(L, "Text", GRAPHICS_TEXT_T, t);
luax_pushtype(L, GRAPHICS_TEXT_ID, t);
return 1;
}
@@ -682,14 +682,14 @@ int w_getBackgroundColor(lua_State *L)
int w_setNewFont(lua_State *L)
{
int ret = w_newFont(L);
Font *font = luax_checktype<Font>(L, -1, "Font", GRAPHICS_FONT_T);
Font *font = luax_checktype<Font>(L, -1, GRAPHICS_FONT_ID);
instance()->setFont(font);
return ret;
}
int w_setFont(lua_State *L)
{
Font *font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
Font *font = luax_checktype<Font>(L, 1, GRAPHICS_FONT_ID);
instance()->setFont(font);
return 0;
}
@@ -699,7 +699,7 @@ int w_getFont(lua_State *L)
Font *f = nullptr;
luax_catchexcept(L, [&](){ f = instance()->getFont(); });
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
luax_pushtype(L, GRAPHICS_FONT_ID, f);
return 1;
}
@@ -913,13 +913,13 @@ int w_isWireframe(lua_State *L)
int w_newScreenshot(lua_State *L)
{
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
love::image::Image *image = luax_getmodule<love::image::Image>(L, MODULE_IMAGE_ID);
bool copyAlpha = luax_optboolean(L, 1, false);
love::image::ImageData *i = 0;
luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
i->release();
return 1;
}
@@ -971,7 +971,7 @@ int w_getCanvas(lua_State *L)
for (Canvas *c : canvases)
{
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
luax_pushtype(L, GRAPHICS_CANVAS_ID, c);
n++;
}
@@ -1001,7 +1001,7 @@ int w_getShader(lua_State *L)
{
Shader *shader = instance()->getShader();
if (shader)
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
luax_pushtype(L, GRAPHICS_SHADER_ID, shader);
else
lua_pushnil(L);
@@ -1172,10 +1172,10 @@ int w_draw(lua_State *L)
Quad *quad = nullptr;
int startidx = 2;
if (luax_istype(L, 2, GRAPHICS_QUAD_T))
if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
{
texture = luax_checktexture(L, 1);
quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
startidx = 3;
}
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
@@ -1184,7 +1184,7 @@ int w_draw(lua_State *L)
}
else
{
drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
drawable = luax_checktype<Drawable>(L, 1, GRAPHICS_DRAWABLE_ID);
startidx = 2;
}
@@ -1595,7 +1595,7 @@ extern "C" int luaopen_love_graphics(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "graphics";
w.flags = MODULE_GRAPHICS_T;
w.type = MODULE_GRAPHICS_ID;
w.functions = functions;
w.types = types;
+4 -10
View File
@@ -30,7 +30,7 @@ namespace opengl
Image *luax_checkimage(lua_State *L, int idx)
{
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
return luax_checktype<Image>(L, idx, GRAPHICS_IMAGE_ID);
}
int w_Image_setMipmapFilter(lua_State *L)
@@ -96,18 +96,12 @@ int w_Image_getData(lua_State *L)
if (i->isCompressed())
{
love::image::CompressedData *t = i->getCompressedData();
if (t)
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
else
lua_pushnil(L);
luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
}
else
{
love::image::ImageData *t = i->getImageData();
if (t)
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
else
lua_pushnil(L);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
}
return 1;
@@ -134,7 +128,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_image(lua_State *L)
{
return luax_register_type(L, "Image", functions);
return luax_register_type(L, GRAPHICS_IMAGE_ID, functions);
}
} // opengl
+4 -4
View File
@@ -36,7 +36,7 @@ namespace opengl
Mesh *luax_checkmesh(lua_State *L, int idx)
{
return luax_checktype<Mesh>(L, idx, "Mesh", GRAPHICS_MESH_T);
return luax_checktype<Mesh>(L, idx, GRAPHICS_MESH_ID);
}
int w_Mesh_setVertex(lua_State *L)
@@ -265,9 +265,9 @@ int w_Mesh_getTexture(lua_State *L)
// FIXME: big hack right here.
if (typeid(*tex) == typeid(Image))
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
else if (typeid(*tex) == typeid(Canvas))
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
else
return luaL_error(L, "Unable to determine texture type.");
@@ -368,7 +368,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_mesh(lua_State *L)
{
return luax_register_type(L, "Mesh", functions);
return luax_register_type(L, GRAPHICS_MESH_ID, functions);
}
} // opengl
@@ -41,7 +41,7 @@ namespace opengl
ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx)
{
return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T);
return luax_checktype<ParticleSystem>(L, idx, GRAPHICS_PARTICLE_SYSTEM_ID);
}
int w_ParticleSystem_clone(lua_State *L)
@@ -51,7 +51,7 @@ int w_ParticleSystem_clone(lua_State *L)
ParticleSystem *clone = nullptr;
luax_catchexcept(L, [&](){ clone = t->clone(); });
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, clone);
luax_pushtype(L, GRAPHICS_PARTICLE_SYSTEM_ID, clone);
clone->release();
return 1;
}
@@ -71,9 +71,9 @@ int w_ParticleSystem_getTexture(lua_State *L)
// FIXME: big hack right here.
if (typeid(*tex) == typeid(Image))
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
else if (typeid(*tex) == typeid(Canvas))
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
else
return luaL_error(L, "Unable to determine texture type.");
@@ -596,7 +596,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
{
lua_rawgeti(L, 2, i);
Quad *q = luax_checktype<Quad>(L, -1, "Quad", GRAPHICS_QUAD_T);
Quad *q = luax_checktype<Quad>(L, -1, GRAPHICS_QUAD_ID);
quads.push_back(q);
lua_pop(L, 1);
@@ -606,7 +606,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
{
for (int i = 2; i <= lua_gettop(L); i++)
{
Quad *q = luax_checktype<Quad>(L, i, "Quad", GRAPHICS_QUAD_T);
Quad *q = luax_checktype<Quad>(L, i, GRAPHICS_QUAD_ID);
quads.push_back(q);
}
}
@@ -624,7 +624,7 @@ int w_ParticleSystem_getQuads(lua_State *L)
for (int i = 0; i < (int) quads.size(); i++)
{
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]);
luax_pushtype(L, GRAPHICS_QUAD_ID, quads[i]);
lua_rawseti(L, -2, i + 1);
}
@@ -784,7 +784,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_particlesystem(lua_State *L)
{
return luax_register_type(L, "ParticleSystem", functions);
return luax_register_type(L, GRAPHICS_PARTICLE_SYSTEM_ID, functions);
}
} // opengl
+3 -3
View File
@@ -32,7 +32,7 @@ namespace opengl
Shader *luax_checkshader(lua_State *L, int idx)
{
return luax_checktype<Shader>(L, idx, "Shader", GRAPHICS_SHADER_T);
return luax_checktype<Shader>(L, idx, GRAPHICS_SHADER_ID);
}
int w_Shader_getWarnings(lua_State *L)
@@ -308,7 +308,7 @@ int w_Shader_send(lua_State *L)
// Texture (Image or Canvas).
p = (Proxy *) lua_touserdata(L, 3);
if (p->flags[GRAPHICS_TEXTURE_ID])
if (typeFlags[p->type][GRAPHICS_TEXT_ID])
return w_Shader_sendTexture(L);
break;
@@ -381,7 +381,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_shader(lua_State *L)
{
return luax_register_type(L, "Shader", functions);
return luax_register_type(L, GRAPHICS_SHADER_ID, functions);
}
} // opengl
@@ -36,7 +36,7 @@ namespace opengl
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx)
{
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
return luax_checktype<SpriteBatch>(L, idx, GRAPHICS_SPRITE_BATCH_ID);
}
int w_SpriteBatch_add(lua_State *L)
@@ -45,9 +45,9 @@ int w_SpriteBatch_add(lua_State *L)
Quad *quad = nullptr;
int startidx = 2;
if (luax_istype(L, 2, GRAPHICS_QUAD_T))
if (luax_istype(L, 2, GRAPHICS_QUAD_ID))
{
quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
quad = luax_totype<Quad>(L, 2, GRAPHICS_QUAD_ID);
startidx = 3;
}
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
@@ -83,9 +83,9 @@ int w_SpriteBatch_set(lua_State *L)
Quad *quad = nullptr;
int startidx = 3;
if (luax_istype(L, 3, GRAPHICS_QUAD_T))
if (luax_istype(L, 3, GRAPHICS_QUAD_ID))
{
quad = luax_totype<Quad>(L, 3, "Quad", GRAPHICS_QUAD_T);
quad = luax_totype<Quad>(L, 3, GRAPHICS_QUAD_ID);
startidx = 4;
}
else if (lua_isnil(L, 3) && !lua_isnoneornil(L, 4))
@@ -140,9 +140,9 @@ int w_SpriteBatch_getTexture(lua_State *L)
// FIXME: big hack right here.
if (typeid(*tex) == typeid(Image))
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
else if (typeid(*tex) == typeid(Canvas))
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
else
return luaL_error(L, "Unable to determine texture type.");
@@ -241,7 +241,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_spritebatch(lua_State *L)
{
return luax_register_type(L, "SpriteBatch", functions);
return luax_register_type(L, GRAPHICS_SPRITE_BATCH_ID, functions);
}
} // opengl
@@ -33,9 +33,7 @@ namespace opengl
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx);
int w_SpriteBatch_add(lua_State *L);
int w_SpriteBatch_addg(lua_State *L);
int w_SpriteBatch_set(lua_State *L);
int w_SpriteBatch_setg(lua_State *L);
int w_SpriteBatch_clear(lua_State *L);
int w_SpriteBatch_flush(lua_State *L);
int w_SpriteBatch_setTexture(lua_State *L);
+3 -3
View File
@@ -29,7 +29,7 @@ namespace opengl
Text *luax_checktext(lua_State *L, int idx)
{
return luax_checktype<Text>(L, idx, "Text", GRAPHICS_TEXT_T);
return luax_checktype<Text>(L, idx, GRAPHICS_TEXT_ID);
}
int w_Text_set(lua_State *L)
@@ -139,7 +139,7 @@ int w_Text_getFont(lua_State *L)
{
Text *t = luax_checktext(L, 1);
Font *f = t->getFont();
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
luax_pushtype(L, GRAPHICS_FONT_ID, f);
return 1;
}
@@ -172,7 +172,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_text(lua_State *L)
{
return luax_register_type(L, "Text", functions);
return luax_register_type(L, GRAPHICS_TEXT_ID, functions);
}
} // opengl
+2 -2
View File
@@ -28,7 +28,7 @@ namespace graphics
Quad *luax_checkquad(lua_State *L, int idx)
{
return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
return luax_checktype<Quad>(L, idx, GRAPHICS_QUAD_ID);
}
int w_Quad_setViewport(lua_State *L)
@@ -73,7 +73,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_quad(lua_State *L)
{
return luax_register_type(L, "Quad", functions);
return luax_register_type(L, GRAPHICS_QUAD_ID, functions);
}
} // graphics
+1 -1
View File
@@ -27,7 +27,7 @@ namespace graphics
Texture *luax_checktexture(lua_State *L, int idx)
{
return luax_checktype<Texture>(L, idx, "Texture", GRAPHICS_TEXTURE_T);
return luax_checktype<Texture>(L, idx, GRAPHICS_TEXTURE_ID);
}
int w_Texture_getWidth(lua_State *L)
+2 -2
View File
@@ -28,7 +28,7 @@ namespace image
CompressedData *luax_checkcompresseddata(lua_State *L, int idx)
{
return luax_checktype<CompressedData>(L, idx, "CompressedData", IMAGE_COMPRESSED_DATA_T);
return luax_checktype<CompressedData>(L, idx, IMAGE_COMPRESSED_DATA_ID);
}
int w_CompressedData_getWidth(lua_State *L)
@@ -111,7 +111,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_compresseddata(lua_State *L)
{
return luax_register_type(L, "CompressedData", functions);
return luax_register_type(L, IMAGE_COMPRESSED_DATA_ID, functions);
}
} // image
+4 -4
View File
@@ -47,7 +47,7 @@ int w_newImageData(lua_State *L)
ImageData *t = nullptr;
luax_catchexcept(L, [&](){ t = instance()->newImageData(w, h); });
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
t->release();
return 1;
}
@@ -61,7 +61,7 @@ int w_newImageData(lua_State *L)
[&]() { data->release(); }
);
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
t->release();
return 1;
}
@@ -76,7 +76,7 @@ int w_newCompressedData(lua_State *L)
[&]() { data->release(); }
);
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
luax_pushtype(L, IMAGE_COMPRESSED_DATA_ID, t);
t->release();
return 1;
}
@@ -120,7 +120,7 @@ extern "C" int luaopen_love_image(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "image";
w.flags = MODULE_IMAGE_T;
w.type = MODULE_IMAGE_ID;
w.functions = functions;
w.types = types;
+3 -3
View File
@@ -30,7 +30,7 @@ namespace image
ImageData *luax_checkimagedata(lua_State *L, int idx)
{
return luax_checktype<ImageData>(L, idx, "ImageData", IMAGE_IMAGE_DATA_T);
return luax_checktype<ImageData>(L, idx, IMAGE_IMAGE_DATA_ID);
}
int w_ImageData_getWidth(lua_State *L)
@@ -245,7 +245,7 @@ int w_ImageData_encode(lua_State *L)
if (lua_isstring(L, 2))
luax_convobj(L, 2, "filesystem", "newFile");
love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T);
love::filesystem::File *file = luax_checktype<love::filesystem::File>(L, 2, FILESYSTEM_FILE_ID);
if (lua_isnoneornil(L, 3))
{
@@ -285,7 +285,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_imagedata(lua_State *L)
{
return luax_register_type(L, "ImageData", functions);
return luax_register_type(L, IMAGE_IMAGE_DATA_ID, functions);
}
} // image
+2 -2
View File
@@ -31,7 +31,7 @@ namespace joystick
Joystick *luax_checkjoystick(lua_State *L, int idx)
{
return luax_checktype<Joystick>(L, idx, "Joystick", JOYSTICK_JOYSTICK_T);
return luax_checktype<Joystick>(L, idx, JOYSTICK_JOYSTICK_ID);
}
int w_Joystick_isConnected(lua_State *L)
@@ -255,7 +255,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_joystick(lua_State *L)
{
return luax_register_type(L, "Joystick", functions);
return luax_register_type(L, JOYSTICK_JOYSTICK_ID, functions);
}
} // joystick
+2 -2
View File
@@ -40,7 +40,7 @@ int w_getJoysticks(lua_State *L)
for (int i = 0; i < stickcount; i++)
{
Joystick *stick = instance()->getJoystick(i);
luax_pushtype(L, "Joystick", JOYSTICK_JOYSTICK_T, stick);
luax_pushtype(L, JOYSTICK_JOYSTICK_ID, stick);
lua_rawseti(L, -2, i + 1);
}
@@ -254,7 +254,7 @@ extern "C" int luaopen_love_joystick(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "joystick";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
+1 -1
View File
@@ -169,7 +169,7 @@ extern "C" int luaopen_love_keyboard(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "keyboard";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = 0;
+3 -3
View File
@@ -30,7 +30,7 @@ namespace math
BezierCurve *luax_checkbeziercurve(lua_State *L, int idx)
{
return luax_checktype<BezierCurve>(L, idx, "BezierCurve", MATH_BEZIER_CURVE_T);
return luax_checktype<BezierCurve>(L, idx, MATH_BEZIER_CURVE_ID);
}
int w_BezierCurve_getDegree(lua_State *L)
@@ -44,7 +44,7 @@ int w_BezierCurve_getDerivative(lua_State *L)
{
BezierCurve *curve = luax_checkbeziercurve(L, 1);
BezierCurve *deriv = new BezierCurve(curve->getDerivative());
luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, deriv);
luax_pushtype(L, MATH_BEZIER_CURVE_ID, deriv);
deriv->release();
return 1;
}
@@ -183,7 +183,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_beziercurve(lua_State *L)
{
return luax_register_type(L, "BezierCurve", functions);
return luax_register_type(L, MATH_BEZIER_CURVE_ID, functions);
}
} // math
+3 -3
View File
@@ -100,7 +100,7 @@ int w_newRandomGenerator(lua_State *L)
return luaL_error(L, "%s", lua_tostring(L, -1));
}
luax_pushtype(L, "RandomGenerator", MATH_RANDOM_GENERATOR_T, t);
luax_pushtype(L, MATH_RANDOM_GENERATOR_ID, t);
t->release();
return 1;
}
@@ -139,7 +139,7 @@ int w_newBezierCurve(lua_State *L)
}
BezierCurve *curve = Math::instance.newBezierCurve(points);
luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, curve);
luax_pushtype(L, MATH_BEZIER_CURVE_ID, curve);
curve->release();
return 1;
}
@@ -384,7 +384,7 @@ extern "C" int luaopen_love_math(lua_State *L)
WrappedModule w;
w.module = &Math::instance;
w.name = "math";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
+2 -2
View File
@@ -84,7 +84,7 @@ int luax_getrandom(lua_State *L, int startidx, double r)
RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx)
{
return luax_checktype<RandomGenerator>(L, idx, "RandomGenerator", MATH_RANDOM_GENERATOR_T);
return luax_checktype<RandomGenerator>(L, idx, MATH_RANDOM_GENERATOR_ID);
}
int w_RandomGenerator_random(lua_State *L)
@@ -148,7 +148,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_randomgenerator(lua_State *L)
{
return luax_register_type(L, "RandomGenerator", functions);
return luax_register_type(L, MATH_RANDOM_GENERATOR_ID, functions);
}
} // math
+2 -2
View File
@@ -28,7 +28,7 @@ namespace mouse
Cursor *luax_checkcursor(lua_State *L, int idx)
{
return luax_checktype<Cursor>(L, idx, "Cursor", MOUSE_CURSOR_T);
return luax_checktype<Cursor>(L, idx, MOUSE_CURSOR_ID);
}
int w_Cursor_getType(lua_State *L)
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_cursor(lua_State *L)
{
return luax_register_type(L, "Cursor", functions);
return luax_register_type(L, MOUSE_CURSOR_ID, functions);
}
} // mouse
+6 -6
View File
@@ -36,16 +36,16 @@ int w_newCursor(lua_State *L)
{
Cursor *cursor = nullptr;
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
luax_convobj(L, 1, "image", "newImageData");
love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
int hotx = luaL_optint(L, 2, 0);
int hoty = luaL_optint(L, 3, 0);
luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
cursor->release();
return 1;
}
@@ -61,7 +61,7 @@ int w_getSystemCursor(lua_State *L)
Cursor *cursor = 0;
luax_catchexcept(L, [&](){ cursor = instance()->getSystemCursor(systemCursor); });
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
return 1;
}
@@ -84,7 +84,7 @@ int w_getCursor(lua_State *L)
Cursor *cursor = instance()->getCursor();
if (cursor)
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
luax_pushtype(L, MOUSE_CURSOR_ID, cursor);
else
lua_pushnil(L);
@@ -242,7 +242,7 @@ extern "C" int luaopen_love_mouse(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "mouse";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
+2 -2
View File
@@ -435,7 +435,7 @@ int Body::getFixtureList(lua_State *L) const
Fixture *fixture = (Fixture *)Memoizer::find(f);
if (!fixture)
throw love::Exception("A fixture has escaped Memoizer!");
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
luax_pushtype(L, PHYSICS_FIXTURE_ID, fixture);
lua_rawseti(L, -2, i);
i++;
}
@@ -483,7 +483,7 @@ int Body::getContactList(lua_State *L) const
else
contact->retain();
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
contact->release();
lua_rawseti(L, -2, i);
i++;
+4 -4
View File
@@ -146,7 +146,7 @@ int Physics::newPolygonShape(lua_State *L)
}
PolygonShape *p = new PolygonShape(s);
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, p);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, p);
p->release();
return 1;
}
@@ -208,7 +208,7 @@ int Physics::newChainShape(lua_State *L)
delete[] vecs;
ChainShape *c = new ChainShape(s);
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, c);
c->release();
return 1;
}
@@ -281,8 +281,8 @@ Fixture *Physics::newFixture(Body *body, Shape *shape, float density)
int Physics::getDistance(lua_State *L)
{
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, "Fixture", PHYSICS_FIXTURE_T);
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, PHYSICS_FIXTURE_ID);
b2DistanceProxy pA, pB;
b2DistanceInput i;
b2DistanceOutput o;
+10 -10
View File
@@ -57,7 +57,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
{
Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
if (a != 0)
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
else
throw love::Exception("A fixture has escaped Memoizer!");
}
@@ -66,7 +66,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
{
Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
if (b != 0)
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
else
throw love::Exception("A fixture has escaped Memoizer!");
}
@@ -77,7 +77,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
else
cobj->retain();
luax_pushtype(L, "Contact", (PHYSICS_CONTACT_T), cobj);
luax_pushtype(L, PHYSICS_CONTACT_ID, cobj);
cobj->release();
int args = 3;
@@ -128,8 +128,8 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b)
{
lua_State *L = ref->getL();
ref->push();
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
lua_call(L, 2, 1);
return luax_toboolean(L, -1);
}
@@ -156,7 +156,7 @@ bool World::QueryCallback::ReportFixture(b2Fixture *fixture)
Fixture *f = (Fixture *)Memoizer::find(fixture);
if (!f)
throw love::Exception("A fixture has escaped Memoizer!");
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
lua_call(L, 1, 1);
return luax_toboolean(L, -1);
}
@@ -183,7 +183,7 @@ float32 World::RayCastCallback::ReportFixture(b2Fixture *fixture, const b2Vec2 &
Fixture *f = (Fixture *)Memoizer::find(fixture);
if (!f)
throw love::Exception("A fixture has escaped Memoizer!");
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
b2Vec2 scaledPoint = Physics::scaleUp(point);
lua_pushnumber(L, scaledPoint.x);
lua_pushnumber(L, scaledPoint.y);
@@ -431,7 +431,7 @@ int World::getBodyList(lua_State *L) const
Body *body = (Body *)Memoizer::find(b);
if (!body)
throw love::Exception("A body has escaped Memoizer!");
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
luax_pushtype(L, PHYSICS_BODY_ID, body);
lua_rawseti(L, -2, i);
i++;
}
@@ -449,7 +449,7 @@ int World::getJointList(lua_State *L) const
if (!j) break;
Joint *joint = (Joint *)Memoizer::find(j);
if (!joint) throw love::Exception("A joint has escaped Memoizer!");
luax_pushtype(L, "Joint", PHYSICS_JOINT_T, joint);
luax_pushtype(L, PHYSICS_JOINT_ID, joint);
lua_rawseti(L, -2, i);
i++;
}
@@ -470,7 +470,7 @@ int World::getContactList(lua_State *L) const
contact = new Contact(c);
else
contact->retain();
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
contact->release();
lua_rawseti(L, -2, i);
i++;
+4 -4
View File
@@ -30,7 +30,7 @@ namespace box2d
Body *luax_checkbody(lua_State *L, int idx)
{
Body *b = luax_checktype<Body>(L, idx, "Body", PHYSICS_BODY_T);
Body *b = luax_checktype<Body>(L, idx, PHYSICS_BODY_ID);
if (b->body == 0)
luaL_error(L, "Attempt to use destroyed body.");
return b;
@@ -526,7 +526,7 @@ int w_Body_getWorld(lua_State *L)
{
Body *t = luax_checkbody(L, 1);
World *world = t->getWorld();
luax_pushtype(L, "World", PHYSICS_WORLD_T, world);
luax_pushtype(L, PHYSICS_WORLD_ID, world);
return 1;
}
@@ -566,7 +566,7 @@ int w_Body_destroy(lua_State *L)
int w_Body_isDestroyed(lua_State *L)
{
Body *b = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *b = luax_checktype<Body>(L, 1, PHYSICS_BODY_ID);
luax_pushboolean(L, b->body == nullptr);
return 1;
}
@@ -650,7 +650,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_body(lua_State *L)
{
return luax_register_type(L, "Body", functions);
return luax_register_type(L, PHYSICS_BODY_ID, functions);
}
} // box2d
@@ -31,7 +31,7 @@ namespace box2d
ChainShape *luax_checkchainshape(lua_State *L, int idx)
{
return luax_checktype<ChainShape>(L, idx, "ChainShape", PHYSICS_CHAIN_SHAPE_T);
return luax_checktype<ChainShape>(L, idx, PHYSICS_CHAIN_SHAPE_ID);
}
int w_ChainShape_setNextVertex(lua_State *L)
@@ -65,7 +65,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
EdgeShape *e = 0;
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, e);
e->release();
return 1;
}
@@ -127,7 +127,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_chainshape(lua_State *L)
{
return luax_register_type(L, "ChainShape", functions);
return luax_register_type(L, PHYSICS_CHAIN_SHAPE_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
CircleShape *luax_checkcircleshape(lua_State *L, int idx)
{
return luax_checktype<CircleShape>(L, idx, "CircleShape", PHYSICS_CIRCLE_SHAPE_T);
return luax_checktype<CircleShape>(L, idx, PHYSICS_CIRCLE_SHAPE_ID);
}
int w_CircleShape_getRadius(lua_State *L)
@@ -83,7 +83,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_circleshape(lua_State *L)
{
return luax_register_type(L, "CircleShape", functions);
return luax_register_type(L, PHYSICS_CIRCLE_SHAPE_ID, functions);
}
} // box2d
+5 -5
View File
@@ -30,7 +30,7 @@ namespace box2d
Contact *luax_checkcontact(lua_State *L, int idx)
{
Contact *c = luax_checktype<Contact>(L, idx, "Contact", PHYSICS_CONTACT_T);
Contact *c = luax_checktype<Contact>(L, idx, PHYSICS_CONTACT_ID);
if (!c->isValid())
luaL_error(L, "Attempt to use destroyed contact.");
return c;
@@ -146,14 +146,14 @@ int w_Contact_getFixtures(lua_State *L)
Fixture *b = nullptr;
luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
return 2;
}
int w_Contact_isDestroyed(lua_State *L)
{
Contact *c = luax_checktype<Contact>(L, 1, "Contact", PHYSICS_CONTACT_T);
Contact *c = luax_checktype<Contact>(L, 1, PHYSICS_CONTACT_ID);
luax_pushboolean(L, !c->isValid());
return 1;
}
@@ -181,7 +181,7 @@ extern "C" int luaopen_contact(lua_State *L)
{ 0, 0 }
};
return luax_register_type(L, "Contact", functions);
return luax_register_type(L, PHYSICS_CONTACT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx)
{
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T);
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, PHYSICS_DISTANCE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -104,7 +104,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_distancejoint(lua_State *L)
{
return luax_register_type(L, "DistanceJoint", functions);
return luax_register_type(L, PHYSICS_DISTANCE_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -29,7 +29,7 @@ namespace box2d
EdgeShape *luax_checkedgeshape(lua_State *L, int idx)
{
return luax_checktype<EdgeShape>(L, idx, "EdgeShape", PHYSICS_EDGE_SHAPE_T);
return luax_checktype<EdgeShape>(L, idx, PHYSICS_EDGE_SHAPE_ID);
}
int w_EdgeShape_getPoints(lua_State *L)
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_edgeshape(lua_State *L)
{
return luax_register_type(L, "EdgeShape", functions);
return luax_register_type(L, PHYSICS_EDGE_SHAPE_ID, functions);
}
} // box2d
+9 -9
View File
@@ -30,7 +30,7 @@ namespace box2d
Fixture *luax_checkfixture(lua_State *L, int idx)
{
Fixture *f = luax_checktype<Fixture>(L, idx, "Fixture", PHYSICS_FIXTURE_T);
Fixture *f = luax_checktype<Fixture>(L, idx, PHYSICS_FIXTURE_ID);
if (!f->isValid())
luaL_error(L, "Attempt to use destroyed fixture.");
return f;
@@ -111,7 +111,7 @@ int w_Fixture_getBody(lua_State *L)
Body *body = t->getBody();
if (body == 0)
return 0;
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
luax_pushtype(L, PHYSICS_BODY_ID, body);
return 1;
}
@@ -124,19 +124,19 @@ int w_Fixture_getShape(lua_State *L)
switch (shape->getType())
{
case Shape::SHAPE_EDGE:
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
break;
case Shape::SHAPE_CHAIN:
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, shape);
break;
case Shape::SHAPE_CIRCLE:
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
break;
case Shape::SHAPE_POLYGON:
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
break;
default:
luax_pushtype(L, "Shape", PHYSICS_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_SHAPE_ID, shape);
break;
}
shape->release();
@@ -264,7 +264,7 @@ int w_Fixture_destroy(lua_State *L)
int w_Fixture_isDestroyed(lua_State *L)
{
Fixture *f = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
Fixture *f = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
luax_pushboolean(L, !f->isValid());
return 1;
}
@@ -303,7 +303,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_fixture(lua_State *L)
{
return luax_register_type(L, "Fixture", functions);
return luax_register_type(L, PHYSICS_FIXTURE_ID, functions);
}
} // box2d
@@ -30,7 +30,7 @@ namespace box2d
FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx)
{
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, "FrictionJoint", PHYSICS_FRICTION_JOINT_T);
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, PHYSICS_FRICTION_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_frictionjoint(lua_State *L)
{
return luax_register_type(L, "FrictionJoint", functions);
return luax_register_type(L, PHYSICS_FRICTION_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -30,7 +30,7 @@ namespace box2d
GearJoint *luax_checkgearjoint(lua_State *L, int idx)
{
GearJoint *j = luax_checktype<GearJoint>(L, idx, "GearJoint", PHYSICS_GEAR_JOINT_T);
GearJoint *j = luax_checktype<GearJoint>(L, idx, PHYSICS_GEAR_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_gearjoint(lua_State *L)
{
return luax_register_type(L, "GearJoint", functions);
return luax_register_type(L, PHYSICS_GEAR_JOINT_ID, functions);
}
} // box2d
+16 -16
View File
@@ -38,27 +38,27 @@ void luax_pushjoint(lua_State *L, Joint *j)
switch (j->getType())
{
case Joint::JOINT_DISTANCE:
return luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
case Joint::JOINT_REVOLUTE:
return luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
case Joint::JOINT_PRISMATIC:
return luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
return luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
case Joint::JOINT_MOUSE:
return luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
case Joint::JOINT_PULLEY:
return luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
return luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
case Joint::JOINT_GEAR:
return luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
return luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
case Joint::JOINT_FRICTION:
return luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
return luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
case Joint::JOINT_WELD:
return luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
return luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
case Joint::JOINT_WHEEL:
return luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
return luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
case Joint::JOINT_ROPE:
return luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
case Joint::JOINT_MOTOR:
return luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
return luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
default:
return lua_pushnil(L);
}
@@ -66,7 +66,7 @@ void luax_pushjoint(lua_State *L, Joint *j)
Joint *luax_checkjoint(lua_State *L, int idx)
{
Joint *t = luax_checktype<Joint>(L, idx, "Joint", PHYSICS_JOINT_T);
Joint *t = luax_checktype<Joint>(L, idx, PHYSICS_JOINT_ID);
if (!t->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return t;
@@ -92,8 +92,8 @@ int w_Joint_getBodies(lua_State *L)
b2 = t->getBodyB();
});
luax_pushtype(L, "Body", PHYSICS_BODY_T, b1);
luax_pushtype(L, "Body", PHYSICS_BODY_T, b2);
luax_pushtype(L, PHYSICS_BODY_ID, b1);
luax_pushtype(L, PHYSICS_BODY_ID, b2);
return 2;
}
@@ -149,7 +149,7 @@ int w_Joint_destroy(lua_State *L)
int w_Joint_isDestroyed(lua_State *L)
{
Joint *t = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
Joint *t = luax_checktype<Joint>(L, 1, PHYSICS_JOINT_ID);
luax_pushboolean(L, !t->isValid());
return 1;
}
@@ -171,7 +171,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_joint(lua_State *L)
{
return luax_register_type(L, "Joint", functions);
return luax_register_type(L, PHYSICS_JOINT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
{
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, "MotorJoint", PHYSICS_MOTOR_JOINT_T);
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, PHYSICS_MOTOR_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -138,7 +138,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_motorjoint(lua_State *L)
{
return luax_register_type(L, "MotorJoint", functions);
return luax_register_type(L, PHYSICS_MOTOR_JOINT_ID, functions);
}
@@ -29,7 +29,7 @@ namespace box2d
MouseJoint *luax_checkmousejoint(lua_State *L, int idx)
{
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, "MouseJoint", PHYSICS_MOUSE_JOINT_T);
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, PHYSICS_MOUSE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -122,7 +122,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_mousejoint(lua_State *L)
{
return luax_register_type(L, "MouseJoint", functions);
return luax_register_type(L, PHYSICS_MOUSE_JOINT_ID, functions);
}
} // box2d
+42 -42
View File
@@ -59,7 +59,7 @@ int w_newWorld(lua_State *L)
World *w;
luax_catchexcept(L, [&](){ w = instance()->newWorld(gx, gy, sleep); });
luax_pushtype(L, "World", PHYSICS_WORLD_T, w);
luax_pushtype(L, PHYSICS_WORLD_ID, w);
w->release();
return 1;
@@ -67,7 +67,7 @@ int w_newWorld(lua_State *L)
int w_newBody(lua_State *L)
{
World *world = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
World *world = luax_checkworld(L, 1);
float x = (float)luaL_optnumber(L, 2, 0.0);
float y = (float)luaL_optnumber(L, 3, 0.0);
@@ -78,7 +78,7 @@ int w_newBody(lua_State *L)
Body *body;
luax_catchexcept(L, [&](){ body = instance()->newBody(world, x, y, btype); });
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
luax_pushtype(L, PHYSICS_BODY_ID, body);
body->release();
return 1;
}
@@ -90,7 +90,7 @@ int w_newFixture(lua_State *L)
float density = (float)luaL_optnumber(L, 3, 1.0f);
Fixture *fixture;
luax_catchexcept(L, [&](){ fixture = instance()->newFixture(body, shape, density); });
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
luax_pushtype(L, PHYSICS_FIXTURE_ID, fixture);
fixture->release();
return 1;
}
@@ -104,7 +104,7 @@ int w_newCircleShape(lua_State *L)
float radius = (float)luaL_checknumber(L, 1);
CircleShape *shape;
luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(radius); });
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
shape->release();
return 1;
}
@@ -115,7 +115,7 @@ int w_newCircleShape(lua_State *L)
float radius = (float)luaL_checknumber(L, 3);
CircleShape *shape;
luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(x, y, radius); });
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
shape->release();
return 1;
}
@@ -133,7 +133,7 @@ int w_newRectangleShape(lua_State *L)
float h = (float)luaL_checknumber(L, 2);
PolygonShape *shape;
luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(w, h); });
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
shape->release();
return 1;
}
@@ -146,7 +146,7 @@ int w_newRectangleShape(lua_State *L)
float angle = (float)luaL_optnumber(L, 5, 0);
PolygonShape *shape;
luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(x, y, w, h, angle); });
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
shape->release();
return 1;
}
@@ -162,7 +162,7 @@ int w_newEdgeShape(lua_State *L)
float y2 = (float)luaL_checknumber(L, 4);
EdgeShape *shape;
luax_catchexcept(L, [&](){ shape = instance()->newEdgeShape(x1, y1, x2, y2); });
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
shape->release();
return 1;
}
@@ -183,8 +183,8 @@ int w_newChainShape(lua_State *L)
int w_newDistanceJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float x1 = (float)luaL_checknumber(L, 3);
float y1 = (float)luaL_checknumber(L, 4);
float x2 = (float)luaL_checknumber(L, 5);
@@ -194,27 +194,27 @@ int w_newDistanceJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
});
luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
j->release();
return 1;
}
int w_newMouseJoint(lua_State *L)
{
Body *body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body = luax_checkbody(L, 1);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
MouseJoint *j;
luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
j->release();
return 1;
}
int w_newRevoluteJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float x = (float)luaL_checknumber(L, 3);
float y = (float)luaL_checknumber(L, 4);
bool collideConnected = luax_optboolean(L, 5, false);
@@ -222,15 +222,15 @@ int w_newRevoluteJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected);
});
luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
j->release();
return 1;
}
int w_newPrismaticJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB, ax, ay;
@@ -255,15 +255,15 @@ int w_newPrismaticJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
});
luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
j->release();
return 1;
}
int w_newPulleyJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float gx1 = (float)luaL_checknumber(L, 3);
float gy1 = (float)luaL_checknumber(L, 4);
float gx2 = (float)luaL_checknumber(L, 5);
@@ -279,15 +279,15 @@ int w_newPulleyJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected);
});
luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
j->release();
return 1;
}
int w_newGearJoint(lua_State *L)
{
Joint *joint1 = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
Joint *joint2 = luax_checktype<Joint>(L, 2, "Joint", PHYSICS_JOINT_T);
Joint *joint1 = luax_checkjoint(L, 1);
Joint *joint2 = luax_checkjoint(L, 2);
float ratio = (float)luaL_optnumber(L, 3, 1.0);
bool collideConnected = luax_optboolean(L, 4, false);
@@ -295,15 +295,15 @@ int w_newGearJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
});
luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
j->release();
return 1;
}
int w_newFrictionJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB;
@@ -324,15 +324,15 @@ int w_newFrictionJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
});
luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
j->release();
return 1;
}
int w_newWeldJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB;
@@ -353,15 +353,15 @@ int w_newWeldJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
});
luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
j->release();
return 1;
}
int w_newWheelJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB, ax, ay;
@@ -387,15 +387,15 @@ int w_newWheelJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
});
luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
j->release();
return 1;
}
int w_newRopeJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float x1 = (float)luaL_checknumber(L, 3);
float y1 = (float)luaL_checknumber(L, 4);
float x2 = (float)luaL_checknumber(L, 5);
@@ -406,15 +406,15 @@ int w_newRopeJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
});
luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
j->release();
return 1;
}
int w_newMotorJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
MotorJoint *j = 0;
if (!lua_isnoneornil(L, 3))
{
@@ -427,7 +427,7 @@ int w_newMotorJoint(lua_State *L)
{
luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
}
luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
j->release();
return 1;
}
@@ -517,7 +517,7 @@ extern "C" int luaopen_love_physics(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "physics";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
@@ -29,7 +29,7 @@ namespace box2d
PolygonShape *luax_checkpolygonshape(lua_State *L, int idx)
{
return luax_checktype<PolygonShape>(L, idx, "PolygonShape", PHYSICS_POLYGON_SHAPE_T);
return luax_checktype<PolygonShape>(L, idx, PHYSICS_POLYGON_SHAPE_ID);
}
int w_PolygonShape_getPoints(lua_State *L)
@@ -63,7 +63,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_polygonshape(lua_State *L)
{
return luax_register_type(L, "PolygonShape", functions);
return luax_register_type(L, PHYSICS_POLYGON_SHAPE_ID, functions);
}
} // box2d
@@ -30,7 +30,7 @@ namespace box2d
PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx)
{
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, PHYSICS_PRISMATIC_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_prismaticjoint(lua_State *L)
{
return luax_register_type(L, "PrismaticJoint", functions);
return luax_register_type(L, PHYSICS_PRISMATIC_JOINT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx)
{
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, "PulleyJoint", PHYSICS_PULLEY_JOINT_T);
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, PHYSICS_PULLEY_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -85,7 +85,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_pulleyjoint(lua_State *L)
{
return luax_register_type(L, "PulleyJoint", functions);
return luax_register_type(L, PHYSICS_PULLEY_JOINT_ID, functions);
}
} // box2d
@@ -30,7 +30,7 @@ namespace box2d
RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx)
{
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T);
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, PHYSICS_REVOLUTE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_revolutejoint(lua_State *L)
{
return luax_register_type(L, "RevoluteJoint", functions);
return luax_register_type(L, PHYSICS_REVOLUTE_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -29,7 +29,7 @@ namespace box2d
RopeJoint *luax_checkropejoint(lua_State *L, int idx)
{
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, "RopeJoint", PHYSICS_ROPE_JOINT_T);
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, PHYSICS_ROPE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_ropejoint(lua_State *L)
{
return luax_register_type(L, "RopeJoint", functions);
return luax_register_type(L, PHYSICS_ROPE_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -30,7 +30,7 @@ namespace box2d
Shape *luax_checkshape(lua_State *L, int idx)
{
return luax_checktype<Shape>(L, idx, "Shape", PHYSICS_SHAPE_T);
return luax_checktype<Shape>(L, idx, PHYSICS_SHAPE_ID);
}
int w_Shape_getType(lua_State *L)
@@ -108,7 +108,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_shape(lua_State *L)
{
return luax_register_type(L, "Shape", functions);
return luax_register_type(L, PHYSICS_SHAPE_ID, functions);
}
} // box2d
+2 -2
View File
@@ -29,7 +29,7 @@ namespace box2d
WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
{
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, "WeldJoint", PHYSICS_WELD_JOINT_T);
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, PHYSICS_WELD_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -87,7 +87,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_weldjoint(lua_State *L)
{
return luax_register_type(L, "WeldJoint", functions);
return luax_register_type(L, PHYSICS_WELD_JOINT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
WheelJoint *luax_checkwheeljoint(lua_State *L, int idx)
{
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, "WheelJoint", PHYSICS_WHEEL_JOINT_T);
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, PHYSICS_WHEEL_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -163,7 +163,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_wheeljoint(lua_State *L)
{
return luax_register_type(L, "WheelJoint", functions);
return luax_register_type(L, PHYSICS_WHEEL_JOINT_ID, functions);
}
} // box2d
+3 -3
View File
@@ -29,7 +29,7 @@ namespace box2d
World *luax_checkworld(lua_State *L, int idx)
{
World *w = luax_checktype<World>(L, idx, "World", PHYSICS_WORLD_T);
World *w = luax_checktype<World>(L, idx, PHYSICS_WORLD_ID);
if (!w->isValid())
luaL_error(L, "Attempt to use destroyed world.");
return w;
@@ -191,7 +191,7 @@ int w_World_destroy(lua_State *L)
int w_World_isDestroyed(lua_State *L)
{
World *w = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
World *w = luax_checktype<World>(L, 1, PHYSICS_WORLD_ID);
luax_pushboolean(L, !w->isValid());
return 1;
}
@@ -225,7 +225,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_world(lua_State *L)
{
return luax_register_type(L, "World", functions);
return luax_register_type(L, PHYSICS_WORLD_ID, functions);
}
} // box2d
+2 -2
View File
@@ -27,7 +27,7 @@ namespace sound
Decoder *luax_checkdecoder(lua_State *L, int idx)
{
return luax_checktype<Decoder>(L, idx, "Decoder", SOUND_DECODER_T);
return luax_checktype<Decoder>(L, idx, SOUND_DECODER_ID);
}
int w_Decoder_getChannels(lua_State *L)
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_decoder(lua_State *L)
{
return luax_register_type(L, "Decoder", functions);
return luax_register_type(L, SOUND_DECODER_ID, functions);
}
} // sound
+4 -4
View File
@@ -49,7 +49,7 @@ int w_newSoundData(lua_State *L)
else
{
// Convert to Decoder, if necessary.
if (!luax_istype(L, 1, SOUND_DECODER_T))
if (!luax_istype(L, 1, SOUND_DECODER_ID))
{
w_newDecoder(L);
lua_replace(L, 1);
@@ -58,7 +58,7 @@ int w_newSoundData(lua_State *L)
luax_catchexcept(L, [&](){ t = instance()->newSoundData(luax_checkdecoder(L, 1)); });
}
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, t);
luax_pushtype(L, SOUND_SOUND_DATA_ID, t);
t->release();
return 1;
}
@@ -77,7 +77,7 @@ int w_newDecoder(lua_State *L)
if (t == nullptr)
return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str());
luax_pushtype(L, "Decoder", SOUND_DECODER_T, t);
luax_pushtype(L, SOUND_DECODER_ID, t);
t->release();
return 1;
}
@@ -111,7 +111,7 @@ extern "C" int luaopen_love_sound(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "sound";
w.flags = MODULE_SOUND_T;
w.type = MODULE_SOUND_ID;
w.functions = functions;
w.types = types;
+2 -2
View File
@@ -29,7 +29,7 @@ namespace sound
SoundData *luax_checksounddata(lua_State *L, int idx)
{
return luax_checktype<SoundData>(L, idx, "SoundData", SOUND_SOUND_DATA_T);
return luax_checktype<SoundData>(L, idx, SOUND_SOUND_DATA_ID);
}
int w_SoundData_getChannels(lua_State *L)
@@ -105,7 +105,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_sounddata(lua_State *L)
{
return luax_register_type(L, "SoundData", functions);
return luax_register_type(L, SOUND_SOUND_DATA_ID, functions);
}
} // sound
+1 -1
View File
@@ -110,7 +110,7 @@ extern "C" int luaopen_love_system(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "system";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = nullptr;
+1 -1
View File
@@ -109,7 +109,7 @@ void LuaThread::onError()
return;
Proxy p;
p.flags = THREAD_THREAD_T;
p.type = THREAD_THREAD_ID;
p.object = this;
std::vector<StrongRef<Variant>> vargs = {
+2 -2
View File
@@ -40,7 +40,7 @@ void releaseVariant(Channel *c, Variant *v)
Channel *luax_checkchannel(lua_State *L, int idx)
{
return luax_checktype<Channel>(L, idx, "Channel", THREAD_CHANNEL_T);
return luax_checktype<Channel>(L, idx, THREAD_CHANNEL_ID);
}
int w_Channel_push(lua_State *L)
@@ -129,7 +129,7 @@ static const luaL_Reg type_functions[] = {
extern "C" int luaopen_channel(lua_State *L)
{
return luax_register_type(L, "Channel", type_functions);
return luax_register_type(L, THREAD_CHANNEL_ID, type_functions);
}
}
}
+2 -2
View File
@@ -27,7 +27,7 @@ namespace thread
LuaThread *luax_checkthread(lua_State *L, int idx)
{
return luax_checktype<LuaThread>(L, idx, "Thread", THREAD_THREAD_T);
return luax_checktype<LuaThread>(L, idx, THREAD_THREAD_ID);
}
int w_Thread_start(lua_State *L)
@@ -91,7 +91,7 @@ static const luaL_Reg type_functions[] = {
extern "C" int luaopen_thread(lua_State *L)
{
return luax_register_type(L, "Thread", type_functions);
return luax_register_type(L, THREAD_THREAD_ID, type_functions);
}
} // thread
+8 -8
View File
@@ -61,22 +61,22 @@ int w_newThread(lua_State *L)
else
luax_convobj(L, 1, "filesystem", "newFileData");
}
else if (luax_istype(L, 1, FILESYSTEM_FILE_T))
else if (luax_istype(L, 1, FILESYSTEM_FILE_ID))
luax_convobj(L, 1, "filesystem", "newFileData");
if (luax_istype(L, 1, FILESYSTEM_FILE_DATA_T))
if (luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
{
love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, "FileData", FILESYSTEM_FILE_DATA_T);
love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, FILESYSTEM_FILE_DATA_ID);
name = std::string("@") + fdata->getFilename();
data = fdata;
}
else
{
data = luax_checktype<love::Data>(L, 1, "Data", DATA_T);
data = luax_checktype<love::Data>(L, 1, DATA_ID);
}
LuaThread *t = instance()->newThread(name, data);
luax_pushtype(L, "Thread", THREAD_THREAD_T, t);
luax_pushtype(L, THREAD_THREAD_ID, t);
t->release();
return 1;
}
@@ -84,7 +84,7 @@ int w_newThread(lua_State *L)
int w_newChannel(lua_State *L)
{
Channel *c = instance()->newChannel();
luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
luax_pushtype(L, THREAD_CHANNEL_ID, c);
c->release();
return 1;
}
@@ -93,7 +93,7 @@ int w_getChannel(lua_State *L)
{
std::string name = luax_checkstring(L, 1);
Channel *c = instance()->getChannel(name);
luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
luax_pushtype(L, THREAD_CHANNEL_ID, c);
c->release();
return 1;
}
@@ -125,7 +125,7 @@ extern "C" int luaopen_love_thread(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "thread";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = module_functions;
w.types = types;
+1 -1
View File
@@ -94,7 +94,7 @@ extern "C" int luaopen_love_timer(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "timer";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = 0;
+1 -1
View File
@@ -90,7 +90,7 @@ extern "C" int luaopen_love_touch(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "touch";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = nullptr;
+3 -6
View File
@@ -292,7 +292,7 @@ int w_getPosition(lua_State *L)
int w_setIcon(lua_State *L)
{
image::ImageData *i = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
image::ImageData *i = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
luax_pushboolean(L, instance()->setIcon(i));
return 1;
}
@@ -300,10 +300,7 @@ int w_setIcon(lua_State *L)
int w_getIcon(lua_State *L)
{
image::ImageData *i = instance()->getIcon();
if (i)
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
else
lua_pushnil(L);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, i);
return 1;
}
@@ -500,7 +497,7 @@ extern "C" int luaopen_love_window(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "window";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = 0;