module lib.sdl2._assert

Code Map

module lib.sdl2._assert;


enum SDL_ASSERTION_RETRY;
enum SDL_ASSERTION_BREAK;
enum SDL_ASSERTION_ABORT;
enum SDL_ASSERTION_IGNORE;
enum SDL_ASSERTION_ALWAYS_IGNORE;

alias SDL_assert_state = i32;
alias SDL_AssertionHandler = fn (const(const(SDL_assert_data)*), void*) (SDL_assert_state);

struct SDL_assert_data
{
public:
	always_ignore: i32;
	trigger_count: u32;
	condition: char*;
	filename: char*;
	linenum: i32;
	_function: char*;
	next: SDL_assert_data*;
}

//! \brief Set an application-defined assertion handler.
fn SDL_SetAssertionHandler(handler: SDL_AssertionHandler, userdata: void*);
//! \brief Get a list of all assertion failures.
fn SDL_GetAssertionReport() SDL_assert_data*;
//! \brief Reset the list of all assertion failures.
fn SDL_ResetAssertionReport();
fn SDL_SetAssertionHandler(handler: SDL_AssertionHandler, userdata: void*)

\brief Set an application-defined assertion handler.

This allows an app to show its own assertion UI and/or force the response to an assertion failure. If the app doesn't provide this, SDL will try to do the right thing, popping up a system-specific GUI dialog, and probably minimizing any fullscreen windows.

This callback may fire from any thread, but it runs wrapped in a mutex, so it will only fire from one thread at a time.

Setting the callback to NULL restores SDL's original internal handler.

This callback is NOT reset to SDL's internal handler upon SDL_Quit()!

\return SDL_assert_state value of how to handle the assertion failure.

\param handler Callback function, called when an assertion fails. \param userdata A pointer passed to the callback as-is.

fn SDL_GetAssertionReport() SDL_assert_data*

\brief Get a list of all assertion failures.

Get all assertions triggered since last call to SDL_ResetAssertionReport(), or the start of the program.

The proper way to examine this data looks something like this:

const SDL_assert_data *item = SDL_GetAssertionReport(); while (item) { printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", item->condition, item->function, item->filename, item->linenum, item->trigger_count, item->always_ignore ? "yes" : "no"); item = item->next; }

\return List of all assertions. \sa SDL_ResetAssertionReport

fn SDL_ResetAssertionReport()

\brief Reset the list of all assertion failures.

Reset list of all assertions triggered.

\sa SDL_GetAssertionReport