Squashed 'deps/nostalgia/' changes from c7bc2a95..e27eee50

e27eee50 [teagba] Add set and scroll background offset functions
fd610454 [nostalgia/gfx] Fix compiler warning
e61d4647 [nostalgia/gfx] Fix BG tilesheet loading, add background offset functions
c275c5f5 [hull] Disable building hull for now
fbf49ba5 [ox/std] Add pre- and post-increment operators to Span
92f74b27 [ox/std] Add null check for deallocating in consteval context Vector
934f0c92 [ox/std] Add beginsWith and endsWith variants that that cingle chars
ee9a3e11 [ox/std] Cleanup
16886cdf [hull] Add start on command interpreter
08b9508d [ox/std] Give std::ignore a named type
69bd968f [nostalgia/player] Fix build
4e7dc666 [nostalgia,olympic] Rename string len() functions to size()
bea0cf5a [ox/std] Rename string len() functions to size()

git-subtree-dir: deps/nostalgia
git-subtree-split: e27eee50f05bb437710313430e0d9cef636a66b1
This commit is contained in:
2025-07-30 00:40:03 -05:00
parent 8a74e044dc
commit 1bfb7f99c2
47 changed files with 340 additions and 142 deletions

View File

@@ -19,6 +19,9 @@ else()
endif()
add_subdirectory(applib)
#if(NOT APPLE)
# add_subdirectory(hull)
#endif()
add_subdirectory(keel)
add_subdirectory(turbine)
if(${OLYMPIC_BUILD_STUDIO})

View File

