LuaHelpers::DeepCopy

This commit is contained in:
Glenn Maynard
2006-10-15 01:40:11 +00:00
parent f7bb9fe3a4
commit 10b96b08b8
2 changed files with 19 additions and 0 deletions
+15
View File
@@ -659,6 +659,21 @@ int LuaHelpers::TypeError( Lua *L, int iArgNo, const char *szName )
}
}
void LuaHelpers::DeepCopy( lua_State *L )
{
luaL_checktype( L, -2, LUA_TTABLE );
luaL_checktype( L, -1, LUA_TTABLE );
/* Call DeepCopy(t, u), where t is our referenced object and u is the new table. */
lua_getglobal( L, "DeepCopy" );
ASSERT_M( !lua_isnil(L, -1), "DeepCopy() missing" );
ASSERT_M( lua_isfunction(L, -1), "DeepCopy() not a function" );
lua_insert( L, lua_gettop(L)-2 );
lua_call( L, 2, 0 );
}
namespace
{
int lua_pushvalues( lua_State *L )
+4
View File
@@ -62,6 +62,10 @@ namespace LuaHelpers
/* Create a Lua array (a table with indices starting at 1) of the given vector,
* and push it on the stack. */
void CreateTableFromArrayB( Lua *L, const vector<bool> &aIn );
/* Recursively copy elements from the table at stack element -2 into the table
* at stack -1. Pop both elements from the stack. */
void DeepCopy( lua_State *L );
/* Read the table at the top of the stack back into a vector. */
void ReadArrayFromTableB( Lua *L, vector<bool> &aOut );