[nostalgia,olympic] Cleanup

This commit is contained in:
2024-12-13 22:00:03 -06:00
parent 28ebe93b77
commit 96d27eecd1
27 changed files with 64 additions and 64 deletions

View File

@ -155,7 +155,7 @@ class AssetRef: public ox::SignalHandler {
private:
constexpr ox::Error emitUpdated() const noexcept {
updated.emit();
return OxError(0);
return ox::Error(0);
}
};
@ -207,7 +207,7 @@ class AssetManager {
ox::Result<AssetRef<T>> getAsset(ox::StringView const assetId) const noexcept {
oxRequire(out, m_cache.at(assetId));
if (!out || !*out) {
return OxError(1, "asset is null");
return ox::Error(1, "asset is null");
}
return AssetRef<T>(out->get());
}
@ -256,7 +256,7 @@ class AssetManager {
auto &am = m_assetTypeManagers[typeId];
auto const out = dynamic_cast<AssetTypeManager<T>*>(am.get());
if (!out) {
return OxError(1, "no AssetTypeManager for type");
return ox::Error(1, "no AssetTypeManager for type");
}
return out;
}

View File

@ -113,7 +113,7 @@ ox::Result<keel::AssetRef<T>> readObjNoCache(
oxRequire(addr, getPreloadAddr(ctx, assetId));
return keel::AssetRef<T>(std::bit_cast<T const*>(uintptr_t{addr}));
} else {
return OxError(1);
return ox::Error(1);
}
}
@ -146,7 +146,7 @@ ox::Result<keel::AssetRef<T>> readObj(
oxRequire(addr, getPreloadAddr(ctx, file));
return keel::AssetRef<T>(std::bit_cast<T const*>(uintptr_t{addr}));
} else {
return OxError(1);
return ox::Error(1);
}
#endif
}

View File

@ -14,7 +14,7 @@ constexpr bool valid(auto const&) noexcept {
}
constexpr ox::Error repair(auto const&) noexcept {
return OxError(1, "No repair function for this type");
return ox::Error(1, "No repair function for this type");
}
constexpr ox::Error ensureValid(auto &o) noexcept {

View File

@ -8,11 +8,11 @@ namespace keel {
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept {
if (buff.size() < K1HdrSz) [[unlikely]] {
return OxError(1, "Insufficient data to contain complete Keel header");
return ox::Error(1, "Insufficient data to contain complete Keel header");
}
constexpr ox::StringView k1Hdr = "K1;";
if (k1Hdr != ox::StringView(buff.data(), k1Hdr.bytes())) [[unlikely]] {
return OxError(2, "No Keel asset header data");
return ox::Error(2, "No Keel asset header data");
}
return ox::UUID::fromString(ox::StringView(&buff[k1Hdr.bytes()], 36));
}
@ -30,7 +30,7 @@ ox::Result<ox::StringView> readAssetTypeId(ox::BufferView buff) noexcept {
const auto err = readUuidHeader(buff).error;
const auto offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] {
return OxError(1, "Buffer too small for expected data");
return ox::Error(1, "Buffer too small for expected data");
}
return ox::readClawTypeId(buff + offset);
}
@ -40,7 +40,7 @@ ox::Result<AssetHdr> readAssetHeader(ox::BufferView buff) noexcept {
const auto err = readUuidHeader(buff).moveTo(out.value.uuid);
const auto offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] {
return OxError(1, "Buffer too small for expected data");
return ox::Error(1, "Buffer too small for expected data");
}
buff += offset;
oxReturnError(ox::readClawHeader(buff).moveTo(out.value.clawHdr));

View File

@ -16,7 +16,7 @@ ox::Result<char*> loadRom(ox::StringViewCR path) noexcept {
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
if (!file.good()) {
oxErrorf("Could not find ROM file: {}", path);
return OxError(1, "Could not find ROM file");
return ox::Error(1, "Could not find ROM file");
}
try {
auto const size = file.tellg();
@ -26,10 +26,10 @@ ox::Result<char*> loadRom(ox::StringViewCR path) noexcept {
return buff;
} catch (std::ios_base::failure const&e) {
oxErrorf("Could not read ROM file due to file IO failure: {}", e.what());
return OxError(2, "Could not read ROM file");
return ox::Error(2, "Could not read ROM file");
} catch (std::bad_alloc const&e) {
oxErrorf("Could not read ROM file due to new failure: {}", e.what());
return OxError(2, "Could not allocate memory for ROM file");
return ox::Error(2, "Could not allocate memory for ROM file");
}
}
@ -69,7 +69,7 @@ static ox::Error buildUuidMap(Context &ctx, ox::StringViewCR path) noexcept {
ox::Error buildUuidMap(Context &ctx) noexcept {
if (!ctx.rom) {
return OxError(1, "No ROM FS");
return ox::Error(1, "No ROM FS");
}
return buildUuidMap(ctx, "");
}
@ -79,7 +79,7 @@ ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept {
oxRequire(out, ctx.pathToUuid.at(path));
return *out;
#else
return OxError(1, "UUID to path conversion not supported on this platform");
return ox::Error(1, "UUID to path conversion not supported on this platform");
#endif
}
@ -105,7 +105,7 @@ ox::Result<ox::CStringView> getPath(Context &ctx, ox::FileAddress const&fileAddr
oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView{*out};
#else
return OxError(1, "UUID to path conversion not supported on this platform");
return ox::Error(1, "UUID to path conversion not supported on this platform");
#endif
} else {
return ox::CStringView{path};
@ -119,7 +119,7 @@ ox::Result<ox::CStringView> getPath(Context &ctx, ox::CStringView fileId) noexce
oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView{*out};
#else
return OxError(1, "UUID to path conversion not supported on this platform");
return ox::Error(1, "UUID to path conversion not supported on this platform");
#endif
} else {
return ox::CStringView{fileId};
@ -132,7 +132,7 @@ ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringView uuid) noe
oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView(*out);
#else
return OxError(1, "UUID to path conversion not supported on this platform");
return ox::Error(1, "UUID to path conversion not supported on this platform");
#endif
}
@ -141,7 +141,7 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::StringViewCR uuid) noex
oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView(*out);
#else
return OxError(1, "UUID to path conversion not supported on this platform");
return ox::Error(1, "UUID to path conversion not supported on this platform");
#endif
}
@ -150,7 +150,7 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
oxRequireM(out, ctx.uuidToPath.at(uuid.toString()));
return ox::CStringView(*out);
#else
return OxError(1, "UUID to path conversion not supported on this platform");
return ox::Error(1, "UUID to path conversion not supported on this platform");
#endif
}
@ -200,7 +200,7 @@ ox::Result<char*> loadRom(ox::StringViewCR) noexcept {
return current + headerLen;
}
}
return OxError(1);
return ox::Error(1);
}
void unloadRom(char*) noexcept {
@ -223,7 +223,7 @@ ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::FileAddress const
}
ox::Error reloadAsset(keel::Context&, ox::StringView) noexcept {
return OxError(1, "reloadAsset is unsupported on this platform");
return ox::Error(1, "reloadAsset is unsupported on this platform");
}
}
@ -247,7 +247,7 @@ ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexc
#ifdef OX_HAS_PASSTHROUGHFS
return {ox::make_unique<ox::PassThroughFS>(path)};
#else
return OxError(2);
return ox::Error(2);
#endif
}
}