@@ -3,6 +3,11 @@ add_library(
OlympicApplib INTERFACE
)
target_link_libraries(
OlympicApplib INTERFACE
OxLogConn
)
target_sources(
OlympicApplib INTERFACE
applib.cpp

View File

@@ -0,0 +1,12 @@
add_library(Hull)
target_sources(
Hull PUBLIC
FILE_SET CXX_MODULES FILES
hull.cpp
)
target_link_libraries(
Hull PUBLIC
OxStd
)

98
src/olympic/hull/hull.cpp Normal file
View File

@@ -0,0 +1,98 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
module;
#include <ox/std/string.hpp>
export module hull;
namespace hull {
export
template<typename Str = ox::String, size_t SmallVecSz = 0>
constexpr ox::Result<ox::Vector<Str, SmallVecSz>> parseCmd(ox::StringViewCR cmd) noexcept
requires(ox::is_same_v<Str, ox::String> || ox::is_same_v<Str, ox::StringView>) {
auto const tokens = split(cmd, ' ');
ox::Vector<Str, SmallVecSz> args;
char waitingFor{};
auto const handleString = [&waitingFor, &args](
ox::StringViewCR token,
char const delimiter) {
if (endsWith(token, delimiter)) {
args.emplace_back(substr(token, 1, token.size() - 1));
} else {
waitingFor = delimiter;
args.emplace_back(substr(token, 1));
}
};
for (auto const &token : tokens) {
if (waitingFor) {
if (endsWith(token, waitingFor)) {
waitingFor = 0;
}
auto &tgt = *args.back().value;
if constexpr (ox::is_same_v<Str, ox::String>) {
tgt += substr(token, 0, token.size() - 1);
} else {
tgt = {tgt.data(), tgt.size() + token.size() - 1};
}
} else if (beginsWith(token, '"')) {
handleString(token, '"');
} else if (beginsWith(token, '\'')) {
handleString(token, '\'');
} else {
args.emplace_back(token);
}
}
if (waitingFor) {
return ox::Error{1, "unterminated string"};
}
return args;
}
template<typename Str = ox::String>
[[nodiscard]]
static constexpr bool testParse(ox::StringViewCR cmd, std::initializer_list<ox::StringView> const &expected) noexcept {
auto const [args, err] = parseCmd<Str>(cmd);
static constexpr auto equals = [](auto const &a, auto const &b) {
if (a.size() != b.size()) {
return false;
}
for (auto i = 0u; i < a.size(); ++i) {
if (a[i] != b[i]) {
return false;
}
}
return true;
};
return !err && equals(args, ox::Vector(expected));
}
static_assert(testParse("echo asdf", {"echo", "asdf"}));
static_assert(testParse<ox::String>("echo asdf", {"echo", "asdf"}));
static_assert(testParse("echo \"asdf\"", {"echo", "asdf"}));
static_assert(testParse<ox::String>("echo \"asdf\"", {"echo", "asdf"}));
static_assert(testParse("echo 'asdf'", {"echo", "asdf"}));
static_assert(testParse<ox::String>("echo 'asdf'", {"echo", "asdf"}));
static_assert(testParse("echo 'asdf' aoue", {"echo", "asdf", "aoue"}));
static_assert(testParse<ox::String>("echo 'asdf' aoue", {"echo", "asdf", "aoue"}));
export class Prompt {
private:
ox::String m_cmd;
ox::String m_workingDir{"/"};
ox::Vector<ox::String> m_prevCmds;
public:
private:
};
}

View File

@@ -59,7 +59,7 @@ static ox::Error buildUuidMap(Context &ctx, ox::StringViewCR path, DuplicateSet
auto const [uuid, err] = readUuidHeader(buff);
if (!err) {
// check for duplication
if (duplicates && ctx.uuidToPath[uuid.toString()].len()) {
if (duplicates && ctx.uuidToPath[uuid.toString()].size()) {
auto &dl = (*duplicates)[uuid];
if (dl.empty()) {
dl.emplace_back(ctx.uuidToPath[uuid.toString()]);

View File

@@ -88,7 +88,7 @@ static ox::Error pack(
oxOutf("Final ROM buff size: {} bytes\n", romBuff.size());
OX_RETURN_ERROR(writeFileBuff(argRomBin, romBuff));
OX_REQUIRE(manifestJson, ox::writeOCString(manifest));
OX_RETURN_ERROR(writeFileBuff(argManifest, {manifestJson.data(), manifestJson.len()}));
OX_RETURN_ERROR(writeFileBuff(argManifest, {manifestJson.data(), manifestJson.size()}));
return {};
}

View File

@@ -16,7 +16,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db";
constexpr ox::StringView hdr = "K1;8d814442-f46e-4cc3-8edc-ca3c01cc86db;";
OX_REQUIRE(uuid, ox::UUID::fromString(uuidStr));
ox::Array<char, hdr.len()> buff;
ox::Array<char, hdr.size()> buff;
ox::CharBuffWriter bw(buff);
OX_RETURN_ERROR(keel::writeUuidHeader(bw, uuid));
oxExpect(ox::StringView(buff.data(), buff.size()), hdr);

View File

@@ -192,7 +192,7 @@ void NewMenu::drawLastPageButtons(Context &sctx) noexcept {
}
void NewMenu::finish(Context &sctx) noexcept {
if (m_itemName.len() == 0) {
if (m_itemName.size() == 0) {
oxLogError(ox::Error{1, "New file error: no file name"});
return;
}

View File

@@ -57,7 +57,7 @@ void ProjectExplorer::dirContextMenu(ox::StringViewCR path) const noexcept {
if (ImGui::MenuItem("Add Directory")) {
addDir.emit(path);
}
if (path.len() && ImGui::MenuItem("Delete")) {
if (path.size() && ImGui::MenuItem("Delete")) {
deleteItem.emit(path);
}
ImGui::EndPopup();

View File

@@ -40,8 +40,8 @@ constexpr ox::Result<ox::StringView> fileExt(ox::StringViewCR path) noexcept {
[[nodiscard]]
constexpr ox::StringView parentDir(ox::StringView path) noexcept {
if (path.len() && path[path.len() - 1] == '/') {
path = substr(path, 0, path.len() - 1);
if (path.size() && path[path.size() - 1] == '/') {
path = substr(path, 0, path.size() - 1);
}
auto const extStart = ox::find(path.crbegin(), path.crend(), '/').offset();
return substr(path, 0, extStart);

View File

@@ -13,10 +13,10 @@ namespace studio {
FDFilterItem::FDFilterItem(ox::StringViewCR pName, ox::StringViewCR pSpec) noexcept {
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
name.resize(pName.len() + 1);
ox::strncpy(name.data(), pName.data(), pName.len());
spec.resize(pSpec.len() + 1);
ox::strncpy(spec.data(), pSpec.data(), pSpec.len());
name.resize(pName.size() + 1);
ox::strncpy(name.data(), pName.data(), pName.size());
spec.resize(pSpec.size() + 1);
ox::strncpy(spec.data(), pSpec.data(), pSpec.size());
OX_ALLOW_UNSAFE_BUFFERS_END
}