mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
feat(debug): add basic debug functions
This commit is contained in:
parent
3728c3d167
commit
d817c41985
4 changed files with 61 additions and 0 deletions
11
bc/Debug.cpp
Normal file
11
bc/Debug.cpp
Normal file
|
|
@ -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;
|
||||
}
|
||||
29
bc/Debug.hpp
Normal file
29
bc/Debug.hpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef BC_DEBUG_HPP
|
||||
#define BC_DEBUG_HPP
|
||||
|
||||
#include "bc/System_Debug.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
#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
|
||||
3
bc/System_Debug.cpp
Normal file
3
bc/System_Debug.cpp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include "bc/System_Debug.hpp"
|
||||
|
||||
Blizzard::System_Debug::AssertCallback Blizzard::System_Debug::s_assertCallback;
|
||||
18
bc/System_Debug.hpp
Normal file
18
bc/System_Debug.hpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef BC_SYSTEM_DEBUG_HPP
|
||||
#define BC_SYSTEM_DEBUG_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue