Changeset 440 for trunk/src/lua/lua_state.cc
- Timestamp:
- 07/23/15 21:16:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r437 r440 116 116 if ( !p.resolve( m_state, global ) ) 117 117 { 118 NV_LOG_ERROR( "Lua error : not a valid path - ", p.to_string() .c_str());118 NV_LOG_ERROR( "Lua error : not a valid path - ", p.to_string() ); 119 119 return false; 120 120 } … … 123 123 { 124 124 lua_pop( m_state, 1 ); 125 NV_LOG_ERROR( "Lua error : not a valid function - ", p.to_string() .c_str());125 NV_LOG_ERROR( "Lua error : not a valid function - ", p.to_string() ); 126 126 return false; 127 127 } … … 212 212 lua_pop( m_state, 1 ); 213 213 return shash64( result ); 214 }215 216 std::string lua::table_guard::get_std_string( string_view element, string_view defval /*= string_view() */ )217 {218 lua_getfield( m_state, -1, element.data() );219 size_t l = 0;220 const char* str = nullptr;221 if ( lua_type( m_state, -1 ) == LUA_TSTRING )222 {223 str = lua_tolstring( m_state, -1, &l );224 }225 else226 {227 l = defval.size();228 str = defval.data();229 }230 std::string result( str, l );231 lua_pop( m_state, 1 );232 return result;233 214 } 234 215 … … 250 231 lua_pop( m_state, 1 ); 251 232 return result; 233 } 234 235 string128 lua::table_guard::get_string128( string_view element, string_view defval ) 236 { 237 lua_getfield( m_state, -1, element.data() ); 238 size_t l = 0; 239 const char* str = nullptr; 240 if ( lua_type( m_state, -1 ) == LUA_TSTRING ) 241 { 242 str = lua_tolstring( m_state, -1, &l ); 243 } 244 else 245 { 246 l = defval.size(); 247 str = defval.data(); 248 } 249 string128 result( str, l ); 250 lua_pop( m_state, 1 ); 251 return result; 252 252 } 253 253
Note: See TracChangeset
for help on using the changeset viewer.