Exemplo n.º 1
0
bool csp::OpLua::Init( lua::LuaStack& args, InitError& initError )
{
	lua::LuaStackValue self = args[1];
	if( !self.IsTable() )
		return initError.ArgError( 1, "OpLua table expected." );

	self.PushValue();
	m_self = args.RefInRegistry();

	return true;
}
Exemplo n.º 2
0
void csp::OpAlt::InitCases( lua::LuaStack& args )
{
	m_numCases = args.NumArgs()/2;
	m_cases = CORE_NEW AltCase [ m_numCases ];

	int initCase = 0;
	for( int i = 1; i <= args.NumArgs(); i += 2 )
	{
		lua::LuaStackValue guard = args[i];
		lua::LuaStackValue closure = args[i+1];

		closure.PushValue();
		m_cases[ initCase ].m_closureRefKey = args.RefInRegistry();

		if( IsChannelArg(guard) )
		{
			Channel* pChannel = GetChannelArg( guard );
			CORE_ASSERT( pChannel != NULL );
			pChannel->SetAttachmentIn( *this );

			guard.PushValue();
			m_cases[ initCase ].m_channelRefKey = args.RefInRegistry();
			m_cases[ initCase ].m_pChannel = pChannel;
		}
		else if( guard.IsNumber() )
		{
			m_cases[ initCase ].m_time = guard.GetNumber();
		}
		else if( guard.IsNil() )
		{
			CORE_ASSERT( m_pNilCase == NULL );
			m_pNilCase = m_cases + initCase;
		}

		++initCase;
	}
}
Exemplo n.º 3
0
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 );
}