Changeset 188 for trunk/src


Ignore:
Timestamp:
08/04/13 06:37:00 (12 years ago)
Author:
epyon
Message:
  • lua/path - bugfix
  • lua/state - added is_defined(path)
  • lua/table_guard - added is_defined(path), get_unsigned, get_size
File:
1 edited

Legend:

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

    r187 r188  
    216216}
    217217
     218size_t lua::table_guard::get_size()
     219{
     220        return lua_rawlen( L->get_raw(), -1 );
     221}
     222
     223
    218224bool lua::table_guard::has_field( const string& element )
    219225{
     
    248254}
    249255
     256unsigned lua::table_guard::get_unsigned( const string& element, unsigned defval /*= "" */ )
     257{
     258        lua_getfield( L->L, -1, element.c_str() );
     259        int result = lua_type( L->L, -1 ) == LUA_TNUMBER ? lua_tounsigned( L->L, -1 ) : defval;
     260        lua_pop( L->L, 1 );
     261        return result;
     262}
     263
    250264double lua::table_guard::get_double( const string& element, double defval /*= "" */ )
    251265{
     
    274288}
    275289
     290bool nv::lua::table_guard::is_defined( const path& p )
     291{
     292        return L->is_defined( p, false );
     293}
    276294
    277295void lua::table_guard::get_raw_flags( const std::string& element, uint8* data, uint32 count )
     
    393411}
    394412
     413
     414bool nv::lua::state::is_defined( const path& p, bool global )
     415{
     416        if ( !p.resolve( L, global ) )
     417        {
     418                return false;
     419        }
     420        bool result = !lua_isnil( L, -1 );
     421        lua_pop( L, 1 );
     422        return result;
     423}
     424
    395425int lua::state::call_function( int nargs, int nresults )
    396426{
Note: See TracChangeset for help on using the changeset viewer.