1 2 // Copyright 2018 - 2021 Michael D. Parker 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.sdl.bind.sdlassert; 8 9 import bindbc.sdl.config; 10 11 enum SDL_assert_state : uint { 12 SDL_ASSERTION_RETRY = 0, 13 SDL_ASSERTION_BREAK = 1, 14 SDL_ASSERTION_ABORT = 2, 15 SDL_ASSERTION_IGNORE = 3, 16 SDL_ASSERTION_ALWAYS_IGNORE = 4 17 } 18 alias SDL_AssertState = SDL_assert_state; 19 mixin(expandEnum!SDL_AssertState); 20 21 struct SDL_assert_data { 22 int always_ignore; 23 uint trigger_count; 24 const(char) *condition; 25 const(char) *filename; 26 int linenum; 27 const(char) *function_; 28 const(SDL_assert_data) *next; 29 } 30 alias SDL_AssertData = SDL_assert_data; 31 32 extern(C) nothrow alias SDL_AssertionHandler = SDL_AssertState function(const(SDL_AssertData)* data, void* userdata); 33 34 static if(staticBinding) { 35 extern(C) @nogc nothrow { 36 void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void* userdata); 37 const(SDL_assert_data)* SDL_GetAssertionReport(); 38 void SDL_ResetAssertionReport(); 39 40 static if(sdlSupport >= SDLSupport.sdl202) { 41 SDL_AssertionHandler SDL_GetAssertionHandler(void** puserdata); 42 SDL_AssertionHandler SDL_GetDefaultAssertionHandler(); 43 } 44 } 45 } 46 else { 47 extern(C) @nogc nothrow { 48 alias pSDL_SetAssertionHandler = void function(SDL_AssertionHandler handler, void* userdata); 49 alias pSDL_GetAssertionReport = const(SDL_assert_data)* function(); 50 alias pSDL_ResetAssertionReport = void function(); 51 } 52 53 __gshared { 54 pSDL_SetAssertionHandler SDL_SetAssertionHandler; 55 pSDL_GetAssertionReport SDL_GetAssertionReport; 56 pSDL_ResetAssertionReport SDL_ResetAssertionReport; 57 } 58 59 static if(sdlSupport >= SDLSupport.sdl202) { 60 extern(C) @nogc nothrow { 61 alias pSDL_GetAssertionHandler = SDL_AssertionHandler function(void** puserdata); 62 alias pSDL_GetDefaultAssertionHandler = SDL_AssertionHandler function(); 63 } 64 65 __gshared { 66 pSDL_GetAssertionHandler SDL_GetAssertionHandler; 67 pSDL_GetDefaultAssertionHandler SDL_GetDefaultAssertionHandler; 68 } 69 } 70 }