diff --git a/bc/Debug.cpp b/bc/Debug.cpp new file mode 100644 index 0000000..e120a81 --- /dev/null +++ b/bc/Debug.cpp @@ -0,0 +1,11 @@ +#include "bc/Debug.hpp" + +void Blizzard::Debug::Assert(const char* a1, const char* a2, uint32_t a3) { + if (System_Debug::s_assertCallback) { + System_Debug::s_assertCallback(a1, "", a2, a3); + } +} + +void Blizzard::Debug::SetAssertHandler(Blizzard::System_Debug::AssertCallback callback) { + System_Debug::s_assertCallback = callback; +} diff --git a/bc/Debug.hpp b/bc/Debug.hpp new file mode 100644 index 0000000..f88e04c --- /dev/null +++ b/bc/Debug.hpp @@ -0,0 +1,29 @@ +#ifndef BC_DEBUG_HPP +#define BC_DEBUG_HPP + +#include "bc/System_Debug.hpp" +#include + +#if defined(NDEBUG) +#define BLIZZARD_ASSERT(x) \ + if (!(x)) { \ + return 0; \ + } +#else +#define BLIZZARD_ASSERT(x) \ + if (!(x)) { \ + Blizzard::Debug::Assert(#x, __FILE__, __LINE__); \ + } +#endif + +namespace Blizzard { +namespace Debug { + +// Functions +void Assert(const char* a1, const char* a2, uint32_t a3); +void SetAssertHandler(Blizzard::System_Debug::AssertCallback callback); + +} // namespace Debug +} // namespace Blizzard + +#endif diff --git a/bc/System_Debug.cpp b/bc/System_Debug.cpp new file mode 100644 index 0000000..485c453 --- /dev/null +++ b/bc/System_Debug.cpp @@ -0,0 +1,3 @@ +#include "bc/System_Debug.hpp" + +Blizzard::System_Debug::AssertCallback Blizzard::System_Debug::s_assertCallback; diff --git a/bc/System_Debug.hpp b/bc/System_Debug.hpp new file mode 100644 index 0000000..1a0e5a0 --- /dev/null +++ b/bc/System_Debug.hpp @@ -0,0 +1,18 @@ +#ifndef BC_SYSTEM_DEBUG_HPP +#define BC_SYSTEM_DEBUG_HPP + +#include + +namespace Blizzard { +namespace System_Debug { + +// Types +typedef void (*AssertCallback)(const char*, const char*, const char*, uint32_t); + +// Variables +extern AssertCallback s_assertCallback; + +} // namespace System_Debug +} // namespace Blizzard + +#endif