- Timestamp:
- 06/14/15 14:31:00 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/library.cc
r402 r403 44 44 { 45 45 m_handle = nullptr; 46 NV_THROW( library_error, "Can't load library!", name.data() ); 46 NV_LOG_CRITICAL( "library \"", name, "\" : failed to load!" ); 47 NV_ABORT( "Can't load library!" ); 47 48 } 48 49 } … … 70 71 return true; 71 72 } 72 NV_LOG_NOTICE( "library : loading '", m_name, "'..." );73 NV_LOG_NOTICE( "library \"", string_view( m_name ), "\" : loading..." ); 73 74 74 75 std::string name = m_name; … … 84 85 if ( m_handle == NULL ) 85 86 { 86 NV_LOG_NOTICE( "library : '", name, "' failed to open." );87 NV_LOG_NOTICE( "library \"", string_view( name ), "\" : failed to open!" ); 87 88 return false; 88 89 } 89 NV_LOG_NOTICE( "library : '", name, "'loaded." );90 NV_LOG_NOTICE( "library \"", string_view( name ), "\" : loaded." ); 90 91 return true; 91 92 } … … 96 97 if ( !result ) 97 98 { 98 NV_THROW( library_error, "Can't find symbol " + std::string(symbol.data(),symbol.size()) + "!", m_name ); 99 NV_LOG_CRITICAL( "library \"", string_view( m_name ), "\" : can't find symbol \"", symbol, "\"" ); 100 NV_ABORT( "Library symbol load failed!" ); 99 101 } 100 102 return result; … … 115 117 if ( ! NV_LIB_CLOSE( m_handle ) ) 116 118 { 117 NV_LOG_ERROR( "library : can't close library '", m_name, "'!" );119 NV_LOG_ERROR( "library \"", string_view( m_name ), "\" : can't close library!" ); 118 120 } 119 121 m_handle = nullptr; -
trunk/src/gfx/texture_font.cc
r399 r403 11 11 12 12 using namespace nv; 13 14 #define NV_CHECK_FREETYPE_ERROR( error, ... ) \ 15 if ( error != 0 ) { \ 16 NV_LOG_CRITICAL( "freetype : ", __VA_ARGS__ ); \ 17 NV_ABORT( "freetype : freetype library error!" ); \ 18 } 13 19 14 20 texture_glyph::texture_glyph() … … 45 51 46 52 error = FT_Init_FreeType( (FT_Library*)(&m_rlibrary) ); 47 if ( error ) NV_THROW( std::runtime_error, "FT_Error");53 NV_CHECK_FREETYPE_ERROR( error, "error on FT_Init_FreeType, code - ", error ); 48 54 49 55 error = FT_New_Face( (FT_Library)(m_rlibrary), filename, 0, (FT_Face*)(&m_rface) ); 50 if ( error ) NV_THROW( std::runtime_error, "FT_Error");56 NV_CHECK_FREETYPE_ERROR( error, "error on FT_New_Face, code - ", error ); 51 57 52 58 error = FT_Set_Char_Size( (FT_Face)(m_rface), (int)(size*64), 0, 72*64, 72 ); 53 if ( error ) NV_THROW( std::runtime_error, "FT_Error");59 NV_CHECK_FREETYPE_ERROR( error, "error on FT_Set_Char_Size, code - ", error ); 54 60 55 61 FT_Set_Transform( (FT_Face)(m_rface), &matrix, NULL ); … … 123 129 FT_UInt glyph_index = FT_Get_Char_Index( face, c ); 124 130 FT_Error error = FT_Load_Glyph( face, glyph_index, flags ); 125 if ( error ) 126 { 127 NV_LOG_ERROR( "FT_Error while loading glyphs, error: ", error, " code: ", c ); 128 NV_THROW( std::runtime_error, "FT_Error while loading glyphs" ); 129 } 131 NV_CHECK_FREETYPE_ERROR( error, "error on FT_Load_Glyph, gylph '", c ,"' code - ", error ); 130 132 131 133 FT_GlyphSlot slot = face->glyph; … … 141 143 if ( r.pos.x < 0 ) 142 144 { 143 NV_LOG_ ERROR( "Atlas full while loading glyphs, r.pos.x: ", r.pos.x, " code: ", c);144 NV_ THROW( std::runtime_error, "Atlas full while loading glyphs" );145 NV_LOG_CRITICAL( "texture_font : atlas full while loading glyphs, gylph '", c, "' r.pos.x = ", r.pos.x ); 146 NV_ABORT( "texture_font : atlas full while loading gylphs!" ); 145 147 } 146 148 if (depth == 4) -
trunk/src/gl/gl_context.cc
r398 r403 379 379 void gl_context::set_viewport( const ivec4& viewport ) 380 380 { 381 if ( viewport.z < 0 || viewport.w < 0 ) 382 { 383 NV_THROW( logic_error, "viewport width and height must be greater than zero!"); 384 } 385 381 NV_ASSERT_ALWAYS( viewport.z > 0 && viewport.w > 0, "viewport dimensions must be greater than zero!" ); 386 382 m_viewport = viewport; 387 383 glViewport( viewport.x, viewport.y, viewport.z, viewport.w ); … … 456 452 } 457 453 458 if ( scissor.dim.x < 0 || scissor.dim.y < 0 )459 {460 NV_THROW( logic_error, "scissor_test.rect width and height must be greater than zero!" );461 }462 454 463 455 if ( scissor.enabled ) 464 456 { 457 NV_ASSERT_ALWAYS( scissor.dim.x > 0 && scissor.dim.y > 0, "scissor_test.rect dimension equal to zero!" ); 458 465 459 if ( m_render_state.scissor_test.dim != scissor.dim || m_render_state.scissor_test.pos != scissor.pos ) 466 460 { … … 514 508 void gl_context::apply_depth_range( const depth_range& range ) 515 509 { 516 if ( range.near < 0.0 || range.near > 1.0 ) 517 { 518 NV_THROW( logic_error, "render_state.depth_range.near must be between zero and one!"); 519 } 520 if ( range.far < 0.0 || range.far > 1.0 ) 521 { 522 NV_THROW( logic_error, "render_state.depth_range.far must be between zero and one!"); 523 } 510 NV_ASSERT_ALWAYS( range.near >= 0.0 && range.near <= 1.0, "render_state.depth_range.near must be between zero and one!" ); 511 NV_ASSERT_ALWAYS( range.far >= 0.0 && range.far <= 1.0, "render_state.depth_range.far must be between zero and one!" ); 524 512 525 513 if ((m_render_state.depth_range.far != range.far) || -
trunk/src/gl/gl_device.cc
r399 r403 238 238 if ( fatal ) 239 239 { 240 NV_LOG_ ERROR( "Uniform '", name, "' not found in program!" );241 NV_ THROW( runtime_error, ( "Uniform '"+name+"' not found!" ));240 NV_LOG_CRITICAL( "gl_device : uniform '", string_view( name ), "' not found in program!" ); 241 NV_ABORT( "gl_device : uniform not found!" ); 242 242 } 243 243 } … … 257 257 if ( fatal ) 258 258 { 259 NV_LOG_ ERROR( "Attribute '", name, "' not found in program!" );260 NV_ THROW( runtime_error, ( "Attribute '"+ name + "' not found!" ));259 NV_LOG_CRITICAL( "gl_device : attribute '", string_view( name ), "' not found in program!" ); 260 NV_ABORT( "gl_device : attribute not found!" ); 261 261 } 262 262 } -
trunk/src/lua/lua_state.cc
r399 r403 15 15 16 16 // stack_guard 17 18 #define NV_LUA_ABORT( func, ... ) \ 19 NV_LOG_CRITICAL( "lua::" func " : ", __VA_ARGS__ ) \ 20 NV_ABORT( "lua::" func " : critical error!" ) 21 17 22 18 23 lua::stack_guard::stack_guard( lua::state* aL ) … … 424 429 if ( lua_isnil( m_state, -1 ) ) 425 430 { 426 NV_ THROW( runtime_error, lua_name.to_string() +" type not registered!" );431 NV_LUA_ABORT( "state::register_object", lua_name, " type not registered!" ); 427 432 } 428 433 deep_pointer_copy( -1, o ); … … 436 441 if ( lua_isnil( m_state, -1 ) ) 437 442 { 438 NV_ THROW( runtime_error, storage.to_string() +" storage not registered!" );443 NV_LUA_ABORT( "state::register_proto", "\"", storage, "\" storage not registered!" ); 439 444 } 440 445 lua_getfield( m_state, -1, id.data() ); 441 446 if ( lua_isnil( m_state, -1 ) ) 442 447 { 443 NV_ THROW( runtime_error, id.to_string() + " not found in " + storage.to_string() + " storage!" );448 NV_LUA_ABORT( "state::register_proto", "\"", id, "\" not found in \"", storage, "\"!" ); 444 449 } 445 450 return lua::ref( luaL_ref( m_state, LUA_REGISTRYINDEX ) ); … … 452 457 if ( lua_isnil( m_state, -1 ) ) 453 458 { 454 NV_ THROW( runtime_error, lua_name.to_string() +" type not registered!" );459 NV_LUA_ABORT( "state::register_native_object_method", "\"", lua_name, "\" type not registered!" ); 455 460 } 456 461 lua_pushcfunction( m_state, f ); … … 502 507 if ( has_functions || has_metatable ) 503 508 { 504 lua_push string( m_state, "__ptr" );509 lua_pushliteral( m_state, "__ptr" ); 505 510 lua_pushlightuserdata( m_state, obj ); 506 511 lua_rawset( m_state, -3 ); … … 569 574 if ( lua_isnil( m_state, -1 ) ) 570 575 { 571 NV_ THROW( runtime_error, name.to_string() +" type not registered!" );576 NV_LUA_ABORT( "state::register_singleton", "\"", name, "\" type not registered!" ); 572 577 } 573 578 deep_pointer_copy( -1, o ); -
trunk/src/stl/assert.cc
r402 r403 9 9 #include "nv/base/assert.hh" 10 10 #undef NV_BASE_COMMON_HH 11 #include "nv/core/logging.hh" 11 12 13 extern "C" { 12 14 #if NV_COMPILER == NV_MSVC 15 NV_NORETURN void __cdecl exit( _In_ int _Code ); 16 #else 17 void exit( int status_code ) NV_NORETURN; 18 #endif 19 } 13 20 14 # 15 21 #if NV_DEBUG 22 # if NV_COMPILER == NV_MSVC 16 23 extern "C" { 17 24 void __cdecl _wassert( const wchar_t * _Message, const wchar_t *_File, unsigned _Line ); 18 25 } 19 26 20 void nv _internal_assert( const wchar_t * message, const wchar_t* file, unsigned line )27 void nv::detail::assert_fail( const wchar_t * message, const wchar_t* file, unsigned line ) 21 28 { 22 29 _wassert( message, file, line ); 23 30 } 24 # else 25 void nv_internal_assert( const wchar_t *, const wchar_t*, unsigned ) {} 26 # endif // NV_DEBUG 27 #else // NV_COMPILER 28 29 # if NV_DEBUG 31 # else // NV_COMPILER 30 32 # if NV_COMPILER == NV_CLANG 31 33 extern "C" { 32 extern void __assert(const char *, const char *, unsigned int, const char *) 33 __attribute__ ((__noreturn__)); 34 extern void __assert(const char *, const char *, unsigned int, const char *) NV_NORETURN; 34 35 } 36 #define NV_ASSERT_IMPL __assert 35 37 # else 36 38 extern "C" { 37 extern void __assert_fail(const char *, const char *, unsigned int, const char *) 38 __attribute__ ((__noreturn__)); 39 extern void __assert_fail(const char *, const char *, unsigned int, const char *) NV_NORETURN; 39 40 } 41 #define NV_ASSERT_IMPL __assert_fail 40 42 # endif 41 __attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )43 NV_NORETURN void nv::detail::assert_fail( const char * assertion, const char * file, unsigned int line, const char * function ) 42 44 { 43 # if NV_COMPILER == NV_CLANG 44 __assert(assertion, file, line, function ); 45 # else 46 __assert_fail(assertion, file, line, function ); 47 # endif 48 } 49 # else 50 void nv_internal_assert( const char * , const char * , unsigned int , const char * ) 51 { 45 NV_ASSERT_IMPL (assertion, file, line, function ); 52 46 } 53 47 # endif 54 48 55 #endif // NV_ COMPILER49 #endif // NV_DEBUG 56 50 51 NV_NORETURN void nv::detail::abort( const char * msg, const char * file, unsigned int line, const char * function ) 52 { 53 NV_LOG_CRITICAL( "Abort called : ", msg ); 54 NV_LOG_CRITICAL( " in ", file, ":", line, " (", function, ")" ); 55 NV_LOG_CRITICAL( "Aborting..." ); 56 exit( 1 ); 57 } 58 59 NV_NORETURN void nv::detail::assert_abort( const char * msg, const char * file, unsigned int line, const char * function ) 60 { 61 NV_LOG_CRITICAL( "Assertion failed: (", msg, ")" ); 62 NV_LOG_CRITICAL( " in ", file, ":", line, " (", function, ")" ); 63 NV_LOG_CRITICAL( "Aborting..." ); 64 exit( 1 ); 65 }
Note: See TracChangeset
for help on using the changeset viewer.