Build type information on first use (load-time), instead of using a hardcoded list

--HG--
branch : dynamiccore2
This commit is contained in:
Bart van Strien
2016-11-13 16:38:57 +01:00
parent 452a8a877e
commit c761202486
192 changed files with 734 additions and 614 deletions
+20 -20
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, PHYSICS_WORLD_ID, w);
luax_pushtype(L, World::type, 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, PHYSICS_BODY_ID, body);
luax_pushtype(L, Body::type, 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, PHYSICS_FIXTURE_ID, fixture);
luax_pushtype(L, Fixture::type, 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, PHYSICS_CIRCLE_SHAPE_ID, shape);
luax_pushtype(L, CircleShape::type, 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, PHYSICS_CIRCLE_SHAPE_ID, shape);
luax_pushtype(L, CircleShape::type, 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, PHYSICS_POLYGON_SHAPE_ID, shape);
luax_pushtype(L, PolygonShape::type, 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, PHYSICS_POLYGON_SHAPE_ID, shape);
luax_pushtype(L, PolygonShape::type, 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, PHYSICS_EDGE_SHAPE_ID, shape);
luax_pushtype(L, EdgeShape::type, 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, PHYSICS_DISTANCE_JOINT_ID, j);
luax_pushtype(L, DistanceJoint::type, 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, PHYSICS_MOUSE_JOINT_ID, j);
luax_pushtype(L, MouseJoint::type, 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, PHYSICS_REVOLUTE_JOINT_ID, j);
luax_pushtype(L, RevoluteJoint::type, 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, PHYSICS_PRISMATIC_JOINT_ID, j);
luax_pushtype(L, PrismaticJoint::type, 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, PHYSICS_PULLEY_JOINT_ID, j);
luax_pushtype(L, PulleyJoint::type, 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, PHYSICS_GEAR_JOINT_ID, j);
luax_pushtype(L, GearJoint::type, 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, PHYSICS_FRICTION_JOINT_ID, j);
luax_pushtype(L, FrictionJoint::type, 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, PHYSICS_WELD_JOINT_ID, j);
luax_pushtype(L, WeldJoint::type, 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, PHYSICS_WHEEL_JOINT_ID, j);
luax_pushtype(L, WheelJoint::type, 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, PHYSICS_ROPE_JOINT_ID, j);
luax_pushtype(L, RopeJoint::type, 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, PHYSICS_MOTOR_JOINT_ID, j);
luax_pushtype(L, MotorJoint::type, j);
j->release();
return 1;
}
@@ -537,7 +537,7 @@ extern "C" int luaopen_love_physics(lua_State *L)
WrappedModule w;
w.module = instance;
w.name = "physics";
w.type = MODULE_ID;
w.type = &Module::type;
w.functions = functions;
w.types = types;