Changeset 441 for trunk/src/lua/lua_raw.cc
- Timestamp:
- 07/24/15 11:13:32 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.