add LuaHelpers::PushValueFunc

This commit is contained in:
Glenn Maynard
2006-10-05 19:57:07 +00:00
parent 2f5b401cbb
commit 47a1ab39bd
2 changed files with 22 additions and 0 deletions
+18
View File
@@ -620,6 +620,24 @@ int LuaHelpers::TypeError( Lua *L, int iArgNo, const char *szName )
}
}
namespace
{
int lua_pushvalues( lua_State *L )
{
int iArgs = lua_tointeger( L, lua_upvalueindex(1) );
for( int i = 0; i < iArgs; ++i )
lua_pushvalue( L, lua_upvalueindex(i+2) );
return iArgs;
}
}
void LuaHelpers::PushValueFunc( lua_State *L, int iArgs )
{
int iTop = lua_gettop( L ) - iArgs + 1;
lua_pushinteger( L, iArgs );
lua_insert( L, iTop );
lua_pushcclosure( L, lua_pushvalues, iArgs+1 );
}
LuaFunctionList::LuaFunctionList( RString name_, lua_CFunction func_ )
{
+4
View File
@@ -76,6 +76,10 @@ namespace LuaHelpers
/* If sStr begins with @, evaluate the rest as an expression and store the result over sStr. */
bool RunAtExpressionS( RString &sStr );
/* Pops the last iArgs arguments from the stack, and return a function that returns
* those values. */
void PushValueFunc( lua_State *L, int iArgs );
template<class T>
void Push( lua_State *L, T *pObject );