Brett 2024-08-09 23:38:25 -04:00
parent 941aedb510
commit 99e735b760
2 changed files with 29 additions and 10 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 0.18.26) set(BLT_VERSION 0.18.27)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -11,12 +11,20 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include <exception> #include <exception>
#include <cstring>
struct abort_exception : public std::exception struct abort_exception : public std::exception
{ {
public: public:
explicit abort_exception(const char* error): error(error) explicit abort_exception(const char* what)
{} {
auto len = std::strlen(what) + 1;
error = static_cast<char*>(std::malloc(len));
std::memcpy(static_cast<char*>(error), what, len);
}
abort_exception(const abort_exception& copy) = delete;
abort_exception& operator=(const abort_exception& copy) = delete;
[[nodiscard]] const char* what() const noexcept override [[nodiscard]] const char* what() const noexcept override
{ {
@ -25,14 +33,20 @@ struct abort_exception : public std::exception
return error; return error;
} }
~abort_exception() override
{
std::free(static_cast<void*>(error));
}
private: private:
const char* error{nullptr}; char* error{nullptr};
}; };
#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
#include <execinfo.h> #include <execinfo.h>
#include <cstdlib> #include <cstdlib>
#endif #endif
#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
@ -47,16 +61,20 @@ struct abort_exception : public std::exception
#define BLT_FREE_STACK_TRACE() void(); #define BLT_FREE_STACK_TRACE() void();
#endif #endif
namespace blt { namespace blt
{
#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
static inline std::string _macro_filename(const std::string& path){
static inline std::string _macro_filename(const std::string& path)
{
auto paths = blt::string::split(path, "/"); auto paths = blt::string::split(path, "/");
auto final = paths[paths.size()-1]; auto final = paths[paths.size() - 1];
if (final == "/") if (final == "/")
return paths[paths.size()-2]; return paths[paths.size() - 2];
return final; return final;
} }
#endif #endif
void b_throw(const char* what, const char* path, int line) void b_throw(const char* what, const char* path, int line)
@ -105,7 +123,8 @@ namespace blt {
if (messages == nullptr) if (messages == nullptr)
return; return;
#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
for (int i = 1; i < size; i++){ for (int i = 1; i < size; i++)
{
int tabs = i - 1; int tabs = i - 1;
std::string buffer; std::string buffer;
for (int j = 0; j < tabs; j++) for (int j = 0; j < tabs; j++)