本文整理汇总了C++中USLuaState::IsType方法的典型用法代码示例。如果您正苦于以下问题:C++ USLuaState::IsType方法的具体用法?C++ USLuaState::IsType怎么用?C++ USLuaState::IsType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USLuaState
的用法示例。
在下文中一共展示了USLuaState::IsType方法的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: _serializeToString
/** @name serializeToString
@text Serializes the specified table or userdata to a string. Useful for sending data to a remote server.
@in MOAISerializer self
@opt table data The table data to serialize.
@opt userdata data The userdata (object) to serialize. You must provide either a table or userdata, but not both.
@out string serialized The serialized string.
*/
int MOAISerializer::_serializeToString ( lua_State* L ) {
USLuaState state ( L );
if ( !state.CheckParams ( 1, "U" )) return 0;
if ( !( state.IsType ( 1, LUA_TTABLE ) || state.IsType ( 1, LUA_TUSERDATA ))) return 0;
USLuaSerializer serializer;
serializer.Affirm ( state, 1 );
serializer.AddLuaReturn ( state, 1 );
STLString result = serializer.SerializeToString ();
lua_pushstring ( state, result );
return 1;
}
示例3: SetRefField
//----------------------------------------------------------------//
void USLuaSerializer::SetRefField ( USLuaState& state, int idx, cc8* name, USLuaObject* object ) {
if ( state.IsType ( idx, LUA_TTABLE )) {
this->PushRef ( state, object );
lua_setfield ( state, -2, name );
}
}