Also added a pretty much untested and totally incomplete STL string type.

This commit is contained in:
2024-01-12 01:31:43 +01:00
parent ff3214fa5a
commit 219a48c616
21 changed files with 138 additions and 12 deletions

50
bastl/include/exception Normal file
View File

@@ -0,0 +1,50 @@
#if !defined(BAD_APPLE_OS_EXCEPTION_INCLUDED)
#define BAD_APPLE_OS_EXCEPTION_INCLUDED
#include <cstdlib>
#include "os/panic.hpp"
#if defined(__cpp_exceptions)
#define __ba_throw throw
#else
#define __ba_throw ba::impl::gAbortHelper(__FILE__, __LINE__) =
#endif
namespace std
{
class exception
{
public:
virtual ~exception() noexcept = default;
virtual const char* what() const noexcept;
};
}
#if !defined(__cpp_exceptions)
namespace ba::impl
{
struct ExceptionAbortHelper
{
private:
const char* mFile = "<unknown>";
int mLine = -1;
public:
[[noreturn]] ExceptionAbortHelper& operator=(const std::exception& ex) noexcept
{
panicf("Uncaught exception with message \"%s\" at %s:%d.", ex.what(), mFile, mLine);
}
ExceptionAbortHelper& operator()(const char* file, int line) noexcept
{
mFile = file;
mLine = line;
return *this;
}
};
extern ExceptionAbortHelper gAbortHelper;
}
#endif // !defined(__cpp_exceptions)
#endif // !defined(BAD_APPLE_OS_EXCEPTION_INCLUDED)