Beispiel #1
0
bool csp::OpLua::CallLua( lua::LuaStack& stack, const char* functionName, int numArgs, int numRets )
{
	CORE_ASSERT( m_self != lua::LUA_NO_REF );
	stack.PushRegistryReferenced( m_self );

	lua::LuaStackValue top = stack.GetTopValue();
	CORE_ASSERT( top.IsTable() );

	stack.GetField( top, functionName );

	if ( !stack.GetTopValue().IsFunction() )
	{
		stack.Pop( numArgs + 2 );
		return false;
	}

	// stack at this point: arg1, arg2, argN, self, function

	stack.Insert( -numArgs-2 );
	stack.Insert( -numArgs-1 );

	// stack at this point: function, self, arg1, arg2, argN

	lua::LuaState luaState( stack.InternalState() );
	lua::Return::Enum result = luaState.Call( 1+numArgs, numRets );
	return result == lua::Return::OK;
}
Beispiel #2
0
bool csp::OpTestSuite_RunAll::Init( lua::LuaStack& args, InitError& initError )
{
    lua::LuaStackValue globals = args.PushGlobalTable();

    for ( lua::LuaStackTableIterator it( globals ); it; it.Next() )
    {
        lua::LuaStackValue name = it.Key();
        lua::LuaStackValue value = it.Value();

        if ( name.IsString() && value.IsTable() && CspHasMetatable( args.InternalState(), value, testSuiteFunctions ) )
        {
            InitTestSuite( args, initError, name.GetString(), value );
        }
    }

    return true;
}