- Timestamp:
- 07/24/15 11:13:32 (10 years ago)
- Location:
- trunk/src/lua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_map_tile.cc
r440 r441 17 17 #include "nv/lua/lua_raw.hh" 18 18 19 // TODO: REMOVE20 #include <string>21 22 19 static const char* NLUA_MAP_TILE_METATABLE = "map_tile"; 23 20 … … 58 55 nv::map_area* map_area = nv::lua::detail::to_map_area( L, 3 ); 59 56 lua_settop( L, 2 ); 60 nv::string_view lts = nv::trimmed( lua_tostring( L, 1 ) ); 61 std::string code( lts.data(), lts.size() ); 62 std::string chars( " \r\t" ); 57 nv::string_buffer code( nv::trimmed( lua_tostring( L, 1 ) ) ); 58 nv::string_view chars( " \r\t" ); 63 59 code.erase( nv::remove_if( code.begin(), code.end(), 64 60 [&chars] ( const char& c ) 65 61 { 66 return chars.find( c ) != std::string::npos;62 return chars.find( c ) != nv::string_view::npos; 67 63 } ), code.end() ); 68 64 -
trunk/src/lua/lua_raw.cc
r438 r441 7 7 #include "nv/lua/lua_raw.hh" 8 8 9 nv::string _viewnlua_typecontent( lua_State* L, int idx )9 nv::string64 nlua_typecontent( lua_State* L, int idx ) 10 10 { 11 11 int type = lua_type( L, idx ); 12 12 switch ( type ) 13 13 { 14 case LUA_TNONE : return "NONE"; 15 case LUA_TNIL : return "NIL"; 16 case LUA_TBOOLEAN : return lua_toboolean( L, idx ) == 0 ? "false" : "true"; 17 //case LUA_TLIGHTUSERDATA : return std::to_string( nv::uint64( lua_touserdata( L, idx ) ) ); 18 //case LUA_TNUMBER : return std::to_string( lua_tonumber( L, idx ) ); 19 // TODO: copy to buffer? 20 case LUA_TSTRING : return nlua_tostringview( L, idx ); 21 case LUA_TTABLE : return "TABLE"; 22 case LUA_TFUNCTION : return "FUNCTION"; 23 // case LUA_TUSERDATA : return std::to_string( nv::uint64( lua_touserdata( L, idx ) ) ); 24 case LUA_TTHREAD : return "THREAD"; 14 case LUA_TNONE : return nv::string64( "NONE" ); 15 case LUA_TNIL : return nv::string64( "NIL" ); 16 case LUA_TBOOLEAN : return nv::string64( lua_toboolean( L, idx ) == 0 ? "false" : "true" ); 17 case LUA_TSTRING : return nv::string64( nlua_tostringview( L, idx ) ); 18 case LUA_TTABLE : return nv::string64( "TABLE" ); 19 case LUA_TFUNCTION : return nv::string64( "FUNCTION" ); 20 case LUA_TTHREAD : return nv::string64( "THREAD" ); 25 21 default : break; 26 22 } 27 static char buffer_data[64];28 nv::array_ref< char > buffer( buffer_data, 64 );29 23 if ( type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA ) 30 24 { 25 nv::string64 buffer; 31 26 size_t l = nv::uint64_to_buffer( buffer, nv::uint64( lua_touserdata( L, idx ) ) ); 32 return nv::string_view( buffer.data(), l );27 return buffer; 33 28 } 34 29 else if ( type == LUA_TNUMBER ) 35 30 { 31 nv::string64 buffer; 36 32 size_t l = nv::f64_to_buffer( buffer, lua_tonumber( L, idx ) ); 37 return nv::string_view( buffer.data(), l );38 } 39 return "UNKNOWN!";33 return buffer; 34 } 35 return nv::string64( "UNKNOWN!" ); 40 36 } 41 37
Note: See TracChangeset
for help on using the changeset viewer.