Browse Source

Fixed some uncaught exceptions in love.physics

Alex Szpakowski 12 years ago
parent
commit
3880646a6a

+ 13 - 11
src/modules/physics/box2d/wrap_Body.cpp

@@ -232,7 +232,7 @@ int w_Body_setX(lua_State *L)
 {
 	Body *t = luax_checkbody(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setX(arg1);
+	ASSERT_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);
-	t->setY(arg1);
+	ASSERT_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);
-	t->setAngle(arg1);
+	ASSERT_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);
-	t->setPosition(arg1, arg2);
+	ASSERT_GUARD(t->setPosition(arg1, arg2);)
 	return 0;
 }
 
 int w_Body_resetMassData(lua_State *L)
 {
 	Body *t = luax_checkbody(L, 1);
-	t->resetMassData();
+	ASSERT_GUARD(t->resetMassData();)
 	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);
-	t->setMass(m);
+	ASSERT_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);
-	t->setInertia(i);
+	ASSERT_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);
-	t->setType(type);
+	ASSERT_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);
-	t->setActive(b);
+	ASSERT_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);
-	t->setFixedRotation(b);
+	ASSERT_GUARD(t->setFixedRotation(b);)
 	return 0;
 }
 
@@ -517,7 +517,9 @@ int w_Body_getFixtureList(lua_State *L)
 {
 	Body *t = luax_checkbody(L, 1);
 	lua_remove(L, 1);
-	return t->getFixtureList(L);
+	int n = 0;
+	ASSERT_GUARD(n = t->getFixtureList(L);)
+	return n;
 }
 
 int w_Body_destroy(lua_State *L)

+ 2 - 2
src/modules/physics/box2d/wrap_ChainShape.cpp

@@ -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);
-	c->setNextVertex(x, y);
+	ASSERT_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);
-	c->setPrevVertex(x, y);
+	ASSERT_GUARD(c->setPrevVertex(x, y);)
 	return 0;
 }
 

+ 1 - 1
src/modules/physics/box2d/wrap_Fixture.cpp

@@ -65,7 +65,7 @@ int w_Fixture_setDensity(lua_State *L)
 {
 	Fixture *t = luax_checkfixture(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setDensity(arg1);
+	ASSERT_GUARD(t->setDensity(arg1);)
 	return 0;
 }
 

+ 3 - 2
src/modules/physics/box2d/wrap_FrictionJoint.cpp

@@ -19,6 +19,7 @@
  **/
 
 #include "wrap_FrictionJoint.h"
+#include "wrap_Physics.h"
 
 namespace love
 {
@@ -39,7 +40,7 @@ int w_FrictionJoint_setMaxForce(lua_State *L)
 {
 	FrictionJoint *t = luax_checkfrictionjoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setMaxForce(arg1);
+	ASSERT_GUARD(t->setMaxForce(arg1);)
 	return 0;
 }
 
@@ -54,7 +55,7 @@ int w_FrictionJoint_setMaxTorque(lua_State *L)
 {
 	FrictionJoint *t = luax_checkfrictionjoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setMaxTorque(arg1);
+	ASSERT_GUARD(t->setMaxTorque(arg1);)
 	return 0;
 }
 

+ 2 - 1
src/modules/physics/box2d/wrap_GearJoint.cpp

@@ -19,6 +19,7 @@
  **/
 
 #include "wrap_GearJoint.h"
+#include "wrap_Physics.h"
 
 namespace love
 {
@@ -39,7 +40,7 @@ int w_GearJoint_setRatio(lua_State *L)
 {
 	GearJoint *t = luax_checkgearjoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setRatio(arg1);
+	ASSERT_GUARD(t->setRatio(arg1);)
 	return 0;
 }
 

+ 4 - 3
src/modules/physics/box2d/wrap_PrismaticJoint.cpp

@@ -19,6 +19,7 @@
  **/
 
 #include "wrap_PrismaticJoint.h"
+#include "wrap_Physics.h"
 
 namespace love
 {
@@ -121,7 +122,7 @@ int w_PrismaticJoint_setUpperLimit(lua_State *L)
 {
 	PrismaticJoint *t = luax_checkprismaticjoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setUpperLimit(arg1);
+	ASSERT_GUARD(t->setUpperLimit(arg1);)
 	return 0;
 }
 
@@ -129,7 +130,7 @@ int w_PrismaticJoint_setLowerLimit(lua_State *L)
 {
 	PrismaticJoint *t = luax_checkprismaticjoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setLowerLimit(arg1);
+	ASSERT_GUARD(t->setLowerLimit(arg1);)
 	return 0;
 }
 
@@ -138,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);
-	t->setLimits(arg1, arg2);
+	ASSERT_GUARD(t->setLimits(arg1, arg2);)
 	return 0;
 }
 

+ 4 - 3
src/modules/physics/box2d/wrap_RevoluteJoint.cpp

@@ -19,6 +19,7 @@
  **/
 
 #include "wrap_RevoluteJoint.h"
+#include "wrap_Physics.h"
 
 namespace love
 {
@@ -121,7 +122,7 @@ int w_RevoluteJoint_setUpperLimit(lua_State *L)
 {
 	RevoluteJoint *t = luax_checkrevolutejoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setUpperLimit(arg1);
+	ASSERT_GUARD(t->setUpperLimit(arg1);)
 	return 0;
 }
 
@@ -129,7 +130,7 @@ int w_RevoluteJoint_setLowerLimit(lua_State *L)
 {
 	RevoluteJoint *t = luax_checkrevolutejoint(L, 1);
 	float arg1 = (float)luaL_checknumber(L, 2);
-	t->setLowerLimit(arg1);
+	ASSERT_GUARD(t->setLowerLimit(arg1);)
 	return 0;
 }
 
@@ -138,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);
-	t->setLimits(arg1, arg2);
+	ASSERT_GUARD(t->setLimits(arg1, arg2);)
 	return 0;
 }