Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2015-03-01 18:32:41 -04:00
parent 3830a0969c
commit 2f419c1c83
79 changed files with 601 additions and 566 deletions
+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", PHYSICS_FIXTURE_T, fixture);
luax_pushtype(L, PHYSICS_FIXTURE_ID, 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", PHYSICS_CONTACT_T, contact);
luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
contact->release();
lua_rawseti(L, -2, i);
i++;
+4 -4
View File
@@ -146,7 +146,7 @@ int Physics::newPolygonShape(lua_State *L)
}
PolygonShape *p = new PolygonShape(s);
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, p);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, 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", PHYSICS_CHAIN_SHAPE_T, c);
luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, c);
c->release();
return 1;
}
@@ -281,8 +281,8 @@ Fixture *Physics::newFixture(Body *body, Shape *shape, float density)
int Physics::getDistance(lua_State *L)
{
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, "Fixture", PHYSICS_FIXTURE_T);
Fixture *fixtureA = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
Fixture *fixtureB = luax_checktype<Fixture>(L, 2, PHYSICS_FIXTURE_ID);
b2DistanceProxy pA, pB;
b2DistanceInput i;
b2DistanceOutput o;
+10 -10
View File
@@ -57,7 +57,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
{
Fixture *a = (Fixture *)Memoizer::find(contact->GetFixtureA());
if (a != 0)
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
else
throw love::Exception("A fixture has escaped Memoizer!");
}
@@ -66,7 +66,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
{
Fixture *b = (Fixture *)Memoizer::find(contact->GetFixtureB());
if (b != 0)
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
else
throw love::Exception("A fixture has escaped Memoizer!");
}
@@ -77,7 +77,7 @@ void World::ContactCallback::process(b2Contact *contact, const b2ContactImpulse
else
cobj->retain();
luax_pushtype(L, "Contact", (PHYSICS_CONTACT_T), cobj);
luax_pushtype(L, PHYSICS_CONTACT_ID, cobj);
cobj->release();
int args = 3;
@@ -128,8 +128,8 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b)
{
lua_State *L = ref->getL();
ref->push();
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
lua_call(L, 2, 1);
return luax_toboolean(L, -1);
}
@@ -156,7 +156,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", PHYSICS_FIXTURE_T, f);
luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
lua_call(L, 1, 1);
return luax_toboolean(L, -1);
}
@@ -183,7 +183,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", PHYSICS_FIXTURE_T, f);
luax_pushtype(L, PHYSICS_FIXTURE_ID, f);
b2Vec2 scaledPoint = Physics::scaleUp(point);
lua_pushnumber(L, scaledPoint.x);
lua_pushnumber(L, scaledPoint.y);
@@ -431,7 +431,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", PHYSICS_BODY_T, body);
luax_pushtype(L, PHYSICS_BODY_ID, body);
lua_rawseti(L, -2, i);
i++;
}
@@ -449,7 +449,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", PHYSICS_JOINT_T, joint);
luax_pushtype(L, PHYSICS_JOINT_ID, joint);
lua_rawseti(L, -2, i);
i++;
}
@@ -470,7 +470,7 @@ int World::getContactList(lua_State *L) const
contact = new Contact(c);
else
contact->retain();
luax_pushtype(L, "Contact", PHYSICS_CONTACT_T, contact);
luax_pushtype(L, PHYSICS_CONTACT_ID, contact);
contact->release();
lua_rawseti(L, -2, i);
i++;
+4 -4
View File
@@ -30,7 +30,7 @@ namespace box2d
Body *luax_checkbody(lua_State *L, int idx)
{
Body *b = luax_checktype<Body>(L, idx, "Body", PHYSICS_BODY_T);
Body *b = luax_checktype<Body>(L, idx, PHYSICS_BODY_ID);
if (b->body == 0)
luaL_error(L, "Attempt to use destroyed body.");
return b;
@@ -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", PHYSICS_WORLD_T, world);
luax_pushtype(L, PHYSICS_WORLD_ID, world);
return 1;
}
@@ -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", PHYSICS_BODY_T);
Body *b = luax_checktype<Body>(L, 1, PHYSICS_BODY_ID);
luax_pushboolean(L, b->body == nullptr);
return 1;
}
@@ -650,7 +650,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_body(lua_State *L)
{
return luax_register_type(L, "Body", functions);
return luax_register_type(L, PHYSICS_BODY_ID, functions);
}
} // box2d
@@ -31,7 +31,7 @@ namespace box2d
ChainShape *luax_checkchainshape(lua_State *L, int idx)
{
return luax_checktype<ChainShape>(L, idx, "ChainShape", PHYSICS_CHAIN_SHAPE_T);
return luax_checktype<ChainShape>(L, idx, PHYSICS_CHAIN_SHAPE_ID);
}
int w_ChainShape_setNextVertex(lua_State *L)
@@ -65,7 +65,7 @@ int w_ChainShape_getChildEdge(lua_State *L)
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
EdgeShape *e = 0;
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
luax_pushtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, e);
e->release();
return 1;
}
@@ -127,7 +127,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_chainshape(lua_State *L)
{
return luax_register_type(L, "ChainShape", functions);
return luax_register_type(L, PHYSICS_CHAIN_SHAPE_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
CircleShape *luax_checkcircleshape(lua_State *L, int idx)
{
return luax_checktype<CircleShape>(L, idx, "CircleShape", PHYSICS_CIRCLE_SHAPE_T);
return luax_checktype<CircleShape>(L, idx, PHYSICS_CIRCLE_SHAPE_ID);
}
int w_CircleShape_getRadius(lua_State *L)
@@ -83,7 +83,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_circleshape(lua_State *L)
{
return luax_register_type(L, "CircleShape", functions);
return luax_register_type(L, PHYSICS_CIRCLE_SHAPE_ID, functions);
}
} // box2d
+5 -5
View File
@@ -30,7 +30,7 @@ namespace box2d
Contact *luax_checkcontact(lua_State *L, int idx)
{
Contact *c = luax_checktype<Contact>(L, idx, "Contact", PHYSICS_CONTACT_T);
Contact *c = luax_checktype<Contact>(L, idx, PHYSICS_CONTACT_ID);
if (!c->isValid())
luaL_error(L, "Attempt to use destroyed contact.");
return c;
@@ -146,14 +146,14 @@ int w_Contact_getFixtures(lua_State *L)
Fixture *b = nullptr;
luax_catchexcept(L, [&](){ t->getFixtures(a, b); });
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a);
luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, b);
luax_pushtype(L, PHYSICS_FIXTURE_ID, a);
luax_pushtype(L, PHYSICS_FIXTURE_ID, b);
return 2;
}
int w_Contact_isDestroyed(lua_State *L)
{
Contact *c = luax_checktype<Contact>(L, 1, "Contact", PHYSICS_CONTACT_T);
Contact *c = luax_checktype<Contact>(L, 1, PHYSICS_CONTACT_ID);
luax_pushboolean(L, !c->isValid());
return 1;
}
@@ -181,7 +181,7 @@ extern "C" int luaopen_contact(lua_State *L)
{ 0, 0 }
};
return luax_register_type(L, "Contact", functions);
return luax_register_type(L, PHYSICS_CONTACT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx)
{
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T);
DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx, PHYSICS_DISTANCE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -104,7 +104,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_distancejoint(lua_State *L)
{
return luax_register_type(L, "DistanceJoint", functions);
return luax_register_type(L, PHYSICS_DISTANCE_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -29,7 +29,7 @@ namespace box2d
EdgeShape *luax_checkedgeshape(lua_State *L, int idx)
{
return luax_checktype<EdgeShape>(L, idx, "EdgeShape", PHYSICS_EDGE_SHAPE_T);
return luax_checktype<EdgeShape>(L, idx, PHYSICS_EDGE_SHAPE_ID);
}
int w_EdgeShape_getPoints(lua_State *L)
@@ -55,7 +55,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_edgeshape(lua_State *L)
{
return luax_register_type(L, "EdgeShape", functions);
return luax_register_type(L, PHYSICS_EDGE_SHAPE_ID, functions);
}
} // box2d
+9 -9
View File
@@ -30,7 +30,7 @@ namespace box2d
Fixture *luax_checkfixture(lua_State *L, int idx)
{
Fixture *f = luax_checktype<Fixture>(L, idx, "Fixture", PHYSICS_FIXTURE_T);
Fixture *f = luax_checktype<Fixture>(L, idx, PHYSICS_FIXTURE_ID);
if (!f->isValid())
luaL_error(L, "Attempt to use destroyed fixture.");
return f;
@@ -111,7 +111,7 @@ int w_Fixture_getBody(lua_State *L)
Body *body = t->getBody();
if (body == 0)
return 0;
luax_pushtype(L, "Body", PHYSICS_BODY_T, body);
luax_pushtype(L, PHYSICS_BODY_ID, 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", PHYSICS_EDGE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
break;
case Shape::SHAPE_CHAIN:
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CHAIN_SHAPE_ID, shape);
break;
case Shape::SHAPE_CIRCLE:
luax_pushtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, shape);
break;
case Shape::SHAPE_POLYGON:
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, shape);
break;
default:
luax_pushtype(L, "Shape", PHYSICS_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_SHAPE_ID, shape);
break;
}
shape->release();
@@ -264,7 +264,7 @@ int w_Fixture_destroy(lua_State *L)
int w_Fixture_isDestroyed(lua_State *L)
{
Fixture *f = luax_checktype<Fixture>(L, 1, "Fixture", PHYSICS_FIXTURE_T);
Fixture *f = luax_checktype<Fixture>(L, 1, PHYSICS_FIXTURE_ID);
luax_pushboolean(L, !f->isValid());
return 1;
}
@@ -303,7 +303,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_fixture(lua_State *L)
{
return luax_register_type(L, "Fixture", functions);
return luax_register_type(L, PHYSICS_FIXTURE_ID, functions);
}
} // box2d
@@ -30,7 +30,7 @@ namespace box2d
FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx)
{
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, "FrictionJoint", PHYSICS_FRICTION_JOINT_T);
FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx, PHYSICS_FRICTION_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_frictionjoint(lua_State *L)
{
return luax_register_type(L, "FrictionJoint", functions);
return luax_register_type(L, PHYSICS_FRICTION_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -30,7 +30,7 @@ namespace box2d
GearJoint *luax_checkgearjoint(lua_State *L, int idx)
{
GearJoint *j = luax_checktype<GearJoint>(L, idx, "GearJoint", PHYSICS_GEAR_JOINT_T);
GearJoint *j = luax_checktype<GearJoint>(L, idx, PHYSICS_GEAR_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -88,7 +88,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_gearjoint(lua_State *L)
{
return luax_register_type(L, "GearJoint", functions);
return luax_register_type(L, PHYSICS_GEAR_JOINT_ID, functions);
}
} // box2d
+16 -16
View File
@@ -38,27 +38,27 @@ void luax_pushjoint(lua_State *L, Joint *j)
switch (j->getType())
{
case Joint::JOINT_DISTANCE:
return luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
case Joint::JOINT_REVOLUTE:
return luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
case Joint::JOINT_PRISMATIC:
return luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
return luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
case Joint::JOINT_MOUSE:
return luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
case Joint::JOINT_PULLEY:
return luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
return luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
case Joint::JOINT_GEAR:
return luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
return luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
case Joint::JOINT_FRICTION:
return luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
return luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
case Joint::JOINT_WELD:
return luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
return luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
case Joint::JOINT_WHEEL:
return luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
return luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
case Joint::JOINT_ROPE:
return luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
return luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
case Joint::JOINT_MOTOR:
return luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
return luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
default:
return lua_pushnil(L);
}
@@ -66,7 +66,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", PHYSICS_JOINT_T);
Joint *t = luax_checktype<Joint>(L, idx, PHYSICS_JOINT_ID);
if (!t->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return t;
@@ -92,8 +92,8 @@ int w_Joint_getBodies(lua_State *L)
b2 = t->getBodyB();
});
luax_pushtype(L, "Body", PHYSICS_BODY_T, b1);
luax_pushtype(L, "Body", PHYSICS_BODY_T, b2);
luax_pushtype(L, PHYSICS_BODY_ID, b1);
luax_pushtype(L, PHYSICS_BODY_ID, b2);
return 2;
}
@@ -149,7 +149,7 @@ int w_Joint_destroy(lua_State *L)
int w_Joint_isDestroyed(lua_State *L)
{
Joint *t = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
Joint *t = luax_checktype<Joint>(L, 1, PHYSICS_JOINT_ID);
luax_pushboolean(L, !t->isValid());
return 1;
}
@@ -171,7 +171,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_joint(lua_State *L)
{
return luax_register_type(L, "Joint", functions);
return luax_register_type(L, PHYSICS_JOINT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
{
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, "MotorJoint", PHYSICS_MOTOR_JOINT_T);
MotorJoint *j = luax_checktype<MotorJoint>(L, idx, PHYSICS_MOTOR_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -138,7 +138,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_motorjoint(lua_State *L)
{
return luax_register_type(L, "MotorJoint", functions);
return luax_register_type(L, PHYSICS_MOTOR_JOINT_ID, functions);
}
@@ -29,7 +29,7 @@ namespace box2d
MouseJoint *luax_checkmousejoint(lua_State *L, int idx)
{
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, "MouseJoint", PHYSICS_MOUSE_JOINT_T);
MouseJoint *j = luax_checktype<MouseJoint>(L, idx, PHYSICS_MOUSE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -122,7 +122,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_mousejoint(lua_State *L)
{
return luax_register_type(L, "MouseJoint", functions);
return luax_register_type(L, PHYSICS_MOUSE_JOINT_ID, functions);
}
} // box2d
+42 -42
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", PHYSICS_WORLD_T, w);
luax_pushtype(L, PHYSICS_WORLD_ID, w);
w->release();
return 1;
@@ -67,7 +67,7 @@ int w_newWorld(lua_State *L)
int w_newBody(lua_State *L)
{
World *world = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
World *world = luax_checkworld(L, 1);
float x = (float)luaL_optnumber(L, 2, 0.0);
float y = (float)luaL_optnumber(L, 3, 0.0);
@@ -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", PHYSICS_BODY_T, body);
luax_pushtype(L, PHYSICS_BODY_ID, 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", PHYSICS_FIXTURE_T, fixture);
luax_pushtype(L, PHYSICS_FIXTURE_ID, 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", PHYSICS_CIRCLE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, 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", PHYSICS_CIRCLE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_CIRCLE_SHAPE_ID, 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", PHYSICS_POLYGON_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, 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", PHYSICS_POLYGON_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_POLYGON_SHAPE_ID, 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", PHYSICS_EDGE_SHAPE_T, shape);
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, shape);
shape->release();
return 1;
}
@@ -183,8 +183,8 @@ int w_newChainShape(lua_State *L)
int w_newDistanceJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float x1 = (float)luaL_checknumber(L, 3);
float y1 = (float)luaL_checknumber(L, 4);
float x2 = (float)luaL_checknumber(L, 5);
@@ -194,27 +194,27 @@ int w_newDistanceJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
});
luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
luax_pushtype(L, PHYSICS_DISTANCE_JOINT_ID, j);
j->release();
return 1;
}
int w_newMouseJoint(lua_State *L)
{
Body *body = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body = luax_checkbody(L, 1);
float x = (float)luaL_checknumber(L, 2);
float y = (float)luaL_checknumber(L, 3);
MouseJoint *j;
luax_catchexcept(L, [&](){ j = instance()->newMouseJoint(body, x, y); });
luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
luax_pushtype(L, PHYSICS_MOUSE_JOINT_ID, j);
j->release();
return 1;
}
int w_newRevoluteJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float x = (float)luaL_checknumber(L, 3);
float y = (float)luaL_checknumber(L, 4);
bool collideConnected = luax_optboolean(L, 5, false);
@@ -222,15 +222,15 @@ int w_newRevoluteJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected);
});
luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
j->release();
return 1;
}
int w_newPrismaticJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB, ax, ay;
@@ -255,15 +255,15 @@ int w_newPrismaticJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
});
luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
j->release();
return 1;
}
int w_newPulleyJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float gx1 = (float)luaL_checknumber(L, 3);
float gy1 = (float)luaL_checknumber(L, 4);
float gx2 = (float)luaL_checknumber(L, 5);
@@ -279,15 +279,15 @@ 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", PHYSICS_PULLEY_JOINT_T, j);
luax_pushtype(L, PHYSICS_PULLEY_JOINT_ID, j);
j->release();
return 1;
}
int w_newGearJoint(lua_State *L)
{
Joint *joint1 = luax_checktype<Joint>(L, 1, "Joint", PHYSICS_JOINT_T);
Joint *joint2 = luax_checktype<Joint>(L, 2, "Joint", PHYSICS_JOINT_T);
Joint *joint1 = luax_checkjoint(L, 1);
Joint *joint2 = luax_checkjoint(L, 2);
float ratio = (float)luaL_optnumber(L, 3, 1.0);
bool collideConnected = luax_optboolean(L, 4, false);
@@ -295,15 +295,15 @@ int w_newGearJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newGearJoint(joint1, joint2, ratio, collideConnected);
});
luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
luax_pushtype(L, PHYSICS_GEAR_JOINT_ID, j);
j->release();
return 1;
}
int w_newFrictionJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB;
@@ -324,15 +324,15 @@ int w_newFrictionJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
});
luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
luax_pushtype(L, PHYSICS_FRICTION_JOINT_ID, j);
j->release();
return 1;
}
int w_newWeldJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB;
@@ -353,15 +353,15 @@ int w_newWeldJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
});
luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
j->release();
return 1;
}
int w_newWheelJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float xA = (float)luaL_checknumber(L, 3);
float yA = (float)luaL_checknumber(L, 4);
float xB, yB, ax, ay;
@@ -387,15 +387,15 @@ 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", PHYSICS_WHEEL_JOINT_T, j);
luax_pushtype(L, PHYSICS_WHEEL_JOINT_ID, j);
j->release();
return 1;
}
int w_newRopeJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
float x1 = (float)luaL_checknumber(L, 3);
float y1 = (float)luaL_checknumber(L, 4);
float x2 = (float)luaL_checknumber(L, 5);
@@ -406,15 +406,15 @@ int w_newRopeJoint(lua_State *L)
luax_catchexcept(L, [&]() {
j = instance()->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
});
luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
luax_pushtype(L, PHYSICS_ROPE_JOINT_ID, j);
j->release();
return 1;
}
int w_newMotorJoint(lua_State *L)
{
Body *body1 = luax_checktype<Body>(L, 1, "Body", PHYSICS_BODY_T);
Body *body2 = luax_checktype<Body>(L, 2, "Body", PHYSICS_BODY_T);
Body *body1 = luax_checkbody(L, 1);
Body *body2 = luax_checkbody(L, 2);
MotorJoint *j = 0;
if (!lua_isnoneornil(L, 3))
{
@@ -427,7 +427,7 @@ int w_newMotorJoint(lua_State *L)
{
luax_catchexcept(L, [&](){ j = instance()->newMotorJoint(body1, body2); });
}
luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
luax_pushtype(L, PHYSICS_MOTOR_JOINT_ID, j);
j->release();
return 1;
}
@@ -517,7 +517,7 @@ extern "C" int luaopen_love_physics(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "physics";
w.flags = MODULE_T;
w.type = MODULE_ID;
w.functions = functions;
w.types = types;
@@ -29,7 +29,7 @@ namespace box2d
PolygonShape *luax_checkpolygonshape(lua_State *L, int idx)
{
return luax_checktype<PolygonShape>(L, idx, "PolygonShape", PHYSICS_POLYGON_SHAPE_T);
return luax_checktype<PolygonShape>(L, idx, PHYSICS_POLYGON_SHAPE_ID);
}
int w_PolygonShape_getPoints(lua_State *L)
@@ -63,7 +63,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_polygonshape(lua_State *L)
{
return luax_register_type(L, "PolygonShape", functions);
return luax_register_type(L, PHYSICS_POLYGON_SHAPE_ID, functions);
}
} // box2d
@@ -30,7 +30,7 @@ namespace box2d
PrismaticJoint *luax_checkprismaticjoint(lua_State *L, int idx)
{
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
PrismaticJoint *j = luax_checktype<PrismaticJoint>(L, idx, PHYSICS_PRISMATIC_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_prismaticjoint(lua_State *L)
{
return luax_register_type(L, "PrismaticJoint", functions);
return luax_register_type(L, PHYSICS_PRISMATIC_JOINT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx)
{
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, "PulleyJoint", PHYSICS_PULLEY_JOINT_T);
PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx, PHYSICS_PULLEY_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -85,7 +85,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_pulleyjoint(lua_State *L)
{
return luax_register_type(L, "PulleyJoint", functions);
return luax_register_type(L, PHYSICS_PULLEY_JOINT_ID, functions);
}
} // box2d
@@ -30,7 +30,7 @@ namespace box2d
RevoluteJoint *luax_checkrevolutejoint(lua_State *L, int idx)
{
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T);
RevoluteJoint *j = luax_checktype<RevoluteJoint>(L, idx, PHYSICS_REVOLUTE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -199,7 +199,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_revolutejoint(lua_State *L)
{
return luax_register_type(L, "RevoluteJoint", functions);
return luax_register_type(L, PHYSICS_REVOLUTE_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -29,7 +29,7 @@ namespace box2d
RopeJoint *luax_checkropejoint(lua_State *L, int idx)
{
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, "RopeJoint", PHYSICS_ROPE_JOINT_T);
RopeJoint *j = luax_checktype<RopeJoint>(L, idx, PHYSICS_ROPE_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -61,7 +61,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_ropejoint(lua_State *L)
{
return luax_register_type(L, "RopeJoint", functions);
return luax_register_type(L, PHYSICS_ROPE_JOINT_ID, functions);
}
} // box2d
+2 -2
View File
@@ -30,7 +30,7 @@ namespace box2d
Shape *luax_checkshape(lua_State *L, int idx)
{
return luax_checktype<Shape>(L, idx, "Shape", PHYSICS_SHAPE_T);
return luax_checktype<Shape>(L, idx, PHYSICS_SHAPE_ID);
}
int w_Shape_getType(lua_State *L)
@@ -108,7 +108,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_shape(lua_State *L)
{
return luax_register_type(L, "Shape", functions);
return luax_register_type(L, PHYSICS_SHAPE_ID, functions);
}
} // box2d
+2 -2
View File
@@ -29,7 +29,7 @@ namespace box2d
WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
{
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, "WeldJoint", PHYSICS_WELD_JOINT_T);
WeldJoint *j = luax_checktype<WeldJoint>(L, idx, PHYSICS_WELD_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -87,7 +87,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_weldjoint(lua_State *L)
{
return luax_register_type(L, "WeldJoint", functions);
return luax_register_type(L, PHYSICS_WELD_JOINT_ID, functions);
}
} // box2d
@@ -29,7 +29,7 @@ namespace box2d
WheelJoint *luax_checkwheeljoint(lua_State *L, int idx)
{
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, "WheelJoint", PHYSICS_WHEEL_JOINT_T);
WheelJoint *j = luax_checktype<WheelJoint>(L, idx, PHYSICS_WHEEL_JOINT_ID);
if (!j->isValid())
luaL_error(L, "Attempt to use destroyed joint.");
return j;
@@ -163,7 +163,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_wheeljoint(lua_State *L)
{
return luax_register_type(L, "WheelJoint", functions);
return luax_register_type(L, PHYSICS_WHEEL_JOINT_ID, functions);
}
} // box2d
+3 -3
View File
@@ -29,7 +29,7 @@ namespace box2d
World *luax_checkworld(lua_State *L, int idx)
{
World *w = luax_checktype<World>(L, idx, "World", PHYSICS_WORLD_T);
World *w = luax_checktype<World>(L, idx, PHYSICS_WORLD_ID);
if (!w->isValid())
luaL_error(L, "Attempt to use destroyed world.");
return w;
@@ -191,7 +191,7 @@ int w_World_destroy(lua_State *L)
int w_World_isDestroyed(lua_State *L)
{
World *w = luax_checktype<World>(L, 1, "World", PHYSICS_WORLD_T);
World *w = luax_checktype<World>(L, 1, PHYSICS_WORLD_ID);
luax_pushboolean(L, !w->isValid());
return 1;
}
@@ -225,7 +225,7 @@ static const luaL_Reg functions[] =
extern "C" int luaopen_world(lua_State *L)
{
return luax_register_type(L, "World", functions);
return luax_register_type(L, PHYSICS_WORLD_ID, functions);
}
} // box2d