#include "Base.h" #include "ScriptController.h" #include "lua_Vector2.h" #include "Base.h" #include "Vector2.h" namespace gameplay { void luaRegister_Vector2() { const luaL_Reg lua_members[] = { {"add", lua_Vector2_add}, {"clamp", lua_Vector2_clamp}, {"distance", lua_Vector2_distance}, {"distanceSquared", lua_Vector2_distanceSquared}, {"dot", lua_Vector2_dot}, {"isOne", lua_Vector2_isOne}, {"isZero", lua_Vector2_isZero}, {"length", lua_Vector2_length}, {"lengthSquared", lua_Vector2_lengthSquared}, {"negate", lua_Vector2_negate}, {"normalize", lua_Vector2_normalize}, {"rotate", lua_Vector2_rotate}, {"scale", lua_Vector2_scale}, {"set", lua_Vector2_set}, {"smooth", lua_Vector2_smooth}, {"subtract", lua_Vector2_subtract}, {"x", lua_Vector2_x}, {"y", lua_Vector2_y}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"add", lua_Vector2_static_add}, {"angle", lua_Vector2_static_angle}, {"clamp", lua_Vector2_static_clamp}, {"dot", lua_Vector2_static_dot}, {"one", lua_Vector2_static_one}, {"subtract", lua_Vector2_static_subtract}, {"unitX", lua_Vector2_static_unitX}, {"unitY", lua_Vector2_static_unitY}, {"zero", lua_Vector2_static_zero}, {NULL, NULL} }; std::vector scopePath; gameplay::ScriptUtil::registerClass("Vector2", lua_members, lua_Vector2__init, lua_Vector2__gc, lua_statics, scopePath); } static Vector2* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "Vector2"); luaL_argcheck(state, userdata != NULL, 1, "'Vector2' expected."); return (Vector2*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance; } int lua_Vector2__gc(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { void* userdata = luaL_checkudata(state, 1, "Vector2"); luaL_argcheck(state, userdata != NULL, 1, "'Vector2' expected."); gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata; if (object->owns) { Vector2* instance = (Vector2*)object->instance; SAFE_DELETE(instance); } return 0; } lua_pushstring(state, "lua_Vector2__gc - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector2__init(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)new Vector2(); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } case 1: { do { if ((lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getFloatPointer(1); void* returnPtr = (void*)new Vector2(param1); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); do { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) break; void* returnPtr = (void*)new Vector2(*param1); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Vector2__init - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 2: { do { if (lua_type(state, 1) == LUA_TNUMBER && lua_type(state, 2) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 1); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); void* returnPtr = (void*)new Vector2(param1, param2); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); do { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) break; // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m2Valid); if (!param2Valid) break; void* returnPtr = (void*)new Vector2(*param1, *param2); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Vector2__init - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0, 1 or 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_add(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } Vector2* instance = getInstance(state); instance->add(*param1); return 0; } lua_pushstring(state, "lua_Vector2_add - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_clamp(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(3, "Vector2", true, ¶m2Valid); if (!param2Valid) { lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'."); lua_error(state); } Vector2* instance = getInstance(state); instance->clamp(*param1, *param2); return 0; } lua_pushstring(state, "lua_Vector2_clamp - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector2_distance(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } Vector2* instance = getInstance(state); float result = instance->distance(*param1); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_distance - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_distanceSquared(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } Vector2* instance = getInstance(state); float result = instance->distanceSquared(*param1); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_distanceSquared - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_dot(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } Vector2* instance = getInstance(state); float result = instance->dot(*param1); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_dot - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_isOne(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector2* instance = getInstance(state); bool result = instance->isOne(); // Push the return value onto the stack. lua_pushboolean(state, result); return 1; } lua_pushstring(state, "lua_Vector2_isOne - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector2_isZero(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector2* instance = getInstance(state); bool result = instance->isZero(); // Push the return value onto the stack. lua_pushboolean(state, result); return 1; } lua_pushstring(state, "lua_Vector2_isZero - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector2_length(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector2* instance = getInstance(state); float result = instance->length(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_length - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector2_lengthSquared(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector2* instance = getInstance(state); float result = instance->lengthSquared(); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_lengthSquared - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector2_negate(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector2* instance = getInstance(state); instance->negate(); return 0; } lua_pushstring(state, "lua_Vector2_negate - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; } int lua_Vector2_normalize(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { do { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Vector2* instance = getInstance(state); void* returnPtr = (void*)&(instance->normalize()); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } } while (0); lua_pushstring(state, "lua_Vector2_normalize - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 2: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", false, ¶m1Valid); if (!param1Valid) break; Vector2* instance = getInstance(state); instance->normalize(param1); return 0; } } while (0); lua_pushstring(state, "lua_Vector2_normalize - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_rotate(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TNUMBER) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); Vector2* instance = getInstance(state); instance->rotate(*param1, param2); return 0; } lua_pushstring(state, "lua_Vector2_rotate - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector2_scale(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 2); Vector2* instance = getInstance(state); instance->scale(param1); return 0; } } while (0); do { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) break; Vector2* instance = getInstance(state); instance->scale(*param1); return 0; } } while (0); lua_pushstring(state, "lua_Vector2_scale - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_set(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getFloatPointer(2); Vector2* instance = getInstance(state); instance->set(param1); return 0; } } while (0); do { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) break; Vector2* instance = getInstance(state); instance->set(*param1); return 0; } } while (0); lua_pushstring(state, "lua_Vector2_set - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } case 3: { do { if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER) { // Get parameter 1 off the stack. float param1 = (float)luaL_checknumber(state, 2); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); Vector2* instance = getInstance(state); instance->set(param1, param2); return 0; } } while (0); do { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) break; // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(3, "Vector2", true, ¶m2Valid); if (!param2Valid) break; Vector2* instance = getInstance(state); instance->set(*param1, *param2); return 0; } } while (0); lua_pushstring(state, "lua_Vector2_set - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2 or 3)."); lua_error(state); break; } } return 0; } int lua_Vector2_smooth(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 4: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TNUMBER && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); // Get parameter 3 off the stack. float param3 = (float)luaL_checknumber(state, 4); Vector2* instance = getInstance(state); instance->smooth(*param1, param2, param3); return 0; } lua_pushstring(state, "lua_Vector2_smooth - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 4)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_add(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m2Valid); if (!param2Valid) { lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'."); lua_error(state); } // Get parameter 3 off the stack. bool param3Valid; gameplay::ScriptUtil::LuaArray param3 = gameplay::ScriptUtil::getObjectPointer(3, "Vector2", false, ¶m3Valid); if (!param3Valid) { lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'."); lua_error(state); } Vector2::add(*param1, *param2, param3); return 0; } lua_pushstring(state, "lua_Vector2_static_add - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_angle(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m2Valid); if (!param2Valid) { lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'."); lua_error(state); } float result = Vector2::angle(*param1, *param2); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_static_angle - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_clamp(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 4: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) && (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m2Valid); if (!param2Valid) { lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'."); lua_error(state); } // Get parameter 3 off the stack. bool param3Valid; gameplay::ScriptUtil::LuaArray param3 = gameplay::ScriptUtil::getObjectPointer(3, "Vector2", true, ¶m3Valid); if (!param3Valid) { lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'."); lua_error(state); } // Get parameter 4 off the stack. bool param4Valid; gameplay::ScriptUtil::LuaArray param4 = gameplay::ScriptUtil::getObjectPointer(4, "Vector2", false, ¶m4Valid); if (!param4Valid) { lua_pushstring(state, "Failed to convert parameter 4 to type 'Vector2'."); lua_error(state); } Vector2::clamp(*param1, *param2, *param3, param4); return 0; } lua_pushstring(state, "lua_Vector2_static_clamp - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 4)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_dot(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m2Valid); if (!param2Valid) { lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'."); lua_error(state); } float result = Vector2::dot(*param1, *param2); // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } lua_pushstring(state, "lua_Vector2_static_dot - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_one(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector2::one()); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_subtract(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 3: { if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(1, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } // Get parameter 2 off the stack. bool param2Valid; gameplay::ScriptUtil::LuaArray param2 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m2Valid); if (!param2Valid) { lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'."); lua_error(state); } // Get parameter 3 off the stack. bool param3Valid; gameplay::ScriptUtil::LuaArray param3 = gameplay::ScriptUtil::getObjectPointer(3, "Vector2", false, ¶m3Valid); if (!param3Valid) { lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'."); lua_error(state); } Vector2::subtract(*param1, *param2, param3); return 0; } lua_pushstring(state, "lua_Vector2_static_subtract - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 3)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_unitX(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector2::unitX()); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_unitY(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector2::unitY()); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector2_static_zero(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 0: { void* returnPtr = (void*)&(Vector2::zero()); if (returnPtr) { gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Vector2"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 0)."); lua_error(state); break; } } return 0; } int lua_Vector2_subtract(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. bool param1Valid; gameplay::ScriptUtil::LuaArray param1 = gameplay::ScriptUtil::getObjectPointer(2, "Vector2", true, ¶m1Valid); if (!param1Valid) { lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'."); lua_error(state); } Vector2* instance = getInstance(state); instance->subtract(*param1); return 0; } lua_pushstring(state, "lua_Vector2_subtract - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; } int lua_Vector2_x(lua_State* state) { // Validate the number of parameters. if (lua_gettop(state) > 2) { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); } Vector2* instance = getInstance(state); if (lua_gettop(state) == 2) { // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); instance->x = param2; return 0; } else { float result = instance->x; // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } } int lua_Vector2_y(lua_State* state) { // Validate the number of parameters. if (lua_gettop(state) > 2) { lua_pushstring(state, "Invalid number of parameters (expected 1 or 2)."); lua_error(state); } Vector2* instance = getInstance(state); if (lua_gettop(state) == 2) { // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 2); instance->y = param2; return 0; } else { float result = instance->y; // Push the return value onto the stack. lua_pushnumber(state, result); return 1; } } }