本文整理汇总了C++中MOAIScopedLuaState::GetTop方法的典型用法代码示例。如果您正苦于以下问题:C++ MOAIScopedLuaState::GetTop方法的具体用法?C++ MOAIScopedLuaState::GetTop怎么用?C++ MOAIScopedLuaState::GetTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOAIScopedLuaState
的用法示例。
在下文中一共展示了MOAIScopedLuaState::GetTop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//----------------------------------------------------------------//
MOAILuaObject::~MOAILuaObject () {
if ( MOAILuaRuntime::IsValid ()) {
MOAILuaRuntime::Get ().DeregisterObject ( *this );
// TODO: change from both patrick's fork and the community branch; double check
if (( !this->mCollected ) && this->mUserdata ) {
MOAIScopedLuaState state = MOAILuaRuntime::Get ().State ();
// clear out the gc
this->mUserdata.PushRef ( state );
u32 top = state.GetTop ();
bool isUserdata = state.IsType ( top, LUA_TUSERDATA );
MOAILuaRuntime::Get ().PurgeUserdata ( state, -1 );
top = state.GetTop ();
isUserdata = state.IsType ( top, LUA_TUSERDATA );
if ( lua_getmetatable ( state, -1 )) {
lua_pushnil ( state );
lua_setfield ( state, -2, "__gc" );
state.Pop ( 1 );
}
top = state.GetTop ();
isUserdata = state.IsType ( top, LUA_TUSERDATA );
// and the ref table
lua_pushnil ( state );
lua_setmetatable ( state, -2 );
}
}
}