From 8a5dc4aef955d0c2bdaf42fb541d9ee928d175ed Mon Sep 17 00:00:00 2001 From: Rick van Vonderen <0945444@hr.nl> Date: Thu, 19 Dec 2019 22:49:50 +0100 Subject: [PATCH] Add parameter support to assert, remove broken std::string support from Log --- inferno/src/inferno/core.h | 12 ++++++++++-- inferno/src/inferno/log.h | 24 +++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/inferno/src/inferno/core.h b/inferno/src/inferno/core.h index f461726..5b117a3 100644 --- a/inferno/src/inferno/core.h +++ b/inferno/src/inferno/core.h @@ -2,6 +2,8 @@ #define CORE_H #include // raise +#include // sprintf +#include // strlen #include // std::bind #define BIT(x) (1 << x) @@ -22,8 +24,14 @@ #define ABORT_SIGNAL SIGABRT #endif - #define NF_ASSERT(x, y) if(!(x)) { NF_DANGER("Assert: {%s}, %s", #x, y); raise(ABORT_SIGNAL); } - #define NF_CORE_ASSERT(x, y) if(!(x)) { NF_CORE_DANGER("Assert: {%s}, %s", #x, y); raise(ABORT_SIGNAL); } + #define NF_ASSERT(x, y, ...) if(!(x)) { \ + char buffer[15 + strlen(y)]; \ + sprintf(buffer, "Assert: {%%s}, %s", y); \ + NF_DANGER(buffer, #x, ##__VA_ARGS__); raise(ABORT_SIGNAL); } + #define NF_CORE_ASSERT(x, y, ...) if(!(x)) { \ + char buffer[15 + strlen(y)]; \ + sprintf(buffer, "Assert: {%%s}, %s", y); \ + NF_CORE_DANGER(buffer, #x, ##__VA_ARGS__); raise(ABORT_SIGNAL); } #else #define NF_ASSERT(x, y) #define NF_CORE_ASSERT(x, y) diff --git a/inferno/src/inferno/log.h b/inferno/src/inferno/log.h index ed790ef..dce7f93 100644 --- a/inferno/src/inferno/log.h +++ b/inferno/src/inferno/log.h @@ -38,37 +38,31 @@ namespace Inferno { } template - void print(const char* color, std::string format, A... arguments) - { - this->print(color, format.c_str(), arguments...); - } - - template - void log(T format, A... arguments) + void log(const char* format, A... arguments) { this->print("", format, arguments...); } - template - void info(T format, A... arguments) + template + void info(const char* format, A... arguments) { this->print("\x1B[34m", format, arguments...); } - template - void warn(T format, A... arguments) + template + void warn(const char* format, A... arguments) { this->print("\x1B[33m", format, arguments...); } - template - void danger(T format, A... arguments) + template + void danger(const char* format, A... arguments) { this->print("\x1B[31m", format, arguments...); } - template - void success(T format, A... arguments) + template + void success(const char* format, A... arguments) { this->print("\x1B[32m", format, arguments...); }