From 8613ae8b81ac0763abfb63d9f32bf981a5414742 Mon Sep 17 00:00:00 2001 From: anulax1225 Date: Fri, 19 Jan 2024 13:34:19 +0100 Subject: [PATCH] Added assertion file --- bakara/src/bakara/core/assert.h | 22 ++++++++++++++++++++++ bakara/src/bakara/core/base.h | 18 ------------------ 2 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 bakara/src/bakara/core/assert.h diff --git a/bakara/src/bakara/core/assert.h b/bakara/src/bakara/core/assert.h new file mode 100644 index 0000000..ce0cf7e --- /dev/null +++ b/bakara/src/bakara/core/assert.h @@ -0,0 +1,22 @@ +#pragma once + +#include "base.h" +#include "string_fmt.h" + +#ifdef BK_ENABLE_ASSERT + #define BK_CORE_VA_MSG_ASSERT(check, msg, ...) if(!(check)) { BK_CORE_ERROR(Bk::format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_DEBUGBREAK(); } + #define BK_CORE_MSG_ASSERT(check, msg) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_DEBUGBREAK(); } + #define BK_CORE_ASSERT(check) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); } + + #define BK_VA_MSG_ASSERT(check, msg, ...) if(!(check)) { BK_ERROR(Bk::format("Assertion [%s] failed at %s:%d\n\tError : %s", BK_STRINGIFY(check), __FILE__, __LINE__, msg), __VA_ARGS__); BK_DEBUGBREAK(); } + #define BK_MSG_ASSERT(check, msg) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}\n\tError : {3}", BK_STRINGIFY(check), __FILE__, __LINE__, msg); BK_DEBUGBREAK(); } + #define BK_ASSERT(check) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); } +#else + #define BK_CORE_MSG_ASSERT(check, msg, ...) + #define BK_CORE_IMP_ASSERT(check, msg) + #define BK_CORE_ASSERT(check) + + #define BK_MSG_ASSERT(check, msg, ...) + #define BK_IMP_ASSERT(check, msg) + #define BK_ASSERT(check) +#endif \ No newline at end of file diff --git a/bakara/src/bakara/core/base.h b/bakara/src/bakara/core/base.h index 55651d8..e24c4f9 100644 --- a/bakara/src/bakara/core/base.h +++ b/bakara/src/bakara/core/base.h @@ -21,22 +21,4 @@ #define BK_DEBUGBREAK() #endif -#ifdef BK_ENABLE_ASSERT - #define BK_CORE_MSG_ASSERT(check, msg, ...) if(!(check)) { BK_CORE_ERROR(msg, __VA_ARGS__); BK_DEBUGBREAK(); } - #define BK_CORE_IMP_ASSERT(check, msg) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed : {1}", BK_STRINGIFY(check), msg); BK_DEBUGBREAK(); } - #define BK_CORE_ASSERT(check) if(!(check)) { BK_CORE_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); } - - #define BK_MSG_ASSERT(check, msg, ...) if(!(check)) { BK_ERROR(msg, __VA_ARGS__); BK_DEBUGBREAK(); } - #define BK_IMP_ASSERT(check, msg) if(!(check)) { BK_ERROR("Assertion [{0}] failed : {1}", BK_STRINGIFY(check), msg); BK_DEBUGBREAK(); } - #define BK_ASSERT(check) if(!(check)) { BK_ERROR("Assertion [{0}] failed at {1}:{2}", BK_STRINGIFY(check), __FILE__, __LINE__); BK_DEBUGBREAK(); } -#else - #define BK_CORE_MSG_ASSERT(check, msg, ...) - #define BK_CORE_IMP_ASSERT(check, msg) - #define BK_CORE_ASSERT(check) - - #define BK_MSG_ASSERT(check, msg, ...) - #define BK_IMP_ASSERT(check, msg) - #define BK_ASSERT(check) -#endif -