[nostalgia,olympic] Cleanup

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

View File

@ -96,7 +96,7 @@ constexpr void repair(TileSheetV2::SubSheet &ss, int bpp) noexcept {
constexpr ox::Error repair(TileSheetV2 &ts) noexcept { constexpr ox::Error repair(TileSheetV2 &ts) noexcept {
if (ts.bpp != 4 && ts.bpp != 8) { if (ts.bpp != 4 && ts.bpp != 8) {
return OxError(1, "Unable to repair TileSheet"); return ox::Error(1, "Unable to repair TileSheet");
} }
repair(ts.subsheet, ts.bpp); repair(ts.subsheet, ts.bpp);
return {}; return {};
@ -166,7 +166,7 @@ constexpr void repair(TileSheetV3::SubSheet &ss, int bpp) noexcept {
constexpr ox::Error repair(TileSheetV3 &ts) noexcept { constexpr ox::Error repair(TileSheetV3 &ts) noexcept {
if (ts.bpp != 4 && ts.bpp != 8) { if (ts.bpp != 4 && ts.bpp != 8) {
return OxError(1, "Unable to repair TileSheet"); return ox::Error(1, "Unable to repair TileSheet");
} }
repair(ts.subsheet, ts.bpp); repair(ts.subsheet, ts.bpp);
return {}; return {};
@ -254,7 +254,7 @@ constexpr void repair(TileSheetV4::SubSheet &ss, int bpp) noexcept {
constexpr ox::Error repair(TileSheetV4 &ts) noexcept { constexpr ox::Error repair(TileSheetV4 &ts) noexcept {
if (ts.bpp != 4 && ts.bpp != 8) { if (ts.bpp != 4 && ts.bpp != 8) {
return OxError(1, "Unable to repair TileSheet"); return ox::Error(1, "Unable to repair TileSheet");
} }
repair(ts.subsheet, ts.bpp); repair(ts.subsheet, ts.bpp);
return {}; return {};

View File

@ -72,7 +72,7 @@ static ox::Error loadTileSheetSet(
for (auto const&entry : set.entries) { for (auto const&entry : set.entries) {
oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), entry.tilesheet)); oxRequire(ts, keel::readObj<CompactTileSheet>(keelCtx(ctx), entry.tilesheet));
if (set.bpp != ts->bpp && ts->bpp == 8) { if (set.bpp != ts->bpp && ts->bpp == 8) {
return OxError(1, "cannot load an 8 BPP tilesheet into a 4 BPP CBB"); return ox::Error(1, "cannot load an 8 BPP tilesheet into a 4 BPP CBB");
} }
for (auto const&s : entry.sections) { for (auto const&s : entry.sections) {
auto const cnt = (static_cast<size_t>(s.tiles) * PixelsPerTile) >> bppMod; auto const cnt = (static_cast<size_t>(s.tiles) * PixelsPerTile) >> bppMod;

View File

@ -81,9 +81,9 @@ static class: public keel::Module {
[](keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) -> ox::Result<bool> { [](keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) -> ox::Result<bool> {
if (typeId == ox::ModelTypeId_v<NostalgiaPalette> || if (typeId == ox::ModelTypeId_v<NostalgiaPalette> ||
typeId == ox::ModelTypeId_v<PaletteV1> || typeId == ox::ModelTypeId_v<PaletteV1> ||
typeId == ox::ModelTypeId_v<PaletteV2> || typeId == ox::ModelTypeId_v<PaletteV2> ||
typeId == ox::ModelTypeId_v<PaletteV3> || typeId == ox::ModelTypeId_v<PaletteV3> ||
typeId == ox::ModelTypeId_v<PaletteV4>) { typeId == ox::ModelTypeId_v<PaletteV4>) {
oxReturnError(keel::convertBuffToBuff<CompactPalette>( oxReturnError(keel::convertBuffToBuff<CompactPalette>(
ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
return true; return true;

View File

@ -586,7 +586,7 @@ ox::Error loadBgTileSheet(
auto const srcPxIdx = srcTileIdx * PixelsPerTile; auto const srcPxIdx = srcTileIdx * PixelsPerTile;
auto const dstPxIdx = dstTileIdx * PixelsPerTile; auto const dstPxIdx = dstTileIdx * PixelsPerTile;
if (dstPxIdx + pxlCnt >= cbbPxls.size()) { if (dstPxIdx + pxlCnt >= cbbPxls.size()) {
return OxError(1, "video mem dst overflow"); return ox::Error(1, "video mem dst overflow");
} }
auto const dst = ox::Span{cbbPxls} + dstPxIdx; auto const dst = ox::Span{cbbPxls} + dstPxIdx;
copyPixels(ts, dst, srcPxIdx, pxlCnt); copyPixels(ts, dst, srcPxIdx, pxlCnt);

View File

@ -76,7 +76,7 @@ static ox::Error toPngFile(
c = color32(color(pal, page, c)) | static_cast<Color32>(0XFF << 24); c = color32(color(pal, page, c)) | static_cast<Color32>(0XFF << 24);
} }
constexpr auto fmt = LCT_RGBA; constexpr auto fmt = LCT_RGBA;
return OxError(static_cast<ox::ErrorCode>( return ox::Error(static_cast<ox::ErrorCode>(
lodepng_encode_file( lodepng_encode_file(
path.c_str(), path.c_str(),
reinterpret_cast<uint8_t const*>(pixels.data()), reinterpret_cast<uint8_t const*>(pixels.data()),

View File

@ -144,7 +144,7 @@ static ox::Error setPixelCount(ox::Vector<uint8_t> &pixels, int8_t pBpp, std::si
sz = cnt; sz = cnt;
break; break;
default: default:
return OxError(1, "Invalid pBpp used for TileSheet::SubSheet::setPixelCount"); return ox::Error(1, "Invalid pBpp used for TileSheet::SubSheet::setPixelCount");
} }
pixels.reserve(sz); pixels.reserve(sz);
pixels.resize(sz); pixels.resize(sz);
@ -187,7 +187,7 @@ ox::Result<ox::StringView> getNameFor(TileSheet::SubSheet const&ss, SubSheetId p
return name; return name;
} }
} }
return OxError(1, "SubSheet not found"); return ox::Error(1, "SubSheet not found");
} }
@ -256,7 +256,7 @@ ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept
parent.subsheets.emplace_back(++ts.idIt, "Subsheet 0", parent.columns, parent.rows, ts.bpp); parent.subsheets.emplace_back(++ts.idIt, "Subsheet 0", parent.columns, parent.rows, ts.bpp);
parent.subsheets.emplace_back(++ts.idIt, "Subsheet 1", 1, 1, ts.bpp); parent.subsheets.emplace_back(++ts.idIt, "Subsheet 1", 1, 1, ts.bpp);
} }
return OxError(0); return ox::Error(0);
} }
ox::Error rmSubSheet( ox::Error rmSubSheet(
@ -345,7 +345,7 @@ static ox::Result<SubSheetId> getIdFor(
return getIdFor(ss, pNamePath, pIt + 1); return getIdFor(ss, pNamePath, pIt + 1);
} }
} }
return OxError(1, "SubSheet not found"); return ox::Error(1, "SubSheet not found");
} }
ox::Result<SubSheetId> getIdFor(TileSheet const&ts, ox::StringViewCR path) noexcept { ox::Result<SubSheetId> getIdFor(TileSheet const&ts, ox::StringViewCR path) noexcept {
@ -363,7 +363,7 @@ static ox::Result<unsigned> getTileOffset(
unsigned pCurrentTotal = 0) noexcept { unsigned pCurrentTotal = 0) noexcept {
// pIt == pNamePath.size() - 1 && // pIt == pNamePath.size() - 1 &&
if (ss.name != pNamePath[pIt]) { if (ss.name != pNamePath[pIt]) {
return OxError(2, "Wrong branch"); return ox::Error(2, "Wrong branch");
} }
if (pIt == pNamePath.size() - 1) { if (pIt == pNamePath.size() - 1) {
return pCurrentTotal; return pCurrentTotal;
@ -376,7 +376,7 @@ static ox::Result<unsigned> getTileOffset(
} }
pCurrentTotal += pixelCnt(sub, pBpp) / PixelsPerTile; pCurrentTotal += pixelCnt(sub, pBpp) / PixelsPerTile;
} }
return OxError(1, "SubSheet not found"); return ox::Error(1, "SubSheet not found");
} }
ox::Result<unsigned> getTileOffset(TileSheet const&ts, ox::StringViewCR pNamePath) noexcept { ox::Result<unsigned> getTileOffset(TileSheet const&ts, ox::StringViewCR pNamePath) noexcept {

View File

@ -14,7 +14,7 @@ Scene::Scene(SceneStatic const&sceneStatic) noexcept:
ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept { ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept {
if (m_sceneStatic.palettes.empty()) { if (m_sceneStatic.palettes.empty()) {
return OxError(1, "Scene has no palettes"); return ox::Error(1, "Scene has no palettes");
} }
auto const&palette = m_sceneStatic.palettes[0]; auto const&palette = m_sceneStatic.palettes[0];
oxReturnError(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet)); oxReturnError(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet));

View File

@ -163,7 +163,7 @@ ox::Error run(
[[maybe_unused]] ox::StringView projectDataDir, [[maybe_unused]] ox::StringView projectDataDir,
ox::SpanView<char const*> args) noexcept { ox::SpanView<char const*> args) noexcept {
if (args.size() < 2) { if (args.size() < 2) {
return OxError(1, "Please provide path to project directory or OxFS file."); return ox::Error(1, "Please provide path to project directory or OxFS file.");
} }
auto const path = args[1]; auto const path = args[1];
oxRequireM(fs, keel::loadRomFs(path)); oxRequireM(fs, keel::loadRomFs(path));

View File

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

View File

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

View File

@ -14,7 +14,7 @@ constexpr bool valid(auto const&) noexcept {
} }
constexpr ox::Error repair(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 { constexpr ox::Error ensureValid(auto &o) noexcept {

View File

@ -8,11 +8,11 @@ namespace keel {
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept { ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept {
if (buff.size() < K1HdrSz) [[unlikely]] { 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;"; constexpr ox::StringView k1Hdr = "K1;";
if (k1Hdr != ox::StringView(buff.data(), k1Hdr.bytes())) [[unlikely]] { 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)); 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 err = readUuidHeader(buff).error;
const auto offset = err ? 0u : K1HdrSz; const auto offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] { 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); 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 err = readUuidHeader(buff).moveTo(out.value.uuid);
const auto offset = err ? 0u : K1HdrSz; const auto offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] { 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; buff += offset;
oxReturnError(ox::readClawHeader(buff).moveTo(out.value.clawHdr)); 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); std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
if (!file.good()) { if (!file.good()) {
oxErrorf("Could not find ROM file: {}", path); 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 { try {
auto const size = file.tellg(); auto const size = file.tellg();
@ -26,10 +26,10 @@ ox::Result<char*> loadRom(ox::StringViewCR path) noexcept {
return buff; return buff;
} catch (std::ios_base::failure const&e) { } catch (std::ios_base::failure const&e) {
oxErrorf("Could not read ROM file due to file IO failure: {}", e.what()); 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) { } catch (std::bad_alloc const&e) {
oxErrorf("Could not read ROM file due to new failure: {}", e.what()); 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 { ox::Error buildUuidMap(Context &ctx) noexcept {
if (!ctx.rom) { if (!ctx.rom) {
return OxError(1, "No ROM FS"); return ox::Error(1, "No ROM FS");
} }
return buildUuidMap(ctx, ""); return buildUuidMap(ctx, "");
} }
@ -79,7 +79,7 @@ ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept {
oxRequire(out, ctx.pathToUuid.at(path)); oxRequire(out, ctx.pathToUuid.at(path));
return *out; return *out;
#else #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 #endif
} }
@ -105,7 +105,7 @@ ox::Result<ox::CStringView> getPath(Context &ctx, ox::FileAddress const&fileAddr
oxRequireM(out, ctx.uuidToPath.at(uuid)); oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView{*out}; return ox::CStringView{*out};
#else #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 #endif
} else { } else {
return ox::CStringView{path}; 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)); oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView{*out}; return ox::CStringView{*out};
#else #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 #endif
} else { } else {
return ox::CStringView{fileId}; 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)); oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView(*out); return ox::CStringView(*out);
#else #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 #endif
} }
@ -141,7 +141,7 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::StringViewCR uuid) noex
oxRequireM(out, ctx.uuidToPath.at(uuid)); oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView(*out); return ox::CStringView(*out);
#else #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 #endif
} }
@ -150,7 +150,7 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
oxRequireM(out, ctx.uuidToPath.at(uuid.toString())); oxRequireM(out, ctx.uuidToPath.at(uuid.toString()));
return ox::CStringView(*out); return ox::CStringView(*out);
#else #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 #endif
} }
@ -200,7 +200,7 @@ ox::Result<char*> loadRom(ox::StringViewCR) noexcept {
return current + headerLen; return current + headerLen;
} }
} }
return OxError(1); return ox::Error(1);
} }
void unloadRom(char*) noexcept { 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 { 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 #ifdef OX_HAS_PASSTHROUGHFS
return {ox::make_unique<ox::PassThroughFS>(path)}; return {ox::make_unique<ox::PassThroughFS>(path)};
#else #else
return OxError(2); return ox::Error(2);
#endif #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); std::ofstream f(std::string(toStdStringView(path)), std::ios::binary);
f.write(buff.data(), static_cast<intptr_t>(buff.size())); f.write(buff.data(), static_cast<intptr_t>(buff.size()));
} catch (std::fstream::failure const&) { } catch (std::fstream::failure const&) {
return OxError(2, "failed to write file"); return ox::Error(2, "failed to write file");
} }
return {}; 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); std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
if (!file.good()) { if (!file.good()) {
oxErrorf("Could not find OxFS file: {}", path); 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 { try {
auto const size = static_cast<std::size_t>(file.tellg()); 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; return buff;
} catch (std::ios_base::failure const&e) { } catch (std::ios_base::failure const&e) {
oxErrorf("Could not read OxFS file: {}", e.what()); 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", ""); auto const argManifest = args.getString("manifest", "");
if (argSrc == "") { if (argSrc == "") {
oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n"); 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 == "") { if (argRomBin == "") {
oxErr("\033[31;1;1merror:\033[0m must specify a path for ROM file\n"); 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); return pack(argSrc, argRomBin, argManifest, projectDataDir);
} }

View File

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

View File

@ -118,12 +118,12 @@ void NewMenu::drawLastPageButtons(studio::StudioContext &sctx) noexcept {
void NewMenu::finish(studio::StudioContext &sctx) noexcept { void NewMenu::finish(studio::StudioContext &sctx) noexcept {
if (m_itemName.len() == 0) { if (m_itemName.len() == 0) {
oxLogError(OxError(1, "New file error: no file name")); oxLogError(ox::Error(1, "New file error: no file name"));
return; return;
} }
auto const&typeMaker = *m_types[static_cast<std::size_t>(m_selectedType)]; auto const&typeMaker = *m_types[static_cast<std::size_t>(m_selectedType)];
if (sctx.project->exists(typeMaker.itemPath(m_itemName))) { if (sctx.project->exists(typeMaker.itemPath(m_itemName))) {
oxLogError(OxError(1, "New file error: file already exists")); oxLogError(ox::Error(1, "New file error: file already exists"));
return; return;
} }
auto const [path, err] = typeMaker.write(sctx, m_itemName); auto const [path, err] = typeMaker.write(sctx, m_itemName);

View File

@ -54,7 +54,7 @@ void ProjectExplorer::setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept {
ox::Error ProjectExplorer::refreshProjectTreeModel(ox::StringViewCR) noexcept { ox::Error ProjectExplorer::refreshProjectTreeModel(ox::StringViewCR) noexcept {
oxRequireM(model, buildProjectTreeModel(*this, "Project", "/", nullptr)); oxRequireM(model, buildProjectTreeModel(*this, "Project", "/", nullptr));
setModel(std::move(model)); setModel(std::move(model));
return OxError(0); return ox::Error(0);
} }
} }

View File

@ -323,7 +323,7 @@ void StudioUI::handleKeyInput() noexcept {
ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept { ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept {
std::error_code ec; std::error_code ec;
std::filesystem::create_directories(toStdStringView(path), ec); std::filesystem::create_directories(toStdStringView(path), ec);
oxReturnError(OxError(ec.value() != 0, "Could not create project directory")); oxReturnError(ox::Error(ec.value() != 0, "Could not create project directory"));
oxReturnError(openProjectPath(path)); oxReturnError(openProjectPath(path));
return m_project->writeTypeStore(); return m_project->writeTypeStore();
} }
@ -354,7 +354,7 @@ ox::Error StudioUI::openFile(ox::StringViewCR path) noexcept {
ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) noexcept { ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) noexcept {
if (!m_project) { if (!m_project) {
return OxError(1, "No project open to open a file from"); return ox::Error(1, "No project open to open a file from");
} }
if (m_openFiles.contains(path)) { if (m_openFiles.contains(path)) {
for (auto &e : m_editors) { for (auto &e : m_editors) {

View File

@ -64,7 +64,7 @@ ox::Error writeConfig(keel::Context &ctx, ox::StringViewCR name, T const&data) n
*buff.back().value = '\n'; *buff.back().value = '\n';
if (auto const err = fs.write(path, buff.data(), buff.size())) { if (auto const err = fs.write(path, buff.data(), buff.size())) {
//oxErrf("Could not read config file: {} - {}\n", path, toStr(err)); //oxErrf("Could not read config file: {} - {}\n", path, toStr(err));
return OxError(2, "Could not read config file"); return ox::Error(2, "Could not read config file");
} }
return {}; return {};
} }

View File

@ -27,7 +27,7 @@ template<typename T>
ox::Result<T> getDragDropPayload(ox::CStringView name) noexcept { ox::Result<T> getDragDropPayload(ox::CStringView name) noexcept {
auto const payload = ImGui::AcceptDragDropPayload(name.c_str()); auto const payload = ImGui::AcceptDragDropPayload(name.c_str());
if (!payload) { if (!payload) {
return OxError(1, "No drag/drop payload"); return ox::Error(1, "No drag/drop payload");
} }
return ox::readClaw<T>({ return ox::readClaw<T>({
reinterpret_cast<char const*>(payload->Data), reinterpret_cast<char const*>(payload->Data),

View File

@ -31,7 +31,7 @@ enum class ProjectEvent {
constexpr ox::Result<ox::StringView> fileExt(ox::StringViewCR path) noexcept { constexpr ox::Result<ox::StringView> fileExt(ox::StringViewCR path) noexcept {
auto const extStart = ox::find(path.crbegin(), path.crend(), '.').offset(); auto const extStart = ox::find(path.crbegin(), path.crend(), '.').offset();
if (!extStart) { if (!extStart) {
return OxError(1, "file path does not have valid extension"); return ox::Error(1, "file path does not have valid extension");
} }
return substr(path, extStart + 1); return substr(path, extStart + 1);
} }

View File

@ -31,9 +31,9 @@ OX_ALLOW_UNSAFE_BUFFERS_END
return out; return out;
} }
case NFD_CANCEL: case NFD_CANCEL:
return OxError(1, "Operation cancelled"); return ox::Error(1, "Operation cancelled");
default: default:
return OxError(2, NFD::GetError()); return ox::Error(2, NFD::GetError());
} }
} }

View File

@ -44,7 +44,7 @@ Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDa
ox::Error Project::create() noexcept { ox::Error Project::create() noexcept {
std::error_code ec; std::error_code ec;
std::filesystem::create_directory(m_path.toStdString(), ec); std::filesystem::create_directory(m_path.toStdString(), ec);
return OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: mkdir failed"); return ox::Error(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: mkdir failed");
} }
ox::String const&Project::projectPath() const noexcept { ox::String const&Project::projectPath() const noexcept {
@ -62,7 +62,7 @@ ox::Error Project::mkdir(ox::StringViewCR path) const noexcept {
fileUpdated.emit(path, {}); fileUpdated.emit(path, {});
} }
return stat.fileType == ox::FileType::Directory ? return stat.fileType == ox::FileType::Directory ?
ox::Error{} : OxError(1, "path exists as normal file"); ox::Error{} : ox::Error(1, "path exists as normal file");
} }
ox::Result<ox::FileStat> Project::stat(ox::StringViewCR path) const noexcept { ox::Result<ox::FileStat> Project::stat(ox::StringViewCR path) const noexcept {

View File

@ -44,7 +44,7 @@ ox::Bounds getWindowBounds(Context&) noexcept {
} }
ox::Error setWindowBounds(Context&, ox::Bounds const&) noexcept { ox::Error setWindowBounds(Context&, ox::Bounds const&) noexcept {
return OxError(1, "setWindowBounds not supported on GBA"); return ox::Error(1, "setWindowBounds not supported on GBA");
} }
} }

View File

@ -55,7 +55,7 @@ OX_ALLOW_UNSAFE_BUFFERS_BEGIN
} }
} }
OX_ALLOW_UNSAFE_BUFFERS_END OX_ALLOW_UNSAFE_BUFFERS_END
return OxError(1); return ox::Error(1);
} }
ox::Result<ContextUPtr> init( ox::Result<ContextUPtr> init(

View File

@ -30,7 +30,7 @@ ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView t
if (ctx.clipboard && ctx.clipboard->typeId() == typeId) { if (ctx.clipboard && ctx.clipboard->typeId() == typeId) {
return ctx.clipboard.get(); return ctx.clipboard.get();
} }
return OxError(1); return ox::Error(1);
} }
} }

View File

@ -204,7 +204,7 @@ ox::Error initGfx(Context &ctx) noexcept {
ctx.window = glfwCreateWindow(240 * Scale, 160 * Scale, ctx.keelCtx.appName.c_str(), nullptr, nullptr); ctx.window = glfwCreateWindow(240 * Scale, 160 * Scale, ctx.keelCtx.appName.c_str(), nullptr, nullptr);
//ctx.window = glfwCreateWindow(876, 743, ctx.keelCtx.appName.c_str(), nullptr, nullptr); //ctx.window = glfwCreateWindow(876, 743, ctx.keelCtx.appName.c_str(), nullptr, nullptr);
if (ctx.window == nullptr) { if (ctx.window == nullptr) {
return OxError(1, "Could not open GLFW window"); return ox::Error(1, "Could not open GLFW window");
} }
glfwSetCursorPosCallback(ctx.window, handleGlfwCursorPosEvent); glfwSetCursorPosCallback(ctx.window, handleGlfwCursorPosEvent);
glfwSetMouseButtonCallback(ctx.window, handleGlfwMouseButtonEvent); glfwSetMouseButtonCallback(ctx.window, handleGlfwMouseButtonEvent);
@ -212,7 +212,7 @@ ox::Error initGfx(Context &ctx) noexcept {
glfwSetWindowUserPointer(ctx.window, &ctx); glfwSetWindowUserPointer(ctx.window, &ctx);
glfwMakeContextCurrent(ctx.window); glfwMakeContextCurrent(ctx.window);
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress))) { if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress))) {
return OxError(2, "Could not init Glad"); return ox::Error(2, "Could not init Glad");
} }
#if TURBINE_USE_IMGUI #if TURBINE_USE_IMGUI
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();