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
+15
View File
@@ -43,6 +43,9 @@ class Object;
class Module;
class Reference;
template<typename T>
class StrongRef;
/**
* Registries represent special tables which can be accessed with
* luax_insistregistry and luax_getregistry.
@@ -285,6 +288,18 @@ int luax_register_searcher(lua_State *L, lua_CFunction f, int pos = -1);
**/
void luax_pushtype(lua_State *L, love::Type &type, love::Object *object);
template <typename T>
void luax_pushtype(lua_State *L, T *object)
{
luax_pushtype(L, T::type, object);
}
template <typename T>
void luax_pushtype(lua_State *L, StrongRef<T> &object)
{
luax_pushtype(L, T::type, object);
}
/**
* Creates a new Lua representation of the given object *without* checking if it
* exists yet, and *without* storing it in a weak table.
+5 -5
View File
@@ -70,7 +70,7 @@ int w_newSource(lua_State *L)
if (t != nullptr)
{
luax_pushtype(L, love::audio::Source::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -88,7 +88,7 @@ int w_newQueueableSource(lua_State *L)
if (t != nullptr)
{
luax_pushtype(L, love::audio::Source::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -150,7 +150,7 @@ int w_pause(lua_State *L)
lua_createtable(L, (int) sources.size(), 0);
for (int i = 0; i < (int) sources.size(); i++)
{
luax_pushtype(L, love::audio::Source::type, sources[i]);
luax_pushtype(L, sources[i]);
lua_rawseti(L, -2, i+1);
}
return 1;
@@ -270,7 +270,7 @@ int w_getRecordedData(lua_State *L)
lua_pushnil(L);
else
{
luax_pushtype(L, love::sound::SoundData::type, sd);
luax_pushtype(L, sd);
sd->release();
}
return 1;
@@ -285,7 +285,7 @@ int w_stopRecording(lua_State *L)
lua_pushnil(L);
else
{
luax_pushtype(L, love::sound::SoundData::type, sd);
luax_pushtype(L, sd);
sd->release();
}
return 1;
+1 -1
View File
@@ -38,7 +38,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, love::audio::Source::type, clone);
luax_pushtype(L, clone);
clone->release();
return 1;
}
+4 -4
View File
@@ -166,7 +166,7 @@ int w_newFile(lua_State *L)
}
}
luax_pushtype(L, File::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -246,7 +246,7 @@ int w_newFileData(lua_State *L)
{
return luax_ioError(L, "%s", e.what());
}
luax_pushtype(L, FileData::type, data);
luax_pushtype(L, data);
return 1;
}
else
@@ -260,7 +260,7 @@ int w_newFileData(lua_State *L)
FileData *t = nullptr;
luax_catchexcept(L, [&](){ t = instance()->newFileData(str, length, filename); });
luax_pushtype(L, FileData::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -474,7 +474,7 @@ int w_lines(lua_State *L)
return luaL_error(L, "Could not open file.");
}
luax_pushtype(L, File::type, file);
luax_pushtype(L, file);
file->release();
}
else
+5 -5
View File
@@ -53,7 +53,7 @@ int w_newRasterizer(lua_State *L)
[&](bool) { d->release(); }
);
luax_pushtype(L, Rasterizer::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -104,7 +104,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
);
}
luax_pushtype(L, Rasterizer::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -152,7 +152,7 @@ int w_newBMFontRasterizer(lua_State *L)
[&](bool) { d->release(); for (auto id : images) id->release(); }
);
luax_pushtype(L, Rasterizer::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -169,7 +169,7 @@ int w_newImageRasterizer(lua_State *L)
luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs, extraspacing); });
luax_pushtype(L, Rasterizer::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -191,7 +191,7 @@ int w_newGlyphData(lua_State *L)
t = instance()->newGlyphData(r, g);
}
luax_pushtype(L, GlyphData::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
+1 -1
View File
@@ -86,7 +86,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
}
});
luax_pushtype(L, GlyphData::type, g);
luax_pushtype(L, g);
g->release();
return 1;
}
+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;
+2 -2
View File
@@ -73,7 +73,7 @@ int w_newImageData(lua_State *L)
memcpy(t->getData(), bytes, t->getSize());
}
luax_pushtype(L, ImageData::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -87,7 +87,7 @@ int w_newImageData(lua_State *L)
[&](bool) { data->release(); }
);
luax_pushtype(L, ImageData::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
+1 -1
View File
@@ -282,7 +282,7 @@ int w_ImageData_encode(lua_State *L)
love::filesystem::FileData *filedata = nullptr;
luax_catchexcept(L, [&](){ filedata = t->encode(format, filename.c_str()); });
luax_pushtype(L, love::filesystem::FileData::type, filedata);
luax_pushtype(L, filedata);
filedata->release();
if (hasfilename)
+1 -1
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::type, stick);
luax_pushtype(L, stick);
lua_rawseti(L, -2, i + 1);
}
+2 -2
View File
@@ -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::type, deriv);
luax_pushtype(L, deriv);
deriv->release();
return 1;
}
@@ -165,7 +165,7 @@ int w_BezierCurve_getSegment(lua_State *L)
BezierCurve *segment;
luax_catchexcept(L, [&](){ segment = curve->getSegment(t1, t2); });
luax_pushtype(L, BezierCurve::type, segment);
luax_pushtype(L, segment);
segment->release();
return 1;
+4 -4
View File
@@ -43,7 +43,7 @@ namespace math
int w__getRandomGenerator(lua_State *L)
{
RandomGenerator *t = Math::instance.getRandomGenerator();
luax_pushtype(L, RandomGenerator::type, t);
luax_pushtype(L, t);
return 1;
}
@@ -74,7 +74,7 @@ int w_newRandomGenerator(lua_State *L)
return luaL_error(L, "%s", lua_tostring(L, -1));
}
luax_pushtype(L, RandomGenerator::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -113,7 +113,7 @@ int w_newBezierCurve(lua_State *L)
}
BezierCurve *curve = Math::instance.newBezierCurve(points);
luax_pushtype(L, BezierCurve::type, curve);
luax_pushtype(L, curve);
curve->release();
return 1;
}
@@ -342,7 +342,7 @@ int w_compress(lua_State *L)
luax_catchexcept(L, [&](){ cdata = compress(format, rawdata, level); });
}
luax_pushtype(L, CompressedData::type, cdata);
luax_pushtype(L, cdata);
return 1;
}
+3 -3
View File
@@ -46,7 +46,7 @@ int w_newCursor(lua_State *L)
luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
luax_pushtype(L, Cursor::type, cursor);
luax_pushtype(L, cursor);
cursor->release();
return 1;
}
@@ -62,7 +62,7 @@ int w_getSystemCursor(lua_State *L)
Cursor *cursor = 0;
luax_catchexcept(L, [&](){ cursor = instance()->getSystemCursor(systemCursor); });
luax_pushtype(L, Cursor::type, cursor);
luax_pushtype(L, cursor);
return 1;
}
@@ -85,7 +85,7 @@ int w_getCursor(lua_State *L)
Cursor *cursor = instance()->getCursor();
if (cursor)
luax_pushtype(L, Cursor::type, cursor);
luax_pushtype(L, cursor);
else
lua_pushnil(L);
+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::type, fixture);
luax_pushtype(L, 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::type, contact);
luax_pushtype(L, contact);
contact->release();
lua_rawseti(L, -2, i);
i++;
+2 -2
View File
@@ -146,7 +146,7 @@ int Physics::newPolygonShape(lua_State *L)
}
PolygonShape *p = new PolygonShape(s);
luax_pushtype(L, PolygonShape::type, p);
luax_pushtype(L, 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::type, c);
luax_pushtype(L, c);
c->release();
return 1;
}
+10 -10
View File
@@ -59,7 +59,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
{
Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
if (a != nullptr)
luax_pushtype(L, Fixture::type, a);
luax_pushtype(L, a);
else
throw love::Exception("A fixture has escaped Memoizer!");
}
@@ -68,7 +68,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
{
Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
if (b != nullptr)
luax_pushtype(L, Fixture::type, b);
luax_pushtype(L, b);
else
throw love::Exception("A fixture has escaped Memoizer!");
}
@@ -79,7 +79,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
else
cobj->retain();
luax_pushtype(L, Contact::type, cobj);
luax_pushtype(L, cobj);
cobj->release();
int args = 3;
@@ -130,8 +130,8 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b)
if (ref != nullptr && L != nullptr)
{
ref->push(L);
luax_pushtype(L, Fixture::type, a);
luax_pushtype(L, Fixture::type, b);
luax_pushtype(L, a);
luax_pushtype(L, b);
lua_call(L, 2, 1);
return luax_toboolean(L, -1);
}
@@ -157,7 +157,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::type, f);
luax_pushtype(L, f);
lua_call(L, 1, 1);
bool cont = luax_toboolean(L, -1);
lua_pop(L, 1);
@@ -186,7 +186,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::type, f);
luax_pushtype(L, f);
b2Vec2 scaledPoint = Physics::scaleUp(point);
lua_pushnumber(L, scaledPoint.x);
lua_pushnumber(L, scaledPoint.y);
@@ -475,7 +475,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::type, body);
luax_pushtype(L, body);
lua_rawseti(L, -2, i);
i++;
}
@@ -493,7 +493,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::type, joint);
luax_pushtype(L, joint);
lua_rawseti(L, -2, i);
i++;
}
@@ -514,7 +514,7 @@ int World::getContactList(lua_State *L) const
contact = new Contact(c);
else
contact->retain();
luax_pushtype(L, Contact::type, contact);
luax_pushtype(L, contact);
contact->release();
lua_rawseti(L, -2, i);
i++;
+1 -1
View File
@@ -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::type, world);
luax_pushtype(L, world);
return 1;
}
@@ -68,7 +68,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
int index = (int) luaL_checknumber(L, 2) - 1; // Convert from 1-based index
EdgeShape *e = 0;
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
luax_pushtype(L, EdgeShape::type, e);
luax_pushtype(L, e);
e->release();
return 1;
}
+2 -2
View File
@@ -146,8 +146,8 @@ int w_Contact_getFixtures(lua_State *L)
Fixture *b = nullptr;
luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
luax_pushtype(L, Fixture::type, a);
luax_pushtype(L, Fixture::type, b);
luax_pushtype(L, a);
luax_pushtype(L, b);
return 2;
}
+6 -6
View File
@@ -111,7 +111,7 @@ int w_Fixture_getBody(lua_State *L)
Body *body = t->getBody();
if (body == 0)
return 0;
luax_pushtype(L, Body::type, body);
luax_pushtype(L, 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::type, shape);
luax_pushtype(L, shape);
break;
case Shape::SHAPE_CHAIN:
luax_pushtype(L, ChainShape::type, shape);
luax_pushtype(L, shape);
break;
case Shape::SHAPE_CIRCLE:
luax_pushtype(L, CircleShape::type, shape);
luax_pushtype(L, shape);
break;
case Shape::SHAPE_POLYGON:
luax_pushtype(L, PolygonShape::type, shape);
luax_pushtype(L, shape);
break;
default:
luax_pushtype(L, Shape::type, shape);
luax_pushtype(L, shape);
break;
}
return 1;
+2 -2
View File
@@ -103,8 +103,8 @@ int w_Joint_getBodies(lua_State *L)
b2 = t->getBodyB();
});
luax_pushtype(L, Body::type, b1);
luax_pushtype(L, Body::type, b2);
luax_pushtype(L, b1);
luax_pushtype(L, b2);
return 2;
}
+19 -19
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::type, w);
luax_pushtype(L, w);
w->release();
return 1;
@@ -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::type, body);
luax_pushtype(L, 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::type, fixture);
luax_pushtype(L, 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::type, shape);
luax_pushtype(L, 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::type, shape);
luax_pushtype(L, 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::type, shape);
luax_pushtype(L, 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::type, shape);
luax_pushtype(L, 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::type, shape);
luax_pushtype(L, shape);
shape->release();
return 1;
}
@@ -194,7 +194,7 @@ int w_newDistanceJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
});
luax_pushtype(L, DistanceJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -206,7 +206,7 @@ int w_newMouseJoint(lua_State *L)
float y = (float)luaL_checknumber(L, 3);
MouseJoint *j;
luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
luax_pushtype(L, MouseJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -237,7 +237,7 @@ int w_newRevoluteJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newRevoluteJoint(body1, body2, xA, yA, xB, yB, collideConnected, referenceAngle);
});
luax_pushtype(L, RevoluteJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -272,7 +272,7 @@ int w_newPrismaticJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected, referenceAngle);
});
luax_pushtype(L, PrismaticJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -296,7 +296,7 @@ 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::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -312,7 +312,7 @@ int w_newGearJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
});
luax_pushtype(L, GearJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -341,7 +341,7 @@ int w_newFrictionJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
});
luax_pushtype(L, FrictionJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -372,7 +372,7 @@ int w_newWeldJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected, referenceAngle);
});
luax_pushtype(L, WeldJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -406,7 +406,7 @@ 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::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -425,7 +425,7 @@ int w_newRopeJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
});
luax_pushtype(L, RopeJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
@@ -447,7 +447,7 @@ int w_newMotorJoint(lua_State *L)
{
luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
}
luax_pushtype(L, MotorJoint::type, j);
luax_pushtype(L, j);
j->release();
return 1;
}
+1 -1
View File
@@ -74,7 +74,7 @@ int w_Decoder_decode(lua_State *L)
decoded / (t->getBitDepth() / 8 * t->getChannels()),
t->getSampleRate(), t->getBitDepth(), t->getChannels());
luax_pushtype(L, SoundData::type, s);
luax_pushtype(L, s);
s->release();
});
}
+2 -2
View File
@@ -46,7 +46,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::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
@@ -77,7 +77,7 @@ int w_newSoundData(lua_State *L)
luax_catchexcept(L, [&](){ t = instance()->newSoundData(luax_checkdecoder(L, 1)); });
}
luax_pushtype(L, SoundData::type, t);
luax_pushtype(L, t);
t->release();
return 1;
}
+3 -3
View File
@@ -76,7 +76,7 @@ int w_newThread(lua_State *L)
}
LuaThread *t = instance()->newThread(name, data);
luax_pushtype(L, LuaThread::type, t);
luax_pushtype(L, 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::type, c);
luax_pushtype(L, 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::type, c);
luax_pushtype(L, c);
c->release();
return 1;
}
+1 -1
View File
@@ -45,7 +45,7 @@ int w_newVideoStream(lua_State *L)
stream = instance()->newVideoStream(file);
});
luax_pushtype(L, VideoStream::type, stream);
luax_pushtype(L, stream);
stream->release();
return 1;
}
+1 -1
View File
@@ -359,7 +359,7 @@ int w_setIcon(lua_State *L)
int w_getIcon(lua_State *L)
{
image::ImageData *i = instance()->getIcon();
luax_pushtype(L, image::ImageData::type, i);
luax_pushtype(L, i);
return 1;
}