refactor(framework): move debug utils to their own namespace

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2026-01-15 20:16:57 -05:00
parent b6df1547e2
commit a51bd5fc33
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
4 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#include "include/public/toon_boom/ext/util.hpp" #include "include/public/toon_boom/ext/util.hpp"
namespace util::debug {
std::ostream devnull(new NullBuffer()); std::ostream devnull(new NullBuffer());
std::ostream& out = TB_EXT_FRAMEWORK_DEBUG ? std::cout : devnull; std::ostream& out = TB_EXT_FRAMEWORK_DEBUG ? std::cout : devnull;
}

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "../PLUG_Services.hpp" #include "../PLUG_Services.hpp"
#include "../toon_boom_layout.hpp" #include "../toon_boom_layout.hpp"
#include "./util.hpp"
#include "QtXml/qdom.h" #include "QtXml/qdom.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QPointer> #include <QtCore/QPointer>
@ -9,6 +10,7 @@
#include <iostream> #include <iostream>
#include <type_traits> #include <type_traits>
using namespace util;
template <typename T> template <typename T>
concept isQWidget = std::is_base_of<QWidget, T>::value; concept isQWidget = std::is_base_of<QWidget, T>::value;
@ -100,7 +102,7 @@ protected:
QObject::connect( QObject::connect(
parent, &QObject::destroyed, m_widget.data(), parent, &QObject::destroyed, m_widget.data(),
[this]() { [this]() {
std::cout << "[parent destroyed] Unparenting widget to prevent " debug::out << "[parent destroyed] Unparenting widget to prevent "
"cross-DLL heap deletion" "cross-DLL heap deletion"
<< std::endl; << std::endl;
if (m_widget) { if (m_widget) {
@ -123,10 +125,10 @@ protected:
if (am) { if (am) {
QList<QString> ids; QList<QString> ids;
am->loadToolbars(element, ids); am->loadToolbars(element, ids);
std::cout << "Registered toolbar with AC_Manager. IDs loaded: " debug::out << "Registered toolbar with AC_Manager. IDs loaded: "
<< ids.size() << std::endl; << ids.size() << std::endl;
for (const auto &id : ids) { for (const auto &id : ids) {
std::cout << " - " << id.toStdString() << std::endl; debug::out << " - " << id.toStdString() << std::endl;
} }
} else { } else {
std::cerr << "Could not get AC_Manager!" << std::endl; std::cerr << "Could not get AC_Manager!" << std::endl;

View File

@ -7,6 +7,8 @@
#if !defined(TB_EXT_FRAMEWORK_DEBUG) #if !defined(TB_EXT_FRAMEWORK_DEBUG)
#define TB_EXT_FRAMEWORK_DEBUG 0 #define TB_EXT_FRAMEWORK_DEBUG 0
#endif #endif
namespace util::debug {
struct NullBuffer : std::streambuf { struct NullBuffer : std::streambuf {
int overflow(int c) { return c; } int overflow(int c) { return c; }
}; };
@ -16,3 +18,4 @@ std::string addrToHex(void *addr);
std::string constAddrToHex(const void *addr); std::string constAddrToHex(const void *addr);
extern std::ostream &out; extern std::ostream &out;
} // namespace util::debug

View File

@ -1,5 +1,6 @@
#include "include/public/toon_boom/ext/util.hpp" #include "include/public/toon_boom/ext/util.hpp"
namespace util::debug {
std::string addrToHex(void* addr) { std::string addrToHex(void* addr) {
return std::format("0x{:010X}", reinterpret_cast<uintptr_t>(addr)); return std::format("0x{:010X}", reinterpret_cast<uintptr_t>(addr));
} }
@ -7,3 +8,4 @@ std::string addrToHex(void* addr) {
std::string constAddrToHex(const void* addr) { std::string constAddrToHex(const void* addr) {
return std::format("0x{:010X}", reinterpret_cast<const uintptr_t>(addr)); return std::format("0x{:010X}", reinterpret_cast<const uintptr_t>(addr));
} }
} // namespace util::debug