Changeset 539 for trunk/src/lua/lua_proxy.cc
- Timestamp:
- 01/24/17 17:55:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_proxy.cc
r538 r539 13 13 using namespace nv::lua; 14 14 15 nv::string64 nv::lua::stack_proxy::get_string64() const 15 uint32 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 20 sint32 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 25 char 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 30 nv::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 35 nv::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 40 bool 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 45 bool nv::lua::stack_proxy::is_number() const 46 { 47 return lua_type( *m_state, m_index ) == LUA_TNUMBER; 48 } 49 50 bool nv::lua::stack_proxy::is_bool() const 51 { 52 return lua_type( *m_state, m_index ) == LUA_TBOOLEAN; 53 } 54 55 bool nv::lua::stack_proxy::is_string() const 56 { 57 return lua_type( *m_state, m_index ) == LUA_TSTRING; 58 } 59 60 bool nv::lua::stack_proxy::is_table() const 61 { 62 return lua_type( *m_state, m_index ) == LUA_TTABLE; 63 } 64 65 nv::string_view nv::lua::stack_proxy::get_string_view() const 16 66 { 17 67 size_t l = 0; … … 21 71 str = lua_tolstring( *m_state, m_index, &l ); 22 72 } 23 return string 64( str, static_cast<uint32>( l ) );73 return string_view( str, static_cast<uint32>( l ) ); 24 74 } 25 75 26 nv::string 64 nv::lua::stack_proxy::to_string64()76 nv::string_view nv::lua::stack_proxy::as_string_view() 27 77 { 28 78 size_t l = 0; 29 79 const char* str = nullptr; 30 80 str = lua_tolstring( *m_state, m_index, &l ); 31 return string 64( str, static_cast<uint32>( l ) );81 return string_view( str, static_cast<uint32>( l ) ); 32 82 } 83 84 nv::lua::temporary_proxy::temporary_proxy( state* state ) 85 : stack_proxy( state, -1 ) 86 { 87 88 } 89 90 nv::lua::temporary_proxy::~temporary_proxy() 91 { 92 lua_pop( *m_state, 1 ); 93 }
Note: See TracChangeset
for help on using the changeset viewer.