本文整理汇总了C++中LuaState::SetTop方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaState::SetTop方法的具体用法?C++ LuaState::SetTop怎么用?C++ LuaState::SetTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaState
的用法示例。
在下文中一共展示了LuaState::SetTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Next
/**
Go to the next entry in the table.
\return Returns true if the iteration is done.
**/
bool LuaStackTableIterator::Next()
{
// This function is only active if Reset() has been called head.
luaplus_assert( IsValid() );
// This is a local helper variable so we don't waste space in the class
// definition.
LuaState* state = m_tableObj.GetState();
// Do any stack management operations.
if ( m_autoStackManagement )
{
state->SetTop( m_startStackIndex + 1 );
}
else
{
// If this luaplus_assert fires, then you left something on the stack.
luaplus_assert( state->GetTop() == m_startStackIndex + 1 );
}
// Do the Lua table iteration.
if ( state->Next( m_tableObj ) == 0 )
{
// Invalidate the iterator.
m_startStackIndex = -1;
return false;
}
// The iterator is still valid.
return true;
}
示例2: loop
/**
Invalidates the iterator. Call this function if you early abort from
an iteration loop (such as before it hits the end).
**/
void LuaStackTableIterator::Invalidate()
{
// See if the iterator is already invalid.
if ( !IsValid() )
return;
// This is a local helper variable so we don't waste space in the class
// definition.
LuaState* state = m_tableObj.GetState();
if ( !m_autoStackManagement )
{
luaplus_assert( state->GetTop() <= m_startStackIndex + 1 );
}
// Set the stack back.
state->SetTop( m_startStackIndex );
// Invalidate the iterator.
m_startStackIndex = -1;
}