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.
This commit is contained in:
@@ -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<bool> &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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,12 +111,7 @@ namespace LuaHelpers
|
||||
}
|
||||
}
|
||||
template<class T>
|
||||
void PushStack( const T &val, lua_State *L )
|
||||
{
|
||||
LuaHelpers::Push( val, L );
|
||||
}
|
||||
template<class T>
|
||||
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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user