Automatically deduce the type in luax_pushtype, if possible

--HG--
branch : dynamiccore2
This commit is contained in:
Bart van Strien
2016-11-13 17:38:42 +01:00
parent 7dd960619d
commit 5d43c9601a
32 changed files with 121 additions and 106 deletions
+1 -1
View File
@@ -77,7 +77,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, love::image::ImageData::type, img);
luax_pushtype(L, img);
img->release();
return 1;
}
+16 -16
View File
@@ -402,7 +402,7 @@ int w_newImage(lua_State *L)
return luaL_error(L, "Could not load image.");
// Push the type.
luax_pushtype(L, Image::type, image);
luax_pushtype(L, image);
image->release();
return 1;
}
@@ -421,7 +421,7 @@ int w_newQuad(lua_State *L)
double sh = luaL_checknumber(L, 6);
Quad *quad = instance()->newQuad(v, sw, sh);
luax_pushtype(L, Quad::type, quad);
luax_pushtype(L, quad);
quad->release();
return 1;
}
@@ -449,7 +449,7 @@ int w_newFont(lua_State *L)
);
// Push the type.
luax_pushtype(L, Font::type, font);
luax_pushtype(L, font);
font->release();
return 1;
}
@@ -469,7 +469,7 @@ int w_newImageFont(lua_State *L)
const auto &idlevels = i->getImageData();
if (idlevels.empty())
return luaL_argerror(L, 1, "Image must not be compressed.");
luax_pushtype(L, love::image::ImageData::type, idlevels[0].get());
luax_pushtype(L, idlevels[0].get());
lua_replace(L, 1);
}
@@ -491,7 +491,7 @@ int w_newImageFont(lua_State *L)
Font *font = instance()->newFont(rasterizer, filter);
// Push the type.
luax_pushtype(L, Font::type, font);
luax_pushtype(L, font);
font->release();
return 1;
}
@@ -515,7 +515,7 @@ int w_newSpriteBatch(lua_State *L)
[&](){ t = instance()->newSpriteBatch(texture, size, usage); }
);
luax_pushtype(L, SpriteBatch::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -534,7 +534,7 @@ int w_newParticleSystem(lua_State *L)
[&](){ t = instance()->newParticleSystem(texture, int(size)); }
);
luax_pushtype(L, ParticleSystem::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -561,7 +561,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::type, canvas);
luax_pushtype(L, canvas);
canvas->release();
return 1;
}
@@ -654,7 +654,7 @@ int w_newShader(lua_State *L)
try
{
Shader *shader = instance()->newShader(source);
luax_pushtype(L, Shader::type, shader);
luax_pushtype(L, shader);
shader->release();
}
catch (love::Exception &e)
@@ -886,7 +886,7 @@ int w_newMesh(lua_State *L)
else
t = newStandardMesh(L);
luax_pushtype(L, Mesh::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -908,7 +908,7 @@ int w_newText(lua_State *L)
luax_catchexcept(L, [&](){ t = instance()->newText(font, text); });
}
luax_pushtype(L, Text::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -924,7 +924,7 @@ int w_newVideo(lua_State *L)
Video *video = nullptr;
luax_catchexcept(L, [&]() { video = instance()->newVideo(stream); });
luax_pushtype(L, Video::type, video);
luax_pushtype(L, video);
video->release();
return 1;
}
@@ -1021,7 +1021,7 @@ int w_getFont(lua_State *L)
Font *f = nullptr;
luax_catchexcept(L, [&](){ f = instance()->getFont(); });
luax_pushtype(L, Font::type, f);
luax_pushtype(L, f);
return 1;
}
@@ -1254,7 +1254,7 @@ int w_newScreenshot(lua_State *L)
luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
luax_pushtype(L, love::image::ImageData::type, i);
luax_pushtype(L, i);
i->release();
return 1;
}
@@ -1306,7 +1306,7 @@ int w_getCanvas(lua_State *L)
for (Canvas *c : canvases)
{
luax_pushtype(L, Canvas::type, c);
luax_pushtype(L, c);
n++;
}
@@ -1336,7 +1336,7 @@ int w_getShader(lua_State *L)
{
Shader *shader = instance()->getShader();
if (shader)
luax_pushtype(L, Shader::type, shader);
luax_pushtype(L, shader);
else
lua_pushnil(L);
+2 -2
View File
@@ -98,7 +98,7 @@ int w_Image_getData(lua_State *L)
{
for (const auto &cdata : i->getCompressedData())
{
luax_pushtype(L, love::image::CompressedImageData::type, cdata.get());
luax_pushtype(L, cdata.get());
n++;
}
}
@@ -106,7 +106,7 @@ int w_Image_getData(lua_State *L)
{
for (const auto &data : i->getImageData())
{
luax_pushtype(L, love::image::ImageData::type, data.get());
luax_pushtype(L, data.get());
n++;
}
}
@@ -51,7 +51,7 @@ int w_ParticleSystem_clone(lua_State *L)
ParticleSystem *clone = nullptr;
luax_catchexcept(L, [&](){ clone = t->clone(); });
luax_pushtype(L, ParticleSystem::type, clone);
luax_pushtype(L, clone);
clone->release();
return 1;
}
@@ -612,7 +612,7 @@ int w_ParticleSystem_getQuads(lua_State *L)
for (int i = 0; i < (int) quads.size(); i++)
{
luax_pushtype(L, Quad::type, quads[i]);
luax_pushtype(L, quads[i]);
lua_rawseti(L, -2, i + 1);
}
+1 -1
View File
@@ -199,7 +199,7 @@ int w_Text_getFont(lua_State *L)
{
Text *t = luax_checktext(L, 1);
Font *f = t->getFont();
luax_pushtype(L, Font::type, f);
luax_pushtype(L, f);
return 1;
}
+2 -2
View File
@@ -40,7 +40,7 @@ Video *luax_checkvideo(lua_State *L, int idx)
int w_Video_getStream(lua_State *L)
{
Video *video = luax_checkvideo(L, 1);
luax_pushtype(L, love::video::VideoStream::type, video->getStream());
luax_pushtype(L, video->getStream());
return 1;
}
@@ -49,7 +49,7 @@ int w_Video_getSource(lua_State *L)
Video *video = luax_checkvideo(L, 1);
auto source = video->getSource();
if (source)
luax_pushtype(L, love::audio::Source::type, video->getSource());
luax_pushtype(L, video->getSource());
else
lua_pushnil(L);
return 1;