Changeset 380 for trunk/src/lua
- Timestamp:
- 05/29/15 17:28:16 (10 years ago)
- Location:
- trunk/src/lua
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_glm.cc
r378 r380 295 295 switch ( v.length() ) 296 296 { 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; 301 301 default: 302 302 lua_pushliteral( L, "(vector?)" ); break; -
trunk/src/lua/lua_path.cc
r376 r380 32 32 } 33 33 34 void lua::path::push( nv:: size_tvalue )34 void lua::path::push( nv::uint32 value ) 35 35 { 36 36 m_elements[ m_count ].value = value; … … 50 50 if (m_count == 0) return false; 51 51 if (global) lua_pushglobaltable( L ); 52 for ( inti = 0; i < m_count; ++i )52 for ( uint32 i = 0; i < m_count; ++i ) 53 53 { 54 54 if ( lua_istable( L, -1 ) ) … … 76 76 std::string nv::lua::path::to_string() const 77 77 { 78 std::string result; 79 result.reserve( 64 ); 78 char buffer[64]; 79 char* start = buffer; 80 char* current = buffer; 80 81 bool dot = false; 82 bool oos = false; 81 83 for ( const element& e : m_elements ) 82 84 { 83 if ( dot ) result.append("."); 85 if ( current - start > 48 ) { oos = true; break; } 86 if ( dot ) *current++ = '.'; 84 87 if ( e.length == 0 ) 85 88 { 86 result.append("[" + nv::to_string( e.value ) + "]" ); 89 *current++ = '['; 90 current += uint32_to_buffer( e.value, current ); 91 *current++ = ']'; 87 92 dot = false; 88 93 } 89 94 else 90 95 { 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; 92 99 dot = true; 93 100 } 94 101 } 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) ); 96 110 } -
trunk/src/lua/lua_raw.cc
r368 r380 11 11 std::string nlua_typecontent( lua_State* L, int idx ) 12 12 { 13 switch ( lua_type( L, idx ) ) 13 int type = lua_type( L, idx ); 14 switch ( type ) 14 15 { 15 16 case LUA_TNONE : return "NONE"; 16 17 case LUA_TNIL : return "NIL"; 17 18 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 ) ); 20 21 case LUA_TSTRING : return lua_tostring( L, idx ); 21 22 case LUA_TTABLE : return "TABLE"; 22 23 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 ) ) ); 24 25 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!"; 27 40 } 28 41 -
trunk/src/lua/lua_state.cc
r376 r380 179 179 } 180 180 181 st ring lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ )181 std::string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ ) 182 182 { 183 183 lua_getfield( m_state, -1, element.data() );
Note: See TracChangeset
for help on using the changeset viewer.