Squashed 'deps/nostalgia/' changes from 5f10edd3..0daf938f
0daf938f [nostalgia/core/studio] Cleanup, make all number keys after num colors jump to last b90ab27a [nostalgia/core/studio] Fix Palette Color Name input to properly take focus c711f435 [nostalgia/core/studio] Fix PaletteEditor 0 key shortcut 84cb03d8 [nostalgia/core/studio] Cleanup 945a55f9 [studio] Fix Project to cut off correct end of OC data 2173b12c [nostalgia/core/studio] Give PaletteEditor keyboard shortcuts aa970b1f [keel,studio] Cleanup 6ad79b30 [ox] Cleanup a7cf2673 [studio] Remove null terminator from OC output 1a9f0d49 [ox] Rename CRString to StringCR a1b5b565 [olympic,nostalgia] Rename CRStringView to StringViewCR 256be6da [glutils] Rename CRStringView to StringViewCR cc10631b [ox] Rename CRStringView to StringViewCR 829dc029 [keel] Fix Linux build e8a1ff06 [ox/oc] Fix Linux build bdfb5e97 [nostalgia/core] Cleanup 396fecab [ox/oc] Add option for writeOC to return a string 5373b63c [keel,studio] Removing null terminator from JSON file output 8b655c40 [ox/std] Add HashMap::values 92d85d11 Merge commit '9f5f3e26efed6cd27f2a8ff0746f018d75986934' 118fef61 [buildcore] Remove python -m prefix from mypy command 8769305d [nostalgia] Allow disabling of BUILD_SHARED_LIBS c5999050 [nostalgia] Add support for partial tilesheet loading da23c930 [ox/std] Add oxModelFwdDecl macro for broken Apple Clang 3ae1d6c8 [ox/std] Make operator[] in Array and Vector nodiscard a7af6c66 [keel] Cleanup 0cc6757c [keel] Add manifest to pack output 3b8eaef3 [keel] Move vald and repair funcs to their own file, make conversion to validation b7990ed2 [keel] Make pack file copy logging nest for dir level 71313ed8 [ox/std] Cleanup 10531b6e [keel] Cleanup dfbc298d [keel] Add pack file copy status to logging 76760daf [ox/std] Cleanup Defer 5834b9c9 [ox/std] Cleanup logging output 2a584905 [ox/fs] More cleanup and bug fix from previous cleanup 702b166b [ox/fs] Cleanup 8dd837b3 [nostalgia/core] Add a valid function for CompactTileSheet 1d262597 [keel] Make default repair return a no repair error 712299fa [studio] Cleanup c45efa60 [ox/std] Make Result copyTo and moveTo able to convert git-subtree-dir: deps/nostalgia git-subtree-split: 0daf938f765b3a3ce8ba7fb292572a6a5a004634
This commit is contained in:
4
deps/ox/src/ox/std/array.hpp
vendored
4
deps/ox/src/ox/std/array.hpp
vendored
@@ -41,7 +41,7 @@ class Array {
|
||||
|
||||
constexpr Array(Array &&other) noexcept;
|
||||
|
||||
~Array() = default;
|
||||
constexpr ~Array() = default;
|
||||
|
||||
constexpr iterator<> begin() noexcept {
|
||||
return iterator<>(&m_items[0], 0, ArraySize);
|
||||
@@ -81,8 +81,10 @@ class Array {
|
||||
|
||||
constexpr Array &operator=(Array &&other) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr T &operator[](std::size_t i) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr const T &operator[](std::size_t i) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
|
25
deps/ox/src/ox/std/assert.hpp
vendored
25
deps/ox/src/ox/std/assert.hpp
vendored
@@ -22,9 +22,9 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
void panic(CRStringView file, int line, CRStringView panicMsg, const Error &err = OxError(0)) noexcept;
|
||||
void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = OxError(0)) noexcept;
|
||||
|
||||
constexpr void constexprPanic(CRStringView file, int line, CRStringView panicMsg, const Error &err = OxError(0)) noexcept {
|
||||
constexpr void constexprPanic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = OxError(0)) noexcept {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
panic(file, line, panicMsg, err);
|
||||
} else {
|
||||
@@ -32,12 +32,12 @@ constexpr void constexprPanic(CRStringView file, int line, CRStringView panicMsg
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void assertFunc(CRStringView file, int line, bool pass, [[maybe_unused]]CRStringView assertTxt, [[maybe_unused]]CRStringView msg) noexcept {
|
||||
constexpr void assertFunc(StringViewCR file, int line, bool pass, [[maybe_unused]]StringViewCR assertTxt, [[maybe_unused]]StringViewCR msg) noexcept {
|
||||
if (!pass) {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
#ifdef OX_USE_STDLIB
|
||||
oxErrf("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, msg);
|
||||
printStackTrace(2);
|
||||
auto output = sfmt("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, msg);
|
||||
output += genStackTrace(2);
|
||||
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]", msg, assertTxt, file, line);
|
||||
std::abort();
|
||||
#else
|
||||
@@ -51,19 +51,20 @@ constexpr void assertFunc(CRStringView file, int line, bool pass, [[maybe_unused
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void assertFunc(CRStringView file, int line, const Error &err, CRStringView, CRStringView assertMsg) noexcept {
|
||||
constexpr void assertFunc(StringViewCR file, int line, const Error &err, StringViewCR, StringViewCR assertMsg) noexcept {
|
||||
if (err) {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
#if defined(OX_USE_STDLIB)
|
||||
oxErrf("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, assertMsg);
|
||||
auto msg = sfmt("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, assertMsg);
|
||||
if (err.msg) {
|
||||
oxErrf("\tError Message:\t{}\n", err.msg);
|
||||
msg += sfmt("\tError Message:\t{}\n", err.msg);
|
||||
}
|
||||
oxErrf("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
|
||||
msg += sfmt("\tError Code:\t{}\n", static_cast<ErrorCode>(err));
|
||||
if (err.file != nullptr) {
|
||||
oxErrf("\tError Location:\t{}:{}\n", err.file, err.line);
|
||||
msg += sfmt("\tError Location:\t{}:{}\n", err.file, err.line);
|
||||
}
|
||||
printStackTrace(2);
|
||||
msg += genStackTrace(2);
|
||||
oxErr(msg);
|
||||
oxTracef("assert", "Failed assert: {} [{}:{}]", assertMsg, file, line);
|
||||
std::abort();
|
||||
#else
|
||||
@@ -75,7 +76,7 @@ constexpr void assertFunc(CRStringView file, int line, const Error &err, CRStrin
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void expect(CRStringView file, int line, const auto &actual, const auto &expected) noexcept {
|
||||
constexpr void expect(StringViewCR file, int line, const auto &actual, const auto &expected) noexcept {
|
||||
if (actual != expected) {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
#if defined(OX_USE_STDLIB)
|
||||
|
9
deps/ox/src/ox/std/defer.hpp
vendored
9
deps/ox/src/ox/std/defer.hpp
vendored
@@ -8,8 +8,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "error.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
template<typename T>
|
||||
@@ -18,13 +16,12 @@ class Defer {
|
||||
T m_deferredFunc;
|
||||
|
||||
public:
|
||||
Defer(T deferredFunc) {
|
||||
m_deferredFunc = deferredFunc;
|
||||
constexpr Defer(T deferredFunc) noexcept: m_deferredFunc(deferredFunc) {
|
||||
}
|
||||
|
||||
Defer(const Defer&) = delete;
|
||||
|
||||
~Defer() {
|
||||
constexpr ~Defer() {
|
||||
m_deferredFunc();
|
||||
}
|
||||
|
||||
@@ -34,4 +31,4 @@ class Defer {
|
||||
|
||||
}
|
||||
|
||||
#define oxDefer ox::Defer oxConcat(oxDefer_, __LINE__) = [&]
|
||||
#define oxDefer ox::Defer const oxConcat(oxDefer_, __LINE__) =
|
||||
|
9
deps/ox/src/ox/std/error.hpp
vendored
9
deps/ox/src/ox/std/error.hpp
vendored
@@ -165,21 +165,24 @@ struct [[nodiscard]] Result {
|
||||
return error == 0;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) const& noexcept {
|
||||
template<typename U>
|
||||
constexpr Error copyTo(U &val) const& noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = value;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) && noexcept {
|
||||
template<typename U>
|
||||
constexpr Error copyTo(U &val) && noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = std::move(value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error moveTo(type &val) noexcept {
|
||||
template<typename U>
|
||||
constexpr Error moveTo(U &val) noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = std::move(value);
|
||||
}
|
||||
|
13
deps/ox/src/ox/std/hashmap.hpp
vendored
13
deps/ox/src/ox/std/hashmap.hpp
vendored
@@ -64,6 +64,9 @@ class HashMap {
|
||||
[[nodiscard]]
|
||||
constexpr Vector<K> const&keys() const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Vector<T> values() const noexcept;
|
||||
|
||||
constexpr void clear();
|
||||
|
||||
private:
|
||||
@@ -198,6 +201,16 @@ constexpr Vector<K> const&HashMap<K, T>::keys() const noexcept {
|
||||
return m_keys;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
constexpr Vector<T> HashMap<K, T>::values() const noexcept {
|
||||
Vector<T> out;
|
||||
out.reserve(m_pairs.size());
|
||||
for (auto const&p : m_pairs) {
|
||||
out.emplace_back(p->value);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
constexpr void HashMap<K, T>::clear() {
|
||||
for (std::size_t i = 0; i < m_pairs.size(); i++) {
|
||||
|
4
deps/ox/src/ox/std/istring.hpp
vendored
4
deps/ox/src/ox/std/istring.hpp
vendored
@@ -35,7 +35,7 @@ class IString {
|
||||
|
||||
constexpr IString(const char *str) noexcept;
|
||||
|
||||
constexpr IString &operator=(CRStringView str) noexcept;
|
||||
constexpr IString &operator=(StringViewCR str) noexcept;
|
||||
|
||||
constexpr IString &operator=(const char *str) noexcept;
|
||||
|
||||
@@ -119,7 +119,7 @@ constexpr IString<size> &IString<size>::operator=(Integer_c auto i) noexcept {
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr IString<size> &IString<size>::operator=(ox::CRStringView str) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator=(ox::StringViewCR str) noexcept {
|
||||
std::size_t strLen = str.len();
|
||||
if (cap() < strLen) {
|
||||
strLen = cap();
|
||||
|
22
deps/ox/src/ox/std/stacktrace.cpp
vendored
22
deps/ox/src/ox/std/stacktrace.cpp
vendored
@@ -57,6 +57,28 @@ static auto symbolicate([[maybe_unused]]void **frames,
|
||||
}
|
||||
#endif // defined(OX_USE_STDLIB) && __has_include(<unistd.h>)
|
||||
|
||||
ox::String genStackTrace([[maybe_unused]]unsigned shave) noexcept {
|
||||
ox::String out;
|
||||
#if defined(OX_USE_STDLIB) && __has_include(<unistd.h>) && __has_include(<execinfo.h>)
|
||||
constexpr auto FrameCnt = 100;
|
||||
Vector<void*, FrameCnt> frames(FrameCnt);
|
||||
#ifdef OX_OS_FreeBSD
|
||||
using FrameCnt_t = unsigned;
|
||||
#else
|
||||
using FrameCnt_t = signed;
|
||||
#endif
|
||||
frames.resize(static_cast<std::size_t>(backtrace(frames.data(), static_cast<FrameCnt_t>(frames.size()))));
|
||||
if (frames.size() - shave > 2) {
|
||||
const auto symbolicatedStacktrace = symbolicate(frames.data() + shave, frames.size() - shave, "\t");
|
||||
out+= "Stacktrace:\n";
|
||||
for (const auto &s : symbolicatedStacktrace) {
|
||||
out += sfmt("\t{}\n", s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return out;
|
||||
}
|
||||
|
||||
void printStackTrace([[maybe_unused]]unsigned shave) noexcept {
|
||||
#if defined(OX_USE_STDLIB) && __has_include(<unistd.h>) && __has_include(<execinfo.h>)
|
||||
constexpr auto FrameCnt = 100;
|
||||
|
5
deps/ox/src/ox/std/stacktrace.hpp
vendored
5
deps/ox/src/ox/std/stacktrace.hpp
vendored
@@ -8,8 +8,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "string.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
[[nodiscard]]
|
||||
ox::String genStackTrace([[maybe_unused]]unsigned shave) noexcept;
|
||||
|
||||
/**
|
||||
* Prints a stack trace to stderr.
|
||||
*
|
||||
|
20
deps/ox/src/ox/std/string.hpp
vendored
20
deps/ox/src/ox/std/string.hpp
vendored
@@ -46,7 +46,7 @@ class BasicString {
|
||||
|
||||
constexpr explicit BasicString(StringLiteral const&str) noexcept;
|
||||
|
||||
constexpr explicit BasicString(CRStringView str) noexcept;
|
||||
constexpr explicit BasicString(StringViewCR str) noexcept;
|
||||
|
||||
constexpr explicit BasicString(BasicString const&) noexcept;
|
||||
|
||||
@@ -126,7 +126,7 @@ class BasicString {
|
||||
|
||||
constexpr BasicString &operator=(BasicString &&src) noexcept;
|
||||
|
||||
constexpr BasicString &operator=(CRStringView src) noexcept;
|
||||
constexpr BasicString &operator=(StringViewCR src) noexcept;
|
||||
|
||||
constexpr BasicString &operator+=(const char *str) noexcept;
|
||||
|
||||
@@ -148,7 +148,7 @@ class BasicString {
|
||||
|
||||
constexpr BasicString operator+(Integer_c auto i) const noexcept;
|
||||
|
||||
constexpr BasicString operator+(CRStringView src) const noexcept;
|
||||
constexpr BasicString operator+(StringViewCR src) const noexcept;
|
||||
|
||||
constexpr BasicString operator+(BasicString const&src) const noexcept;
|
||||
|
||||
@@ -243,7 +243,7 @@ class BasicString {
|
||||
constexpr std::size_t bytes() const noexcept;
|
||||
|
||||
private:
|
||||
constexpr void set(CRStringView str) noexcept;
|
||||
constexpr void set(StringViewCR str) noexcept;
|
||||
|
||||
constexpr void set(const char8_t *str) noexcept;
|
||||
};
|
||||
@@ -278,7 +278,7 @@ constexpr BasicString<SmallStringSize_v>::BasicString(StringLiteral const&str) n
|
||||
}
|
||||
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr BasicString<SmallStringSize_v>::BasicString(CRStringView str) noexcept {
|
||||
constexpr BasicString<SmallStringSize_v>::BasicString(StringViewCR str) noexcept {
|
||||
set(str);
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operat
|
||||
}
|
||||
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator=(CRStringView src) noexcept {
|
||||
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator=(StringViewCR src) noexcept {
|
||||
set(src);
|
||||
return *this;
|
||||
}
|
||||
@@ -416,7 +416,7 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
|
||||
}
|
||||
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(CRStringView src) const noexcept {
|
||||
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(StringViewCR src) const noexcept {
|
||||
const std::size_t strLen = src.len();
|
||||
const auto currentLen = len();
|
||||
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
|
||||
@@ -521,7 +521,7 @@ constexpr std::size_t BasicString<SmallStringSize_v>::len() const noexcept {
|
||||
}
|
||||
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr void BasicString<SmallStringSize_v>::set(CRStringView str) noexcept {
|
||||
constexpr void BasicString<SmallStringSize_v>::set(StringViewCR str) noexcept {
|
||||
std::size_t const strBytes = str.bytes();
|
||||
m_buff.resize(strBytes + 1);
|
||||
copy_n(str.data(), strBytes, m_buff.data());
|
||||
@@ -539,11 +539,11 @@ constexpr void BasicString<SmallStringSize_v>::set(const char8_t *str) noexcept
|
||||
extern template class BasicString<8>;
|
||||
|
||||
using String = BasicString<8>;
|
||||
using CRString = String const&;
|
||||
using StringCR = String const&;
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::String toString(ox::CRStringView sv) noexcept {
|
||||
constexpr ox::String toString(ox::StringViewCR sv) noexcept {
|
||||
return ox::String(sv);
|
||||
}
|
||||
|
||||
|
12
deps/ox/src/ox/std/stringview.hpp
vendored
12
deps/ox/src/ox/std/stringview.hpp
vendored
@@ -58,16 +58,16 @@ class StringView: public detail::BaseStringView {
|
||||
|
||||
};
|
||||
|
||||
using CRStringView = const StringView&;
|
||||
using StringViewCR = const StringView&;
|
||||
|
||||
constexpr auto operator==(CRStringView s1, CRStringView s2) noexcept {
|
||||
constexpr auto operator==(StringViewCR s1, StringViewCR s2) noexcept {
|
||||
if (s2.len() != s1.len()) {
|
||||
return false;
|
||||
}
|
||||
return ox::strncmp(s1.data(), s2.data(), s1.len()) == 0;
|
||||
}
|
||||
|
||||
constexpr auto operator<=>(CRStringView s1, CRStringView s2) noexcept {
|
||||
constexpr auto operator<=>(StringViewCR s1, StringViewCR s2) noexcept {
|
||||
const auto maxLen = ox::min(s1.len(), s2.len());
|
||||
const auto a = &s1.front();
|
||||
const auto b = &s2.front();
|
||||
@@ -87,18 +87,18 @@ constexpr auto operator<=>(CRStringView s1, CRStringView s2) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
constexpr auto write(Writer_c auto &writer, ox::CRStringView sv) noexcept {
|
||||
constexpr auto write(Writer_c auto &writer, ox::StringViewCR sv) noexcept {
|
||||
return writer.write(sv.data(), sv.bytes());
|
||||
}
|
||||
|
||||
#ifdef OX_USE_STDLIB
|
||||
constexpr auto toStdStringView(CRStringView sv) noexcept {
|
||||
constexpr auto toStdStringView(StringViewCR sv) noexcept {
|
||||
return std::string_view(sv.data(), sv.bytes());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
constexpr ox::Result<int> atoi(ox::CRStringView str) noexcept {
|
||||
constexpr ox::Result<int> atoi(ox::StringViewCR str) noexcept {
|
||||
int total = 0;
|
||||
int multiplier = 1;
|
||||
for (auto i = static_cast<int64_t>(str.len()) - 1; i != -1; --i) {
|
||||
|
18
deps/ox/src/ox/std/strops.hpp
vendored
18
deps/ox/src/ox/std/strops.hpp
vendored
@@ -34,19 +34,19 @@ constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool beginsWith(CRStringView base, CRStringView beginning) noexcept {
|
||||
constexpr bool beginsWith(StringViewCR base, StringViewCR beginning) noexcept {
|
||||
const auto beginningLen = ox::min(beginning.len(), base.len());
|
||||
return base.len() >= beginning.len() && ox::strncmp(base.data(), beginning, beginningLen) == 0;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
|
||||
constexpr bool endsWith(StringViewCR base, StringViewCR ending) noexcept {
|
||||
const auto endingLen = ending.len();
|
||||
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t find(CRStringView str, char search) noexcept {
|
||||
constexpr std::size_t find(StringViewCR str, char search) noexcept {
|
||||
std::size_t i = 0;
|
||||
for (; i < str.len(); ++i) {
|
||||
if (str[i] == search) {
|
||||
@@ -57,7 +57,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
||||
constexpr std::size_t find(StringViewCR str, StringViewCR search) noexcept {
|
||||
std::size_t i = 0;
|
||||
for (; i < str.len(); ++i) {
|
||||
if (beginsWith(substr(str, i), search)) {
|
||||
@@ -69,9 +69,9 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
||||
|
||||
template<std::size_t smallSz = 0>
|
||||
[[nodiscard]]
|
||||
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
|
||||
constexpr ox::Vector<ox::StringView, smallSz> split(StringViewCR str, char del) noexcept {
|
||||
ox::Vector<ox::StringView, smallSz> out;
|
||||
constexpr auto nextSeg = [](CRStringView current, char del) {
|
||||
constexpr auto nextSeg = [](StringViewCR current, char del) {
|
||||
return substr(current, find(current, del) + 1);
|
||||
};
|
||||
for (auto current = str; current.len(); current = nextSeg(current, del)) {
|
||||
@@ -86,9 +86,9 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del)
|
||||
|
||||
template<std::size_t smallSz = 0>
|
||||
[[nodiscard]]
|
||||
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
|
||||
constexpr ox::Vector<ox::StringView, smallSz> split(StringViewCR str, StringViewCR del) noexcept {
|
||||
ox::Vector<ox::StringView, smallSz> out;
|
||||
constexpr auto nextSeg = [](CRStringView current, CRStringView del) {
|
||||
constexpr auto nextSeg = [](StringViewCR current, StringViewCR del) {
|
||||
return substr(current, find(current, del) + del.len());
|
||||
};
|
||||
for (auto current = str; current.len(); current = nextSeg(current, del)) {
|
||||
@@ -102,7 +102,7 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringVi
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::Result<std::size_t> lastIndexOf(ox::CRStringView str, int character) noexcept {
|
||||
constexpr ox::Result<std::size_t> lastIndexOf(ox::StringViewCR str, int character) noexcept {
|
||||
ox::Result<std::size_t> retval = OxError(1, "Character not found");
|
||||
for (auto i = static_cast<int>(str.bytes() - 1); i >= 0; --i) {
|
||||
if (str[static_cast<std::size_t>(i)] == character) {
|
||||
|
37
deps/ox/src/ox/std/tracehook.cpp
vendored
37
deps/ox/src/ox/std/tracehook.cpp
vendored
@@ -24,10 +24,10 @@ static const auto OxPrintTrace = std::getenv("OXTRACE") != nullptr;
|
||||
#define REG_MGBA_DEBUG_FLAGS *reinterpret_cast<volatile uint16_t*>(0x4FFF700)
|
||||
#define REG_MGBA_DEBUG_STRING (reinterpret_cast<char*>(0x4FFF600))
|
||||
|
||||
inline void nullLog(ox::CRStringView) {}
|
||||
inline void (*infoLog)(ox::CRStringView) = nullLog;
|
||||
inline void (*debugLog)(ox::CRStringView) = nullLog;
|
||||
inline void (*errorLog)(ox::CRStringView) = nullLog;
|
||||
inline void nullLog(ox::StringViewCR) {}
|
||||
inline void (*infoLog)(ox::StringViewCR) = nullLog;
|
||||
inline void (*debugLog)(ox::StringViewCR) = nullLog;
|
||||
inline void (*errorLog)(ox::StringViewCR) = nullLog;
|
||||
|
||||
namespace mgba {
|
||||
|
||||
@@ -40,7 +40,7 @@ enum LogChan {
|
||||
};
|
||||
|
||||
template<LogChan chan>
|
||||
static void log(ox::CRStringView str) {
|
||||
static void log(ox::StringViewCR str) {
|
||||
const auto sz = ox::min<std::size_t>(0x100, str.bytes());
|
||||
ox::strncpy(REG_MGBA_DEBUG_STRING, str.data(), sz);
|
||||
REG_MGBA_DEBUG_FLAGS = chan | 0x100;
|
||||
@@ -65,23 +65,28 @@ void oxTraceInitHook() {
|
||||
void oxTraceHook([[maybe_unused]] const char *file, [[maybe_unused]] int line,
|
||||
[[maybe_unused]] const char *ch, [[maybe_unused]] const char *msg) {
|
||||
#if defined(OX_USE_STDLIB)
|
||||
auto const chv = ox::StringView{ch};
|
||||
if (OxPrintTrace) {
|
||||
auto m = std::string_view{msg};
|
||||
if (m.ends_with('\n')) {
|
||||
m = std::string_view{msg, m.size() - 1};
|
||||
}
|
||||
std::cout << std::setw(53) << std::left << ch << "| ";
|
||||
std::cout << std::setw(65) << std::left << msg << '|';
|
||||
std::cout << std::setw(65) << std::left << m << '|';
|
||||
std::cout << " " << file << ':' << line << "\n";
|
||||
} else if (ox::strcmp(ch, "debug") == 0 || ox::strcmp(ch, "info") == 0) {
|
||||
} else if (chv == "debug" || chv == "info") {
|
||||
printf("%s\n", msg);
|
||||
fflush(stdout);
|
||||
} else if (ox::strcmp(ch, "stdout") == 0) {
|
||||
std::ignore = fflush(stdout);
|
||||
} else if (chv == "stdout") {
|
||||
printf("%s", msg);
|
||||
fflush(stdout);
|
||||
} else if (ox::strcmp(ch, "stderr") == 0) {
|
||||
printf("%s", msg);
|
||||
fflush(stdout);
|
||||
} else if (ox::strcmp(ch, "error") == 0) {
|
||||
std::ignore = fflush(stdout);
|
||||
} else if (chv == "stderr") {
|
||||
std::ignore = fprintf(stderr, "%s", msg);
|
||||
std::ignore = fflush(stderr);
|
||||
} else if (chv == "error") {
|
||||
//std::cerr << "\033[31;1;1mERROR:\033[0m (" << file << ':' << line << "): " << msg << '\n';
|
||||
fprintf(stderr, "\033[31;1;1mERROR:\033[0m (%s:%d): %s\n", file, line, msg);
|
||||
fflush(stderr);
|
||||
std::ignore = fprintf(stderr, "\033[31;1;1mERROR:\033[0m (%s:%d): %s\n", file, line, msg);
|
||||
std::ignore = fflush(stderr);
|
||||
}
|
||||
#else
|
||||
if (ox::strcmp(ch, "info") == 0) {
|
||||
|
4
deps/ox/src/ox/std/uuid.hpp
vendored
4
deps/ox/src/ox/std/uuid.hpp
vendored
@@ -31,7 +31,7 @@ constexpr auto isHexChar(char c) noexcept {
|
||||
|| (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
constexpr ox::Result<uint8_t> fromHex(ox::CRStringView v) noexcept {
|
||||
constexpr ox::Result<uint8_t> fromHex(ox::StringViewCR v) noexcept {
|
||||
constexpr auto valMap = [] {
|
||||
ox::Array<uint8_t, 128> out;
|
||||
out['A'] = out['a'] = 10;
|
||||
@@ -125,7 +125,7 @@ class UUID {
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr ox::Result<ox::UUID> fromString(ox::CRStringView s) noexcept {
|
||||
static constexpr ox::Result<ox::UUID> fromString(ox::StringViewCR s) noexcept {
|
||||
if (s.len() < 36) {
|
||||
return OxError(1, "Insufficient data to contain a complete UUID");
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/vector.hpp
vendored
2
deps/ox/src/ox/std/vector.hpp
vendored
@@ -222,8 +222,10 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
|
||||
|
||||
constexpr Vector &operator=(Vector &&other) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr T &operator[](std::size_t i) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr const T &operator[](std::size_t i) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
|
Reference in New Issue
Block a user