コード例 #1
0
ファイル: op_alt.cpp プロジェクト: dromanov/LuaCSP
bool csp::OpAlt::SelectChannelProcessToTrigger( Host& host )
{
	CORE_ASSERT( m_pCaseTriggered == NULL );

	bool allCasesClosed = true;

	for( int i = 0; i < m_numCases; ++i )
	{
		AltCase& altCase = m_cases[ i ];
		if( m_pNilCase == &altCase )
		{
			m_pCaseTriggered = m_pNilCase;
			allCasesClosed = false;

			m_argumentsMoved = true;
			DetachChannels();

			host.PushEvalStep( ThisProcess() );
			break;
		}

		Channel* pChannel = altCase.m_pChannel;
		if( pChannel || altCase.m_time >= 0.0f )
			allCasesClosed = false;

		if( pChannel && pChannel->OutAttached() )
		{
			ChannelAttachmentOut_i& out = pChannel->OutAttachment();
			out.Communicate( host, ThisProcess() );
			break;
		}
	}

	return allCasesClosed;
}
コード例 #2
0
ファイル: op_alt.cpp プロジェクト: dromanov/LuaCSP
void csp::OpAlt::SelectTimeProcessToTrigger( Host& host )
{
	CORE_ASSERT( m_pCaseTriggered == NULL );

	CspTime_t time = host.Time();

	for( int i = 0; i < m_numCases; ++i )
	{
		AltCase& altCase = m_cases[ i ];
		if( m_pNilCase == &altCase )
			continue;

		if( altCase.m_pChannel == NULL && altCase.m_time <= time )
		{
			if( m_pCaseTriggered )
			{
				if( altCase.m_time < m_pCaseTriggered->m_time )
					m_pCaseTriggered = &altCase;
			}
			else
				m_pCaseTriggered = &altCase;
		}
	}

	if( m_pCaseTriggered )
	{
		m_argumentsMoved = true;
		DetachChannels();

		host.PushEvalStep( ThisProcess() );
	}
}
コード例 #3
0
ファイル: luatest.cpp プロジェクト: losinggeneration/LuaCSP
void csp::OpTestSuite_RunAll::UnrefClosure( TestClosure* pClosure )
{
    if( pClosure->refKey != lua::LUA_NO_REF )
    {
        ThisProcess().LuaThread().GetStack().UnrefInRegistry( pClosure->refKey );
        pClosure->refKey = lua::LUA_NO_REF;
    }
}
コード例 #4
0
ファイル: luatest.cpp プロジェクト: losinggeneration/LuaCSP
void csp::OpTestSuite_RunAll::InitTest( lua::LuaStack& stack, InitError&, const char* suiteName, const char* functionName, lua::LuaStackValue& function )
{
    TestClosure* pClosure = CORE_NEW TestClosure();

    lua::LuaState thread = stack.NewThread();
    function.PushValue();
    stack.XMove( thread.GetStack(), 1 );

    pClosure->process.SetLuaThread( thread );
    pClosure->process.SetParentProcess( ThisProcess() );
    pClosure->refKey = stack.RefInRegistry();
    pClosure->suiteName = suiteName;
    pClosure->functionName = functionName;

    ListAddToTail( m_pClosuresHead, m_pClosuresTail, *pClosure );
}
コード例 #5
0
ファイル: op_alt.cpp プロジェクト: dromanov/LuaCSP
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;
}
コード例 #6
0
ファイル: op_alt.cpp プロジェクト: dromanov/LuaCSP
csp::Process& csp::OpAlt::ProcessToEvaluate()
{
	return ThisProcess();
}