Changeset 437 for trunk/src/lua/lua_raw.cc
- Timestamp:
- 07/23/15 08:30:41 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_raw.cc
r435 r437 7 7 #include "nv/lua/lua_raw.hh" 8 8 9 #include "nv/stl/string.hh" 10 11 std::string nlua_typecontent( lua_State* L, int idx ) 9 nv::string_view nlua_typecontent( lua_State* L, int idx ) 12 10 { 13 11 int type = lua_type( L, idx ); … … 19 17 //case LUA_TLIGHTUSERDATA : return std::to_string( nv::uint64( lua_touserdata( L, idx ) ) ); 20 18 //case LUA_TNUMBER : return std::to_string( lua_tonumber( L, idx ) ); 21 case LUA_TSTRING : return lua_tostring( L, idx ); 19 // TODO: copy to buffer? 20 case LUA_TSTRING : return nlua_tostringview( L, idx ); 22 21 case LUA_TTABLE : return "TABLE"; 23 22 case LUA_TFUNCTION : return "FUNCTION"; … … 26 25 default : break; 27 26 } 28 char buffer_data[64];27 static char buffer_data[64]; 29 28 nv::array_ref< char > buffer( buffer_data, 64 ); 30 29 if ( type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA ) 31 30 { 32 31 size_t l = nv::uint64_to_buffer( buffer, nv::uint64( lua_touserdata( L, idx ) ) ); 33 return std::string( buffer_data, l);32 return nv::string_view( buffer.data(), buffer.size() ); 34 33 } 35 34 else if ( type == LUA_TNUMBER ) 36 35 { 37 36 size_t l = nv::f64_to_buffer( buffer, lua_tonumber( L, idx ) ); 38 return std::string( buffer_data, l);37 return nv::string_view( buffer.data(), buffer.size() ); 39 38 } 40 39 return "UNKNOWN!";
Note: See TracChangeset
for help on using the changeset viewer.