#include "Base.h" #include "ScriptController.h" #include "lua_Effect.h" #include "Base.h" #include "Effect.h" #include "FileSystem.h" #include "Game.h" #include "Ref.h" namespace gameplay { void luaRegister_Effect() { const luaL_Reg lua_members[] = { {"addRef", lua_Effect_addRef}, {"bind", lua_Effect_bind}, {"getId", lua_Effect_getId}, {"getRefCount", lua_Effect_getRefCount}, {"getUniform", lua_Effect_getUniform}, {"getUniformCount", lua_Effect_getUniformCount}, {"getVertexAttribute", lua_Effect_getVertexAttribute}, {"release", lua_Effect_release}, {"setValue", lua_Effect_setValue}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"createFromFile", lua_Effect_static_createFromFile}, {"createFromSource", lua_Effect_static_createFromSource}, {"getCurrentEffect", lua_Effect_static_getCurrentEffect}, {NULL, NULL} }; std::vector scopePath; ScriptUtil::registerClass("Effect", lua_members, NULL, lua_Effect__gc, lua_statics, scopePath); } static Effect* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "Effect"); luaL_argcheck(state, userdata != NULL, 1, "'Effect' expected."); return (Effect*)((ScriptUtil::LuaObject*)userdata)->instance; } int lua_Effect__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, "Effect"); luaL_argcheck(state, userdata != NULL, 1, "'Effect' expected."); ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata; if (object->owns) { Effect* instance = (Effect*)object->instance; SAFE_RELEASE(instance); } return 0; } else { lua_pushstring(state, "lua_Effect__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_Effect_addRef(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)) { Effect* instance = getInstance(state); instance->addRef(); return 0; } else { lua_pushstring(state, "lua_Effect_addRef - 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_Effect_bind(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)) { Effect* instance = getInstance(state); instance->bind(); return 0; } else { lua_pushstring(state, "lua_Effect_bind - 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_Effect_getId(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)) { Effect* instance = getInstance(state); const char* result = instance->getId(); // Push the return value onto the stack. lua_pushstring(state, result); return 1; } else { lua_pushstring(state, "lua_Effect_getId - 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_Effect_getRefCount(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)) { Effect* instance = getInstance(state); unsigned int result = instance->getRefCount(); // Push the return value onto the stack. lua_pushunsigned(state, result); return 1; } else { lua_pushstring(state, "lua_Effect_getRefCount - 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_Effect_getUniform(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_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getString(2, false); Effect* instance = getInstance(state); void* returnPtr = (void*)instance->getUniform(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Uniform"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else if ((lua_type(state, 1) == LUA_TUSERDATA) && lua_type(state, 2) == LUA_TNUMBER) { // Get parameter 1 off the stack. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2); Effect* instance = getInstance(state); void* returnPtr = (void*)instance->getUniform(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Uniform"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Effect_getUniform - 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_Effect_getUniformCount(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)) { Effect* instance = getInstance(state); unsigned int result = instance->getUniformCount(); // Push the return value onto the stack. lua_pushunsigned(state, result); return 1; } else { lua_pushstring(state, "lua_Effect_getUniformCount - 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_Effect_getVertexAttribute(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_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getString(2, false); Effect* instance = getInstance(state); void* returnPtr = (void*)new GLint(instance->getVertexAttribute(param1)); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "GLint"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Effect_getVertexAttribute - 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_Effect_release(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)) { Effect* instance = getInstance(state); instance->release(); return 0; } else { lua_pushstring(state, "lua_Effect_release - 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_Effect_setValue(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_TTABLE || lua_type(state, 2) == LUA_TNIL) && lua_type(state, 3) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. float param2 = (float)luaL_checknumber(state, 3); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getFloatPointer(3); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && lua_type(state, 3) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. int param2 = (int)luaL_checkint(state, 3); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getIntPointer(3); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Matrix", true); Effect* instance = getInstance(state); instance->setValue(param1, *param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Matrix", false); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector2", true); Effect* instance = getInstance(state); instance->setValue(param1, *param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector2", false); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector3", true); Effect* instance = getInstance(state); instance->setValue(param1, *param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector3", false); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector4", true); Effect* instance = getInstance(state); instance->setValue(param1, *param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector4", false); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "TextureSampler", false); Effect* instance = getInstance(state); instance->setValue(param1, param2); return 0; } else { lua_pushstring(state, "lua_Effect_setValue - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 4: { 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) && (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getFloatPointer(3); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4); Effect* instance = getInstance(state); instance->setValue(param1, param2, param3); return 0; } else 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) && (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getIntPointer(3); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4); Effect* instance = getInstance(state); instance->setValue(param1, param2, param3); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Matrix", false); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4); Effect* instance = getInstance(state); instance->setValue(param1, param2, param3); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector2", false); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4); Effect* instance = getInstance(state); instance->setValue(param1, param2, param3); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector3", false); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4); Effect* instance = getInstance(state); instance->setValue(param1, param2, param3); return 0; } else 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) && (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) && lua_type(state, 4) == LUA_TNUMBER) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getObjectPointer(2, "Uniform", false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getObjectPointer(3, "Vector4", false); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4); Effect* instance = getInstance(state); instance->setValue(param1, param2, param3); return 0; } else { lua_pushstring(state, "lua_Effect_setValue - 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 or 4)."); lua_error(state); break; } } return 0; } int lua_Effect_static_createFromFile(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_TSTRING || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getString(1, false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getString(2, false); void* returnPtr = (void*)Effect::createFromFile(param1, param2); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Effect"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Effect_static_createFromFile - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 3: { if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getString(1, false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getString(2, false); // Get parameter 3 off the stack. ScriptUtil::LuaArray param3 = ScriptUtil::getString(3, false); void* returnPtr = (void*)Effect::createFromFile(param1, param2, param3); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Effect"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Effect_static_createFromFile - 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_Effect_static_createFromSource(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_TSTRING || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getString(1, false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getString(2, false); void* returnPtr = (void*)Effect::createFromSource(param1, param2); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Effect"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Effect_static_createFromSource - Failed to match the given parameters to a valid function signature."); lua_error(state); } break; } case 3: { if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) && (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) && (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL)) { // Get parameter 1 off the stack. ScriptUtil::LuaArray param1 = ScriptUtil::getString(1, false); // Get parameter 2 off the stack. ScriptUtil::LuaArray param2 = ScriptUtil::getString(2, false); // Get parameter 3 off the stack. ScriptUtil::LuaArray param3 = ScriptUtil::getString(3, false); void* returnPtr = (void*)Effect::createFromSource(param1, param2, param3); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Effect"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_Effect_static_createFromSource - 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_Effect_static_getCurrentEffect(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*)Effect::getCurrentEffect(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Effect"); 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; } }