PopStack() calls

This commit is contained in:
Glenn Maynard
2005-02-22 04:20:58 +00:00
parent 61d94e97d8
commit f762300f49
2 changed files with 59 additions and 11 deletions
+53 -10
View File
@@ -104,6 +104,59 @@ void LuaManager::PushStack( const CString &out, lua_State *L )
lua_pushstring( L, out );
}
bool LuaManager::PopStack( int &out, lua_State *L )
{
if( L == NULL )
L = LUA->L;
out = (int) lua_tonumber( L, -1 );
lua_pop( L, 1 );
return true;
}
bool LuaManager::PopStack( bool &out, lua_State *L )
{
if( L == NULL )
L = LUA->L;
out = lua_toboolean( L, -1 );
lua_pop( L, 1 );
return true;
}
bool LuaManager::PopStack( float &val, lua_State *L )
{
if( L == NULL )
L = LUA->L;
val = lua_tonumber( L, -1 );
lua_pop( L, 1 );
return true;
}
bool LuaManager::PopStack( void *&out, lua_State *L )
{
if( L == NULL )
L = LUA->L;
out = lua_touserdata( L, -1 );
lua_pop( L, 1 );
return true;
}
bool LuaManager::PopStack( CString &out, lua_State *L )
{
if( L == NULL )
L = LUA->L;
const char *pStr = lua_tostring( L, -1 );
if( pStr != NULL )
out = pStr;
lua_pop( L, 1 );
return pStr != NULL;
}
void LuaManager::CreateTableFromArrayB( const vector<bool> &aIn, lua_State *L )
{
if( L == NULL )
@@ -133,16 +186,6 @@ void LuaManager::ReadArrayFromTableB( vector<bool> &aOut, lua_State *L )
}
}
void LuaManager::PopStack( CString &out )
{
/* There must be at least one entry on the stack. */
ASSERT( lua_gettop(L) > 0 );
ASSERT( lua_isstring(L, -1) );
out = lua_tostring( L, -1 );
lua_pop( L, -1 );
}
bool LuaManager::GetStack( int pos, int &out )
{
if( pos < 0 )
+6 -1
View File
@@ -48,6 +48,7 @@ public:
void SetGlobal( const CString &sName, bool val ) { PushStack(val); SetGlobal( sName ); }
void UnsetGlobal( const CString &sName ) { PushStackNil(); SetGlobal( sName ); }
// XXX: yuck
void PushStackNil();
void PushNopFunction();
static void PushStack( bool val, lua_State *L = NULL );
@@ -55,7 +56,11 @@ public:
static void PushStack( int val, lua_State *L = NULL );
static void PushStack( void *val, lua_State *L = NULL );
static void PushStack( const CString &val, lua_State *L = NULL );
void PopStack( CString &out );
static bool PopStack( bool &val, lua_State *L = NULL );
static bool PopStack( float &val, lua_State *L = NULL );
static bool PopStack( int &val, lua_State *L = NULL );
static bool PopStack( void *&val, lua_State *L = NULL );
static bool PopStack( CString &val, lua_State *L = NULL );
bool GetStack( int pos, int &out );
void SetGlobal( const CString &sName );