Exemple #1
0
csp::WorkResult::Enum csp::Process::Evaluate( Host& host, int numArgs )
{
	if( LuaThread().Status() != lua::Return::YIELD && LuaThread().Status() != lua::Return::OK )
		return WorkResult::FINISH;

	if( m_operation )
	{
		WorkResult::Enum result = m_operation->IsFinished()
			? WorkResult::FINISH
			: m_operation->Evaluate( host );

		if( result == WorkResult::FINISH )
		{
			lua::LuaStack luaStack = m_luaThread.GetStack();
			numArgs = m_operation->PushResults( luaStack );
			DeleteOperation( host );
		}
		else
			return WorkResult::YIELD;
	}
	
	WorkResult::Enum result = Resume( numArgs );
	
	if ( result == WorkResult::YIELD && m_operation )
		host.PushEvalStep( *this );
	else if ( result == WorkResult::FINISH && m_parentProcess )
	{
		if( host.GetTopProcess() != m_parentProcess )
			host.PushEvalStep( *m_parentProcess );
	}

	return result;
}
Exemple #2
0
csp::WorkResult::Enum csp::Process::StartEvaluation( Host& host, int numArgs )
{
	CORE_ASSERT( m_operation == NULL );
	CORE_ASSERT( LuaThread().Status() == lua::Return::OK );
	CORE_ASSERT( LuaThread().GetStack()[-numArgs-1].IsFunction() );

	return Evaluate( host, numArgs );
}
Exemple #3
0
csp::WorkResult::Enum csp::Process::Resume( int numArgs )
{
	lua::Return::Enum retValue = LuaThread().Resume( numArgs, m_parentProcess ? &m_parentProcess->LuaThread() : NULL );
	if( retValue == lua::Return::YIELD )
		return WorkResult::YIELD;

	return WorkResult::FINISH;
}
Exemple #4
0
		static LuaThread get(lua_State* l, int index)
		{
			lua_pushvalue(l, index);
			return LuaThread(l, StackTop());
		}