Changeset 441 for trunk/src


Ignore:
Timestamp:
07/24/15 11:13:32 (10 years ago)
Author:
epyon
Message:
  • md5 support moved to legacy code
  • more std::string removal
  • minor fixes in algorithm
Location:
trunk/src/lua
Files:
2 edited

Legend:

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

    r440 r441  
    1717#include "nv/lua/lua_raw.hh"
    1818
    19 // TODO: REMOVE
    20 #include <string>
    21 
    2219static const char* NLUA_MAP_TILE_METATABLE = "map_tile";
    2320
     
    5855        nv::map_area* map_area = nv::lua::detail::to_map_area( L, 3 );
    5956        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" );
    6359        code.erase( nv::remove_if( code.begin(), code.end(),
    6460                [&chars] ( const char& c )
    6561        {
    66                 return chars.find( c ) != std::string::npos;
     62                return chars.find( c ) != nv::string_view::npos;
    6763        } ), code.end() );
    6864
  • trunk/src/lua/lua_raw.cc

    r438 r441  
    77#include "nv/lua/lua_raw.hh"
    88
    9 nv::string_view nlua_typecontent( lua_State* L, int idx )
     9nv::string64 nlua_typecontent( lua_State* L, int idx )
    1010{
    1111        int type = lua_type( L, idx );
    1212        switch ( type )
    1313        {
    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" );
    2521        default : break;
    2622        }
    27         static char buffer_data[64];
    28         nv::array_ref< char > buffer( buffer_data, 64 );
    2923        if ( type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA )
    3024        {
     25                nv::string64 buffer;
    3126                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;
    3328        }
    3429        else if ( type == LUA_TNUMBER )
    3530        {
     31                nv::string64 buffer;
    3632                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!" );
    4036}
    4137
Note: See TracChangeset for help on using the changeset viewer.