sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Assert

Description

A helpful assertion macro!

SDL assertions operate like your usual assert macro, but with some added features:

  • It uses a trick with the sizeof operator, so disabled assertions vaporize out of the compiled code, but variables only referenced in the assertion won't trigger compiler warnings about being unused.
  • It is safe to use with a dangling-else: if (x) SDL_assert(y); else do_something();
  • It works the same everywhere, instead of counting on various platforms' compiler and C runtime to behave.
  • It provides multiple levels of assertion (SDL_assert, SDL_assert_release, SDL_assert_paranoid) instead of a single all-or-nothing option.
  • It offers a variety of responses when an assertion fails (retry, trigger the debugger, abort the program, ignore the failure once, ignore it for the rest of the program's run).
  • It tries to show the user a dialog by default, if possible, but the app can provide a callback to handle assertion failures however they like.
  • It lets failed assertions be retried. Perhaps you had a network failure and just want to retry the test after plugging your network cable back in? You can.
  • It lets the user ignore an assertion failure, if there's a harmless problem that one can continue past.
  • It lets the user mark an assertion as ignored for the rest of the program's run; if there's a harmless problem that keeps popping up.
  • It provides statistics and data on all failed assertions to the app.
  • It allows the default assertion handler to be controlled with environment variables, in case an automated script needs to control it.
  • It can be used as an aid to Clang's static analysis; it will treat SDL assertions as universally true (under the assumption that you are serious about the asserted claims and that your debug builds will detect when these claims were wrong). This can help the analyzer avoid false positives.

To use it: compile a debug build and just sprinkle around tests to check your code!

Synopsis

Documentation

sDL_ASSERT_LEVEL :: CInt Source #

C declaration
macro SDL_ASSERT_LEVEL, defined at SDL3/SDL_assert.h 101:9

sDL_NULL_WHILE_LOOP_CONDITION :: CInt Source #

C declaration
macro SDL_NULL_WHILE_LOOP_CONDITION, defined at SDL3/SDL_assert.h 286:9

newtype SDL_AssertState Source #

Possible outcomes from a triggered assertion.

When an enabled assertion triggers, it may call the assertion handler (possibly one provided by the app via SDL_SetAssertionHandler), which will return one of these values, possibly after asking the user.

Then SDL will respond based on this outcome (loop around to retry the condition, try to break in a debugger, kill the program, or ignore the problem).

C declaration
enum SDL_AssertState, defined at SDL3/SDL_assert.h 319:14

Since: 3.2.0

Constructors

SDL_AssertState 

Fields

Instances

Instances details
Storable SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Generic SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type Rep SDL_AssertState 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertState = D1 ('MetaData "SDL_AssertState" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_AssertState" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUInt)))
Read SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Show SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Eq SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Ord SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Prim SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

CEnum SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CEnumZ SDL_AssertState 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

SequentialCEnum SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

HasFFIType SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type FFIType SDL_AssertState 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ReadRaw SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

StaticSize SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

WriteRaw SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

HasCField SDL_AssertState "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertState "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

offset# :: Proxy# SDL_AssertState -> Proxy# "unwrap" -> Int #

ty ~ CUInt => HasField "unwrap" SDL_AssertState ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertState -> (ty -> SDL_AssertState, ty) #

ty ~ CUInt => HasField "unwrap" (Ptr SDL_AssertState) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertState -> Ptr ty #

type Rep SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertState = D1 ('MetaData "SDL_AssertState" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_AssertState" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUInt)))
type CEnumZ SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type FFIType SDL_AssertState Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertState "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

pattern SDL_ASSERTION_RETRY :: SDL_AssertState Source #

Retry the assert immediately.

C declaration
SDL_ASSERTION_RETRY, defined at SDL3/SDL_assert.h 321:5

pattern SDL_ASSERTION_BREAK :: SDL_AssertState Source #

Make the debugger trigger a breakpoint.

C declaration
SDL_ASSERTION_BREAK, defined at SDL3/SDL_assert.h 322:5

pattern SDL_ASSERTION_ABORT :: SDL_AssertState Source #

Terminate the program.

C declaration
SDL_ASSERTION_ABORT, defined at SDL3/SDL_assert.h 323:5

pattern SDL_ASSERTION_IGNORE :: SDL_AssertState Source #

Ignore the assert.

C declaration
SDL_ASSERTION_IGNORE, defined at SDL3/SDL_assert.h 324:5

pattern SDL_ASSERTION_ALWAYS_IGNORE :: SDL_AssertState Source #

Ignore the assert from now on.

C declaration
SDL_ASSERTION_ALWAYS_IGNORE, defined at SDL3/SDL_assert.h 325:5

data SDL_AssertData Source #

Information about an assertion failure.

This structure is filled in with information about a triggered assertion, used by the assertion handler, then added to the assertion report. This is returned as a linked list from SDL_GetAssertionReport().

C declaration
struct SDL_AssertData, defined at SDL3/SDL_assert.h 337:16

Since: 3.2.0

Constructors

SDL_AssertData 

Fields

  • always_ignore :: CBool

    true if app should always continue when assertion is triggered.

    C declaration
    always_ignore, defined at SDL3/SDL_assert.h 339:10
  • trigger_count :: CUInt

    Number of times this assertion has been triggered.

    C declaration
    trigger_count, defined at SDL3/SDL_assert.h 340:18
  • condition :: PtrConst CChar

    A string of this assert's test code.

    C declaration
    condition, defined at SDL3/SDL_assert.h 341:17
  • filename :: PtrConst CChar

    The source file where this assert lives.

    C declaration
    filename, defined at SDL3/SDL_assert.h 342:17
  • linenum :: CInt

    The line in filename where this assert lives.

    C declaration
    linenum, defined at SDL3/SDL_assert.h 343:9
  • function :: PtrConst CChar

    The name of the function where this assert lives.

    C declaration
    function, defined at SDL3/SDL_assert.h 344:17
  • next :: PtrConst SDL_AssertData

    next item in the linked list.

    C declaration
    next, defined at SDL3/SDL_assert.h 345:34

Instances

Instances details
Storable SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Generic SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Show SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Eq SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ReadRaw SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

StaticSize SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

WriteRaw SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

IsStruct SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

HasCField SDL_AssertData "always_ignore" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "always_ignore" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "always_ignore" = CBool

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "always_ignore" -> Int #

HasCField SDL_AssertData "condition" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "condition" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "condition" -> Int #

HasCField SDL_AssertData "filename" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "filename" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "filename" -> Int #

HasCField SDL_AssertData "function" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "function" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "function" -> Int #

HasCField SDL_AssertData "linenum" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "linenum" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "linenum" = CInt

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "linenum" -> Int #

HasCField SDL_AssertData "next" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "next" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "next" -> Int #

HasCField SDL_AssertData "trigger_count" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertData "trigger_count" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "trigger_count" = CUInt

Methods

offset# :: Proxy# SDL_AssertData -> Proxy# "trigger_count" -> Int #

ty ~ CBool => HasField "always_ignore" SDL_AssertData ty Source #

true if app should always continue when assertion is triggered.

C declaration
always_ignore, defined at SDL3/SDL_assert.h 339:10
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ PtrConst CChar => HasField "condition" SDL_AssertData ty Source #

A string of this assert's test code.

C declaration
condition, defined at SDL3/SDL_assert.h 341:17
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ PtrConst CChar => HasField "filename" SDL_AssertData ty Source #

The source file where this assert lives.

C declaration
filename, defined at SDL3/SDL_assert.h 342:17
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ PtrConst CChar => HasField "function" SDL_AssertData ty Source #

The name of the function where this assert lives.

C declaration
function, defined at SDL3/SDL_assert.h 344:17
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ CInt => HasField "linenum" SDL_AssertData ty Source #

The line in filename where this assert lives.

C declaration
linenum, defined at SDL3/SDL_assert.h 343:9
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ PtrConst SDL_AssertData => HasField "next" SDL_AssertData ty Source #

next item in the linked list.

C declaration
next, defined at SDL3/SDL_assert.h 345:34
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ CUInt => HasField "trigger_count" SDL_AssertData ty Source #

Number of times this assertion has been triggered.

C declaration
trigger_count, defined at SDL3/SDL_assert.h 340:18
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

hasField :: SDL_AssertData -> (ty -> SDL_AssertData, ty) #

ty ~ CBool => HasField "always_ignore" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

ty ~ PtrConst CChar => HasField "condition" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

ty ~ PtrConst CChar => HasField "filename" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

ty ~ PtrConst CChar => HasField "function" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

ty ~ CInt => HasField "linenum" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

ty ~ PtrConst SDL_AssertData => HasField "next" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

ty ~ CUInt => HasField "trigger_count" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

getField :: Ptr SDL_AssertData -> Ptr ty #

type Rep SDL_AssertData Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "always_ignore" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "always_ignore" = CBool
type CFieldType SDL_AssertData "condition" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "filename" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "function" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "linenum" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "linenum" = CInt
type CFieldType SDL_AssertData "next" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "trigger_count" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertData "trigger_count" = CUInt

newtype SDL_AssertionHandler_Aux Source #

Auxiliary type used by SDL_AssertionHandler

C declaration
SDL_AssertionHandler, defined at SDL3/SDL_assert.h 578:35

Instances

Instances details
Generic SDL_AssertionHandler_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type Rep SDL_AssertionHandler_Aux 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertionHandler_Aux = D1 ('MetaData "SDL_AssertionHandler_Aux" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_AssertionHandler_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState))))
FromFunPtr SDL_AssertionHandler_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ToFunPtr SDL_AssertionHandler_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

HasCField SDL_AssertionHandler_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ty ~ (PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState) => HasField "unwrap" SDL_AssertionHandler_Aux ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ty ~ (PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState) => HasField "unwrap" (Ptr SDL_AssertionHandler_Aux) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertionHandler_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertionHandler_Aux = D1 ('MetaData "SDL_AssertionHandler_Aux" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_AssertionHandler_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState))))
type CFieldType SDL_AssertionHandler_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

newtype SDL_AssertionHandler Source #

A callback that fires when an SDL assertion fails.

data
a pointer to the SDL_AssertData structure corresponding to the current assertion.
userdata
what was passed as userdata to SDL_SetAssertionHandler().
Returns
an SDL_AssertState value indicating how to handle the failure.
Thread safety
This callback may be called from any thread that triggers an assert at any time.
C declaration
SDL_AssertionHandler, defined at SDL3/SDL_assert.h 578:35

Since: 3.2.0

Instances

Instances details
Storable SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Generic SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type Rep SDL_AssertionHandler 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertionHandler = D1 ('MetaData "SDL_AssertionHandler" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_AssertionHandler" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_AssertionHandler_Aux))))
Show SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Eq SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Ord SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

HasFFIType SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ReadRaw SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

StaticSize SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

WriteRaw SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

HasCField SDL_AssertionHandler "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Associated Types

type CFieldType SDL_AssertionHandler "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

Methods

offset# :: Proxy# SDL_AssertionHandler -> Proxy# "unwrap" -> Int #

ty ~ FunPtr SDL_AssertionHandler_Aux => HasField "unwrap" SDL_AssertionHandler ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

ty ~ FunPtr SDL_AssertionHandler_Aux => HasField "unwrap" (Ptr SDL_AssertionHandler) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type Rep SDL_AssertionHandler = D1 ('MetaData "SDL_AssertionHandler" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_AssertionHandler" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_AssertionHandler_Aux))))
type FFIType SDL_AssertionHandler Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert

type CFieldType SDL_AssertionHandler "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Assert