Add parameter support to assert, remove broken std::string support from Log
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
#define CORE_H
|
#define CORE_H
|
||||||
|
|
||||||
#include <csignal> // raise
|
#include <csignal> // raise
|
||||||
|
#include <cstdio> // sprintf
|
||||||
|
#include <cstring> // strlen
|
||||||
#include <functional> // std::bind
|
#include <functional> // std::bind
|
||||||
|
|
||||||
#define BIT(x) (1 << x)
|
#define BIT(x) (1 << x)
|
||||||
@@ -22,8 +24,14 @@
|
|||||||
#define ABORT_SIGNAL SIGABRT
|
#define ABORT_SIGNAL SIGABRT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NF_ASSERT(x, y) if(!(x)) { NF_DANGER("Assert: {%s}, %s", #x, y); raise(ABORT_SIGNAL); }
|
#define NF_ASSERT(x, y, ...) if(!(x)) { \
|
||||||
#define NF_CORE_ASSERT(x, y) if(!(x)) { NF_CORE_DANGER("Assert: {%s}, %s", #x, y); raise(ABORT_SIGNAL); }
|
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
|
#else
|
||||||
#define NF_ASSERT(x, y)
|
#define NF_ASSERT(x, y)
|
||||||
#define NF_CORE_ASSERT(x, y)
|
#define NF_CORE_ASSERT(x, y)
|
||||||
|
|||||||
@@ -38,37 +38,31 @@ namespace Inferno {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...A>
|
template<typename ...A>
|
||||||
void print(const char* color, std::string format, A... arguments)
|
void log(const char* format, A... arguments)
|
||||||
{
|
|
||||||
this->print(color, format.c_str(), arguments...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename ...A>
|
|
||||||
void log(T format, A... arguments)
|
|
||||||
{
|
{
|
||||||
this->print("", format, arguments...);
|
this->print("", format, arguments...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename ...A>
|
template<typename ...A>
|
||||||
void info(T format, A... arguments)
|
void info(const char* format, A... arguments)
|
||||||
{
|
{
|
||||||
this->print("\x1B[34m", format, arguments...);
|
this->print("\x1B[34m", format, arguments...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename ...A>
|
template<typename ...A>
|
||||||
void warn(T format, A... arguments)
|
void warn(const char* format, A... arguments)
|
||||||
{
|
{
|
||||||
this->print("\x1B[33m", format, arguments...);
|
this->print("\x1B[33m", format, arguments...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename ...A>
|
template<typename ...A>
|
||||||
void danger(T format, A... arguments)
|
void danger(const char* format, A... arguments)
|
||||||
{
|
{
|
||||||
this->print("\x1B[31m", format, arguments...);
|
this->print("\x1B[31m", format, arguments...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename ...A>
|
template<typename ...A>
|
||||||
void success(T format, A... arguments)
|
void success(const char* format, A... arguments)
|
||||||
{
|
{
|
||||||
this->print("\x1B[32m", format, arguments...);
|
this->print("\x1B[32m", format, arguments...);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user