From d7e64dc979c51eb00188684c189cd16eedf1507c Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Thu, 21 Sep 2006 07:06:18 +0000 Subject: [PATCH] Simplify. PushStack was only calling Push and possibly generating a function for each enumerated type which in the end only called Push. Rename PopStack -> Pop to be symmetric with Push. --- stepmania/src/LuaManager.cpp | 16 ++++++++-------- stepmania/src/LuaManager.h | 7 +------ stepmania/src/MenuTimer.cpp | 2 +- stepmania/src/OptionRowHandler.cpp | 4 ++-- stepmania/src/Preference.cpp | 4 ++-- stepmania/src/ThemeMetric.h | 4 ++-- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index 0a428c51c0..deb6d8aa92 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -58,7 +58,7 @@ static const char *ChunkReaderString( lua_State *L, void *ptr, size_t *size ) void LuaManager::SetGlobal( const RString &sName, int val ) { Lua *L = LUA->Get(); - LuaHelpers::PushStack( val, L ); + LuaHelpers::Push( val, L ); lua_setglobal( L, sName ); LUA->Release(L); } @@ -66,7 +66,7 @@ void LuaManager::SetGlobal( const RString &sName, int val ) void LuaManager::SetGlobal( const RString &sName, float val ) { Lua *L = LUA->Get(); - LuaHelpers::PushStack( val, L ); + LuaHelpers::Push( val, L ); lua_setglobal( L, sName ); LUA->Release(L); } @@ -74,7 +74,7 @@ void LuaManager::SetGlobal( const RString &sName, float val ) void LuaManager::SetGlobal( const RString &sName, bool val ) { Lua *L = LUA->Get(); - LuaHelpers::PushStack( val, L ); + LuaHelpers::Push( val, L ); lua_setglobal( L, sName ); LUA->Release(L); } @@ -82,7 +82,7 @@ void LuaManager::SetGlobal( const RString &sName, bool val ) void LuaManager::SetGlobal( const RString &sName, const RString &val ) { Lua *L = LUA->Get(); - LuaHelpers::PushStack( val, L ); + LuaHelpers::Push( val, L ); lua_setglobal( L, sName ); LUA->Release(L); } @@ -140,7 +140,7 @@ void LuaHelpers::ReadArrayFromTableB( Lua *L, vector &aOut ) static int LuaPanic( lua_State *L ) { RString sErr; - LuaHelpers::PopStack( sErr, L ); + LuaHelpers::Pop( sErr, L ); lua_Debug ar; int level = 0; @@ -501,7 +501,7 @@ bool LuaHelpers::Call( Lua *L, const RString &sFunction, int iArgs, int iResults return true; RString sError; - LuaHelpers::PopStack( sError, L ); + LuaHelpers::Pop( sError, L ); Dialog::OK( ssprintf("Lua runtime error calling functin \"%s\": %s", sFunction.c_str(), sError.c_str()), "LUA_ERROR" ); return false; } @@ -516,7 +516,7 @@ bool LuaHelpers::RunScript( Lua *L, const RString &sScript, const RString &sName if( ret ) { - LuaHelpers::PopStack( sError, L ); + LuaHelpers::Pop( sError, L ); return false; } } @@ -526,7 +526,7 @@ bool LuaHelpers::RunScript( Lua *L, const RString &sScript, const RString &sName int ret = lua_pcall( L, 0, iReturnValues, 0 ); if( ret ) { - LuaHelpers::PopStack( sError, L ); + LuaHelpers::Pop( sError, L ); return false; } } diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index 03f87d5740..eba80dc735 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -111,12 +111,7 @@ namespace LuaHelpers } } template - void PushStack( const T &val, lua_State *L ) - { - LuaHelpers::Push( val, L ); - } - template - bool PopStack( T &val, lua_State *L ) + bool Pop( T &val, lua_State *L ) { bool bRet = LuaHelpers::FromStack( val, -1, L ); lua_pop( L, 1 ); diff --git a/stepmania/src/MenuTimer.cpp b/stepmania/src/MenuTimer.cpp index 8c75b86b99..b6324deb02 100644 --- a/stepmania/src/MenuTimer.cpp +++ b/stepmania/src/MenuTimer.cpp @@ -171,7 +171,7 @@ void MenuTimer::SetText( float fSeconds ) lua_call(L, 1, 1); RString sText; - LuaHelpers::PopStack( sText, L ); + LuaHelpers::Pop( sText, L ); m_text[i].SetText( sText ); } diff --git a/stepmania/src/OptionRowHandler.cpp b/stepmania/src/OptionRowHandler.cpp index c4e8043628..86833df70f 100644 --- a/stepmania/src/OptionRowHandler.cpp +++ b/stepmania/src/OptionRowHandler.cpp @@ -950,7 +950,7 @@ public: lua_pushvalue( L, 1 ); /* Argument 3 (pn): */ - LuaHelpers::PushStack( (int) p, L ); + LuaHelpers::Push( p, L ); ASSERT( lua_gettop(L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ @@ -1004,7 +1004,7 @@ public: lua_pushvalue( L, 1 ); /* Argument 3 (pn): */ - LuaHelpers::PushStack( (int) p, L ); + LuaHelpers::Push( p, L ); ASSERT( lua_gettop(L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */ diff --git a/stepmania/src/Preference.cpp b/stepmania/src/Preference.cpp index 756748ccfc..092b4a0c30 100644 --- a/stepmania/src/Preference.cpp +++ b/stepmania/src/Preference.cpp @@ -85,11 +85,11 @@ void IPreference::SetFromStack( lua_State *L ) } \ template<> void PrefSetFromStack( lua_State *L, type &v ) \ { \ - LuaHelpers::PopStack( v, L ); \ + LuaHelpers::Pop( v, L ); \ } \ template<> void PrefPushValue( lua_State *L, const type &v ) \ { \ - LuaHelpers::PushStack( v, L ); \ + LuaHelpers::Push( v, L ); \ } READFROM_AND_WRITETO( int ) diff --git a/stepmania/src/ThemeMetric.h b/stepmania/src/ThemeMetric.h index 931bfbf3e8..e033a33096 100644 --- a/stepmania/src/ThemeMetric.h +++ b/stepmania/src/ThemeMetric.h @@ -340,7 +340,7 @@ public: else { m_Value.Unset(); - LuaHelpers::PopStack( m_currentValue, L ); + LuaHelpers::Pop( m_currentValue, L ); } LUA->Release(L); @@ -368,7 +368,7 @@ public: m_Value.PushSelf( L ); lua_call(L, 0, 1); ASSERT( !lua_isnil(L, -1) ); - LuaHelpers::PopStack( m_currentValue, L ); + LuaHelpers::Pop( m_currentValue, L ); LUA->Release(L); }