| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
sizeofoperator, 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
- sDL_ASSERT_LEVEL :: CInt
- sDL_NULL_WHILE_LOOP_CONDITION :: CInt
- newtype SDL_AssertState = SDL_AssertState {}
- pattern SDL_ASSERTION_RETRY :: SDL_AssertState
- pattern SDL_ASSERTION_BREAK :: SDL_AssertState
- pattern SDL_ASSERTION_ABORT :: SDL_AssertState
- pattern SDL_ASSERTION_IGNORE :: SDL_AssertState
- pattern SDL_ASSERTION_ALWAYS_IGNORE :: SDL_AssertState
- data SDL_AssertData = SDL_AssertData {}
- newtype SDL_AssertionHandler_Aux = SDL_AssertionHandler_Aux {
- unwrap :: PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState
- newtype SDL_AssertionHandler = SDL_AssertionHandler {}
Documentation
sDL_ASSERT_LEVEL :: CInt Source #
- C declaration
macro SDL_ASSERT_LEVEL, defined atSDL3/SDL_assert.h 101:9
sDL_NULL_WHILE_LOOP_CONDITION :: CInt Source #
- C declaration
macro SDL_NULL_WHILE_LOOP_CONDITION, defined atSDL3/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 atSDL3/SDL_assert.h 319:14
Since: 3.2.0
Constructors
| SDL_AssertState | |
Instances
pattern SDL_ASSERTION_RETRY :: SDL_AssertState Source #
Retry the assert immediately.
- C declaration
SDL_ASSERTION_RETRY, defined atSDL3/SDL_assert.h 321:5
pattern SDL_ASSERTION_BREAK :: SDL_AssertState Source #
Make the debugger trigger a breakpoint.
- C declaration
SDL_ASSERTION_BREAK, defined atSDL3/SDL_assert.h 322:5
pattern SDL_ASSERTION_ABORT :: SDL_AssertState Source #
Terminate the program.
- C declaration
SDL_ASSERTION_ABORT, defined atSDL3/SDL_assert.h 323:5
pattern SDL_ASSERTION_IGNORE :: SDL_AssertState Source #
Ignore the assert.
- C declaration
SDL_ASSERTION_IGNORE, defined atSDL3/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 atSDL3/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 atSDL3/SDL_assert.h 337:16
Since: 3.2.0
Constructors
| SDL_AssertData | |
Fields
| |
Instances
| Storable SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods sizeOf :: SDL_AssertData -> Int # alignment :: SDL_AssertData -> Int # peekElemOff :: Ptr SDL_AssertData -> Int -> IO SDL_AssertData # pokeElemOff :: Ptr SDL_AssertData -> Int -> SDL_AssertData -> IO () # peekByteOff :: Ptr b -> Int -> IO SDL_AssertData # pokeByteOff :: Ptr b -> Int -> SDL_AssertData -> IO () # peek :: Ptr SDL_AssertData -> IO SDL_AssertData # poke :: Ptr SDL_AssertData -> SDL_AssertData -> IO () # | |||||
| Generic SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
Methods from :: SDL_AssertData -> Rep SDL_AssertData x # to :: Rep SDL_AssertData x -> SDL_AssertData # | |||||
| Show SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods showsPrec :: Int -> SDL_AssertData -> ShowS # show :: SDL_AssertData -> String # showList :: [SDL_AssertData] -> ShowS # | |||||
| Eq SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods (==) :: SDL_AssertData -> SDL_AssertData -> Bool # (/=) :: SDL_AssertData -> SDL_AssertData -> Bool # | |||||
| ReadRaw SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods readRaw :: Ptr SDL_AssertData -> IO SDL_AssertData # | |||||
| StaticSize SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods staticSizeOf :: Proxy SDL_AssertData -> Int # staticAlignment :: Proxy SDL_AssertData -> Int # | |||||
| WriteRaw SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods writeRaw :: Ptr SDL_AssertData -> SDL_AssertData -> IO () # | |||||
| IsStruct SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods zero :: SDL_AssertData # | |||||
| HasCField SDL_AssertData "always_ignore" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| HasCField SDL_AssertData "condition" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| HasCField SDL_AssertData "filename" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| HasCField SDL_AssertData "function" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| HasCField SDL_AssertData "linenum" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| HasCField SDL_AssertData "next" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| HasCField SDL_AssertData "trigger_count" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| ty ~ CBool => HasField "always_ignore" SDL_AssertData ty Source # | true if app should always continue when assertion is triggered.
| ||||
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.
| ||||
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.
| ||||
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.
| ||||
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
| ||||
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.
| ||||
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.
| ||||
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 # | |||||
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 # | |||||
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 # | |||||
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 # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods getField :: Ptr SDL_AssertData -> Ptr ty # | |||||
| ty ~ CInt => HasField "linenum" (Ptr SDL_AssertData) (Ptr ty :: Type) Source # | |||||
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 # | |||||
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 # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods getField :: Ptr SDL_AssertData -> Ptr ty # | |||||
| type Rep SDL_AssertData Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert type Rep SDL_AssertData = D1 ('MetaData "SDL_AssertData" "SDL3.Sys.Bindgen.Assert" "sdl3-bindgen-sys-0.0.1.0-inplace" 'False) (C1 ('MetaCons "SDL_AssertData" 'PrefixI 'True) ((S1 ('MetaSel ('Just "always_ignore") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CBool) :*: (S1 ('MetaSel ('Just "trigger_count") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CUInt) :*: S1 ('MetaSel ('Just "condition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PtrConst CChar)))) :*: ((S1 ('MetaSel ('Just "filename") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PtrConst CChar)) :*: S1 ('MetaSel ('Just "linenum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CInt)) :*: (S1 ('MetaSel ('Just "function") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PtrConst CChar)) :*: S1 ('MetaSel ('Just "next") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PtrConst SDL_AssertData)))))) | |||||
| type CFieldType SDL_AssertData "always_ignore" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertData "condition" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertData "filename" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertData "function" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertData "linenum" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertData "next" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertData "trigger_count" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
newtype SDL_AssertionHandler_Aux Source #
Auxiliary type used by SDL_AssertionHandler
- C declaration
SDL_AssertionHandler, defined atSDL3/SDL_assert.h 578:35
Constructors
| SDL_AssertionHandler_Aux | |
Fields
| |
Instances
| Generic SDL_AssertionHandler_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
Methods from :: SDL_AssertionHandler_Aux -> Rep SDL_AssertionHandler_Aux x # to :: Rep SDL_AssertionHandler_Aux x -> SDL_AssertionHandler_Aux # | |||||
| FromFunPtr SDL_AssertionHandler_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods fromFunPtr :: FunPtr SDL_AssertionHandler_Aux -> SDL_AssertionHandler_Aux # | |||||
| ToFunPtr SDL_AssertionHandler_Aux Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods toFunPtr :: SDL_AssertionHandler_Aux -> IO (FunPtr SDL_AssertionHandler_Aux) # | |||||
| HasCField SDL_AssertionHandler_Aux "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| ty ~ (PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState) => HasField "unwrap" SDL_AssertionHandler_Aux ty Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods hasField :: SDL_AssertionHandler_Aux -> (ty -> SDL_AssertionHandler_Aux, ty) # | |||||
| ty ~ (PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState) => HasField "unwrap" (Ptr SDL_AssertionHandler_Aux) (Ptr ty :: Type) Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods getField :: Ptr SDL_AssertionHandler_Aux -> Ptr ty # | |||||
| type Rep SDL_AssertionHandler_Aux Source # | |||||
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 # | |||||
Defined in SDL3.Sys.Bindgen.Assert type CFieldType SDL_AssertionHandler_Aux "unwrap" = PtrConst SDL_AssertData -> Ptr Void -> IO SDL_AssertState | |||||
newtype SDL_AssertionHandler Source #
A callback that fires when an SDL assertion fails.
data- a pointer to the
SDL_AssertDatastructure corresponding to the current assertion. userdata- what was passed as
userdatatoSDL_SetAssertionHandler(). - Returns
- an
SDL_AssertStatevalue 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 atSDL3/SDL_assert.h 578:35
Since: 3.2.0
Constructors
| SDL_AssertionHandler | |
Fields | |
Instances
| Storable SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods sizeOf :: SDL_AssertionHandler -> Int # alignment :: SDL_AssertionHandler -> Int # peekElemOff :: Ptr SDL_AssertionHandler -> Int -> IO SDL_AssertionHandler # pokeElemOff :: Ptr SDL_AssertionHandler -> Int -> SDL_AssertionHandler -> IO () # peekByteOff :: Ptr b -> Int -> IO SDL_AssertionHandler # pokeByteOff :: Ptr b -> Int -> SDL_AssertionHandler -> IO () # peek :: Ptr SDL_AssertionHandler -> IO SDL_AssertionHandler # poke :: Ptr SDL_AssertionHandler -> SDL_AssertionHandler -> IO () # | |||||
| Generic SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
Methods from :: SDL_AssertionHandler -> Rep SDL_AssertionHandler x # to :: Rep SDL_AssertionHandler x -> SDL_AssertionHandler # | |||||
| Show SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods showsPrec :: Int -> SDL_AssertionHandler -> ShowS # show :: SDL_AssertionHandler -> String # showList :: [SDL_AssertionHandler] -> ShowS # | |||||
| Eq SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods (==) :: SDL_AssertionHandler -> SDL_AssertionHandler -> Bool # (/=) :: SDL_AssertionHandler -> SDL_AssertionHandler -> Bool # | |||||
| Ord SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods compare :: SDL_AssertionHandler -> SDL_AssertionHandler -> Ordering # (<) :: SDL_AssertionHandler -> SDL_AssertionHandler -> Bool # (<=) :: SDL_AssertionHandler -> SDL_AssertionHandler -> Bool # (>) :: SDL_AssertionHandler -> SDL_AssertionHandler -> Bool # (>=) :: SDL_AssertionHandler -> SDL_AssertionHandler -> Bool # max :: SDL_AssertionHandler -> SDL_AssertionHandler -> SDL_AssertionHandler # min :: SDL_AssertionHandler -> SDL_AssertionHandler -> SDL_AssertionHandler # | |||||
| HasFFIType SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| ReadRaw SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods readRaw :: Ptr SDL_AssertionHandler -> IO SDL_AssertionHandler # | |||||
| StaticSize SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods | |||||
| WriteRaw SDL_AssertionHandler Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods writeRaw :: Ptr SDL_AssertionHandler -> SDL_AssertionHandler -> IO () # | |||||
| HasCField SDL_AssertionHandler "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Associated Types
| |||||
| ty ~ FunPtr SDL_AssertionHandler_Aux => HasField "unwrap" SDL_AssertionHandler ty Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods hasField :: SDL_AssertionHandler -> (ty -> SDL_AssertionHandler, ty) # | |||||
| ty ~ FunPtr SDL_AssertionHandler_Aux => HasField "unwrap" (Ptr SDL_AssertionHandler) (Ptr ty :: Type) Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert Methods getField :: Ptr SDL_AssertionHandler -> Ptr ty # | |||||
| type Rep SDL_AssertionHandler Source # | |||||
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 # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||
| type CFieldType SDL_AssertionHandler "unwrap" Source # | |||||
Defined in SDL3.Sys.Bindgen.Assert | |||||