本文整理汇总了C++中Host::LuaState方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::LuaState方法的具体用法?C++ Host::LuaState怎么用?C++ Host::LuaState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::LuaState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
csp::WorkResult::Enum csp::OpLua::Work( Host& host, CspTime_t dt )
{
lua::LuaStack& stack = host.LuaState().GetStack();
stack.PushNumber( dt );
if ( !CallLua( stack, "Work", 1, 1 ) )
return WorkResult::FINISH;
WorkResult::Enum workResult = WorkResult::FINISH;
lua::LuaStackValue callResult = stack.GetTopValue();
if( callResult.IsNumber() )
{
switch( callResult.GetInteger() )
{
case WorkResult::FINISH:
workResult = WorkResult::FINISH;
break;
case WorkResult::YIELD:
workResult = WorkResult::YIELD;
break;
default:
break;
}
}
stack.Pop( 1 );
return workResult;
}
示例2: if
csp::WorkResult::Enum csp::OpAlt::Evaluate( Host& host )
{
lua::LuaStack& stack = host.LuaState().GetStack();
if( m_pCaseTriggered == NULL )
{
bool allCasesClosed = SelectChannelProcessToTrigger( host );
if( allCasesClosed )
return WorkResult::FINISH;
}
else
{
if( m_argumentsMoved )
{
m_argumentsMoved = false;
StartTriggeredProcess( host );
UnrefArguments( stack );
UnrefChannels( stack );
}
else if( m_process.IsRunning() )
{
}
else if( m_processRefKey != lua::LUA_NO_REF )
{
UnrefProcess( stack );
return WorkResult::FINISH;
}
}
return WorkResult::YIELD;
}
示例3:
void csp::OpAlt::Terminate( Host& host )
{
lua::LuaStack stack = host.LuaState().GetStack();
m_process.Terminate( host );
DetachChannels();
UnrefChannels( stack );
UnrefArguments( stack );
UnrefClosures( stack );
UnrefProcess( stack );
}
示例4: ThisProcess
csp::WorkResult::Enum csp::OpAlt::StartTriggeredProcess( Host& host )
{
CORE_ASSERT( m_pCaseTriggered );
lua::LuaStack& stack = host.LuaState().GetStack();
lua::LuaState thread = stack.NewThread();
stack.GetTopValue().PushValue();
m_processRefKey = stack.RefInRegistry();
m_process.SetLuaThread( thread );
m_process.SetParentProcess( ThisProcess() );
lua::LuaStack threadStack = thread.GetStack();
threadStack.PushRegistryReferenced( m_pCaseTriggered->m_closureRefKey );
for( int i = 0; i < m_numArguments; ++i )
threadStack.PushRegistryReferenced( m_arguments[i].refKey );
int numArguments = m_numArguments == CSP_NO_ARGS ? 0 : m_numArguments;
WorkResult::Enum result = m_process.StartEvaluation( host, numArguments );
UnrefClosures( stack );
return result;
}