View File

@ -17,7 +17,7 @@ static ox::Error writeFileBuff(ox::StringView path, ox::BufferView const buff) n
std::ofstream f(std::string(toStdStringView(path)), std::ios::binary);
f.write(buff.data(), static_cast<intptr_t>(buff.size()));
} catch (std::fstream::failure const&) {
return OxError(2, "failed to write file");
return ox::Error(2, "failed to write file");
}
return {};
}
@ -26,7 +26,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
if (!file.good()) {
oxErrorf("Could not find OxFS file: {}", path);
return OxError(1, "Could not find OxFS file");
return ox::Error(1, "Could not find OxFS file");
}
try {
auto const size = static_cast<std::size_t>(file.tellg());
@ -36,7 +36,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
return buff;
} catch (std::ios_base::failure const&e) {
oxErrorf("Could not read OxFS file: {}", e.what());
return OxError(2, "Could not read OxFS file");
return ox::Error(2, "Could not read OxFS file");
}
}
@ -88,11 +88,11 @@ static ox::Error run(ox::SpanView<char const*> argv, ox::StringView projectDataD
auto const argManifest = args.getString("manifest", "");
if (argSrc == "") {
oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n");
return OxError(1, "must specify a source directory");
return ox::Error(1, "must specify a source directory");
}
if (argRomBin == "") {
oxErr("\033[31;1;1merror:\033[0m must specify a path for ROM file\n");
return OxError(1, "must specify a path for preload file");
return ox::Error(1, "must specify a path for preload file");
}
return pack(argSrc, argRomBin, argManifest, projectDataDir);
}

View File

@ -18,7 +18,7 @@ static ox::Result<BaseConverter const*> findConverter(
return c;
}
}
return OxError(1, "Could not find converter");
return ox::Error(1, "Could not find converter");
};
static ox::Result<ox::UPtr<Wrap>> convert(
@ -47,7 +47,7 @@ static ox::Result<ox::UPtr<Wrap>> convert(
return subConverter->convertPtrToPtr(ctx, *intermediate);
}
}
return OxError(1, "Could not convert between types");
return ox::Error(1, "Could not convert between types");
}
ox::Result<ox::UPtr<Wrap>> convert(