本文整理汇总了C++中USLuaState::PushTableItr方法的典型用法代码示例。如果您正苦于以下问题:C++ USLuaState::PushTableItr方法的具体用法?C++ USLuaState::PushTableItr怎么用?C++ USLuaState::PushTableItr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USLuaState
的用法示例。
在下文中一共展示了USLuaState::PushTableItr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Affirm
//----------------------------------------------------------------//
uintptr USLuaSerializer::Affirm ( USLuaState& state, int idx ) {
// if we're an object, affirm as such...
if ( state.IsType ( idx, LUA_TUSERDATA )) {
return this->Affirm ( state.GetLuaObject < USLuaObject >( -1 ));
}
// bail if we're not a table
if ( !state.IsType ( idx, LUA_TTABLE )) return 0;
// get the table's address
uintptr tableID = ( uintptr )lua_topointer ( state, idx );
// bail if the table's already been added
if ( this->mTableMap.contains ( tableID )) return tableID;
// add the ref now to avoid cycles
this->mTableMap [ tableID ].SetStrongRef ( state, idx );
// follow the table's refs to make sure everything gets added
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
this->Affirm ( state, -1 );
}
return tableID;
}
示例2: WriteTableInitializer
//----------------------------------------------------------------//
u32 USLuaSerializer::WriteTableInitializer ( USStream& stream, USLuaState& state, int idx, cc8* prefix ) {
u32 count = 0;
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
switch ( lua_type ( state, -2 )) {
case LUA_TSTRING: {
stream.Print ( "\t%s [ \"%s\" ] = ", prefix, lua_tostring ( state, -2 ));
break;
}
case LUA_TNUMBER: {
stream.Print ( "\t%s [ %s ]\t= ", prefix, lua_tostring ( state, -2 ));
break;
}
};
switch ( lua_type ( state, -1 )) {
case LUA_TBOOLEAN: {
int value = lua_toboolean ( state, -1 );
cc8* str = ( value ) ? "true": "false";
stream.Print ( "%s\n", str );
break;
}
case LUA_TTABLE: {
uintptr tableID = ( uintptr )lua_topointer ( state, -1 );
if ( this->mTableMap.contains ( tableID )) {
stream.Print ( "objects [ 0x%08X ]\n", tableID );
}
break;
}
case LUA_TSTRING: {
STLString str = _escapeString ( lua_tostring ( state, -1 ));
stream.Print ( "\"%s\"\n", str.c_str ());
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s\n", lua_tostring ( state, -1 ));
break;
}
case LUA_TUSERDATA: {
USLuaObject* object = state.GetLuaObject < USLuaObject >( -1 );
u32 instanceID = this->GetID ( object );
stream.Print ( "objects [ 0x%08X ]\n", instanceID );
break;
}
case LUA_TLIGHTUSERDATA: {
stream.Print ( "%p,\n", lua_touserdata ( state, -1 ));
break;
}
};
++count;
}
return count;
}
示例3: WriteTable
//----------------------------------------------------------------//
u32 USLuaSerializer::WriteTable ( USStream& stream, USLuaState& state, int idx, u32 tab ) {
STLString indent;
for ( u32 i = 0; i < tab; ++i ) {
indent.append ( "\t" );
}
u32 count = 0;
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
if ( count == 0 ) {
stream.Print ( "\n" );
}
switch ( lua_type ( state, -2 )) {
case LUA_TSTRING: {
stream.Print ( "%s[ \"%s\" ] = ", indent.c_str (), lua_tostring ( state, -2 ));
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s[ %s ]\t= ", indent.c_str (), lua_tostring ( state, -2 ));
break;
}
};
switch ( lua_type ( state, -1 )) {
case LUA_TBOOLEAN: {
int value = lua_toboolean ( state, -1 );
cc8* str = ( value ) ? "true": "false";
stream.Print ( "%s,\n", str );
break;
}
case LUA_TTABLE: {
uintptr tableID = ( uintptr )lua_topointer ( state, -1 );
if ( this->mTableMap.contains ( tableID )) {
stream.Print ( "objects [ 0x%08X ],\n", tableID );
}
else {
stream.Print ( "{" );
if ( this->WriteTable ( stream, state, -1, tab + 1 )) {
stream.Print ( "%s},\n", indent.c_str ());
}
else {
stream.Print ( "},\n" );
}
}
break;
}
case LUA_TSTRING: {
STLString str = _escapeString ( lua_tostring ( state, -1 ));
stream.Print ( "\"%s\",\n", str.c_str ());
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s,\n", lua_tostring ( state, -1 ));
break;
}
case LUA_TLIGHTUSERDATA: {
stream.Print ( "%p,\n", lua_touserdata ( state, -1 ));
break;
}
};
++count;
}
return count;
}