Changeset 437 for trunk/src/lua
- Timestamp:
- 07/23/15 08:30:41 (10 years ago)
- Location:
- trunk/src/lua
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_map_area.cc
r431 r437 137 137 { 138 138 nv::map_area* ma = to_map_area( L, 1 ); 139 nv::string_view result( ma->id_to_string( ma->get_cell( to_coord( L, 2 ) ) ) ); 140 lua_pushlstring( L, result.data(), result.size() ); 139 nlua_pushstringview( L, ma->id_to_string( ma->get_cell( to_coord( L, 2 ) ) ) ); 141 140 return 1; 142 141 } -
trunk/src/lua/lua_nova.cc
r399 r437 817 817 // TODO: check if nova is loaded 818 818 lua_pushcfunction( L, nova_register_storage ); 819 lua_pushlstring( L, name.data(), name.size());819 nlua_pushstringview( L, name ); 820 820 lua_call( L, 1, 1 ); 821 821 lua_setglobal( L, constructor_name.data() ); -
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!"; -
trunk/src/lua/lua_state.cc
r433 r437 134 134 if ( status != 0 ) 135 135 { 136 NV_LOG_ERROR( "Lua error : ", lua_tostring( m_state, -1 ) );136 NV_LOG_ERROR( "Lua error : ", nlua_tostringview( m_state, -1 ) ); 137 137 lua_pop( m_state, 1 ); 138 138 } … … 402 402 if (result) 403 403 { 404 NV_LOG_WARNING( "Failed to load string ", name, ": ", lua_tostring(m_state, -1));404 NV_LOG_WARNING( "Failed to load string ", name, ": ", nlua_tostringview(m_state, -1)); 405 405 return false; 406 406 } … … 414 414 if (result) 415 415 { 416 NV_LOG_WARNING( "Failed to open file ", filename, ": ", lua_tostring( m_state, -1 ) );416 NV_LOG_WARNING( "Failed to open file ", filename, ": ", nlua_tostringview( m_state, -1 ) ); 417 417 return false; 418 418 } … … 425 425 if (result) 426 426 { 427 NV_LOG_WARNING( "Failed to run script ", name, ": ", lua_tostring( m_state, -1 ) );427 NV_LOG_WARNING( "Failed to run script ", name, ": ", nlua_tostringview( m_state, -1 ) ); 428 428 lua_pop( m_state, 1 ); 429 429 } … … 442 442 for ( int i = 0; i < top; ++i ) 443 443 { 444 NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1) .c_str());444 NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1) ); 445 445 } 446 446 } … … 546 546 if ( !object_index.is_valid() ) return; 547 547 lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index.get() ); 548 lua_pushlstring( m_state, metaname.data(), metaname.size());548 nlua_pushstringview( m_state, metaname ); 549 549 lua_pushlightuserdata( m_state, pointer ); 550 550 lua_rawset( m_state, -3 ); … … 572 572 else 573 573 nlua_deepcopy( m_state, -2 ); 574 lua_pushlstring( m_state, id.data(), id.size());574 nlua_pushstringview( m_state, id ); 575 575 lua_pushvalue( m_state, -2 ); 576 576 lua_rawset( m_state, -4 ); … … 590 590 return; 591 591 } 592 lua_pushlstring( m_state, id.data(), id.size());592 nlua_pushstringview( m_state, id ); 593 593 lua_pushnil( m_state ); 594 594 lua_rawset( m_state, -3 );
Note: See TracChangeset
for help on using the changeset viewer.