Changeset 185 for trunk/src


Ignore:
Timestamp:
08/03/13 04:40:16 (12 years ago)
Author:
epyon
Message:
  • lua/state - call any function with any param count and any return value
  • lua/table_guard - call any table/subtable function with any param count and any return value
  • lua/function fix
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_state.cc

    r181 r185  
    264264}
    265265
     266void lua::table_guard::call_get()
     267{
     268        lua_gettable( L->L, -2 );
     269}
     270
     271void lua::table_guard::call_get_raw()
     272{
     273        lua_rawget( L->L, -2 );
     274}
     275
     276
    266277void lua::table_guard::get_raw_flags( const std::string& element, uint8* data, uint32 count )
    267278{
     
    375386        }
    376387}
     388
     389int lua::state::call_function( int nargs, int nresults )
     390{
     391        int status = lua_pcall( L, nargs, nresults, 0 );
     392        if ( status != 0 )
     393        {
     394                std::string error = lua_tostring( L, -1 );
     395                lua_pop( L, 1 );
     396                NV_LOG( LOG_ERROR, "Lua error : " << error )
     397        }
     398        return status;
     399}
     400
     401bool lua::state::push_function( const path& p, bool global )
     402{
     403        if ( !p.resolve( L, global ) )
     404        {
     405                lua_pop( L, 1 );
     406                NV_LOG( LOG_ERROR, "Lua error : not a valid path - " + p.to_string() );
     407                return false;
     408        }
     409
     410        if ( !lua_isfunction( L, -1 ) )
     411        {
     412                lua_pop( L, 1 );
     413                NV_LOG( LOG_ERROR, "Lua error : not a valid function - " + p.to_string() );
     414                return false;
     415        }
     416        return true;
     417}
Note: See TracChangeset for help on using the changeset viewer.