Changeset 380 for trunk/src/lua


Ignore:
Timestamp:
05/29/15 17:28:16 (10 years ago)
Author:
epyon
Message:
  • oops, missed src : got rid of to_string and other std::string utilities (except slurp) string no longer in nv namespace
Location:
trunk/src/lua
Files:
4 edited

Legend:

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

    r378 r380  
    295295        switch ( v.length() )
    296296        {
    297         case 1: lua_pushfstring( L, ( fl ? "(%f)"          : "(%d)" ),          v[0] );
    298         case 2: lua_pushfstring( L, ( fl ? "(%f,%f)"       : "(%d,%d)" ),       v[0], v[1] );
    299         case 3: lua_pushfstring( L, ( fl ? "(%f,%f,%f)"    : "(%d,%d,%d)" ),    v[0], v[1], v[2] );
    300         case 4: lua_pushfstring( L, ( fl ? "(%f,%f,%f,%f)" : "(%d,%d,%d,%d)" ), v[0], v[1], v[2], v[3] );
     297        case 1: lua_pushfstring( L, ( fl ? "(%f)"          : "(%d)" ),          v[0] ); break;
     298        case 2: lua_pushfstring( L, ( fl ? "(%f,%f)"       : "(%d,%d)" ),       v[0], v[1] ); break;
     299        case 3: lua_pushfstring( L, ( fl ? "(%f,%f,%f)"    : "(%d,%d,%d)" ),    v[0], v[1], v[2] ); break;
     300        case 4: lua_pushfstring( L, ( fl ? "(%f,%f,%f,%f)" : "(%d,%d,%d,%d)" ), v[0], v[1], v[2], v[3] ); break;
    301301        default:
    302302                lua_pushliteral( L, "(vector?)" ); break;
  • trunk/src/lua/lua_path.cc

    r376 r380  
    3232}
    3333
    34 void lua::path::push( nv::size_t value )
     34void lua::path::push( nv::uint32 value )
    3535{
    3636        m_elements[ m_count ].value  = value;
     
    5050        if (m_count == 0) return false;
    5151        if (global) lua_pushglobaltable( L );
    52         for (int i = 0; i < m_count; ++i )
     52        for ( uint32 i = 0; i < m_count; ++i )
    5353        {
    5454                if ( lua_istable( L, -1 ) )
     
    7676std::string nv::lua::path::to_string() const
    7777{
    78         std::string result;
    79         result.reserve( 64 );
     78        char buffer[64];
     79        char* start   = buffer;
     80        char* current = buffer;
    8081        bool dot = false;
     82        bool oos = false;
    8183        for ( const element& e : m_elements )
    8284        {
    83                 if ( dot ) result.append(".");
     85                if ( current - start > 48 ) { oos = true; break; }
     86                if ( dot ) *current++ = '.';
    8487                if ( e.length == 0 )
    8588                {
    86                         result.append("[" + nv::to_string( e.value ) + "]" );
     89                        *current++ = '[';
     90                        current += uint32_to_buffer( e.value, current );
     91                        *current++ = ']';
    8792                        dot = false;
    8893                }
    8994                else
    9095                {
    91                         result.append( e.str, e.length );
     96                        if ( size_t(current - start) + e.length > 60 ) { oos = true; break; }
     97                        nvmemcpy( current, e.str, e.length );
     98                        current += e.length;
    9299                        dot = true;
    93100                }
    94101        }
    95         return result;
     102        if (oos)
     103        {
     104                *current++ = '.';
     105                *current++ = '.';
     106                *current++ = '.';
     107        }
     108        *current++ = '\0';
     109        return std::string( buffer, size_t(current - start - 1) );
    96110}
  • trunk/src/lua/lua_raw.cc

    r368 r380  
    1111std::string nlua_typecontent( lua_State* L, int idx )
    1212{
    13         switch ( lua_type( L, idx ) )
     13        int type = lua_type( L, idx );
     14        switch ( type )
    1415        {
    1516        case LUA_TNONE          : return "NONE";
    1617        case LUA_TNIL               : return "NIL";
    1718        case LUA_TBOOLEAN               : return lua_toboolean( L, idx ) == 0 ? "false" : "true";
    18         case LUA_TLIGHTUSERDATA : return nv::to_string( nv::uint64( lua_touserdata( L, idx ) ) );
    19         case LUA_TNUMBER                : return nv::to_string( lua_tonumber( L, idx ) );
     19        //case LUA_TLIGHTUSERDATA       : return std::to_string( nv::uint64( lua_touserdata( L, idx ) ) );
     20        //case LUA_TNUMBER              : return std::to_string( lua_tonumber( L, idx ) );
    2021        case LUA_TSTRING                : return lua_tostring( L, idx );
    2122        case LUA_TTABLE             : return "TABLE";
    2223        case LUA_TFUNCTION              : return "FUNCTION";
    23         case LUA_TUSERDATA              : return nv::to_string( nv::uint64( lua_touserdata( L, idx ) ) );
     24//      case LUA_TUSERDATA              : return std::to_string( nv::uint64( lua_touserdata( L, idx ) ) );
    2425        case LUA_TTHREAD                : return "THREAD";
    25         default : return "UNKNOWN!";
    26         }
     26        default : break;
     27        }
     28        char buffer[64];
     29        if ( type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA )
     30        {
     31                size_t l = nv::uint64_to_buffer( nv::uint64( lua_touserdata( L, idx ) ), buffer );
     32                return std::string( buffer, l );
     33        }
     34        else if ( type == LUA_TNUMBER )
     35        {
     36                size_t l = nv::f64_to_buffer( lua_tonumber( L, idx ), buffer );
     37                return std::string( buffer, l );
     38        }
     39        return "UNKNOWN!";
    2740}
    2841
  • trunk/src/lua/lua_state.cc

    r376 r380  
    179179}
    180180
    181 string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ )
     181std::string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ )
    182182{
    183183        lua_getfield( m_state, -1, element.data() );
Note: See TracChangeset for help on using the changeset viewer.