mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Merged default into minor
--HG-- branch : minor
This commit is contained in:
@@ -63,6 +63,7 @@ int w_newSource(lua_State *L)
|
||||
if (t)
|
||||
{
|
||||
luax_pushtype(L, "Source", AUDIO_SOURCE_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -224,7 +225,10 @@ int w_getRecordedData(lua_State *L)
|
||||
if (!sd)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
{
|
||||
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
|
||||
sd->release();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -233,8 +237,13 @@ int w_stopRecording(lua_State *L)
|
||||
if (luax_optboolean(L, 1, true))
|
||||
{
|
||||
love::sound::SoundData *sd = instance()->stopRecording(true);
|
||||
if (!sd) lua_pushnil(L);
|
||||
else luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
|
||||
if (!sd)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
{
|
||||
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, sd);
|
||||
sd->release();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
instance()->stopRecording(false);
|
||||
|
||||
@@ -38,6 +38,7 @@ int w_Source_clone(lua_State *L)
|
||||
Source *clone = nullptr;
|
||||
luax_catchexcept(L, [&](){ clone = t->clone(); });
|
||||
luax_pushtype(L, "Source", AUDIO_SOURCE_T, clone);
|
||||
clone->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ int w_newFile(lua_State *L)
|
||||
}
|
||||
|
||||
luax_pushtype(L, "File", FILESYSTEM_FILE_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -210,6 +211,7 @@ int w_newFileData(lua_State *L)
|
||||
return luax_ioError(L, "%s", e.what());
|
||||
}
|
||||
luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, data);
|
||||
data->release();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -241,6 +243,7 @@ int w_newFileData(lua_State *L)
|
||||
}
|
||||
|
||||
luax_pushtype(L, "FileData", FILESYSTEM_FILE_DATA_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -396,9 +399,13 @@ int w_lines(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ success = file->open(File::READ); });
|
||||
|
||||
if (!success)
|
||||
{
|
||||
file->release();
|
||||
return luaL_error(L, "Could not open file.");
|
||||
|
||||
}
|
||||
|
||||
luax_pushtype(L, "File", FILESYSTEM_FILE_T, file);
|
||||
file->release();
|
||||
}
|
||||
else
|
||||
return luaL_argerror(L, 1, "expected filename.");
|
||||
|
||||
@@ -58,8 +58,11 @@ int w_newRasterizer(lua_State *L)
|
||||
[&]() { d->release(); }
|
||||
);
|
||||
}
|
||||
else
|
||||
return luaL_argerror(L, 1, "expected ImageData, filename, or FileData");
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -81,6 +84,7 @@ int w_newGlyphData(lua_State *L)
|
||||
}
|
||||
|
||||
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ int w_Rasterizer_getGlyphData(lua_State *L)
|
||||
});
|
||||
|
||||
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, g);
|
||||
g->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ void Graphics::setViewportSize(int width, int height)
|
||||
|
||||
// We want to affect the main screen, not any Canvas that's currently active
|
||||
// (not that any *should* be active when this is called.)
|
||||
std::vector<Canvas *> canvases = getCanvas();
|
||||
std::vector<Object::StrongRef<Canvas>> canvases = states.back().canvases;
|
||||
setCanvas();
|
||||
|
||||
// Set the viewport to top-left corner.
|
||||
@@ -1061,7 +1061,7 @@ love::image::ImageData *Graphics::newScreenshot(love::image::Image *image, bool
|
||||
{
|
||||
// Temporarily unbind the currently active canvas (glReadPixels reads the
|
||||
// active framebuffer, not the main one.)
|
||||
std::vector<Canvas *> canvases = getCanvas();
|
||||
std::vector<Object::StrongRef<Canvas>> canvases = states.back().canvases;
|
||||
setCanvas();
|
||||
|
||||
int w = getWidth();
|
||||
|
||||
@@ -68,6 +68,7 @@ int w_Canvas_getImageData(lua_State *L)
|
||||
love::image::Image *image = luax_getmodule<love::image::Image>(L, "image", MODULE_IMAGE_T);
|
||||
love::image::ImageData *img = canvas->getImageData(image);
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
|
||||
img->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ int w_newImage(lua_State *L)
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, image);
|
||||
image->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -241,6 +242,7 @@ int w_newQuad(lua_State *L)
|
||||
|
||||
Quad *quad = instance()->newQuad(v, sw, sh);
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quad);
|
||||
quad->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -265,6 +267,7 @@ int w_newFont(lua_State *L)
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
font->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -282,8 +285,8 @@ int w_newImageFont(lua_State *L)
|
||||
filter = i->getFilter();
|
||||
love::image::ImageData *id = i->getImageData();
|
||||
if (!id)
|
||||
return luaL_argerror(L, 1, "Image cannot be compressed.");
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id, false);
|
||||
return luaL_argerror(L, 1, "Image must not be compressed.");
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, id);
|
||||
lua_replace(L, 1);
|
||||
}
|
||||
|
||||
@@ -305,6 +308,7 @@ int w_newImageFont(lua_State *L)
|
||||
|
||||
// Push the type.
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, font);
|
||||
font->release();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -327,6 +331,7 @@ int w_newSpriteBatch(lua_State *L)
|
||||
);
|
||||
|
||||
luax_pushtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -343,6 +348,7 @@ int w_newParticleSystem(lua_State *L)
|
||||
);
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -367,6 +373,7 @@ int w_newCanvas(lua_State *L)
|
||||
return luaL_error(L, "Canvas not created, but no error thrown. I don't even...");
|
||||
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, canvas);
|
||||
canvas->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -450,6 +457,7 @@ int w_newShader(lua_State *L)
|
||||
{
|
||||
Shader *shader = instance()->newShader(sources);
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
shader->release();
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
@@ -542,6 +550,7 @@ int w_newMesh(lua_State *L)
|
||||
t->setTexture(tex);
|
||||
|
||||
luax_pushtype(L, "Mesh", GRAPHICS_MESH_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -631,7 +640,6 @@ int w_getFont(lua_State *L)
|
||||
if (f == 0)
|
||||
return 0;
|
||||
|
||||
f->retain();
|
||||
luax_pushtype(L, "Font", GRAPHICS_FONT_T, f);
|
||||
return 1;
|
||||
}
|
||||
@@ -855,6 +863,7 @@ int w_newScreenshot(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ i = instance()->newScreenshot(image, copyAlpha); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
|
||||
i->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -903,16 +912,13 @@ int w_getCanvas(lua_State *L)
|
||||
const std::vector<Canvas *> canvases = instance()->getCanvas();
|
||||
int n = 0;
|
||||
|
||||
if (!canvases.empty())
|
||||
for (Canvas *c : canvases)
|
||||
{
|
||||
for (Canvas *c : canvases)
|
||||
{
|
||||
c->retain();
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
|
||||
n++;
|
||||
}
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, c);
|
||||
n++;
|
||||
}
|
||||
else
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
n = 1;
|
||||
@@ -938,10 +944,7 @@ int w_getShader(lua_State *L)
|
||||
{
|
||||
Shader *shader = instance()->getShader();
|
||||
if (shader)
|
||||
{
|
||||
shader->retain();
|
||||
luax_pushtype(L, "Shader", GRAPHICS_SHADER_T, shader);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
|
||||
@@ -91,10 +91,7 @@ int w_Image_getData(lua_State *L)
|
||||
{
|
||||
love::image::CompressedData *t = i->getCompressedData();
|
||||
if (t)
|
||||
{
|
||||
t->retain();
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
@@ -102,10 +99,7 @@ int w_Image_getData(lua_State *L)
|
||||
{
|
||||
love::image::ImageData *t = i->getImageData();
|
||||
if (t)
|
||||
{
|
||||
t->retain();
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
@@ -263,18 +263,13 @@ int w_Mesh_getTexture(lua_State *L)
|
||||
if (tex == nullptr)
|
||||
return 0;
|
||||
|
||||
tex->retain();
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
luax_pushtype(L, "Image", GRAPHICS_IMAGE_T, tex);
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
else
|
||||
{
|
||||
tex->release();
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ int w_ParticleSystem_clone(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ clone = t->clone(); });
|
||||
|
||||
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, clone);
|
||||
clone->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -67,7 +68,6 @@ int w_ParticleSystem_getTexture(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
Texture *tex = t->getTexture();
|
||||
tex->retain();
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
@@ -75,10 +75,7 @@ int w_ParticleSystem_getTexture(lua_State *L)
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
else
|
||||
{
|
||||
tex->release();
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -608,7 +605,6 @@ int w_ParticleSystem_getQuads(lua_State *L)
|
||||
|
||||
for (size_t i = 0; i < quads.size(); i++)
|
||||
{
|
||||
quads[i]->retain();
|
||||
luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ int w_SpriteBatch_getTexture(lua_State *L)
|
||||
{
|
||||
SpriteBatch *t = luax_checkspritebatch(L, 1);
|
||||
Texture *tex = t->getTexture();
|
||||
tex->retain();
|
||||
|
||||
// FIXME: big hack right here.
|
||||
if (typeid(*tex) == typeid(Image))
|
||||
@@ -145,10 +144,7 @@ int w_SpriteBatch_getTexture(lua_State *L)
|
||||
else if (typeid(*tex) == typeid(Canvas))
|
||||
luax_pushtype(L, "Canvas", GRAPHICS_CANVAS_T, tex);
|
||||
else
|
||||
{
|
||||
tex->release();
|
||||
return luaL_error(L, "Unable to determine texture type.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ int w_newImageData(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ t = instance()->newImageData(w, h); });
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -61,6 +62,7 @@ int w_newImageData(lua_State *L)
|
||||
);
|
||||
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -75,6 +77,7 @@ int w_newCompressedData(lua_State *L)
|
||||
);
|
||||
|
||||
luax_pushtype(L, "CompressedData", IMAGE_COMPRESSED_DATA_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ int w_getJoysticks(lua_State *L)
|
||||
for (int i = 0; i < stickcount; i++)
|
||||
{
|
||||
Joystick *stick = instance()->getJoystick(i);
|
||||
stick->retain();
|
||||
luax_pushtype(L, "Joystick", JOYSTICK_JOYSTICK_T, stick);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,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);
|
||||
deriv->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ int w_newRandomGenerator(lua_State *L)
|
||||
}
|
||||
|
||||
luax_pushtype(L, "RandomGenerator", MATH_RANDOM_GENERATOR_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -139,6 +140,7 @@ int w_newBezierCurve(lua_State *L)
|
||||
|
||||
BezierCurve *curve = Math::instance.newBezierCurve(points);
|
||||
luax_pushtype(L, "BezierCurve", MATH_BEZIER_CURVE_T, curve);
|
||||
curve->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ int w_newCursor(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ cursor = instance()->newCursor(data, hotx, hoty); });
|
||||
|
||||
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
|
||||
cursor->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -60,7 +61,6 @@ int w_getSystemCursor(lua_State *L)
|
||||
Cursor *cursor = 0;
|
||||
luax_catchexcept(L, [&](){ cursor = instance()->getSystemCursor(systemCursor); });
|
||||
|
||||
cursor->retain();
|
||||
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
|
||||
return 1;
|
||||
}
|
||||
@@ -84,10 +84,7 @@ int w_getCursor(lua_State *L)
|
||||
Cursor *cursor = instance()->getCursor();
|
||||
|
||||
if (cursor)
|
||||
{
|
||||
cursor->retain();
|
||||
luax_pushtype(L, "Cursor", MOUSE_CURSOR_T, cursor);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
|
||||
@@ -432,7 +432,6 @@ int Body::getFixtureList(lua_State *L) const
|
||||
Fixture *fixture = (Fixture *)Memoizer::find(f);
|
||||
if (!fixture)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
fixture->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
@@ -458,6 +457,7 @@ int Body::getContactList(lua_State *L) const
|
||||
contact->retain();
|
||||
|
||||
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
|
||||
contact->release();
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ int Physics::newPolygonShape(lua_State *L)
|
||||
}
|
||||
|
||||
PolygonShape *p = new PolygonShape(s);
|
||||
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, p);
|
||||
p->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ int Physics::newChainShape(lua_State *L)
|
||||
|
||||
ChainShape *c = new ChainShape(s);
|
||||
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
|
||||
{
|
||||
Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
|
||||
if (a != 0)
|
||||
{
|
||||
a->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
|
||||
}
|
||||
else
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
}
|
||||
@@ -69,10 +66,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
|
||||
{
|
||||
Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
|
||||
if (b != 0)
|
||||
{
|
||||
b->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
|
||||
}
|
||||
else
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
}
|
||||
@@ -84,6 +78,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
|
||||
cobj->retain();
|
||||
|
||||
luax_pushtype(L, "Contact", (PHYSICS_CONTACT_T), cobj);
|
||||
cobj->release();
|
||||
|
||||
int args = 3;
|
||||
if (impulse)
|
||||
@@ -131,8 +126,6 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b)
|
||||
|
||||
if (ref != 0)
|
||||
{
|
||||
a->retain();
|
||||
b->retain();
|
||||
lua_State *L = ref->getL();
|
||||
ref->push();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
|
||||
@@ -163,7 +156,6 @@ bool World::QueryCallback::ReportFixture(b2Fixture *fixture)
|
||||
Fixture *f = (Fixture *)Memoizer::find(fixture);
|
||||
if (!f)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
f->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
|
||||
lua_call(L, 1, 1);
|
||||
return luax_toboolean(L, -1);
|
||||
@@ -191,7 +183,6 @@ float32 World::RayCastCallback::ReportFixture(b2Fixture *fixture, const b2Vec2 &
|
||||
Fixture *f = (Fixture *)Memoizer::find(fixture);
|
||||
if (!f)
|
||||
throw love::Exception("A fixture has escaped Memoizer!");
|
||||
f->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, f);
|
||||
b2Vec2 scaledPoint = Physics::scaleUp(point);
|
||||
lua_pushnumber(L, scaledPoint.x);
|
||||
@@ -440,7 +431,6 @@ int World::getBodyList(lua_State *L) const
|
||||
Body *body = (Body *)Memoizer::find(b);
|
||||
if (!body)
|
||||
throw love::Exception("A body has escaped Memoizer!");
|
||||
body->retain();
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
@@ -459,7 +449,6 @@ 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!");
|
||||
joint->retain();
|
||||
luax_pushtype(L, "Joint", PHYSICS_JOINT_T, joint);
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
@@ -482,6 +471,7 @@ int World::getContactList(lua_State *L) const
|
||||
else
|
||||
contact->retain();
|
||||
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
|
||||
contact->release();
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -526,7 +526,6 @@ int w_Body_getWorld(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
World *world = t->getWorld();
|
||||
world->retain();
|
||||
luax_pushtype(L, "World", PHYSICS_WORLD_T, world);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
|
||||
EdgeShape *e = 0;
|
||||
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
|
||||
e->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,9 +146,7 @@ int w_Contact_getFixtures(lua_State *L)
|
||||
Fixture *b = nullptr;
|
||||
luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
|
||||
|
||||
a->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
|
||||
b->retain();
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,6 @@ int w_Fixture_getBody(lua_State *L)
|
||||
Body *body = t->getBody();
|
||||
if (body == 0)
|
||||
return 0;
|
||||
body->retain();
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
|
||||
return 1;
|
||||
}
|
||||
@@ -140,6 +139,7 @@ int w_Fixture_getShape(lua_State *L)
|
||||
luax_pushtype(L, "Shape", PHYSICS_SHAPE_T, shape);
|
||||
break;
|
||||
}
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,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);
|
||||
w->release();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -78,6 +79,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);
|
||||
body->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -89,6 +91,7 @@ int w_newFixture(lua_State *L)
|
||||
Fixture *fixture;
|
||||
luax_catchexcept(L, [&](){ fixture = instance()->newFixture(body, shape, density); });
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
|
||||
fixture->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -102,6 +105,7 @@ int w_newCircleShape(lua_State *L)
|
||||
CircleShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(radius); });
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
else if (top == 3)
|
||||
@@ -112,6 +116,7 @@ int w_newCircleShape(lua_State *L)
|
||||
CircleShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newCircleShape(x, y, radius); });
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -129,6 +134,7 @@ int w_newRectangleShape(lua_State *L)
|
||||
PolygonShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(w, h); });
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
else if (top == 4 || top == 5)
|
||||
@@ -141,6 +147,7 @@ int w_newRectangleShape(lua_State *L)
|
||||
PolygonShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newRectangleShape(x, y, w, h, angle); });
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -156,6 +163,7 @@ int w_newEdgeShape(lua_State *L)
|
||||
EdgeShape *shape;
|
||||
luax_catchexcept(L, [&](){ shape = instance()->newEdgeShape(x1, y1, x2, y2); });
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
|
||||
shape->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -187,6 +195,7 @@ int w_newDistanceJoint(lua_State *L)
|
||||
j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -198,6 +207,7 @@ int w_newMouseJoint(lua_State *L)
|
||||
MouseJoint *j;
|
||||
luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
|
||||
luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -213,6 +223,7 @@ int w_newRevoluteJoint(lua_State *L)
|
||||
j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -245,6 +256,7 @@ int w_newPrismaticJoint(lua_State *L)
|
||||
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -268,6 +280,7 @@ int w_newPulleyJoint(lua_State *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);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -283,6 +296,7 @@ int w_newGearJoint(lua_State *L)
|
||||
j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -311,6 +325,7 @@ int w_newFrictionJoint(lua_State *L)
|
||||
j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -339,6 +354,7 @@ int w_newWeldJoint(lua_State *L)
|
||||
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -372,6 +388,7 @@ int w_newWheelJoint(lua_State *L)
|
||||
j = instance()->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -390,6 +407,7 @@ int w_newRopeJoint(lua_State *L)
|
||||
j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
|
||||
});
|
||||
luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -410,6 +428,7 @@ int w_newMotorJoint(lua_State *L)
|
||||
luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
|
||||
}
|
||||
luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
|
||||
j->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ int w_newSoundData(lua_State *L)
|
||||
}
|
||||
|
||||
luax_pushtype(L, "SoundData", SOUND_SOUND_DATA_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -77,6 +78,7 @@ int w_newDecoder(lua_State *L)
|
||||
return luaL_error(L, "Extension \"%s\" not supported.", data->getExtension().c_str());
|
||||
|
||||
luax_pushtype(L, "Decoder", SOUND_DECODER_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ int w_newThread(lua_State *L)
|
||||
|
||||
LuaThread *t = instance()->newThread(name, data);
|
||||
luax_pushtype(L, "Thread", THREAD_THREAD_T, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -62,6 +63,7 @@ int w_newChannel(lua_State *L)
|
||||
{
|
||||
Channel *c = instance()->newChannel();
|
||||
luax_pushtype(L, "Channel", THREAD_CHANNEL_T, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -70,6 +72,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);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,10 +262,7 @@ int w_getIcon(lua_State *L)
|
||||
{
|
||||
image::ImageData *i = instance()->getIcon();
|
||||
if (i)
|
||||
{
|
||||
i->retain();
|
||||
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user