mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added configurable assert handler function.
This commit is contained in:
@@ -113,6 +113,32 @@ namespace bx
|
||||
/// Unknown source code location.
|
||||
static constexpr LocationFull kUnknownLocationFull("Unknown?", "Unknown?", 0);
|
||||
|
||||
/// Assert handler function.
|
||||
///
|
||||
/// @param[in] _location Source code location where function is called.
|
||||
/// @param[in] _format Printf style format.
|
||||
/// @param[in] ... Arguments for `_format` specification.
|
||||
///
|
||||
/// @returns True if assert should stop code execution, otherwise returns false.
|
||||
///
|
||||
typedef bool (*AssertHandlerFn)(const Location& _location, const char* _format, va_list _argList);
|
||||
|
||||
/// Set assert handler function.
|
||||
///
|
||||
/// @param[in] _assertHandlerFn Pointer to AssertHandlerFn function.
|
||||
///
|
||||
void setAssertHandler(AssertHandlerFn _assertHandlerFn);
|
||||
|
||||
/// Assert function calls AssertHandlerFn.
|
||||
///
|
||||
/// @param[in] _location Source code location where function is called.
|
||||
/// @param[in] _format Printf style format.
|
||||
/// @param[in] ... Arguments for `_format` specification.
|
||||
///
|
||||
/// @returns True if assert should stop code execution, otherwise returns false.
|
||||
///
|
||||
bool assertFunction(const Location& _location, const char* _format, ...);
|
||||
|
||||
/// Arithmetic type `Ty` limits.
|
||||
template<typename Ty, bool SignT = isSigned<Ty>()>
|
||||
struct LimitsT;
|
||||
|
||||
@@ -302,22 +302,22 @@
|
||||
} \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_ASSERT(_condition, _format, ...) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) ) \
|
||||
{ \
|
||||
BX_TRACE("ASSERT " _format, ##__VA_ARGS__); \
|
||||
bx::debugBreak(); \
|
||||
} \
|
||||
#define _BX_ASSERT(_condition, _format, ...) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) \
|
||||
&& bx::assertFunction(bx::Location::current(), "ASSERT " #_condition " -> " _format, ##__VA_ARGS__) ) \
|
||||
{ \
|
||||
bx::debugBreak(); \
|
||||
} \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_ASSERT_LOC(_location, _condition, _format, ...) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) ) \
|
||||
{ \
|
||||
_BX_TRACE_LOC(_location, "ASSERT " _format, ##__VA_ARGS__); \
|
||||
bx::debugBreak(); \
|
||||
} \
|
||||
#define _BX_ASSERT_LOC(_location, _condition, _format, ...) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) \
|
||||
&& bx::assertFunction(_location, "ASSERT " #_condition " -> " _format, ##__VA_ARGS__) ) \
|
||||
{ \
|
||||
bx::debugBreak(); \
|
||||
} \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_WARN_LOC(_location, _condition, _format, ...) \
|
||||
|
||||
Reference in New Issue
Block a user