Ignore:
Timestamp:
01/24/17 17:55:00 (8 years ago)
Author:
epyon
Message:
  • temporary_proxy implemented
  • table_guard now uses temporary_proxy as main read functionality
File:
1 edited

Legend:

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

    r538 r539  
    1313using namespace nv::lua;
    1414
    15 nv::string64 nv::lua::stack_proxy::get_string64() const
     15uint32 nv::lua::stack_proxy::get_uint32( uint32 def ) const
     16{
     17        return lua_type( *m_state, m_index ) == LUA_TNUMBER ? nlua_tounsigned( *m_state, m_index ) : def;
     18}
     19
     20sint32 nv::lua::stack_proxy::get_sint32( sint32 def ) const
     21{
     22        return lua_type( *m_state, m_index ) == LUA_TNUMBER ? static_cast<sint32>( lua_tointeger( *m_state, m_index ) ) : def;
     23}
     24
     25char nv::lua::stack_proxy::get_char( char def /*= ' ' */ ) const
     26{
     27        return ( lua_type( *m_state, m_index ) == LUA_TSTRING && nlua_rawlen( *m_state, m_index ) > 0 ) ? lua_tostring( *m_state, m_index )[0] : def;
     28}
     29
     30nv::f64 nv::lua::stack_proxy::get_f64( f64 def /*= 0.0 */ ) const
     31{
     32        return lua_type( *m_state, m_index ) == LUA_TNUMBER ? lua_tonumber( *m_state, m_index ) : def;
     33}
     34
     35nv::f32 nv::lua::stack_proxy::get_f32( f32 def /*= 0.0f */ ) const
     36{
     37        return lua_type( *m_state, m_index ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( *m_state, m_index ) ) : def;
     38}
     39
     40bool nv::lua::stack_proxy::get_bool( bool def /*= false */ ) const
     41{
     42        return lua_type( *m_state, m_index ) == LUA_TBOOLEAN ? lua_toboolean( *m_state, m_index ) != 0 : def;
     43}
     44
     45bool nv::lua::stack_proxy::is_number() const
     46{
     47        return lua_type( *m_state, m_index ) == LUA_TNUMBER;
     48}
     49
     50bool nv::lua::stack_proxy::is_bool() const
     51{
     52        return lua_type( *m_state, m_index ) == LUA_TBOOLEAN;
     53}
     54
     55bool nv::lua::stack_proxy::is_string() const
     56{
     57        return lua_type( *m_state, m_index ) == LUA_TSTRING;
     58}
     59
     60bool nv::lua::stack_proxy::is_table() const
     61{
     62        return lua_type( *m_state, m_index ) == LUA_TTABLE;
     63}
     64
     65nv::string_view nv::lua::stack_proxy::get_string_view() const
    1666{
    1767        size_t l = 0;
     
    2171                str = lua_tolstring( *m_state, m_index, &l );
    2272        }
    23         return string64( str, static_cast<uint32>( l ) );
     73        return string_view( str, static_cast<uint32>( l ) );
    2474}
    2575
    26 nv::string64 nv::lua::stack_proxy::to_string64()
     76nv::string_view nv::lua::stack_proxy::as_string_view()
    2777{
    2878        size_t l = 0;
    2979        const char* str = nullptr;
    3080        str = lua_tolstring( *m_state, m_index, &l );
    31         return string64( str, static_cast<uint32>( l ) );
     81        return string_view( str, static_cast<uint32>( l ) );
    3282}
     83
     84nv::lua::temporary_proxy::temporary_proxy( state* state )
     85        : stack_proxy( state, -1 )
     86{
     87
     88}
     89
     90nv::lua::temporary_proxy::~temporary_proxy()
     91{
     92        lua_pop( *m_state, 1 );
     93}
Note: See TracChangeset for help on using the changeset viewer.