Commits

Boolsheet committed ca10243

Changed ASSERT_GUARD to the new exception handling macro.

Comments (0)

Files changed (7)

src/modules/physics/box2d/wrap_Body.cpp

 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		t->setMassData(x, y, m, i);
+	)
 	return 0;
 }
 

src/modules/physics/box2d/wrap_ChainShape.cpp

 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		v = c->getPoint(index);
+	)
 	lua_pushnumber(L, v.x);
 	lua_pushnumber(L, v.y);
 	return 2;

src/modules/physics/box2d/wrap_Fixture.cpp

 {
 	Fixture *t = luax_checkfixture(L, 1);
 	lua_remove(L, 1);
-	ASSERT_GUARD(return t->rayCast(L);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		return t->rayCast(L);
+	)
 }
 
 int w_Fixture_setFilterData(lua_State *L)

src/modules/physics/box2d/wrap_Physics.cpp

 	bool sleep = luax_optboolean(L, 3, true);
 
 	World *w;
-	ASSERT_GUARD(w = instance->newWorld(gx, gy, sleep);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		w = instance->newWorld(gx, gy, sleep);
+	)
 	luax_newtype(L, "World", PHYSICS_WORLD_T, (void *)w);
 
 	return 1;
 	Body::Type bodyType;
 	Body::getConstant(type, bodyType);
 	Body *body;
-	ASSERT_GUARD(body = instance->newBody(world, x, y, bodyType);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		body = instance->newBody(world, x, y, bodyType);
+	)
 	luax_newtype(L, "Body", PHYSICS_BODY_T, (void *)body);
 	return 1;
 }
 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		fixture = instance->newFixture(body, shape, density);
+	)
 	luax_newtype(L, "Fixture", PHYSICS_FIXTURE_T, (void *)fixture);
 	return 1;
 }
 	{
 		float radius = (float)luaL_checknumber(L, 1);
 		CircleShape *shape;
-		ASSERT_GUARD(shape = instance->newCircleShape(radius);)
+		LOVE_EH_CATCH_AND_ERROR
+		(
+			shape = instance->newCircleShape(radius);
+		)
 		luax_newtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, (void *)shape);
 		return 1;
 	}
 		float y = (float)luaL_checknumber(L, 2);
 		float radius = (float)luaL_checknumber(L, 3);
 		CircleShape *shape;
-		ASSERT_GUARD(shape = instance->newCircleShape(x, y, radius);)
+		LOVE_EH_CATCH_AND_ERROR
+		(
+			shape = instance->newCircleShape(x, y, radius);
+		)
 		luax_newtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, (void *)shape);
 		return 1;
 	}
 		float w = (float)luaL_checknumber(L, 1);
 		float h = (float)luaL_checknumber(L, 2);
 		PolygonShape *shape;
-		ASSERT_GUARD(shape = instance->newRectangleShape(w, h);)
+		LOVE_EH_CATCH_AND_ERROR
+		(
+			shape = instance->newRectangleShape(w, h);
+		)
 		luax_newtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, (void *)shape);
 		return 1;
 	}
 		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);)
+		LOVE_EH_CATCH_AND_ERROR
+		(
+			shape = instance->newRectangleShape(x, y, w, h, angle);
+		)
 		luax_newtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, (void *)shape);
 		return 1;
 	}
 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		shape = instance->newEdgeShape(x1, y1, x2, y2);
+	)
 	luax_newtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, (void *)shape);
 	return 1;
 }
 
 int w_newPolygonShape(lua_State *L)
 {
-	ASSERT_GUARD(return instance->newPolygonShape(L);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		return instance->newPolygonShape(L);
+	)
 }
 
 int w_newChainShape(lua_State *L)
 {
-	ASSERT_GUARD(return instance->newChainShape(L);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		return instance->newChainShape(L);
+	)
 }
 
 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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newDistanceJoint(body1, body2, x1, y1, x2, y2, collideConnected);
+	)
 	luax_newtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, (void *)j);
 	return 1;
 }
 	float x = (float)luaL_checknumber(L, 2);
 	float y = (float)luaL_checknumber(L, 3);
 	MouseJoint *j;
-	ASSERT_GUARD(j = instance->newMouseJoint(body, x, y);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newMouseJoint(body, x, y);
+	)
 	luax_newtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, (void *)j);
 	return 1;
 }
 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newRevoluteJoint(body1, body2, x, y, collideConnected);
+	)
 	luax_newtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, (void *)j);
 	return 1;
 }
 		collideConnected = luax_optboolean(L, 7, false);
 	}
 	PrismaticJoint *j;
-	ASSERT_GUARD(j = instance->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
+	)
 	luax_newtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, (void *)j);
 	return 1;
 }
 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newPulleyJoint(body1, body2, b2Vec2(gx1,gy1), b2Vec2(gx2,gy2), b2Vec2(x1,y1), b2Vec2(x2,y2), ratio, collideConnected);
+	)
 	luax_newtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, (void *)j);
 	return 1;
 }
 	bool collideConnected = luax_optboolean(L, 4, false);
 
 	GearJoint *j;
-	ASSERT_GUARD(j = instance->newGearJoint(joint1, joint2, ratio, collideConnected);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newGearJoint(joint1, joint2, ratio, collideConnected);
+	)
 	luax_newtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, (void *)j);
 	return 1;
 }
 		collideConnected = luax_optboolean(L, 5, false);
 	}
 	FrictionJoint *j;
-	ASSERT_GUARD(j = instance->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newFrictionJoint(body1, body2, xA, yA, xB, yB, collideConnected);
+	)
 	luax_newtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, (void *)j);
 	return 1;
 }
 		collideConnected = luax_optboolean(L, 5, false);
 	}
 	WeldJoint *j;
-	ASSERT_GUARD(j = instance->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
+	)
 	luax_newtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, (void *)j);
 	return 1;
 }
 	}
 
 	WheelJoint *j;
-	ASSERT_GUARD(j = instance->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newWheelJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
+	)
 	luax_newtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, (void *)j);
 	return 1;
 }
 	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);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		j = instance->newRopeJoint(body1, body2, x1, y1, x2, y2, maxLength, collideConnected);
+	)
 	luax_newtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, (void *)j);
 	return 1;
 }

src/modules/physics/box2d/wrap_Physics.h

 #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

src/modules/physics/box2d/wrap_Shape.cpp

 {
 	Shape *t = luax_checkshape(L, 1);
 	lua_remove(L, 1);
-	ASSERT_GUARD(return t->rayCast(L);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		return t->rayCast(L);
+	)
 }
 
 int w_Shape_computeAABB(lua_State *L)

src/modules/physics/box2d/wrap_World.cpp

 {
 	World *t = luax_checkworld(L, 1);
 	float dt = (float)luaL_checknumber(L, 2);
-	ASSERT_GUARD(t->update(dt);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		t->update(dt);
+	)
 	return 0;
 }
 
 {
 	World *t = luax_checkworld(L, 1);
 	lua_remove(L, 1);
-	ASSERT_GUARD(return t->rayCast(L);)
+	LOVE_EH_CATCH_AND_ERROR
+	(
+		return t->rayCast(L);
+	)
 }
 
 int w_World_destroy(lua_State *L)