various changes from sm4 and sm-ssc (svn); see updated changelog for the full information

This commit is contained in:
AJ Kelly
2010-02-18 23:17:24 -06:00
parent f9bfc80fa9
commit 5c5ef54a48
26 changed files with 436 additions and 260 deletions
+37
View File
@@ -116,6 +116,43 @@ void LuaHelpers::ReadArrayFromTableB( Lua *L, vector<bool> &aOut )
}
}
namespace
{
/* Creates a table from an XNode and leaves it on the stack. */
void CreateTableFromXNodeRecursive( Lua *L, const XNode *pNode )
{
// create our base table
lua_newtable( L );
FOREACH_CONST_Attr( pNode, pAttr )
{
lua_pushstring( L, pAttr->first ); // push key
pNode->PushAttrValue( L, pAttr->first ); // push value
//add key-value pair to our table
lua_settable( L, -3 );
}
FOREACH_CONST_Child( pNode, c )
{
const XNode *pChild = c;
lua_pushstring( L, pChild->m_sName ); // push key
// push value (more correctly, build this child's table and leave it there
CreateTableFromXNodeRecursive( L, pChild );
// add key-value pair to the table
lua_settable( L, -3 );
}
}
}
void LuaHelpers::CreateTableFromXNode( Lua *L, const XNode *pNode )
{
// This creates our table and leaves it on the stack.
CreateTableFromXNodeRecursive( L, pNode );
}
static int GetLuaStack( lua_State *L )
{