PopStack() calls
This commit is contained in:
@@ -104,6 +104,59 @@ void LuaManager::PushStack( const CString &out, lua_State *L )
|
|||||||
lua_pushstring( L, out );
|
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 )
|
void LuaManager::CreateTableFromArrayB( const vector<bool> &aIn, lua_State *L )
|
||||||
{
|
{
|
||||||
if( L == NULL )
|
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 )
|
bool LuaManager::GetStack( int pos, int &out )
|
||||||
{
|
{
|
||||||
if( pos < 0 )
|
if( pos < 0 )
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
void SetGlobal( const CString &sName, bool val ) { PushStack(val); SetGlobal( sName ); }
|
void SetGlobal( const CString &sName, bool val ) { PushStack(val); SetGlobal( sName ); }
|
||||||
void UnsetGlobal( const CString &sName ) { PushStackNil(); SetGlobal( sName ); }
|
void UnsetGlobal( const CString &sName ) { PushStackNil(); SetGlobal( sName ); }
|
||||||
|
|
||||||
|
// XXX: yuck
|
||||||
void PushStackNil();
|
void PushStackNil();
|
||||||
void PushNopFunction();
|
void PushNopFunction();
|
||||||
static void PushStack( bool val, lua_State *L = NULL );
|
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( int val, lua_State *L = NULL );
|
||||||
static void PushStack( void *val, lua_State *L = NULL );
|
static void PushStack( void *val, lua_State *L = NULL );
|
||||||
static void PushStack( const CString &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 );
|
bool GetStack( int pos, int &out );
|
||||||
void SetGlobal( const CString &sName );
|
void SetGlobal( const CString &sName );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user