1/**
2 * Copyright (c) 2006-2023 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_WeldJoint.h"
22
23namespace love
24{
25namespace physics
26{
27namespace box2d
28{
29
30WeldJoint *luax_checkweldjoint(lua_State *L, int idx)
31{
32 WeldJoint *j = luax_checktype<WeldJoint>(L, idx);
33 if (!j->isValid())
34 luaL_error(L, "Attempt to use destroyed joint.");
35 return j;
36}
37
38int w_WeldJoint_setFrequency(lua_State *L)
39{
40 WeldJoint *t = luax_checkweldjoint(L, 1);
41 float arg1 = (float)luaL_checknumber(L, 2);
42 t->setFrequency(arg1);
43 return 0;
44}
45
46int w_WeldJoint_getFrequency(lua_State *L)
47{
48 WeldJoint *t = luax_checkweldjoint(L, 1);
49 lua_pushnumber(L, t->getFrequency());
50 return 1;
51}
52
53int w_WeldJoint_setDampingRatio(lua_State *L)
54{
55 WeldJoint *t = luax_checkweldjoint(L, 1);
56 float arg1 = (float)luaL_checknumber(L, 2);
57 t->setDampingRatio(arg1);
58 return 0;
59}
60
61int w_WeldJoint_getDampingRatio(lua_State *L)
62{
63 WeldJoint *t = luax_checkweldjoint(L, 1);
64 lua_pushnumber(L, t->getDampingRatio());
65 return 1;
66}
67
68int w_WeldJoint_getReferenceAngle(lua_State *L)
69{
70 WeldJoint *t = luax_checkweldjoint(L, 1);
71 lua_pushnumber(L, t->getReferenceAngle());
72 return 1;
73}
74
75static const luaL_Reg w_WeldJoint_functions[] =
76{
77 { "setFrequency", w_WeldJoint_setFrequency },
78 { "getFrequency", w_WeldJoint_getFrequency },
79 { "setDampingRatio", w_WeldJoint_setDampingRatio },
80 { "getDampingRatio", w_WeldJoint_getDampingRatio },
81 { "getReferenceAngle", w_WeldJoint_getReferenceAngle },
82 { 0, 0 }
83};
84
85extern "C" int luaopen_weldjoint(lua_State *L)
86{
87 return luax_register_type(L, &WeldJoint::type, w_Joint_functions, w_WeldJoint_functions, nullptr);
88}
89
90} // box2d
91} // physics
92} // love
93