This commit is contained in:
Glenn Maynard
2007-01-15 04:17:15 +00:00
parent a1611de0c4
commit 17ad7bb1bf
4 changed files with 26 additions and 0 deletions
+7
View File
@@ -193,6 +193,13 @@ void LuaTable::Set( Lua *L, const RString &sKey )
lua_settop( L, iTop-1 ); // remove all of the above
}
void LuaTable::Get( Lua *L, const RString &sKey )
{
this->PushSelf( L );
lua_getfield( L, -1, sKey );
lua_remove( L, -2 ); // remove self
}
namespace LuaHelpers
{
template<> void Push<LuaReference>( lua_State *L, const LuaReference &Object )
+3
View File
@@ -81,6 +81,9 @@ class LuaTable: public LuaReference
public:
LuaTable();
/* Get the key with the given name, and push it on the stack. */
void Get( Lua *L, const RString &sKey );
/* Set a key by the given name to a value on the stack, and pop the value
* off the stack. */
void Set( Lua *L, const RString &sKey );
+5
View File
@@ -174,6 +174,11 @@ const LuaReference &Message::GetParamTable() const
return *m_pParams;
}
void Message::GetParamFromStack( lua_State *L, const RString &sName ) const
{
m_pParams->Get( L, sName );
}
void Message::SetParamFromStack( lua_State *L, const RString &sName )
{
m_pParams->Set( L, sName );
+11
View File
@@ -156,8 +156,19 @@ struct Message
void PushParamTable( lua_State *L );
const LuaReference &GetParamTable() const;
void GetParamFromStack( lua_State *L, const RString &sName ) const;
void SetParamFromStack( lua_State *L, const RString &sName );
template<typename T>
bool GetParam( const RString &sName, T &val ) const
{
Lua *L = LUA->Get();
GetParamFromStack( L, sName );
bool bRet = LuaHelpers::Pop( L, val );
LUA->Release( L );
return bRet;
}
template<typename T>
void SetParam( const RString &sName, const T &val )
{