本文整理汇总了C++中MOAILuaState::TableItrNext方法的典型用法代码示例。如果您正苦于以下问题:C++ MOAILuaState::TableItrNext方法的具体用法?C++ MOAILuaState::TableItrNext怎么用?C++ MOAILuaState::TableItrNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOAILuaState
的用法示例。
在下文中一共展示了MOAILuaState::TableItrNext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AffirmMemberID
//----------------------------------------------------------------//
uintptr MOAISerializer::AffirmMemberID ( MOAILuaState& state, int idx ) {
// if we're an object, affirm as such...
if ( state.IsType ( idx, LUA_TUSERDATA )) {
return this->AffirmMemberID ( state.GetLuaObject < MOAILuaObject >( -1 ));
}
// bail if we're not a table
if ( !state.IsType ( idx, LUA_TTABLE )) return 0;
// get the table's address
uintptr memberID = ( uintptr )lua_topointer ( state, idx );
// bail if the table's already been added
if ( this->mTableMap.contains ( memberID )) return memberID;
// add the ref now to avoid cycles
this->mTableMap [ memberID ].SetStrongRef ( state, idx );
// follow the table's refs to make sure everything gets added
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
this->AffirmMemberID ( state, -1 );
}
return memberID;
}
示例2: SerializeIn
//----------------------------------------------------------------//
void MOAIGlyphSet::SerializeIn ( MOAILuaState& state ) {
UNUSED ( state );
this->mSize = state.GetField ( -1, "mSize", this->mSize );
this->mHeight = state.GetField ( -1, "mHeight", this->mHeight );
this->mAscent = state.GetField ( -1, "mAscent", this->mAscent );
if ( state.GetFieldWithType ( -1, "mGlyphMap", LUA_TTABLE )) {
u32 itr = state.PushTableItr ( -1 );
while ( state.TableItrNext ( itr )) {
u32 c = state.GetValue < u32 >( -2, 0 );
MOAIGlyph& glyph = this->mGlyphMap [ c ];
glyph.SerializeIn ( state );
}
state.Pop ( 1 );
}
GlyphMapIt glyphMapIt = this->mGlyphMap.begin ();
for ( ; glyphMapIt != this->mGlyphMap.end (); ++glyphMapIt ) {
MOAIGlyph& glyph = glyphMapIt->second;
if ( glyph.mPageID == MOAIGlyph::NULL_PAGE_ID ) {
glyph.mNext = this->mPending;
this->mPending = &glyph;
}
else {
glyph.mNext = this->mGlyphs;
this->mGlyphs = &glyph;
}
}
}
示例3: _luaToJSONObject
//----------------------------------------------------------------//
json_t* _luaToJSONObject ( lua_State* L, int idx ) {
MOAILuaState state ( L );
json_t* object = json_object ();
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
if ( lua_type ( state, -2 ) != LUA_TSTRING ) continue;
STLString key = lua_tostring ( state, -2 );
json_t* value = _luaToJSON ( state, -1 );
if ( value ) {
json_object_set_new ( object, key, value );
}
}
return object;
}
示例4: WriteTableInitializer
//----------------------------------------------------------------//
u32 MOAISerializer::WriteTableInitializer ( USStream& stream, MOAILuaState& state, int idx, cc8* prefix ) {
u32 count = 0;
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
int keyType = lua_type ( state, -2 );
int valType = lua_type ( state, -1 );
cc8* keyName = lua_tostring ( state, -2 );
switch ( valType ) {
case LUA_TNONE:
case LUA_TNIL:
case LUA_TFUNCTION:
case LUA_TUSERDATA:
case LUA_TTHREAD:
continue;
}
switch ( keyType ) {
case LUA_TSTRING: {
stream.Print ( "\t%s [ \"%s\" ] = ", prefix, keyName );
break;
}
case LUA_TNUMBER: {
stream.Print ( "\t%s [ %s ]\t= ", prefix, keyName );
break;
}
};
switch ( valType ) {
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: {
MOAILuaObject* object = state.GetLuaObject < MOAILuaObject >( -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;
}
示例5: WriteTable
//----------------------------------------------------------------//
u32 MOAISerializer::WriteTable ( USStream& stream, MOAILuaState& 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 )) {
int keyType = lua_type ( state, -2 );
int valType = lua_type ( state, -1 );
cc8* keyName = lua_tostring ( state, -2 );
switch ( valType ) {
case LUA_TNONE:
case LUA_TNIL:
case LUA_TFUNCTION:
case LUA_TUSERDATA:
case LUA_TTHREAD:
continue;
}
if ( count == 0 ) {
stream.Print ( "\n" );
}
switch ( keyType ) {
case LUA_TSTRING: {
stream.Print ( "%s[ \"%s\" ] = ", indent.c_str (), keyName );
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s[ %s ]\t= ", indent.c_str (), keyName );
break;
}
};
switch ( valType ) {
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;
}