1 /**
2 * Copyright (c) 2006-2011 LOVE Development Team
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty.  In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 *    claim that you wrote the original software. If you use this software
14 *    in a product, an acknowledgment in the product documentation would be
15 *    appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 *    misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 **/
20 
21 #include "wrap_PrismaticJoint.h"
22 
23 namespace love
24 {
25 namespace physics
26 {
27 namespace box2d
28 {
luax_checkprismaticjoint(lua_State * L,int idx)29 	PrismaticJoint * luax_checkprismaticjoint(lua_State * L, int idx)
30 	{
31 		return luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
32 	}
33 
w_PrismaticJoint_getJointTranslation(lua_State * L)34 	int w_PrismaticJoint_getJointTranslation(lua_State * L)
35 	{
36 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
37 		lua_pushnumber(L, t->getJointTranslation());
38 		return 1;
39 	}
40 
w_PrismaticJoint_getJointSpeed(lua_State * L)41 	int w_PrismaticJoint_getJointSpeed(lua_State * L)
42 	{
43 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
44 		lua_pushnumber(L, t->getJointSpeed());
45 		return 1;
46 	}
47 
w_PrismaticJoint_setMotorEnabled(lua_State * L)48 	int w_PrismaticJoint_setMotorEnabled(lua_State * L)
49 	{
50 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
51 		bool arg1 = luax_toboolean(L, 2);
52 		t->setMotorEnabled(arg1);
53 		return 0;
54 	}
55 
w_PrismaticJoint_isMotorEnabled(lua_State * L)56 	int w_PrismaticJoint_isMotorEnabled(lua_State * L)
57 	{
58 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
59 		luax_pushboolean(L, t->isMotorEnabled());
60 		return 1;
61 	}
62 
w_PrismaticJoint_setMaxMotorForce(lua_State * L)63 	int w_PrismaticJoint_setMaxMotorForce(lua_State * L)
64 	{
65 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
66 		float arg1 = (float)luaL_checknumber(L, 2);
67 		t->setMaxMotorForce(arg1);
68 		return 0;
69 	}
70 
w_PrismaticJoint_getMaxMotorForce(lua_State * L)71 	int w_PrismaticJoint_getMaxMotorForce(lua_State * L)
72 	{
73 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
74 		lua_pushnumber(L, t->getMaxMotorForce());
75 		return 1;
76 	}
77 
w_PrismaticJoint_setMotorSpeed(lua_State * L)78 	int w_PrismaticJoint_setMotorSpeed(lua_State * L)
79 	{
80 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
81 		float arg1 = (float)luaL_checknumber(L, 2);
82 		t->setMotorSpeed(arg1);
83 		return 0;
84 	}
85 
w_PrismaticJoint_getMotorSpeed(lua_State * L)86 	int w_PrismaticJoint_getMotorSpeed(lua_State * L)
87 	{
88 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
89 		lua_pushnumber(L, t->getMotorSpeed());
90 		return 1;
91 	}
92 
w_PrismaticJoint_getMotorForce(lua_State * L)93 	int w_PrismaticJoint_getMotorForce(lua_State * L)
94 	{
95 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
96 		lua_pushnumber(L, t->getMotorForce());
97 		return 1;
98 	}
99 
w_PrismaticJoint_setLimitsEnabled(lua_State * L)100 	int w_PrismaticJoint_setLimitsEnabled(lua_State * L)
101 	{
102 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
103 		bool arg1 = luax_toboolean(L, 2);
104 		t->setLimitsEnabled(arg1);
105 		return 0;
106 	}
107 
w_PrismaticJoint_isLimitsEnabled(lua_State * L)108 	int w_PrismaticJoint_isLimitsEnabled(lua_State * L)
109 	{
110 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
111 		luax_pushboolean(L, t->isLimitsEnabled());
112 		return 1;
113 	}
114 
w_PrismaticJoint_setUpperLimit(lua_State * L)115 	int w_PrismaticJoint_setUpperLimit(lua_State * L)
116 	{
117 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
118 		float arg1 = (float)luaL_checknumber(L, 2);
119 		t->setUpperLimit(arg1);
120 		return 0;
121 	}
122 
w_PrismaticJoint_setLowerLimit(lua_State * L)123 	int w_PrismaticJoint_setLowerLimit(lua_State * L)
124 	{
125 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
126 		float arg1 = (float)luaL_checknumber(L, 2);
127 		t->setLowerLimit(arg1);
128 		return 0;
129 	}
130 
w_PrismaticJoint_setLimits(lua_State * L)131 	int w_PrismaticJoint_setLimits(lua_State * L)
132 	{
133 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
134 		float arg1 = (float)luaL_checknumber(L, 2);
135 		float arg2 = (float)luaL_checknumber(L, 3);
136 		t->setLimits(arg1, arg2);
137 		return 0;
138 	}
139 
w_PrismaticJoint_getLowerLimit(lua_State * L)140 	int w_PrismaticJoint_getLowerLimit(lua_State * L)
141 	{
142 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
143 		lua_pushnumber(L, t->getLowerLimit());
144 		return 1;
145 	}
146 
w_PrismaticJoint_getUpperLimit(lua_State * L)147 	int w_PrismaticJoint_getUpperLimit(lua_State * L)
148 	{
149 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
150 		lua_pushnumber(L, t->getUpperLimit());
151 		return 1;
152 	}
153 
w_PrismaticJoint_getLimits(lua_State * L)154 	int w_PrismaticJoint_getLimits(lua_State * L)
155 	{
156 		PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
157 		lua_remove(L, 1);
158 		return t->getLimits(L);
159 	}
160 
161 	static const luaL_Reg functions[] = {
162 		{ "getJointTranslation", w_PrismaticJoint_getJointTranslation },
163 		{ "getJointSpeed", w_PrismaticJoint_getJointSpeed },
164 		{ "setMotorEnabled", w_PrismaticJoint_setMotorEnabled },
165 		{ "isMotorEnabled", w_PrismaticJoint_isMotorEnabled },
166 		{ "setMaxMotorForce", w_PrismaticJoint_setMaxMotorForce },
167 		{ "getMaxMotorForce", w_PrismaticJoint_getMaxMotorForce },
168 		{ "setMotorSpeed", w_PrismaticJoint_setMotorSpeed },
169 		{ "getMotorSpeed", w_PrismaticJoint_getMotorSpeed },
170 		{ "getMotorForce", w_PrismaticJoint_getMotorForce },
171 		{ "setLimitsEnabled", w_PrismaticJoint_setLimitsEnabled },
172 		{ "isLimitsEnabled", w_PrismaticJoint_isLimitsEnabled },
173 		{ "setUpperLimit", w_PrismaticJoint_setUpperLimit },
174 		{ "setLowerLimit", w_PrismaticJoint_setLowerLimit },
175 		{ "setLimits", w_PrismaticJoint_setLimits },
176 		{ "getLowerLimit", w_PrismaticJoint_getLowerLimit },
177 		{ "getUpperLimit", w_PrismaticJoint_getUpperLimit },
178 		{ "getLimits", w_PrismaticJoint_getLimits },
179 		// From Joint.
180 		{ "getType", w_Joint_getType },
181 		{ "getAnchors", w_Joint_getAnchors },
182 		{ "getReactionForce", w_Joint_getReactionForce },
183 		{ "getReactionTorque", w_Joint_getReactionTorque },
184 		{ "setCollideConnected", w_Joint_setCollideConnected },
185 		{ "getCollideConnected", w_Joint_getCollideConnected },
186 		{ "destroy", w_Joint_destroy },
187 		{ 0, 0 }
188 	};
189 
luaopen_prismaticjoint(lua_State * L)190 	int luaopen_prismaticjoint(lua_State * L)
191 	{
192 		return luax_register_type(L, "PrismaticJoint", functions);
193 	}
194 
195 } // box2d
196 } // physics
197 } // love
198