mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Automatically deduce the type in luax_checktype, luax_getmodule, luax_optmodule and luax_totype
--HG-- branch : dynamiccore2
This commit is contained in:
@@ -63,9 +63,9 @@ int w_newSource(lua_State *L)
|
||||
|
||||
luax_catchexcept(L, [&]() {
|
||||
if (luax_istype(L, 1, love::sound::SoundData::type))
|
||||
t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1, love::sound::SoundData::type));
|
||||
t = instance()->newSource(luax_totype<love::sound::SoundData>(L, 1));
|
||||
else if (luax_istype(L, 1, love::sound::Decoder::type))
|
||||
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, love::sound::Decoder::type));
|
||||
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1));
|
||||
});
|
||||
|
||||
if (t != nullptr)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace audio
|
||||
|
||||
Source *luax_checksource(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Source>(L, idx, love::audio::Source::type);
|
||||
return luax_checktype<Source>(L, idx);
|
||||
}
|
||||
|
||||
int w_Source_clone(lua_State *L)
|
||||
@@ -344,7 +344,7 @@ int w_Source_queue(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 2, love::sound::SoundData::type))
|
||||
{
|
||||
auto s = luax_totype<love::sound::SoundData>(L, 2, love::sound::SoundData::type);
|
||||
auto s = luax_totype<love::sound::SoundData>(L, 2);
|
||||
|
||||
int offset = 0;
|
||||
size_t length = s->getSize();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace filesystem
|
||||
|
||||
DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<DroppedFile>(L, idx, DroppedFile::type);
|
||||
return luax_checktype<DroppedFile>(L, idx);
|
||||
}
|
||||
|
||||
extern "C" int luaopen_droppedfile(lua_State *L)
|
||||
|
||||
@@ -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, love::filesystem::File::type);
|
||||
return luax_checktype<File>(L, idx);
|
||||
}
|
||||
|
||||
int w_File_getSize(lua_State *L)
|
||||
@@ -152,7 +152,7 @@ int w_File_write(lua_State *L)
|
||||
{
|
||||
try
|
||||
{
|
||||
love::Data *data = luax_totype<love::Data>(L, 2, love::Data::type);
|
||||
love::Data *data = luax_totype<love::Data>(L, 2);
|
||||
result = file->write(data, luaL_optinteger(L, 3, data->getSize()));
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
@@ -227,7 +227,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::type);
|
||||
File *file = luax_checktype<File>(L, lua_upvalueindex(1));
|
||||
|
||||
// Only accept read mode at this point.
|
||||
if (file->getMode() != File::MODE_READ)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace filesystem
|
||||
|
||||
FileData *luax_checkfiledata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<FileData>(L, idx, FileData::type);
|
||||
return luax_checktype<FileData>(L, idx);
|
||||
}
|
||||
|
||||
int w_FileData_getFilename(lua_State *L)
|
||||
|
||||
@@ -115,7 +115,7 @@ int w_mount(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 1, DroppedFile::type))
|
||||
{
|
||||
DroppedFile *file = luax_totype<DroppedFile>(L, 1, DroppedFile::type);
|
||||
DroppedFile *file = luax_totype<DroppedFile>(L, 1);
|
||||
archive = file->getFilename();
|
||||
}
|
||||
else
|
||||
@@ -400,7 +400,7 @@ static int w_write_or_append(lua_State *L, File::Mode mode)
|
||||
|
||||
if (luax_istype(L, 2, love::Data::type))
|
||||
{
|
||||
love::Data *data = luax_totype<love::Data>(L, 2, love::Data::type);
|
||||
love::Data *data = luax_totype<love::Data>(L, 2);
|
||||
input = (const char *) data->getData();
|
||||
len = data->getSize();
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
lua_rawgeti(L, 2, i);
|
||||
|
||||
convimagedata(L, -1);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, image::ImageData::type);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, -1);
|
||||
images.push_back(id);
|
||||
id->retain();
|
||||
|
||||
@@ -141,7 +141,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, image::ImageData::type);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, i);
|
||||
images.push_back(id);
|
||||
id->retain();
|
||||
}
|
||||
@@ -163,7 +163,7 @@ int w_newImageRasterizer(lua_State *L)
|
||||
|
||||
convimagedata(L, 1);
|
||||
|
||||
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, image::ImageData::type);
|
||||
image::ImageData *d = luax_checktype<image::ImageData>(L, 1);
|
||||
std::string glyphs = luax_checkstring(L, 2);
|
||||
int extraspacing = (int) luaL_optnumber(L, 3, 0);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace font
|
||||
|
||||
GlyphData *luax_checkglyphdata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<GlyphData>(L, idx, GlyphData::type);
|
||||
return luax_checktype<GlyphData>(L, idx);
|
||||
}
|
||||
|
||||
int w_GlyphData_getWidth(lua_State *L)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace font
|
||||
|
||||
Rasterizer *luax_checkrasterizer(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Rasterizer>(L, idx, Rasterizer::type);
|
||||
return luax_checktype<Rasterizer>(L, idx);
|
||||
}
|
||||
|
||||
int w_Rasterizer_getHeight(lua_State *L)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Canvas *luax_checkcanvas(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Canvas>(L, idx, Canvas::type);
|
||||
return luax_checktype<Canvas>(L, idx);
|
||||
}
|
||||
|
||||
int w_Canvas_renderTo(lua_State *L)
|
||||
@@ -68,7 +68,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, love::image::Image::type);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L);
|
||||
int x = (int) luaL_optnumber(L, 2, 0);
|
||||
int y = (int) luaL_optnumber(L, 3, 0);
|
||||
int w = (int) luaL_optnumber(L, 4, canvas->getWidth());
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace opengl
|
||||
|
||||
Font *luax_checkfont(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Font>(L, idx, Font::type);
|
||||
return luax_checktype<Font>(L, idx);
|
||||
}
|
||||
|
||||
int w_Font_getHeight(lua_State *L)
|
||||
|
||||
@@ -442,7 +442,7 @@ 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, love::font::Rasterizer::type);
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1);
|
||||
|
||||
luax_catchexcept(L, [&]() {
|
||||
font = instance()->newFont(rasterizer, instance()->getDefaultFilter()); }
|
||||
@@ -464,7 +464,7 @@ int w_newImageFont(lua_State *L)
|
||||
// Convert to ImageData if necessary.
|
||||
if (luax_istype(L, 1, Image::type))
|
||||
{
|
||||
Image *i = luax_checktype<Image>(L, 1, Image::type);
|
||||
Image *i = luax_checktype<Image>(L, 1);
|
||||
filter = i->getFilter();
|
||||
const auto &idlevels = i->getImageData();
|
||||
if (idlevels.empty())
|
||||
@@ -485,7 +485,7 @@ int w_newImageFont(lua_State *L)
|
||||
luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newImageRasterizer");
|
||||
}
|
||||
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, love::font::Rasterizer::type);
|
||||
love::font::Rasterizer *rasterizer = luax_checktype<love::font::Rasterizer>(L, 1);
|
||||
|
||||
// Create the font.
|
||||
Font *font = instance()->newFont(rasterizer, filter);
|
||||
@@ -806,7 +806,7 @@ static Mesh *newCustomMesh(lua_State *L)
|
||||
else if (luax_istype(L, 2, Data::type))
|
||||
{
|
||||
// Vertex data comes directly from a Data object.
|
||||
Data *data = luax_checktype<Data>(L, 2, Data::type);
|
||||
Data *data = luax_checktype<Data>(L, 2);
|
||||
luax_catchexcept(L, [&](){ t = instance()->newMesh(vertexformat, data->getData(), data->getSize(), drawmode, usage); });
|
||||
}
|
||||
else
|
||||
@@ -920,7 +920,7 @@ int w_newVideo(lua_State *L)
|
||||
if (!luax_istype(L, 1, love::video::VideoStream::type))
|
||||
luax_convobj(L, 1, "video", "newVideoStream");
|
||||
|
||||
auto stream = luax_checktype<love::video::VideoStream>(L, 1, love::video::VideoStream::type);
|
||||
auto stream = luax_checktype<love::video::VideoStream>(L, 1);
|
||||
Video *video = nullptr;
|
||||
|
||||
luax_catchexcept(L, [&]() { video = instance()->newVideo(stream); });
|
||||
@@ -1004,14 +1004,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::type);
|
||||
Font *font = luax_checktype<Font>(L, -1);
|
||||
instance()->setFont(font);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_setFont(lua_State *L)
|
||||
{
|
||||
Font *font = luax_checktype<Font>(L, 1, Font::type);
|
||||
Font *font = luax_checktype<Font>(L, 1);
|
||||
instance()->setFont(font);
|
||||
return 0;
|
||||
}
|
||||
@@ -1248,7 +1248,7 @@ int w_isWireframe(lua_State *L)
|
||||
|
||||
int w_newScreenshot(lua_State *L)
|
||||
{
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, love::image::Image::type);
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L);
|
||||
bool copyAlpha = luax_optboolean(L, 1, false);
|
||||
love::image::ImageData *i = 0;
|
||||
|
||||
@@ -1528,7 +1528,7 @@ int w_draw(lua_State *L)
|
||||
if (luax_istype(L, 2, Quad::type))
|
||||
{
|
||||
texture = luax_checktexture(L, 1);
|
||||
quad = luax_totype<Quad>(L, 2, Quad::type);
|
||||
quad = luax_totype<Quad>(L, 2);
|
||||
startidx = 3;
|
||||
}
|
||||
else if (lua_isnil(L, 2) && !lua_isnoneornil(L, 3))
|
||||
@@ -1537,7 +1537,7 @@ int w_draw(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
drawable = luax_checktype<Drawable>(L, 1, Drawable::type);
|
||||
drawable = luax_checktype<Drawable>(L, 1);
|
||||
startidx = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace opengl
|
||||
|
||||
Image *luax_checkimage(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Image>(L, idx, Image::type);
|
||||
return luax_checktype<Image>(L, idx);
|
||||
}
|
||||
|
||||
int w_Image_setMipmapFilter(lua_State *L)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace opengl
|
||||
|
||||
Mesh *luax_checkmesh(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Mesh>(L, idx, Mesh::type);
|
||||
return luax_checktype<Mesh>(L, idx);
|
||||
}
|
||||
|
||||
static inline size_t writeByteData(lua_State *L, int startidx, int components, char *data)
|
||||
@@ -119,7 +119,7 @@ int w_Mesh_setVertices(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 2, Data::type))
|
||||
{
|
||||
Data *d = luax_checktype<Data>(L, 2, Data::type);
|
||||
Data *d = luax_checktype<Data>(L, 2);
|
||||
|
||||
size_t datasize = std::min(d->getSize(), (t->getVertexCount() - vertoffset) * stride);
|
||||
char *bytedata = (char *) t->mapVertexData() + byteoffset;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace opengl
|
||||
|
||||
ParticleSystem *luax_checkparticlesystem(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ParticleSystem>(L, idx, ParticleSystem::type);
|
||||
return luax_checktype<ParticleSystem>(L, idx);
|
||||
}
|
||||
|
||||
int w_ParticleSystem_clone(lua_State *L)
|
||||
@@ -584,7 +584,7 @@ int w_ParticleSystem_setQuads(lua_State *L)
|
||||
{
|
||||
lua_rawgeti(L, 2, i);
|
||||
|
||||
Quad *q = luax_checktype<Quad>(L, -1, Quad::type);
|
||||
Quad *q = luax_checktype<Quad>(L, -1);
|
||||
quads.push_back(q);
|
||||
|
||||
lua_pop(L, 1);
|
||||
@@ -594,7 +594,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::type);
|
||||
Quad *q = luax_checktype<Quad>(L, i);
|
||||
quads.push_back(q);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace opengl
|
||||
|
||||
Shader *luax_checkshader(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Shader>(L, idx, Shader::type);
|
||||
return luax_checktype<Shader>(L, idx);
|
||||
}
|
||||
|
||||
int w_Shader_getWarnings(lua_State *L)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace opengl
|
||||
|
||||
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<SpriteBatch>(L, idx, SpriteBatch::type);
|
||||
return luax_checktype<SpriteBatch>(L, idx);
|
||||
}
|
||||
|
||||
static inline int w_SpriteBatch_add_or_set(lua_State *L, SpriteBatch *t, int startidx, int index)
|
||||
@@ -45,7 +45,7 @@ static inline int w_SpriteBatch_add_or_set(lua_State *L, SpriteBatch *t, int sta
|
||||
|
||||
if (luax_istype(L, startidx, Quad::type))
|
||||
{
|
||||
quad = luax_totype<Quad>(L, startidx, Quad::type);
|
||||
quad = luax_totype<Quad>(L, startidx);
|
||||
startidx++;
|
||||
}
|
||||
else if (lua_isnil(L, startidx) && !lua_isnoneornil(L, startidx + 1))
|
||||
@@ -201,7 +201,7 @@ int w_SpriteBatch_attachAttribute(lua_State *L)
|
||||
{
|
||||
SpriteBatch *t = luax_checkspritebatch(L, 1);
|
||||
const char *name = luaL_checkstring(L, 2);
|
||||
Mesh *m = luax_checktype<Mesh>(L, 3, Mesh::type);
|
||||
Mesh *m = luax_checktype<Mesh>(L, 3);
|
||||
|
||||
luax_catchexcept(L, [&](){ t->attachAttribute(name, m); });
|
||||
return 0;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace opengl
|
||||
|
||||
Text *luax_checktext(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Text>(L, idx, Text::type);
|
||||
return luax_checktype<Text>(L, idx);
|
||||
}
|
||||
|
||||
void luax_checkcoloredstring(lua_State *L, int idx, std::vector<Font::ColoredString> &strings)
|
||||
@@ -190,7 +190,7 @@ int w_Text_clear(lua_State *L)
|
||||
int w_Text_setFont(lua_State *L)
|
||||
{
|
||||
Text *t = luax_checktext(L, 1);
|
||||
Font *f = luax_checktype<Font>(L, 2, Font::type);
|
||||
Font *f = luax_checktype<Font>(L, 2);
|
||||
luax_catchexcept(L, [&](){ t->setFont(f); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace opengl
|
||||
|
||||
Video *luax_checkvideo(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Video>(L, idx, Video::type);
|
||||
return luax_checktype<Video>(L, idx);
|
||||
}
|
||||
|
||||
int w_Video_getStream(lua_State *L)
|
||||
@@ -62,7 +62,7 @@ int w_Video_setSource(lua_State *L)
|
||||
video->setSource(nullptr);
|
||||
else
|
||||
{
|
||||
auto source = luax_checktype<love::audio::Source>(L, 2, love::audio::Source::type);
|
||||
auto source = luax_checktype<love::audio::Source>(L, 2);
|
||||
video->setSource(source);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace graphics
|
||||
|
||||
Quad *luax_checkquad(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Quad>(L, idx, Quad::type);
|
||||
return luax_checktype<Quad>(L, idx);
|
||||
}
|
||||
|
||||
int w_Quad_setViewport(lua_State *L)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace graphics
|
||||
|
||||
Texture *luax_checktexture(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Texture>(L, idx, Texture::type);
|
||||
return luax_checktype<Texture>(L, idx);
|
||||
}
|
||||
|
||||
int w_Texture_getWidth(lua_State *L)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace image
|
||||
|
||||
CompressedImageData *luax_checkcompressedimagedata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<CompressedImageData>(L, idx, CompressedImageData::type);
|
||||
return luax_checktype<CompressedImageData>(L, idx);
|
||||
}
|
||||
|
||||
int w_CompressedImageData_getWidth(lua_State *L)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace image
|
||||
|
||||
ImageData *luax_checkimagedata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ImageData>(L, idx, ImageData::type);
|
||||
return luax_checktype<ImageData>(L, idx);
|
||||
}
|
||||
|
||||
int w_ImageData_getFormat(lua_State *L)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace joystick
|
||||
|
||||
Joystick *luax_checkjoystick(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Joystick>(L, idx, Joystick::type);
|
||||
return luax_checktype<Joystick>(L, idx);
|
||||
}
|
||||
|
||||
int w_Joystick_isConnected(lua_State *L)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace math
|
||||
|
||||
BezierCurve *luax_checkbeziercurve(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<BezierCurve>(L, idx, BezierCurve::type);
|
||||
return luax_checktype<BezierCurve>(L, idx);
|
||||
}
|
||||
|
||||
int w_BezierCurve_getDegree(lua_State *L)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace math
|
||||
|
||||
CompressedData *luax_checkcompresseddata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<CompressedData>(L, idx, CompressedData::type);
|
||||
return luax_checktype<CompressedData>(L, idx);
|
||||
}
|
||||
|
||||
int w_CompressedData_getFormat(lua_State *L)
|
||||
|
||||
@@ -338,7 +338,7 @@ int w_compress(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
Data *rawdata = luax_checktype<Data>(L, 1, Data::type);
|
||||
Data *rawdata = luax_checktype<Data>(L, 1);
|
||||
luax_catchexcept(L, [&](){ cdata = compress(format, rawdata, level); });
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ int w_decompress(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 1, Data::type))
|
||||
{
|
||||
Data *data = luax_checktype<Data>(L, 1, Data::type);
|
||||
Data *data = luax_checktype<Data>(L, 1);
|
||||
cbytes = (const char *) data->getData();
|
||||
compressedsize = data->getSize();
|
||||
}
|
||||
@@ -398,7 +398,7 @@ int w_encode(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 2, Data::type))
|
||||
{
|
||||
Data *data = luax_totype<Data>(L, 2, Data::type);
|
||||
Data *data = luax_totype<Data>(L, 2);
|
||||
src = (const char *) data->getData();
|
||||
srclen = data->getSize();
|
||||
}
|
||||
@@ -432,7 +432,7 @@ int w_decode(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 2, Data::type))
|
||||
{
|
||||
Data *data = luax_totype<Data>(L, 2, Data::type);
|
||||
Data *data = luax_totype<Data>(L, 2);
|
||||
src = (const char *) data->getData();
|
||||
srclen = data->getSize();
|
||||
}
|
||||
@@ -468,7 +468,7 @@ int w_hash(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
Data *rawdata = luax_checktype<Data>(L, 2, Data::type);
|
||||
Data *rawdata = luax_checktype<Data>(L, 2);
|
||||
luax_catchexcept(L, [&](){ hash = love::math::hash(function, rawdata); });
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ RandomGenerator::Seed luax_checkrandomseed(lua_State *L, int idx)
|
||||
|
||||
RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<RandomGenerator>(L, idx, RandomGenerator::type);
|
||||
return luax_checktype<RandomGenerator>(L, idx);
|
||||
}
|
||||
|
||||
int w_RandomGenerator__random(lua_State *L)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace mouse
|
||||
|
||||
Cursor *luax_checkcursor(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Cursor>(L, idx, Cursor::type);
|
||||
return luax_checktype<Cursor>(L, idx);
|
||||
}
|
||||
|
||||
int w_Cursor_getType(lua_State *L)
|
||||
|
||||
@@ -40,7 +40,7 @@ int w_newCursor(lua_State *L)
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, love::filesystem::File::type) || luax_istype(L, 1, love::filesystem::FileData::type))
|
||||
luax_convobj(L, 1, "image", "newImageData");
|
||||
|
||||
love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1, love::image::ImageData::type);
|
||||
love::image::ImageData *data = luax_checktype<love::image::ImageData>(L, 1);
|
||||
int hotx = (int) luaL_optnumber(L, 2, 0);
|
||||
int hoty = (int) luaL_optnumber(L, 3, 0);
|
||||
|
||||
|
||||
@@ -296,8 +296,8 @@ Fixture *Physics::newFixture(Body *body, Shape *shape, float density)
|
||||
|
||||
int Physics::getDistance(lua_State *L)
|
||||
{
|
||||
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, Fixture::type);
|
||||
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, Fixture::type);
|
||||
Fixture *fixtureA = luax_checktype<Fixture>(L, 1);
|
||||
Fixture *fixtureB = luax_checktype<Fixture>(L, 2);
|
||||
b2DistanceProxy pA, pB;
|
||||
b2DistanceInput i;
|
||||
b2DistanceOutput o;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Body *luax_checkbody(lua_State *L, int idx)
|
||||
{
|
||||
Body *b = luax_checktype<Body>(L, idx, Body::type);
|
||||
Body *b = luax_checktype<Body>(L, idx);
|
||||
if (b->body == 0)
|
||||
luaL_error(L, "Attempt to use destroyed body.");
|
||||
return b;
|
||||
@@ -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::type);
|
||||
Body *b = luax_checktype<Body>(L, 1);
|
||||
luax_pushboolean(L, b->body == nullptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace box2d
|
||||
|
||||
ChainShape *luax_checkchainshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<ChainShape>(L, idx, ChainShape::type);
|
||||
return luax_checktype<ChainShape>(L, idx);
|
||||
}
|
||||
|
||||
int w_ChainShape_setNextVertex(lua_State *L)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
CircleShape *luax_checkcircleshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<CircleShape>(L, idx, CircleShape::type);
|
||||
return luax_checktype<CircleShape>(L, idx);
|
||||
}
|
||||
|
||||
int w_CircleShape_getRadius(lua_State *L)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Contact *luax_checkcontact(lua_State *L, int idx)
|
||||
{
|
||||
Contact *c = luax_checktype<Contact>(L, idx, Contact::type);
|
||||
Contact *c = luax_checktype<Contact>(L, idx);
|
||||
if (!c->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed contact.");
|
||||
return c;
|
||||
@@ -153,7 +153,7 @@ int w_Contact_getFixtures(lua_State *L)
|
||||
|
||||
int w_Contact_isDestroyed(lua_State *L)
|
||||
{
|
||||
Contact *c = luax_checktype<Contact>(L, 1, Contact::type);
|
||||
Contact *c = luax_checktype<Contact>(L, 1);
|
||||
luax_pushboolean(L, !c->isValid());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx)
|
||||
{
|
||||
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, DistanceJoint::type);
|
||||
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
EdgeShape *luax_checkedgeshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<EdgeShape>(L, idx, EdgeShape::type);
|
||||
return luax_checktype<EdgeShape>(L, idx);
|
||||
}
|
||||
|
||||
int w_EdgeShape_setNextVertex(lua_State *L)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Fixture *luax_checkfixture(lua_State *L, int idx)
|
||||
{
|
||||
Fixture *f = luax_checktype<Fixture>(L, idx, Fixture::type);
|
||||
Fixture *f = luax_checktype<Fixture>(L, idx);
|
||||
if (!f->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed fixture.");
|
||||
return f;
|
||||
@@ -263,7 +263,7 @@ int w_Fixture_destroy(lua_State *L)
|
||||
|
||||
int w_Fixture_isDestroyed(lua_State *L)
|
||||
{
|
||||
Fixture *f = luax_checktype<Fixture>(L, 1, Fixture::type);
|
||||
Fixture *f = luax_checktype<Fixture>(L, 1);
|
||||
luax_pushboolean(L, !f->isValid());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx)
|
||||
{
|
||||
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, FrictionJoint::type);
|
||||
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
GearJoint *luax_checkgearjoint(lua_State *L, int idx)
|
||||
{
|
||||
GearJoint *j = luax_checktype<GearJoint>(L, idx, GearJoint::type);
|
||||
GearJoint *j = luax_checktype<GearJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -77,7 +77,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::type);
|
||||
Joint *t = luax_checktype<Joint>(L, idx);
|
||||
if (!t->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return t;
|
||||
@@ -160,7 +160,7 @@ int w_Joint_destroy(lua_State *L)
|
||||
|
||||
int w_Joint_isDestroyed(lua_State *L)
|
||||
{
|
||||
Joint *t = luax_checktype<Joint>(L, 1, Joint::type);
|
||||
Joint *t = luax_checktype<Joint>(L, 1);
|
||||
luax_pushboolean(L, !t->isValid());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
|
||||
{
|
||||
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, MotorJoint::type);
|
||||
MotorJoint *j = luax_checktype<MotorJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
MouseJoint *luax_checkmousejoint(lua_State *L, int idx)
|
||||
{
|
||||
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, MouseJoint::type);
|
||||
MouseJoint *j = luax_checktype<MouseJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
PolygonShape *luax_checkpolygonshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<PolygonShape>(L, idx, PolygonShape::type);
|
||||
return luax_checktype<PolygonShape>(L, idx);
|
||||
}
|
||||
|
||||
int w_PolygonShape_getPoints(lua_State *L)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx)
|
||||
{
|
||||
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, PrismaticJoint::type);
|
||||
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx)
|
||||
{
|
||||
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, PulleyJoint::type);
|
||||
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx)
|
||||
{
|
||||
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, RevoluteJoint::type);
|
||||
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
RopeJoint *luax_checkropejoint(lua_State *L, int idx)
|
||||
{
|
||||
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, RopeJoint::type);
|
||||
RopeJoint *j = luax_checktype<RopeJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace box2d
|
||||
|
||||
Shape *luax_checkshape(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Shape>(L, idx, Shape::type);
|
||||
return luax_checktype<Shape>(L, idx);
|
||||
}
|
||||
|
||||
int w_Shape_getType(lua_State *L)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
|
||||
{
|
||||
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, WeldJoint::type);
|
||||
WeldJoint *j = luax_checktype<WeldJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
WheelJoint *luax_checkwheeljoint(lua_State *L, int idx)
|
||||
{
|
||||
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, WheelJoint::type);
|
||||
WheelJoint *j = luax_checktype<WheelJoint>(L, idx);
|
||||
if (!j->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed joint.");
|
||||
return j;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace box2d
|
||||
|
||||
World *luax_checkworld(lua_State *L, int idx)
|
||||
{
|
||||
World *w = luax_checktype<World>(L, idx, World::type);
|
||||
World *w = luax_checktype<World>(L, idx);
|
||||
if (!w->isValid())
|
||||
luaL_error(L, "Attempt to use destroyed world.");
|
||||
return w;
|
||||
@@ -203,7 +203,7 @@ int w_World_destroy(lua_State *L)
|
||||
|
||||
int w_World_isDestroyed(lua_State *L)
|
||||
{
|
||||
World *w = luax_checktype<World>(L, 1, World::type);
|
||||
World *w = luax_checktype<World>(L, 1);
|
||||
luax_pushboolean(L, !w->isValid());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace sound
|
||||
|
||||
Decoder *luax_checkdecoder(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Decoder>(L, idx, Decoder::type);
|
||||
return luax_checktype<Decoder>(L, idx);
|
||||
}
|
||||
|
||||
int w_Decoder_getChannels(lua_State *L)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace sound
|
||||
|
||||
SoundData *luax_checksounddata(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<SoundData>(L, idx, SoundData::type);
|
||||
return luax_checktype<SoundData>(L, idx);
|
||||
}
|
||||
|
||||
int w_SoundData_getChannels(lua_State *L)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace thread
|
||||
|
||||
Channel *luax_checkchannel(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<Channel>(L, idx, Channel::type);
|
||||
return luax_checktype<Channel>(L, idx);
|
||||
}
|
||||
|
||||
int w_Channel_push(lua_State *L)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace thread
|
||||
|
||||
LuaThread *luax_checkthread(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<LuaThread>(L, idx, LuaThread::type);
|
||||
return luax_checktype<LuaThread>(L, idx);
|
||||
}
|
||||
|
||||
int w_Thread_start(lua_State *L)
|
||||
|
||||
@@ -66,13 +66,13 @@ int w_newThread(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 1, love::filesystem::FileData::type))
|
||||
{
|
||||
love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1, love::filesystem::FileData::type);
|
||||
love::filesystem::FileData *fdata = luax_checktype<love::filesystem::FileData>(L, 1);
|
||||
name = std::string("@") + fdata->getFilename();
|
||||
data = fdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = luax_checktype<love::Data>(L, 1, love::Data::type);
|
||||
data = luax_checktype<love::Data>(L, 1);
|
||||
}
|
||||
|
||||
LuaThread *t = instance()->newThread(name, data);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace video
|
||||
|
||||
VideoStream *luax_checkvideostream(lua_State *L, int idx)
|
||||
{
|
||||
return luax_checktype<VideoStream>(L, idx, VideoStream::type);
|
||||
return luax_checktype<VideoStream>(L, idx);
|
||||
}
|
||||
|
||||
int w_VideoStream_setSync(lua_State *L)
|
||||
@@ -36,14 +36,14 @@ int w_VideoStream_setSync(lua_State *L)
|
||||
|
||||
if (luax_istype(L, 2, love::audio::Source::type))
|
||||
{
|
||||
auto src = luax_totype<love::audio::Source>(L, 2, love::audio::Source::type);
|
||||
auto src = luax_totype<love::audio::Source>(L, 2);
|
||||
auto sync = new VideoStream::SourceSync(src);
|
||||
stream->setSync(sync);
|
||||
sync->release();
|
||||
}
|
||||
else if (luax_istype(L, 2, VideoStream::type))
|
||||
{
|
||||
auto other = luax_totype<VideoStream>(L, 2, VideoStream::type);
|
||||
auto other = luax_totype<VideoStream>(L, 2);
|
||||
stream->setSync(other->getSync());
|
||||
}
|
||||
else if (lua_isnoneornil(L, 2))
|
||||
|
||||
@@ -351,7 +351,7 @@ int w_getPosition(lua_State *L)
|
||||
|
||||
int w_setIcon(lua_State *L)
|
||||
{
|
||||
image::ImageData *i = luax_checktype<image::ImageData>(L, 1, image::ImageData::type);
|
||||
image::ImageData *i = luax_checktype<image::ImageData>(L, 1);
|
||||
luax_pushboolean(L, instance()->setIcon(i));
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user