mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Fixed undefined behaviour when love exceptions are converted into Lua errors (resolves issue #729)
This commit is contained in:
@@ -254,8 +254,8 @@ int Physics::getDistance(lua_State *L)
|
||||
b2DistanceOutput o;
|
||||
b2SimplexCache c;
|
||||
c.count = 0;
|
||||
try
|
||||
{
|
||||
|
||||
EXCEPT_GUARD(
|
||||
pA.Set(fixtureA->fixture->GetShape(), 0);
|
||||
pB.Set(fixtureB->fixture->GetShape(), 0);
|
||||
i.proxyA = pA;
|
||||
@@ -264,11 +264,8 @@ int Physics::getDistance(lua_State *L)
|
||||
i.transformB = fixtureB->fixture->GetBody()->GetTransform();
|
||||
i.useRadii = true;
|
||||
b2Distance(&o, &c, &i);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
luaL_error(L, "%s", e.what());
|
||||
}
|
||||
)
|
||||
|
||||
lua_pushnumber(L, Physics::scaleUp(o.distance));
|
||||
lua_pushnumber(L, Physics::scaleUp(o.pointA.x));
|
||||
lua_pushnumber(L, Physics::scaleUp(o.pointA.y));
|
||||
|
||||
@@ -232,7 +232,7 @@ int w_Body_setX(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setX(arg1);)
|
||||
EXCEPT_GUARD(t->setX(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ int w_Body_setY(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setY(arg1);)
|
||||
EXCEPT_GUARD(t->setY(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ int w_Body_setAngle(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setAngle(arg1);)
|
||||
EXCEPT_GUARD(t->setAngle(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -274,14 +274,14 @@ int w_Body_setPosition(lua_State *L)
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_checknumber(L, 3);
|
||||
ASSERT_GUARD(t->setPosition(arg1, arg2);)
|
||||
EXCEPT_GUARD(t->setPosition(arg1, arg2);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Body_resetMassData(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
ASSERT_GUARD(t->resetMassData();)
|
||||
EXCEPT_GUARD(t->resetMassData();)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ int w_Body_setMassData(lua_State *L)
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float m = (float)luaL_checknumber(L, 4);
|
||||
float i = (float)luaL_checknumber(L, 5);
|
||||
ASSERT_GUARD(t->setMassData(x, y, m, i);)
|
||||
EXCEPT_GUARD(t->setMassData(x, y, m, i);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ int w_Body_setMass(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
float m = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setMass(m);)
|
||||
EXCEPT_GUARD(t->setMass(m);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ int w_Body_setInertia(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
float i = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setInertia(i);)
|
||||
EXCEPT_GUARD(t->setInertia(i);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ int w_Body_setType(lua_State *L)
|
||||
const char *typeStr = luaL_checkstring(L, 2);
|
||||
Body::Type type;
|
||||
Body::getConstant(typeStr, type);
|
||||
ASSERT_GUARD(t->setType(type);)
|
||||
EXCEPT_GUARD(t->setType(type);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ int w_Body_setActive(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
bool b = luax_toboolean(L, 2);
|
||||
ASSERT_GUARD(t->setActive(b);)
|
||||
EXCEPT_GUARD(t->setActive(b);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ int w_Body_setFixedRotation(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
bool b = luax_toboolean(L, 2);
|
||||
ASSERT_GUARD(t->setFixedRotation(b);)
|
||||
EXCEPT_GUARD(t->setFixedRotation(b);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -518,21 +518,14 @@ int w_Body_getFixtureList(lua_State *L)
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
lua_remove(L, 1);
|
||||
int n = 0;
|
||||
ASSERT_GUARD(n = t->getFixtureList(L);)
|
||||
EXCEPT_GUARD(n = t->getFixtureList(L);)
|
||||
return n;
|
||||
}
|
||||
|
||||
int w_Body_destroy(lua_State *L)
|
||||
{
|
||||
Body *t = luax_checkbody(L, 1);
|
||||
try
|
||||
{
|
||||
t->destroy();
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
luaL_error(L, "%s", e.what());
|
||||
}
|
||||
EXCEPT_GUARD(t->destroy();)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ int w_ChainShape_setNextVertex(lua_State *L)
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
ASSERT_GUARD(c->setNextVertex(x, y);)
|
||||
EXCEPT_GUARD(c->setNextVertex(x, y);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ int w_ChainShape_setPrevVertex(lua_State *L)
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
ASSERT_GUARD(c->setPrevVertex(x, y);)
|
||||
EXCEPT_GUARD(c->setPrevVertex(x, y);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
|
||||
EdgeShape *e = 0;
|
||||
ASSERT_GUARD(e = c->getChildEdge(index);)
|
||||
EXCEPT_GUARD(e = c->getChildEdge(index);)
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
|
||||
return 1;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ int w_ChainShape_getPoint(lua_State *L)
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
|
||||
b2Vec2 v;
|
||||
ASSERT_GUARD(v = c->getPoint(index);)
|
||||
EXCEPT_GUARD(v = c->getPoint(index);)
|
||||
lua_pushnumber(L, v.x);
|
||||
lua_pushnumber(L, v.y);
|
||||
return 2;
|
||||
|
||||
@@ -65,7 +65,7 @@ int w_Fixture_setDensity(lua_State *L)
|
||||
{
|
||||
Fixture *t = luax_checkfixture(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setDensity(arg1);)
|
||||
EXCEPT_GUARD(t->setDensity(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,9 @@ int w_Fixture_rayCast(lua_State *L)
|
||||
{
|
||||
Fixture *t = luax_checkfixture(L, 1);
|
||||
lua_remove(L, 1);
|
||||
ASSERT_GUARD(return t->rayCast(L);)
|
||||
int ret = 0;
|
||||
EXCEPT_GUARD(ret = t->rayCast(L);)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_Fixture_setFilterData(lua_State *L)
|
||||
@@ -256,14 +258,7 @@ int w_Fixture_setGroupIndex(lua_State *L)
|
||||
int w_Fixture_destroy(lua_State *L)
|
||||
{
|
||||
Fixture *t = luax_checkfixture(L, 1);
|
||||
try
|
||||
{
|
||||
t->destroy();
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
luaL_error(L, "%s", e.what());
|
||||
}
|
||||
EXCEPT_GUARD(t->destroy();)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ int w_FrictionJoint_setMaxForce(lua_State *L)
|
||||
{
|
||||
FrictionJoint *t = luax_checkfrictionjoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setMaxForce(arg1);)
|
||||
EXCEPT_GUARD(t->setMaxForce(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ int w_FrictionJoint_setMaxTorque(lua_State *L)
|
||||
{
|
||||
FrictionJoint *t = luax_checkfrictionjoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setMaxTorque(arg1);)
|
||||
EXCEPT_GUARD(t->setMaxTorque(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ int w_GearJoint_setRatio(lua_State *L)
|
||||
{
|
||||
GearJoint *t = luax_checkgearjoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setRatio(arg1);)
|
||||
EXCEPT_GUARD(t->setRatio(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,14 +78,7 @@ int w_Joint_getCollideConnected(lua_State *L)
|
||||
int w_Joint_destroy(lua_State *L)
|
||||
{
|
||||
Joint *t = luax_checkjoint(L, 1);
|
||||
try
|
||||
{
|
||||
t->destroyJoint();
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
luaL_error(L, "%s", e.what());
|
||||
}
|
||||
EXCEPT_GUARD(t->destroyJoint();)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ int w_newWorld(lua_State *L)
|
||||
bool sleep = luax_optboolean(L, 3, true);
|
||||
|
||||
World *w;
|
||||
ASSERT_GUARD(w = instance->newWorld(gx, gy, sleep);)
|
||||
EXCEPT_GUARD(w = instance->newWorld(gx, gy, sleep);)
|
||||
luax_pushtype(L, "World", PHYSICS_WORLD_T, w);
|
||||
|
||||
return 1;
|
||||
@@ -75,7 +75,7 @@ int w_newBody(lua_State *L)
|
||||
return luaL_error(L, "Invalid Body type: %s", typestr);
|
||||
|
||||
Body *body;
|
||||
ASSERT_GUARD(body = instance->newBody(world, x, y, btype);)
|
||||
EXCEPT_GUARD(body = instance->newBody(world, x, y, btype);)
|
||||
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
|
||||
return 1;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ int w_newFixture(lua_State *L)
|
||||
Shape *shape = luax_checkshape(L, 2);
|
||||
float density = (float)luaL_optnumber(L, 3, 1.0f);
|
||||
Fixture *fixture;
|
||||
ASSERT_GUARD(fixture = instance->newFixture(body, shape, density);)
|
||||
EXCEPT_GUARD(fixture = instance->newFixture(body, shape, density);)
|
||||
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, fixture);
|
||||
return 1;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ int w_newCircleShape(lua_State *L)
|
||||
{
|
||||
float radius = (float)luaL_checknumber(L, 1);
|
||||
CircleShape *shape;
|
||||
ASSERT_GUARD(shape = instance->newCircleShape(radius);)
|
||||
EXCEPT_GUARD(shape = instance->newCircleShape(radius);)
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
return 1;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ int w_newCircleShape(lua_State *L)
|
||||
float y = (float)luaL_checknumber(L, 2);
|
||||
float radius = (float)luaL_checknumber(L, 3);
|
||||
CircleShape *shape;
|
||||
ASSERT_GUARD(shape = instance->newCircleShape(x, y, radius);)
|
||||
EXCEPT_GUARD(shape = instance->newCircleShape(x, y, radius);)
|
||||
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
|
||||
return 1;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ int w_newRectangleShape(lua_State *L)
|
||||
float w = (float)luaL_checknumber(L, 1);
|
||||
float h = (float)luaL_checknumber(L, 2);
|
||||
PolygonShape *shape;
|
||||
ASSERT_GUARD(shape = instance->newRectangleShape(w, h);)
|
||||
EXCEPT_GUARD(shape = instance->newRectangleShape(w, h);)
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
return 1;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ int w_newRectangleShape(lua_State *L)
|
||||
float h = (float)luaL_checknumber(L, 4);
|
||||
float angle = (float)luaL_optnumber(L, 5, 0);
|
||||
PolygonShape *shape;
|
||||
ASSERT_GUARD(shape = instance->newRectangleShape(x, y, w, h, angle);)
|
||||
EXCEPT_GUARD(shape = instance->newRectangleShape(x, y, w, h, angle);)
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
|
||||
return 1;
|
||||
}
|
||||
@@ -153,19 +153,23 @@ int w_newEdgeShape(lua_State *L)
|
||||
float x2 = (float)luaL_checknumber(L, 3);
|
||||
float y2 = (float)luaL_checknumber(L, 4);
|
||||
EdgeShape *shape;
|
||||
ASSERT_GUARD(shape = instance->newEdgeShape(x1, y1, x2, y2);)
|
||||
EXCEPT_GUARD(shape = instance->newEdgeShape(x1, y1, x2, y2);)
|
||||
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, shape);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_newPolygonShape(lua_State *L)
|
||||
{
|
||||
ASSERT_GUARD(return instance->newPolygonShape(L);)
|
||||
int ret = 0;
|
||||
EXCEPT_GUARD(ret = instance->newPolygonShape(L);)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_newChainShape(lua_State *L)
|
||||
{
|
||||
ASSERT_GUARD(return instance->newChainShape(L);)
|
||||
int ret = 0;
|
||||
EXCEPT_GUARD(ret = instance->newChainShape(L);)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_newDistanceJoint(lua_State *L)
|
||||
@@ -178,7 +182,7 @@ int w_newDistanceJoint(lua_State *L)
|
||||
float y2 = (float)luaL_checknumber(L, 6);
|
||||
bool collideConnected = luax_optboolean(L, 7, false);
|
||||
DistanceJoint *j;
|
||||
ASSERT_GUARD(j = instance->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);)
|
||||
luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -189,7 +193,7 @@ int w_newMouseJoint(lua_State *L)
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
MouseJoint *j;
|
||||
ASSERT_GUARD(j = instance->newMouseJoint(body, x, y);)
|
||||
EXCEPT_GUARD(j = instance->newMouseJoint(body, x, y);)
|
||||
luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -202,7 +206,7 @@ int w_newRevoluteJoint(lua_State *L)
|
||||
float y = (float)luaL_checknumber(L, 4);
|
||||
bool collideConnected = luax_optboolean(L, 5, false);
|
||||
RevoluteJoint *j;
|
||||
ASSERT_GUARD(j = instance->newRevoluteJoint(body1, body2, x, y, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newRevoluteJoint(body1, body2, x, y, collideConnected);)
|
||||
luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -232,7 +236,7 @@ int w_newPrismaticJoint(lua_State *L)
|
||||
collideConnected = luax_optboolean(L, 7, false);
|
||||
}
|
||||
PrismaticJoint *j;
|
||||
ASSERT_GUARD(j = instance->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);)
|
||||
luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -253,7 +257,7 @@ int w_newPulleyJoint(lua_State *L)
|
||||
bool collideConnected = luax_optboolean(L, 12, true); // PulleyJoints default to colliding connected bodies, see b2PulleyJoint.h
|
||||
|
||||
PulleyJoint *j;
|
||||
ASSERT_GUARD(j = instance->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected);)
|
||||
EXCEPT_GUARD(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);
|
||||
return 1;
|
||||
}
|
||||
@@ -266,7 +270,7 @@ int w_newGearJoint(lua_State *L)
|
||||
bool collideConnected = luax_optboolean(L, 4, false);
|
||||
|
||||
GearJoint *j;
|
||||
ASSERT_GUARD(j = instance->newGearJoint(joint1, joint2, ratio, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newGearJoint(joint1, joint2, ratio, collideConnected);)
|
||||
luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -292,7 +296,7 @@ int w_newFrictionJoint(lua_State *L)
|
||||
collideConnected = luax_optboolean(L, 5, false);
|
||||
}
|
||||
FrictionJoint *j;
|
||||
ASSERT_GUARD(j = instance->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);)
|
||||
luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -318,7 +322,7 @@ int w_newWeldJoint(lua_State *L)
|
||||
collideConnected = luax_optboolean(L, 5, false);
|
||||
}
|
||||
WeldJoint *j;
|
||||
ASSERT_GUARD(j = instance->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);)
|
||||
luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -349,7 +353,7 @@ int w_newWheelJoint(lua_State *L)
|
||||
}
|
||||
|
||||
WheelJoint *j;
|
||||
ASSERT_GUARD(j = instance->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);)
|
||||
luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -365,7 +369,7 @@ int w_newRopeJoint(lua_State *L)
|
||||
float maxLength = (float)luaL_checknumber(L, 7);
|
||||
bool collideConnected = luax_optboolean(L, 8, false);
|
||||
RopeJoint *j;
|
||||
ASSERT_GUARD(j = instance->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);)
|
||||
EXCEPT_GUARD(j = instance->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);)
|
||||
luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
|
||||
return 1;
|
||||
}
|
||||
@@ -378,14 +382,7 @@ int w_getDistance(lua_State *L)
|
||||
int w_setMeter(lua_State *L)
|
||||
{
|
||||
int arg1 = luaL_checkint(L, 1);
|
||||
try
|
||||
{
|
||||
Physics::setMeter(arg1);
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
EXCEPT_GUARD(Physics::setMeter(arg1);)
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -451,14 +448,7 @@ extern "C" int luaopen_love_physics(lua_State *L)
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new Physics();
|
||||
}
|
||||
catch(Exception &e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
EXCEPT_GUARD(instance = new Physics();)
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "common/config.h"
|
||||
#include "Physics.h"
|
||||
|
||||
#define ASSERT_GUARD(A) try { A } catch (love::Exception & e) { return luaL_error(L, "%s", e.what()); }
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace physics
|
||||
|
||||
@@ -122,7 +122,7 @@ int w_PrismaticJoint_setUpperLimit(lua_State *L)
|
||||
{
|
||||
PrismaticJoint *t = luax_checkprismaticjoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setUpperLimit(arg1);)
|
||||
EXCEPT_GUARD(t->setUpperLimit(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ int w_PrismaticJoint_setLowerLimit(lua_State *L)
|
||||
{
|
||||
PrismaticJoint *t = luax_checkprismaticjoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setLowerLimit(arg1);)
|
||||
EXCEPT_GUARD(t->setLowerLimit(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ int w_PrismaticJoint_setLimits(lua_State *L)
|
||||
PrismaticJoint *t = luax_checkprismaticjoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_checknumber(L, 3);
|
||||
ASSERT_GUARD(t->setLimits(arg1, arg2);)
|
||||
EXCEPT_GUARD(t->setLimits(arg1, arg2);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ int w_RevoluteJoint_setUpperLimit(lua_State *L)
|
||||
{
|
||||
RevoluteJoint *t = luax_checkrevolutejoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setUpperLimit(arg1);)
|
||||
EXCEPT_GUARD(t->setUpperLimit(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ int w_RevoluteJoint_setLowerLimit(lua_State *L)
|
||||
{
|
||||
RevoluteJoint *t = luax_checkrevolutejoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->setLowerLimit(arg1);)
|
||||
EXCEPT_GUARD(t->setLowerLimit(arg1);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ int w_RevoluteJoint_setLimits(lua_State *L)
|
||||
RevoluteJoint *t = luax_checkrevolutejoint(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_checknumber(L, 3);
|
||||
ASSERT_GUARD(t->setLimits(arg1, arg2);)
|
||||
EXCEPT_GUARD(t->setLimits(arg1, arg2);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ int w_Shape_rayCast(lua_State *L)
|
||||
{
|
||||
Shape *t = luax_checkshape(L, 1);
|
||||
lua_remove(L, 1);
|
||||
ASSERT_GUARD(return t->rayCast(L);)
|
||||
int ret = 0;
|
||||
EXCEPT_GUARD(ret = t->rayCast(L);)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_Shape_computeAABB(lua_State *L)
|
||||
|
||||
@@ -39,7 +39,7 @@ int w_World_update(lua_State *L)
|
||||
{
|
||||
World *t = luax_checkworld(L, 1);
|
||||
float dt = (float)luaL_checknumber(L, 2);
|
||||
ASSERT_GUARD(t->update(dt);)
|
||||
EXCEPT_GUARD(t->update(dt);)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,20 +162,15 @@ int w_World_rayCast(lua_State *L)
|
||||
{
|
||||
World *t = luax_checkworld(L, 1);
|
||||
lua_remove(L, 1);
|
||||
ASSERT_GUARD(return t->rayCast(L);)
|
||||
int ret = 0;
|
||||
EXCEPT_GUARD(ret = t->rayCast(L);)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int w_World_destroy(lua_State *L)
|
||||
{
|
||||
World *t = luax_checkworld(L, 1);
|
||||
try
|
||||
{
|
||||
t->destroy();
|
||||
}
|
||||
catch(love::Exception &e)
|
||||
{
|
||||
luaL_error(L, "%s", e.what());
|
||||
}
|
||||
EXCEPT_GUARD(t->destroy();)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user