#include "Base.h" #include "ScriptController.h" #include "lua_RenderTarget.h" #include "Base.h" #include "Game.h" #include "Ref.h" #include "RenderTarget.h" namespace gameplay { void luaRegister_RenderTarget() { const luaL_Reg lua_members[] = { {"addRef", lua_RenderTarget_addRef}, {"getId", lua_RenderTarget_getId}, {"getRefCount", lua_RenderTarget_getRefCount}, {"getTexture", lua_RenderTarget_getTexture}, {"release", lua_RenderTarget_release}, {NULL, NULL} }; const luaL_Reg lua_statics[] = { {"create", lua_RenderTarget_static_create}, {"getRenderTarget", lua_RenderTarget_static_getRenderTarget}, {NULL, NULL} }; std::vector scopePath; ScriptUtil::registerClass("RenderTarget", lua_members, NULL, lua_RenderTarget__gc, lua_statics, scopePath); } static RenderTarget* getInstance(lua_State* state) { void* userdata = luaL_checkudata(state, 1, "RenderTarget"); luaL_argcheck(state, userdata != NULL, 1, "'RenderTarget' expected."); return (RenderTarget*)((ScriptUtil::LuaObject*)userdata)->instance; } int lua_RenderTarget__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, "RenderTarget"); luaL_argcheck(state, userdata != NULL, 1, "'RenderTarget' expected."); ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata; if (object->owns) { RenderTarget* instance = (RenderTarget*)object->instance; SAFE_RELEASE(instance); } return 0; } else { lua_pushstring(state, "lua_RenderTarget__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_RenderTarget_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)) { RenderTarget* instance = getInstance(state); instance->addRef(); return 0; } else { lua_pushstring(state, "lua_RenderTarget_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_RenderTarget_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)) { RenderTarget* 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_RenderTarget_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_RenderTarget_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)) { RenderTarget* 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_RenderTarget_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_RenderTarget_getTexture(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)) { RenderTarget* instance = getInstance(state); void* returnPtr = (void*)instance->getTexture(); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "Texture"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_RenderTarget_getTexture - 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_RenderTarget_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)) { RenderTarget* instance = getInstance(state); instance->release(); return 0; } else { lua_pushstring(state, "lua_RenderTarget_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_RenderTarget_static_create(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_TSTRING || lua_type(state, 1) == LUA_TNIL) && lua_type(state, 2) == LUA_TNUMBER && lua_type(state, 3) == LUA_TNUMBER) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(1, false); // Get parameter 2 off the stack. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2); // Get parameter 3 off the stack. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3); void* returnPtr = (void*)RenderTarget::create(param1, param2, param3); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = true; luaL_getmetatable(state, "RenderTarget"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_RenderTarget_static_create - 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_RenderTarget_static_getRenderTarget(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_TSTRING || lua_type(state, 1) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = ScriptUtil::getString(1, false); void* returnPtr = (void*)RenderTarget::getRenderTarget(param1); if (returnPtr) { ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject)); object->instance = returnPtr; object->owns = false; luaL_getmetatable(state, "RenderTarget"); lua_setmetatable(state, -2); } else { lua_pushnil(state); } return 1; } else { lua_pushstring(state, "lua_RenderTarget_static_getRenderTarget - 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; } }