diff --git a/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp b/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp index 88b0f985..a22461a5 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp @@ -32,18 +32,18 @@ struct Sprite { unsigned priority = 0; }; -oxModelBegin(Sprite) - oxModelField(idx) - oxModelField(x) - oxModelField(y) - oxModelField(enabled) - oxModelField(tileIdx) - oxModelField(spriteShape) - oxModelField(spriteSize) - oxModelField(flipX) - oxModelField(bpp) - oxModelField(priority) -oxModelEnd() +OX_MODEL_BEGIN(Sprite) + OX_MODEL_FIELD(idx) + OX_MODEL_FIELD(x) + OX_MODEL_FIELD(y) + OX_MODEL_FIELD(enabled) + OX_MODEL_FIELD(tileIdx) + OX_MODEL_FIELD(spriteShape) + OX_MODEL_FIELD(spriteSize) + OX_MODEL_FIELD(flipX) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(priority) +OX_MODEL_END() struct BgTile { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.BgTile"; @@ -54,12 +54,12 @@ struct BgTile { unsigned flipY = false; }; -oxModelBegin(BgTile) - oxModelField(tileIdx) - oxModelField(palBank) - oxModelField(horizontalFlip) - oxModelField(verticalFlip) -oxModelEnd() +OX_MODEL_BEGIN(BgTile) + OX_MODEL_FIELD(tileIdx) + OX_MODEL_FIELD(palBank) + OX_MODEL_FIELD(horizontalFlip) + OX_MODEL_FIELD(verticalFlip) +OX_MODEL_END() struct TileSheetSetEntrySection { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntrySection"; @@ -72,10 +72,10 @@ struct TileSheetSetEntrySection { } }; -oxModelBegin(TileSheetSetEntrySection) - oxModelField(begin) - oxModelField(tiles) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetSetEntrySection) + OX_MODEL_FIELD(begin) + OX_MODEL_FIELD(tiles) +OX_MODEL_END() struct TileSheetSetEntry { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntry"; @@ -84,10 +84,10 @@ struct TileSheetSetEntry { ox::Vector sections; }; -oxModelBegin(TileSheetSetEntry) - oxModelField(tilesheet) - oxModelField(sections) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetSetEntry) + OX_MODEL_FIELD(tilesheet) + OX_MODEL_FIELD(sections) +OX_MODEL_END() struct TileSheetSet { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSet"; @@ -97,10 +97,10 @@ struct TileSheetSet { ox::Vector entries; }; -oxModelBegin(TileSheetSet) - oxModelField(bpp) - oxModelField(entries) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetSet) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(entries) +OX_MODEL_END() void addEntry(TileSheetSet &set, ox::FileAddress path, int32_t begin = 0, int32_t size = -1) noexcept; diff --git a/src/nostalgia/modules/core/include/nostalgia/core/palette.hpp b/src/nostalgia/modules/core/include/nostalgia/core/palette.hpp index 2550ba33..8da07c47 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/palette.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/palette.hpp @@ -26,12 +26,12 @@ struct PaletteColorV1 { constexpr operator Color16() const noexcept { return color16(r, g, b, a); } }; -oxModelBegin(PaletteColorV1) - oxModelField(r) - oxModelField(g) - oxModelField(b) - oxModelField(a) -oxModelEnd() +OX_MODEL_BEGIN(PaletteColorV1) + OX_MODEL_FIELD(r) + OX_MODEL_FIELD(g) + OX_MODEL_FIELD(b) + OX_MODEL_FIELD(a) +OX_MODEL_END() using PaletteColor = PaletteColorV1; @@ -53,10 +53,10 @@ struct PalettePageV1 { } }; -oxModelBegin(PalettePageV1) - oxModelField(name) - oxModelField(colors) -oxModelEnd() +OX_MODEL_BEGIN(PalettePageV1) + OX_MODEL_FIELD(name) + OX_MODEL_FIELD(colors) +OX_MODEL_END() using PalettePage = PalettePageV1; @@ -67,9 +67,9 @@ struct NostalgiaPalette { ox::Vector colors = {}; }; -oxModelBegin(NostalgiaPalette) - oxModelField(colors) -oxModelEnd() +OX_MODEL_BEGIN(NostalgiaPalette) + OX_MODEL_FIELD(colors) +OX_MODEL_END() struct PaletteV1 { @@ -78,9 +78,9 @@ struct PaletteV1 { ox::Vector colors; }; -oxModelBegin(PaletteV1) - oxModelField(colors) -oxModelEnd() +OX_MODEL_BEGIN(PaletteV1) + OX_MODEL_FIELD(colors) +OX_MODEL_END() struct PaletteV2 { @@ -90,9 +90,9 @@ struct PaletteV2 { ox::Vector> pages; }; -oxModelBegin(PaletteV2) - oxModelField(pages) -oxModelEnd() +OX_MODEL_BEGIN(PaletteV2) + OX_MODEL_FIELD(pages) +OX_MODEL_END() struct PaletteV3 { @@ -110,14 +110,14 @@ struct PaletteV3 { ox::Vector> pages; }; -oxModelBegin(PaletteV3::ColorInfo) - oxModelField(name) -oxModelEnd() +OX_MODEL_BEGIN(PaletteV3::ColorInfo) + OX_MODEL_FIELD(name) +OX_MODEL_END() -oxModelBegin(PaletteV3) - oxModelField(colorInfo) - oxModelField(pages) -oxModelEnd() +OX_MODEL_BEGIN(PaletteV3) + OX_MODEL_FIELD(colorInfo) + OX_MODEL_FIELD(pages) +OX_MODEL_END() [[nodiscard]] constexpr bool valid(PaletteV3 const&p) noexcept { @@ -144,10 +144,10 @@ struct PaletteV4 { ox::Vector pages; }; -oxModelBegin(PaletteV4) - oxModelField(colorNames) - oxModelField(pages) -oxModelEnd() +OX_MODEL_BEGIN(PaletteV4) + OX_MODEL_FIELD(colorNames) + OX_MODEL_FIELD(pages) +OX_MODEL_END() [[nodiscard]] constexpr bool valid(PaletteV4 const&p) noexcept { @@ -176,9 +176,9 @@ struct CompactPaletteV1 { ox::Vector> pages{}; }; -oxModelBegin(CompactPaletteV1) - oxModelField(pages) -oxModelEnd() +OX_MODEL_BEGIN(CompactPaletteV1) + OX_MODEL_FIELD(pages) +OX_MODEL_END() [[nodiscard]] constexpr bool valid(CompactPaletteV1 const&p) noexcept { diff --git a/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp b/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp index 235d7e1a..bbb7aca7 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/tilesheet.hpp @@ -437,65 +437,65 @@ ox::Pair get2Pixels8Bpp( CompactTileSheet const&ts, size_t idx) noexcept; -oxModelBegin(TileSheetV1) - oxModelField(bpp) - oxModelField(rows) - oxModelField(columns) - oxModelField(defaultPalette) - oxModelField(pal) - oxModelField(pixels) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV1) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(rows) + OX_MODEL_FIELD(columns) + OX_MODEL_FIELD(defaultPalette) + OX_MODEL_FIELD(pal) + OX_MODEL_FIELD(pixels) +OX_MODEL_END() -oxModelBegin(TileSheetV2::SubSheet) - oxModelField(name) - oxModelField(rows) - oxModelField(columns) - oxModelField(subsheets) - oxModelField(pixels) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV2::SubSheet) + OX_MODEL_FIELD(name) + OX_MODEL_FIELD(rows) + OX_MODEL_FIELD(columns) + OX_MODEL_FIELD(subsheets) + OX_MODEL_FIELD(pixels) +OX_MODEL_END() -oxModelBegin(TileSheetV2) - oxModelField(bpp) - oxModelField(defaultPalette) - oxModelField(subsheet) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV2) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(defaultPalette) + OX_MODEL_FIELD(subsheet) +OX_MODEL_END() -oxModelBegin(TileSheetV3::SubSheet) - oxModelField(name) - oxModelField(rows) - oxModelField(columns) - oxModelField(subsheets) - oxModelField(pixels) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV3::SubSheet) + OX_MODEL_FIELD(name) + OX_MODEL_FIELD(rows) + OX_MODEL_FIELD(columns) + OX_MODEL_FIELD(subsheets) + OX_MODEL_FIELD(pixels) +OX_MODEL_END() -oxModelBegin(TileSheetV3) - oxModelField(bpp) - oxModelField(idIt) - oxModelField(defaultPalette) - oxModelField(subsheet) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV3) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(idIt) + OX_MODEL_FIELD(defaultPalette) + OX_MODEL_FIELD(subsheet) +OX_MODEL_END() -oxModelBegin(TileSheetV4::SubSheet) - oxModelField(id) - oxModelField(name) - oxModelField(rows) - oxModelField(columns) - oxModelField(subsheets) - oxModelField(pixels) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV4::SubSheet) + OX_MODEL_FIELD(id) + OX_MODEL_FIELD(name) + OX_MODEL_FIELD(rows) + OX_MODEL_FIELD(columns) + OX_MODEL_FIELD(subsheets) + OX_MODEL_FIELD(pixels) +OX_MODEL_END() -oxModelBegin(TileSheetV4) - oxModelField(bpp) - oxModelField(idIt) - oxModelField(defaultPalette) - oxModelField(subsheet) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetV4) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(idIt) + OX_MODEL_FIELD(defaultPalette) + OX_MODEL_FIELD(subsheet) +OX_MODEL_END() -oxModelBegin(CompactTileSheetV1) - oxModelField(bpp) - oxModelField(defaultPalette) - oxModelField(pixels) -oxModelEnd() +OX_MODEL_BEGIN(CompactTileSheetV1) + OX_MODEL_FIELD(bpp) + OX_MODEL_FIELD(defaultPalette) + OX_MODEL_FIELD(pixels) +OX_MODEL_END() ox::Vector resizeTileSheetData( ox::Vector const&srcPixels, diff --git a/src/nostalgia/modules/core/src/gba/context.cpp b/src/nostalgia/modules/core/src/gba/context.cpp index 2d99f862..69f7c403 100644 --- a/src/nostalgia/modules/core/src/gba/context.cpp +++ b/src/nostalgia/modules/core/src/gba/context.cpp @@ -21,7 +21,7 @@ ox::Error initGfx(Context &ctx, InitParams const&) noexcept; ox::Result init(turbine::Context &tctx, InitParams const¶ms) noexcept { auto ctx = ox::make_unique(tctx); - oxReturnError(initGfx(*ctx, params)); + OX_RETURN_ERROR(initGfx(*ctx, params)); return ContextUPtr(std::move(ctx)); } diff --git a/src/nostalgia/modules/core/src/gba/gfx.cpp b/src/nostalgia/modules/core/src/gba/gfx.cpp index 8b34955b..de6084b5 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.cpp +++ b/src/nostalgia/modules/core/src/gba/gfx.cpp @@ -70,7 +70,7 @@ static ox::Error loadTileSheetSet( size_t tileWriteIdx = 0; size_t const bppMod = set.bpp == 4; for (auto const&entry : set.entries) { - oxRequire(ts, keel::readObj(keelCtx(ctx), entry.tilesheet)); + OX_REQUIRE(ts, keel::readObj(keelCtx(ctx), entry.tilesheet)); if (set.bpp != ts->bpp && ts->bpp == 8) { return ox::Error(1, "cannot load an 8 BPP tilesheet into a 4 BPP CBB"); } @@ -138,7 +138,7 @@ ox::Error loadBgTileSheet( } }); if (paletteBank.has_value() && ts.defaultPalette) { - oxReturnError(loadBgPalette(ctx, *paletteBank, ts.defaultPalette)); + OX_RETURN_ERROR(loadBgPalette(ctx, *paletteBank, ts.defaultPalette)); } return {}; } @@ -148,7 +148,7 @@ ox::Error loadBgTileSheet( unsigned const cbb, TileSheetSet const&set) noexcept { auto const bpp = static_cast(set.bpp); - oxReturnError(loadTileSheetSet(ctx, MEM_BG_TILES[cbb], set)); + OX_RETURN_ERROR(loadTileSheetSet(ctx, MEM_BG_TILES[cbb], set)); // update bpp of all bgs with the updated cbb ctx.cbbData[cbb].bpp = bpp; teagba::iterateBgCtl([bpp, cbb](volatile BgCtl &bgCtl) { @@ -178,7 +178,7 @@ ox::Error loadSpriteTileSheet( MEM_SPRITE_TILES[i] = v; } if (loadDefaultPalette && ts.defaultPalette) { - oxReturnError(loadSpritePalette(ctx, ts.defaultPalette)); + OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette)); } setSpritesBpp(static_cast(ts.bpp)); return {}; @@ -188,7 +188,7 @@ ox::Error loadSpriteTileSheet( Context &ctx, TileSheetSet const&set) noexcept { auto const bpp = static_cast(set.bpp); - oxReturnError(loadTileSheetSet(ctx, {MEM_SPRITE_TILES, 32 * ox::units::KB}, set)); + OX_RETURN_ERROR(loadTileSheetSet(ctx, {MEM_SPRITE_TILES, 32 * ox::units::KB}, set)); setSpritesBpp(bpp); return {}; } diff --git a/src/nostalgia/modules/core/src/gfx.cpp b/src/nostalgia/modules/core/src/gfx.cpp index c0ecf501..94f8eb6d 100644 --- a/src/nostalgia/modules/core/src/gfx.cpp +++ b/src/nostalgia/modules/core/src/gfx.cpp @@ -22,7 +22,7 @@ ox::Error loadBgPalette( Context &ctx, size_t palBank, ox::StringViewCR palettePath) noexcept { - oxRequire(pal, keel::readObj(keelCtx(ctx), palettePath)); + OX_REQUIRE(pal, keel::readObj(keelCtx(ctx), palettePath)); return loadBgPalette(ctx, palBank, *pal, 0); } @@ -30,21 +30,21 @@ ox::Error loadBgPalette( Context &ctx, size_t palBank, ox::FileAddress const&paletteAddr) noexcept { - oxRequire(pal, keel::readObj(keelCtx(ctx), paletteAddr)); + OX_REQUIRE(pal, keel::readObj(keelCtx(ctx), paletteAddr)); return loadBgPalette(ctx, palBank, *pal, 0); } ox::Error loadSpritePalette( Context &ctx, ox::StringViewCR palettePath) noexcept { - oxRequire(pal, keel::readObj(keelCtx(ctx), palettePath)); + OX_REQUIRE(pal, keel::readObj(keelCtx(ctx), palettePath)); return loadSpritePalette(ctx, *pal, 0); } ox::Error loadSpritePalette( Context &ctx, ox::FileAddress const&paletteAddr) noexcept { - oxRequire(pal, keel::readObj(keelCtx(ctx), paletteAddr)); + OX_REQUIRE(pal, keel::readObj(keelCtx(ctx), paletteAddr)); return loadSpritePalette(ctx, *pal, 0); } @@ -55,7 +55,7 @@ ox::Error loadBgTileSheet( size_t dstTileIdx, size_t srcTileIdx, size_t tileCnt) noexcept { - oxRequire(ts, keel::readObj(keelCtx(ctx), tsAddr)); + OX_REQUIRE(ts, keel::readObj(keelCtx(ctx), tsAddr)); return loadBgTileSheet(ctx, cbb, *ts, dstTileIdx, srcTileIdx, tileCnt); } @@ -66,7 +66,7 @@ ox::Error loadBgTileSheet( size_t dstTileIdx, size_t srcTileIdx, size_t tileCnt) noexcept { - oxRequire(ts, keel::readObj(keelCtx(ctx), tsPath)); + OX_REQUIRE(ts, keel::readObj(keelCtx(ctx), tsPath)); return loadBgTileSheet(ctx, cbb, *ts, dstTileIdx, srcTileIdx, tileCnt); } @@ -75,7 +75,7 @@ ox::Error loadBgTileSheet( unsigned cbb, ox::StringViewCR tilesheetPath, ox::Optional const&paletteBank) noexcept { - oxRequire(ts, keel::readObj(keelCtx(ctx), tilesheetPath)); + OX_REQUIRE(ts, keel::readObj(keelCtx(ctx), tilesheetPath)); return loadBgTileSheet(ctx, cbb, *ts, paletteBank); } @@ -84,7 +84,7 @@ ox::Error loadBgTileSheet( unsigned cbb, ox::FileAddress const&tilesheetAddr, ox::Optional const&paletteBank) noexcept { - oxRequire(ts, keel::readObj(keelCtx(ctx), tilesheetAddr)); + OX_REQUIRE(ts, keel::readObj(keelCtx(ctx), tilesheetAddr)); return loadBgTileSheet(ctx, cbb, *ts, paletteBank); } @@ -92,7 +92,7 @@ ox::Error loadSpriteTileSheet( Context &ctx, ox::StringViewCR tilesheetPath, bool loadDefaultPalette) noexcept { - oxRequire(ts, readObj(keelCtx(ctx), tilesheetPath)); + OX_REQUIRE(ts, readObj(keelCtx(ctx), tilesheetPath)); return loadSpriteTileSheet(ctx, *ts, loadDefaultPalette); } @@ -100,7 +100,7 @@ ox::Error loadSpriteTileSheet( Context &ctx, ox::FileAddress const&tilesheetAddr, bool loadDefaultPalette) noexcept { - oxRequire(ts, readObj(keelCtx(ctx), tilesheetAddr)); + OX_REQUIRE(ts, readObj(keelCtx(ctx), tilesheetAddr)); return loadSpriteTileSheet(ctx, *ts, loadDefaultPalette); } @@ -247,7 +247,7 @@ ox::Error initConsole(Context &ctx) noexcept { constexpr ox::FileAddress PaletteAddr = ox::StringLiteral("/Palettes/Charset.npal"); setBgStatus(ctx, 0b0001); setBgCbb(ctx, 0, 0); - oxReturnError(loadBgTileSheet(ctx, 0, TilesheetAddr)); + OX_RETURN_ERROR(loadBgTileSheet(ctx, 0, TilesheetAddr)); return loadBgPalette(ctx, 0, PaletteAddr); } diff --git a/src/nostalgia/modules/core/src/keel/keelmodule.cpp b/src/nostalgia/modules/core/src/keel/keelmodule.cpp index 91fc3fcc..d67b7836 100644 --- a/src/nostalgia/modules/core/src/keel/keelmodule.cpp +++ b/src/nostalgia/modules/core/src/keel/keelmodule.cpp @@ -72,7 +72,7 @@ static class: public keel::Module { typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v) { - oxReturnError(keel::convertBuffToBuff( + OX_RETURN_ERROR(keel::convertBuffToBuff( ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); return true; } @@ -84,7 +84,7 @@ static class: public keel::Module { typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v || typeId == ox::ModelTypeId_v) { - oxReturnError(keel::convertBuffToBuff( + OX_RETURN_ERROR(keel::convertBuffToBuff( ctx, buff, ox::ClawFormat::Metal).moveTo(buff)); return true; } diff --git a/src/nostalgia/modules/core/src/opengl/context.cpp b/src/nostalgia/modules/core/src/opengl/context.cpp index 8f410300..9d0cbc6a 100644 --- a/src/nostalgia/modules/core/src/opengl/context.cpp +++ b/src/nostalgia/modules/core/src/opengl/context.cpp @@ -25,7 +25,7 @@ Context::~Context() noexcept { ox::Result init(turbine::Context &tctx, InitParams const¶ms) noexcept { auto ctx = ox::make_unique(tctx, params); - oxReturnError(initGfx(*ctx, params)); + OX_RETURN_ERROR(initGfx(*ctx, params)); return ContextUPtr(ctx.release()); } diff --git a/src/nostalgia/modules/core/src/opengl/gfx.cpp b/src/nostalgia/modules/core/src/opengl/gfx.cpp index 044754c3..e8bbba21 100644 --- a/src/nostalgia/modules/core/src/opengl/gfx.cpp +++ b/src/nostalgia/modules/core/src/opengl/gfx.cpp @@ -464,8 +464,8 @@ ox::Error initGfx( const auto bgFshad = ox::sfmt(renderer::bgfshadTmpl, gl::GlslVersion); const auto spriteVshad = ox::sfmt(renderer::spritevshadTmpl, gl::GlslVersion); const auto spriteFshad = ox::sfmt(renderer::spritefshadTmpl, gl::GlslVersion); - oxReturnError(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx.bgShader)); - oxReturnError( + OX_RETURN_ERROR(glutils::buildShaderProgram(bgVshad, bgFshad).moveTo(ctx.bgShader)); + OX_RETURN_ERROR( glutils::buildShaderProgram(spriteVshad, spriteFshad).moveTo(ctx.spriteShader)); for (auto &cbb : ctx.cbbs) { initBackgroundBufferset(ctx.bgShader, cbb); @@ -538,8 +538,8 @@ static ox::Result buildSetTsd( TileSheetData setTsd; setTsd.width = TileWidth; for (auto const&entry : set.entries) { - oxRequire(tilesheet, readObj(kctx, entry.tilesheet)); - oxRequire(tsd, normalizeTileSheet(*tilesheet)); + OX_REQUIRE(tilesheet, readObj(kctx, entry.tilesheet)); + OX_REQUIRE(tsd, normalizeTileSheet(*tilesheet)); for (auto const&s : entry.sections) { auto const size = s.tiles * PixelsPerTile; for (auto i = 0; i < size; ++i) { @@ -604,9 +604,9 @@ ox::Error loadBgTileSheet( ox::Optional const&paletteBank) noexcept { auto const bytesPerTile = static_cast(PixelsPerTile / (1 + (ts.bpp == 4))); auto const tiles = ts.pixels.size() / bytesPerTile; - oxReturnError(loadBgTileSheet(ctx, cbb, ts, 0, 0, tiles)); + OX_RETURN_ERROR(loadBgTileSheet(ctx, cbb, ts, 0, 0, tiles)); if (paletteBank.has_value() && ts.defaultPalette) { - oxReturnError(loadBgPalette(ctx, *paletteBank, ts.defaultPalette)); + OX_RETURN_ERROR(loadBgPalette(ctx, *paletteBank, ts.defaultPalette)); } return {}; } @@ -615,7 +615,7 @@ ox::Error loadBgTileSheet( Context &ctx, unsigned cbb, TileSheetSet const&set) noexcept { - oxRequire(setTsd, buildSetTsd(ctx, set)); + OX_REQUIRE(setTsd, buildSetTsd(ctx, set)); ctx.cbbs[cbb].tex = renderer::createTexture(setTsd.width, setTsd.height, setTsd.pixels.data()); return {}; } @@ -624,11 +624,11 @@ ox::Error loadSpriteTileSheet( Context &ctx, CompactTileSheet const&ts, bool loadDefaultPalette) noexcept { - oxRequire(tsd, normalizeTileSheet(ts)); + OX_REQUIRE(tsd, normalizeTileSheet(ts)); oxTracef("nostalgia.core.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height); ctx.spriteBlocks.tex = renderer::createTexture(tsd.width, tsd.height, tsd.pixels.data()); if (loadDefaultPalette) { - oxReturnError(loadSpritePalette(ctx, ts.defaultPalette)); + OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette)); } return {}; } @@ -636,7 +636,7 @@ ox::Error loadSpriteTileSheet( ox::Error loadSpriteTileSheet( Context &ctx, TileSheetSet const&set) noexcept { - oxRequire(setTsd, buildSetTsd(ctx, set)); + OX_REQUIRE(setTsd, buildSetTsd(ctx, set)); ctx.spriteBlocks.tex = renderer::createTexture(setTsd.width, setTsd.height, setTsd.pixels.data()); return {}; } diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor/commands/addcolorcommand.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor/commands/addcolorcommand.cpp index c93313d6..b92f3721 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor/commands/addcolorcommand.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor/commands/addcolorcommand.cpp @@ -25,9 +25,9 @@ ox::Error AddColorCommand::redo() noexcept { } ox::Error AddColorCommand::undo() noexcept { - oxReturnError(m_pal.colorNames.erase(m_idx)); + OX_RETURN_ERROR(m_pal.colorNames.erase(m_idx)); for (auto &page : m_pal.pages) { - oxReturnError(page.colors.erase(m_idx)); + OX_RETURN_ERROR(page.colors.erase(m_idx)); } return {}; } diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor/commands/removecolorcommand.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor/commands/removecolorcommand.cpp index 7cd03f72..d3c16053 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor/commands/removecolorcommand.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor/commands/removecolorcommand.cpp @@ -25,9 +25,9 @@ int RemoveColorCommand::commandId() const noexcept { ox::Error RemoveColorCommand::redo() noexcept { m_colorInfo = std::move(m_pal.colorNames[m_idx]); - oxReturnError(m_pal.colorNames.erase(m_idx)); + OX_RETURN_ERROR(m_pal.colorNames.erase(m_idx)); for (auto &page : m_pal.pages) { - oxReturnError(page.colors.erase(m_idx)); + OX_RETURN_ERROR(page.colors.erase(m_idx)); } return {}; } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/addsubsheetcommand.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/addsubsheetcommand.cpp index 8aa99f17..1e1b024f 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/addsubsheetcommand.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/addsubsheetcommand.cpp @@ -49,7 +49,7 @@ ox::Error AddSubSheetCommand::undo() noexcept { --m_img.idIt; } else { for (auto idx = m_addedSheets.rbegin(); idx != m_addedSheets.rend(); ++idx) { - oxReturnError(rmSubSheet(m_img, *idx)); + OX_RETURN_ERROR(rmSubSheet(m_img, *idx)); --m_img.idIt; } } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/cutpastecommand.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/cutpastecommand.hpp index 6df44640..d6f648d5 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/cutpastecommand.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/cutpastecommand.hpp @@ -10,14 +10,14 @@ namespace nostalgia::core { -oxModelFwdDecl(class TileSheetClipboard); +OX_MODEL_FWD_DECL(class TileSheetClipboard); class TileSheetClipboard: public turbine::ClipboardObject { public: static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard"; static constexpr auto TypeVersion = 1; - oxModelFriend(TileSheetClipboard); + OX_MODEL_FRIEND(TileSheetClipboard); struct Pixel { static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard.Pixel"; @@ -36,14 +36,14 @@ class TileSheetClipboard: public turbine::ClipboardObject { ox::Vector const&pixels() const noexcept; }; -oxModelBegin(TileSheetClipboard::Pixel) - oxModelField(colorIdx) - oxModelField(pt) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetClipboard::Pixel) + OX_MODEL_FIELD(colorIdx) + OX_MODEL_FIELD(pt) +OX_MODEL_END() -oxModelBegin(TileSheetClipboard) - oxModelFieldRename(m_pixels, pixels) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetClipboard) + OX_MODEL_FIELD_RENAME(m_pixels, pixels) +OX_MODEL_END() class CutPasteCommand: public TileSheetCommand { private: diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/rmsubsheetcommand.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/rmsubsheetcommand.cpp index 4ea13a2d..5b8108f0 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/rmsubsheetcommand.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/commands/rmsubsheetcommand.cpp @@ -16,7 +16,7 @@ core::RmSubSheetCommand::RmSubSheetCommand(TileSheet &img, TileSheet::SubSheetId ox::Error RmSubSheetCommand::redo() noexcept { auto &parent = getSubSheet(m_img, m_parentIdx); m_sheet = std::move(parent.subsheets[*m_idx.back().value]); - oxReturnError(parent.subsheets.erase(*m_idx.back().value).error); + OX_RETURN_ERROR(parent.subsheets.erase(*m_idx.back().value).error); return {}; } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index 7abdf648..4f781f99 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -21,9 +21,9 @@ struct TileSheetEditorConfig { TileSheet::SubSheetIdx activeSubsheet{}; }; -oxModelBegin(TileSheetEditorConfig) - oxModelFieldRename(activeSubsheet, active_subsheet) -oxModelEnd() +OX_MODEL_BEGIN(TileSheetEditorConfig) + OX_MODEL_FIELD_RENAME(activeSubsheet, active_subsheet) +OX_MODEL_END() static ox::Vector normalizePixelSizes( ox::Vector const&inPixels, @@ -346,7 +346,7 @@ void TileSheetEditorImGui::showSubsheetEditor() noexcept { } ox::Error TileSheetEditorImGui::exportSubhseetToPng(int const scale) const noexcept { - oxRequire(path, studio::saveFile({{"PNG", "png"}})); + OX_REQUIRE(path, studio::saveFile({{"PNG", "png"}})); // subsheet to png auto const&img = m_model.img(); auto const&s = m_model.activeSubSheet(); diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp index c16e51a8..bfef4a27 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp @@ -132,7 +132,7 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept { } ox::Error TileSheetEditorModel::setPalette(ox::StringView path) noexcept { - oxRequire(uuid, keelCtx(m_tctx).pathToUuid.at(path)); + OX_REQUIRE(uuid, keelCtx(m_tctx).pathToUuid.at(path)); pushCommand(ox::make(activeSubSheetIdx(), m_img, uuid->toString())); return {}; } @@ -250,7 +250,7 @@ ox::Error TileSheetEditorModel::markUpdatedCmdId(studio::UndoCommand const*cmd) m_updated = true; const auto cmdId = cmd->commandId(); if (static_cast(cmdId) == CommandId::PaletteChange) { - oxReturnError(readObj(keelCtx(m_tctx), m_img.defaultPalette).moveTo(m_pal)); + OX_RETURN_ERROR(readObj(keelCtx(m_tctx), m_img.defaultPalette).moveTo(m_pal)); m_palettePage = ox::min(m_pal->pages.size(), 0); paletteChanged.emit(); } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp index 8ebd53f1..7b1c3188 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditorview.cpp @@ -16,8 +16,8 @@ TileSheetEditorView::TileSheetEditorView(studio::StudioContext &sctx, ox::String m_pixelsDrawer(m_model) { glBindVertexArray(0); // build shaders - oxThrowError(m_pixelsDrawer.buildShader()); - oxThrowError(m_pixelGridDrawer.buildShader()); + OX_THROW_ERROR(m_pixelsDrawer.buildShader()); + OX_THROW_ERROR(m_pixelGridDrawer.buildShader()); m_model.activeSubsheetChanged.connect(this, &TileSheetEditorView::setActiveSubsheet); } diff --git a/src/nostalgia/modules/core/src/tilesheet.cpp b/src/nostalgia/modules/core/src/tilesheet.cpp index b8993292..6a113935 100644 --- a/src/nostalgia/modules/core/src/tilesheet.cpp +++ b/src/nostalgia/modules/core/src/tilesheet.cpp @@ -162,7 +162,7 @@ unsigned pixelCnt(TileSheet::SubSheet const&ss, int8_t pBpp) noexcept { ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const&sz) noexcept { ox::Vector out; - oxReturnError(setPixelCount(out, pBpp, static_cast(sz.width * sz.height) * PixelsPerTile)); + OX_RETURN_ERROR(setPixelCount(out, pBpp, static_cast(sz.width * sz.height) * PixelsPerTile)); auto const w = ox::min(ss.columns, sz.width) * TileWidth; auto const h = ox::min(ss.rows, sz.height) * TileHeight; for (auto x = 0; x < w; ++x) { diff --git a/src/nostalgia/modules/core/test/tests.cpp b/src/nostalgia/modules/core/test/tests.cpp index 48b2825e..1d468125 100644 --- a/src/nostalgia/modules/core/test/tests.cpp +++ b/src/nostalgia/modules/core/test/tests.cpp @@ -16,8 +16,8 @@ static std::map tests = { "readWriteTileSheet", []() -> ox::Error { core::TileSheet in; - oxRequire(buff, ox::writeMC(in)); - oxRequire(out, ox::readMC(buff)); + OX_REQUIRE(buff, ox::writeMC(in)); + OX_REQUIRE(out, ox::readMC(buff)); oxAssert(in.subsheet.name == out.subsheet.name, "subsheet.name serialization broken"); return {}; } diff --git a/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp b/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp index 709a0ab4..3cc9825a 100644 --- a/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp +++ b/src/nostalgia/modules/scene/include/nostalgia/scene/scenestatic.hpp @@ -57,12 +57,12 @@ struct TileDoc { }; -oxModelBegin(TileDoc) - oxModelFieldRename(subsheetId, subsheet_id) - oxModelFieldRename(subsheetPath, subsheet_path) - oxModelField(type) - oxModelFieldRename(layerAttachments, layer_attachments) -oxModelEnd() +OX_MODEL_BEGIN(TileDoc) + OX_MODEL_FIELD_RENAME(subsheetId, subsheet_id) + OX_MODEL_FIELD_RENAME(subsheetPath, subsheet_path) + OX_MODEL_FIELD(type) + OX_MODEL_FIELD_RENAME(layerAttachments, layer_attachments) +OX_MODEL_END() struct SceneDoc { @@ -95,11 +95,11 @@ struct SceneDoc { } }; -oxModelBegin(SceneDoc) - oxModelField(tilesheet) - oxModelField(palettes) - oxModelField(tiles) -oxModelEnd() +OX_MODEL_BEGIN(SceneDoc) + OX_MODEL_FIELD(tilesheet) + OX_MODEL_FIELD(palettes) + OX_MODEL_FIELD(tiles) +OX_MODEL_END() constexpr void setTopEdge(uint8_t &layerAttachments, unsigned val) noexcept { @@ -215,14 +215,14 @@ struct SceneStatic { }; -oxModelBegin(SceneStatic) - oxModelField(tilesheet) - oxModelField(palettes) - oxModelField(columns) - oxModelField(rows) - oxModelField(tileMapIdx) - oxModelField(tileType) - oxModelField(layerAttachments) -oxModelEnd() +OX_MODEL_BEGIN(SceneStatic) + OX_MODEL_FIELD(tilesheet) + OX_MODEL_FIELD(palettes) + OX_MODEL_FIELD(columns) + OX_MODEL_FIELD(rows) + OX_MODEL_FIELD(tileMapIdx) + OX_MODEL_FIELD(tileType) + OX_MODEL_FIELD(layerAttachments) +OX_MODEL_END() } diff --git a/src/nostalgia/modules/scene/src/keel/typeconv.cpp b/src/nostalgia/modules/scene/src/keel/typeconv.cpp index ac1e4d11..ede20690 100644 --- a/src/nostalgia/modules/scene/src/keel/typeconv.cpp +++ b/src/nostalgia/modules/scene/src/keel/typeconv.cpp @@ -37,7 +37,7 @@ ox::Error SceneDocToSceneStaticConverter::convert( keel::Context &ctx, SceneDoc &src, SceneStatic &dst) const noexcept { - oxRequire(ts, keel::readObj(ctx, src.tilesheet)); + OX_REQUIRE(ts, keel::readObj(ctx, src.tilesheet)); const auto layerCnt = src.tiles.size(); dst.setLayerCnt(layerCnt); dst.tilesheet = ox::FileAddress(src.tilesheet); @@ -53,8 +53,8 @@ ox::Error SceneDocToSceneStaticConverter::convert( for (const auto &srcTile : row) { auto dstTile = dstLayer.tile(tileIdx); dstTile.tileType = srcTile.type; - oxRequire(path, srcTile.getSubsheetPath(*ts)); - oxRequire(mapIdx, getTileOffset(*ts, path)); + OX_REQUIRE(path, srcTile.getSubsheetPath(*ts)); + OX_REQUIRE(mapIdx, getTileOffset(*ts, path)); dstTile.tileMapIdx = static_cast(mapIdx); setLayerAttachments(layerIdx, srcTile, dstTile); ++tileIdx; diff --git a/src/nostalgia/modules/scene/src/scene.cpp b/src/nostalgia/modules/scene/src/scene.cpp index 2f4ba0db..aa08f354 100644 --- a/src/nostalgia/modules/scene/src/scene.cpp +++ b/src/nostalgia/modules/scene/src/scene.cpp @@ -17,8 +17,8 @@ ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept { return ox::Error(1, "Scene has no palettes"); } auto const&palette = m_sceneStatic.palettes[0]; - oxReturnError(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet)); - oxReturnError(core::loadBgPalette(ctx, 0, palette)); + OX_RETURN_ERROR(core::loadBgTileSheet(ctx, 0, m_sceneStatic.tilesheet)); + OX_RETURN_ERROR(core::loadBgPalette(ctx, 0, palette)); // disable all backgrounds core::setBgStatus(ctx, 0); for (auto layerNo = 0u; auto const&layer : m_sceneStatic.tileMapIdx) { diff --git a/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp b/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp index 4a457c3e..b7891a89 100644 --- a/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp +++ b/src/nostalgia/modules/scene/src/studio/sceneeditor-imgui.cpp @@ -48,7 +48,7 @@ void SceneEditorImGui::onActivated() noexcept { ox::Error SceneEditorImGui::saveItem() noexcept { const auto sctx = applicationData(m_ctx); - oxReturnError(sctx->project->writeObj(itemPath(), m_editor.scene())); + OX_RETURN_ERROR(sctx->project->writeObj(itemPath(), m_editor.scene())); return {}; } diff --git a/src/olympic/keel/include/keel/asset.hpp b/src/olympic/keel/include/keel/asset.hpp index 7639a37a..a3d5da7a 100644 --- a/src/olympic/keel/include/keel/asset.hpp +++ b/src/olympic/keel/include/keel/asset.hpp @@ -16,8 +16,8 @@ constexpr auto K1HdrSz = 40; ox::Result readUuidHeader(ox::BufferView buff) noexcept; ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexcept { - oxReturnError(write(writer, "K1;")); - oxReturnError(uuid.toString(writer)); + OX_RETURN_ERROR(write(writer, "K1;")); + OX_RETURN_ERROR(uuid.toString(writer)); return writer.put(';'); } @@ -29,8 +29,8 @@ ox::Result readAsset(ox::BufferView buff) noexcept { offset = K1HdrSz; // the size of K1 headers } auto out = ox::readClaw(buff + offset); - oxReturnError(out); - oxReturnError(ensureValid(out.value)); + OX_RETURN_ERROR(out); + OX_RETURN_ERROR(ensureValid(out.value)); return out; } diff --git a/src/olympic/keel/include/keel/assetmanager.hpp b/src/olympic/keel/include/keel/assetmanager.hpp index 8632dd82..a857879d 100644 --- a/src/olympic/keel/include/keel/assetmanager.hpp +++ b/src/olympic/keel/include/keel/assetmanager.hpp @@ -205,7 +205,7 @@ class AssetManager { AssetTypeManager(Loader loader) noexcept: m_loader(loader) {} ox::Result> getAsset(ox::StringView const assetId) const noexcept { - oxRequire(out, m_cache.at(assetId)); + OX_REQUIRE(out, m_cache.at(assetId)); if (!out || !*out) { return ox::Error(1, "asset is null"); } @@ -214,7 +214,7 @@ class AssetManager { ox::Result> loadAsset(ox::StringView const assetId) noexcept { auto &p = m_cache[assetId]; - oxRequireM(obj, m_loader(assetId)); + OX_REQUIRE_M(obj, m_loader(assetId)); if (!p) { p = ox::make_unique>(std::move(obj)); } else { @@ -226,7 +226,7 @@ class AssetManager { ox::Error reloadAsset(ox::StringView const assetId) noexcept { auto &p = m_cache[assetId]; - oxRequireM(obj, m_loader(assetId)); + OX_REQUIRE_M(obj, m_loader(assetId)); if (!p) { p = ox::make_unique>(std::move(obj)); } else { @@ -274,7 +274,7 @@ class AssetManager { template ox::Result> getAsset(ox::StringView assetId) noexcept { - oxRequire(m, getTypeManager()); + OX_REQUIRE(m, getTypeManager()); return m->getAsset(assetId); } @@ -285,8 +285,8 @@ class AssetManager { template ox::Result> loadAsset(ox::StringView assetId) noexcept { - oxRequire(m, getTypeManager()); - oxRequire(out, m->loadAsset(assetId)); + OX_REQUIRE(m, getTypeManager()); + OX_REQUIRE(out, m->loadAsset(assetId)); m_fileUpdated[assetId].connect(m, &AssetTypeManager::reloadAsset); return out; } diff --git a/src/olympic/keel/include/keel/media.hpp b/src/olympic/keel/include/keel/media.hpp index 5f1b227e..6d6a7be0 100644 --- a/src/olympic/keel/include/keel/media.hpp +++ b/src/olympic/keel/include/keel/media.hpp @@ -25,9 +25,9 @@ struct PreloadPtr { uint64_t preloadAddr = 0; }; -oxModelBegin(PreloadPtr) - oxModelField(preloadAddr) -oxModelEnd() +OX_MODEL_BEGIN(PreloadPtr) + OX_MODEL_FIELD(preloadAddr) +OX_MODEL_END() ox::Result getPreloadAddr(keel::Context &ctx, ox::FileAddress const&addr) noexcept; ox::Result getPreloadAddr(keel::Context &ctx, ox::StringViewCR path) noexcept; @@ -63,14 +63,14 @@ namespace detail { template constexpr auto makeLoader(Context &ctx) { return [&ctx](ox::StringView assetId) -> ox::Result { - oxRequire(p, ctx.uuidToPath.at(assetId)); - oxRequire(buff, ctx.rom->read(*p)); + OX_REQUIRE(p, ctx.uuidToPath.at(assetId)); + OX_REQUIRE(buff, ctx.rom->read(*p)); auto [obj, err] = readAsset(buff); if (err) { if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) { return err; } - oxReturnError(convert(ctx, buff, &obj)); + OX_RETURN_ERROR(convert(ctx, buff, &obj)); } return std::move(obj); }; @@ -97,7 +97,7 @@ ox::Result> readObjFile( auto [cached, err] = ctx.assetManager.getAsset(assetId); if (err) { ctx.assetManager.initTypeManager(detail::makeLoader, ctx); - oxReturnError(ctx.assetManager.loadAsset(assetId).moveTo(cached)); + OX_RETURN_ERROR(ctx.assetManager.loadAsset(assetId).moveTo(cached)); } return cached; } @@ -110,7 +110,7 @@ ox::Result> readObjNoCache( keel::Context &ctx, ox::StringViewCR assetId) noexcept { if constexpr(ox::preloadable::value) { - oxRequire(addr, getPreloadAddr(ctx, assetId)); + OX_REQUIRE(addr, getPreloadAddr(ctx, assetId)); return keel::AssetRef(std::bit_cast(uintptr_t{addr})); } else { return ox::Error(1); @@ -139,11 +139,11 @@ ox::Result> readObj( ox::FileAddress const&file, [[maybe_unused]] bool forceLoad = false) noexcept { #ifndef OX_BARE_METAL - oxRequire(assetId, file.getPath()); + OX_REQUIRE(assetId, file.getPath()); return readObj(ctx, ox::StringView(assetId), forceLoad); #else if constexpr(ox::preloadable::value) { - oxRequire(addr, getPreloadAddr(ctx, file)); + OX_REQUIRE(addr, getPreloadAddr(ctx, file)); return keel::AssetRef(std::bit_cast(uintptr_t{addr})); } else { return ox::Error(1); @@ -157,7 +157,7 @@ ox::Error writeObj( ox::FileAddress const&file, T const&obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept { - oxRequire(objBuff, ox::writeClaw(obj, fmt)); + OX_REQUIRE(objBuff, ox::writeClaw(obj, fmt)); return ctx.rom->write(file, objBuff.data(), objBuff.size()); } diff --git a/src/olympic/keel/include/keel/pack.hpp b/src/olympic/keel/include/keel/pack.hpp index 532b4ef6..658bad6e 100644 --- a/src/olympic/keel/include/keel/pack.hpp +++ b/src/olympic/keel/include/keel/pack.hpp @@ -20,11 +20,11 @@ struct ManifestEntry { ox::String type; }; -oxModelBegin(ManifestEntry) - oxModelField(inode) - oxModelField(preloaded) - oxModelField(type) -oxModelEnd() +OX_MODEL_BEGIN(ManifestEntry) + OX_MODEL_FIELD(inode) + OX_MODEL_FIELD(preloaded) + OX_MODEL_FIELD(type) +OX_MODEL_END() struct Manifest { static constexpr auto TypeName = "net.drinkingtea.keel.Manifest"; @@ -32,9 +32,9 @@ struct Manifest { ox::HashMap files; }; -oxModelBegin(Manifest) - oxModelField(files) -oxModelEnd() +OX_MODEL_BEGIN(Manifest) + OX_MODEL_FIELD(files) +OX_MODEL_END() class Context; @@ -113,24 +113,24 @@ ox::Error preloadObj( ox::Preloader &pl, ox::StringView const path) noexcept { // load file - oxRequireM(buff, romFs.read(path)); - oxRequireM(obj, keel::readAsset(ts, buff)); + OX_REQUIRE_M(buff, romFs.read(path)); + OX_REQUIRE_M(obj, keel::readAsset(ts, buff)); if (obj.type()->preloadable) { // preload auto const size = ox::sizeOf(&obj); auto const alignment = ox::alignOf(obj); - oxRequire(a, pl.startAlloc(size, alignment)); + OX_REQUIRE(a, pl.startAlloc(size, alignment)); auto const err = ox::preload(&pl, &obj); - oxReturnError(pl.endAlloc()); - oxReturnError(err); + OX_RETURN_ERROR(pl.endAlloc()); + OX_RETURN_ERROR(err); keel::PreloadPtr const p{.preloadAddr = a}; - oxReturnError(ox::writeMC(p).moveTo(buff)); + OX_RETURN_ERROR(ox::writeMC(p).moveTo(buff)); oxOutf("preloaded {} as a {} @ {} to {}\n", path, obj.type()->typeName, a, a + size); } else { // strip the Claw header (it is not needed after preloading) and write back out to dest fs - oxReturnError(ox::writeMC(obj).moveTo(buff)); + OX_RETURN_ERROR(ox::writeMC(obj).moveTo(buff)); } - oxReturnError(romFs.write(path, buff.data(), buff.size())); + OX_RETURN_ERROR(romFs.write(path, buff.data(), buff.size())); return {}; } @@ -145,13 +145,13 @@ ox::Error preloadDir( ox::StringViewCR path) noexcept { // copy oxTracef("pack.preload", "path: {}", path); - oxRequire(fileList, romFs.ls(path)); + OX_REQUIRE(fileList, romFs.ls(path)); for (auto const&name : fileList) { auto const filePath = ox::sfmt("{}{}", path, name); - oxRequire(stat, romFs.stat(filePath)); + OX_REQUIRE(stat, romFs.stat(filePath)); if (stat.fileType == ox::FileType::Directory) { auto const dir = ox::sfmt("{}{}/", path, name); - oxReturnError(preloadDir(manifest, ts, romFs, pl, dir)); + OX_RETURN_ERROR(preloadDir(manifest, ts, romFs, pl, dir)); } else { auto const err = preloadObj(ts, romFs, pl, filePath); if (err) { @@ -177,14 +177,14 @@ ox::Error appendBinary(ox::Buffer &binBuff, ox::SpanView const&fsBuff, ox: static_assert(mediaHdr.bytes() == hdrSize); static_assert(preloadHdr.bytes() == hdrSize); ox::BufferWriter w(&binBuff); - oxReturnError(padbin(w, hdrSize)); - oxReturnError(w.write(mediaHdr.data(), mediaHdr.bytes())); - oxReturnError(w.write(fsBuff.data(), fsBuff.size())); - oxReturnError(padbin(w, hdrSize)); - oxReturnError(w.write(preloadHdr.data(), preloadHdr.bytes())); - oxReturnError(pl.offsetPtrs(binBuff.size())); + OX_RETURN_ERROR(padbin(w, hdrSize)); + OX_RETURN_ERROR(w.write(mediaHdr.data(), mediaHdr.bytes())); + OX_RETURN_ERROR(w.write(fsBuff.data(), fsBuff.size())); + OX_RETURN_ERROR(padbin(w, hdrSize)); + OX_RETURN_ERROR(w.write(preloadHdr.data(), preloadHdr.bytes())); + OX_RETURN_ERROR(pl.offsetPtrs(binBuff.size())); auto const&plBuff = pl.buff(); - oxReturnError(w.write(plBuff.data(), plBuff.size())); + OX_RETURN_ERROR(w.write(plBuff.data(), plBuff.size())); return {}; } diff --git a/src/olympic/keel/include/keel/typeconv.hpp b/src/olympic/keel/include/keel/typeconv.hpp index 5d72f359..d4dde272 100644 --- a/src/olympic/keel/include/keel/typeconv.hpp +++ b/src/olympic/keel/include/keel/typeconv.hpp @@ -110,15 +110,15 @@ class Converter: public BaseConverter { ox::Result> convertPtrToPtr( keel::Context &ctx, Wrap &src) const noexcept final { auto dst = makeWrap(); - oxReturnError(convert(ctx, wrapCast(src), wrapCast(*dst))); + OX_RETURN_ERROR(convert(ctx, wrapCast(src), wrapCast(*dst))); return {std::move(dst)}; } ox::Result> convertBuffToPtr( keel::Context &ctx, ox::BufferView const&srcBuff) const noexcept final { - oxRequireM(src, readAsset(srcBuff)); + OX_REQUIRE_M(src, readAsset(srcBuff)); auto dst = makeWrap(); - oxReturnError(convert(ctx, src, wrapCast(*dst))); + OX_RETURN_ERROR(convert(ctx, src, wrapCast(*dst))); return {std::move(dst)}; } @@ -137,7 +137,7 @@ template ox::Result convert(keel::Context &ctx, ox::BufferView const&srcBuffer) noexcept { static constexpr auto DstTypeName = ox::requireModelTypeName(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion(); - oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); + OX_REQUIRE(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); return std::move(wrapCast(out)); } @@ -145,7 +145,7 @@ template ox::Error convert(keel::Context &ctx, ox::BufferView const&buff, DstType *outObj) noexcept { static constexpr auto DstTypeName = ox::requireModelTypeName(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion(); - oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion)); + OX_REQUIRE(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion)); *outObj = std::move(wrapCast(*outPtr)); return {}; } @@ -155,14 +155,14 @@ ox::Result convertBuffToBuff( keel::Context &ctx, ox::BufferView const&srcBuffer, ox::ClawFormat fmt) noexcept { static constexpr auto DstTypeName = ox::requireModelTypeName(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion(); - oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); + OX_REQUIRE(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); return ox::writeClaw(wrapCast(*out), fmt); } template ox::Result transformRule(keel::Context &ctx, ox::Buffer &buff, ox::StringView typeId) noexcept { if (typeId == ox::ModelTypeId_v) { - oxReturnError(keel::convertBuffToBuff(ctx, buff, fmt).moveTo(buff)); + OX_RETURN_ERROR(keel::convertBuffToBuff(ctx, buff, fmt).moveTo(buff)); return true; } return false; diff --git a/src/olympic/keel/src/asset.cpp b/src/olympic/keel/src/asset.cpp index c2dca0ea..b24ab975 100644 --- a/src/olympic/keel/src/asset.cpp +++ b/src/olympic/keel/src/asset.cpp @@ -43,7 +43,7 @@ ox::Result readAssetHeader(ox::BufferView buff) noexcept { return ox::Error(1, "Buffer too small for expected data"); } buff += offset; - oxReturnError(ox::readClawHeader(buff).moveTo(out.value.clawHdr)); + OX_RETURN_ERROR(ox::readClawHeader(buff).moveTo(out.value.clawHdr)); return out; } diff --git a/src/olympic/keel/src/keel.cpp b/src/olympic/keel/src/keel.cpp index 39f78e98..dbaf50a8 100644 --- a/src/olympic/keel/src/keel.cpp +++ b/src/olympic/keel/src/keel.cpp @@ -30,7 +30,7 @@ ox::Error init( ox::Result> init(ox::UPtr &&fs, ox::StringViewCR appName) noexcept { auto ctx = ox::make_unique(); - oxReturnError(keel::init(*ctx, std::move(fs), appName)); + OX_RETURN_ERROR(keel::init(*ctx, std::move(fs), appName)); return ctx; } diff --git a/src/olympic/keel/src/media.cpp b/src/olympic/keel/src/media.cpp index ab05f088..714a6fde 100644 --- a/src/olympic/keel/src/media.cpp +++ b/src/olympic/keel/src/media.cpp @@ -48,19 +48,19 @@ void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uui } static ox::Error buildUuidMap(Context &ctx, ox::StringViewCR path) noexcept { - oxRequire(files, ctx.rom->ls(path)); + OX_REQUIRE(files, ctx.rom->ls(path)); for (auto const&f : files) { - oxRequireM(filePath, ox::join("/", ox::Array{path, f})); - oxRequire(stat, ctx.rom->stat(filePath)); + OX_REQUIRE_M(filePath, ox::join("/", ox::Array{path, f})); + OX_REQUIRE(stat, ctx.rom->stat(filePath)); if (stat.fileType == ox::FileType::NormalFile) { - oxRequire(data, ctx.rom->read(filePath)); + OX_REQUIRE(data, ctx.rom->read(filePath)); auto const [hdr, err] = readAssetHeader(data); if (!err) { createUuidMapping(ctx, filePath, hdr.uuid); } } else if (stat.fileType == ox::FileType::Directory) { if (!beginsWith(f, ".")) { - oxReturnError(buildUuidMap(ctx, filePath)); + OX_RETURN_ERROR(buildUuidMap(ctx, filePath)); } } } @@ -76,7 +76,7 @@ ox::Error buildUuidMap(Context &ctx) noexcept { ox::Result pathToUuid(Context &ctx, ox::StringViewCR path) noexcept { #ifndef OX_BARE_METAL - oxRequire(out, ctx.pathToUuid.at(path)); + OX_REQUIRE(out, ctx.pathToUuid.at(path)); return *out; #else return ox::Error(1, "UUID to path conversion not supported on this platform"); @@ -84,7 +84,7 @@ ox::Result pathToUuid(Context &ctx, ox::StringViewCR path) noexcept { } ox::Result getUuid(Context &ctx, ox::FileAddress const&fileAddr) noexcept { - oxRequire(path, fileAddr.getPath()); + OX_REQUIRE(path, fileAddr.getPath()); return getUuid(ctx, path); } @@ -98,11 +98,11 @@ ox::Result getUuid(Context &ctx, ox::StringView path) noexcept { } ox::Result getPath(Context &ctx, ox::FileAddress const&fileAddr) noexcept { - oxRequire(path, fileAddr.getPath()); + OX_REQUIRE(path, fileAddr.getPath()); if (beginsWith(path, "uuid://")) { auto const uuid = substr(path, 7); #ifndef OX_BARE_METAL - oxRequireM(out, ctx.uuidToPath.at(uuid)); + OX_REQUIRE_M(out, ctx.uuidToPath.at(uuid)); return ox::CStringView{*out}; #else return ox::Error(1, "UUID to path conversion not supported on this platform"); @@ -116,7 +116,7 @@ ox::Result getPath(Context &ctx, ox::CStringView fileId) noexce if (beginsWith(fileId, "uuid://")) { auto const uuid = substr(fileId, 7); #ifndef OX_BARE_METAL - oxRequireM(out, ctx.uuidToPath.at(uuid)); + OX_REQUIRE_M(out, ctx.uuidToPath.at(uuid)); return ox::CStringView{*out}; #else return ox::Error(1, "UUID to path conversion not supported on this platform"); @@ -129,7 +129,7 @@ ox::Result getPath(Context &ctx, ox::CStringView fileId) noexce ox::Result uuidUrlToPath(Context &ctx, ox::StringView uuid) noexcept { uuid = substr(uuid, 7); #ifndef OX_BARE_METAL - oxRequireM(out, ctx.uuidToPath.at(uuid)); + OX_REQUIRE_M(out, ctx.uuidToPath.at(uuid)); return ox::CStringView(*out); #else return ox::Error(1, "UUID to path conversion not supported on this platform"); @@ -138,7 +138,7 @@ ox::Result uuidUrlToPath(Context &ctx, ox::StringView uuid) noe ox::Result uuidToPath(Context &ctx, ox::StringViewCR uuid) noexcept { #ifndef OX_BARE_METAL - oxRequireM(out, ctx.uuidToPath.at(uuid)); + OX_REQUIRE_M(out, ctx.uuidToPath.at(uuid)); return ox::CStringView(*out); #else return ox::Error(1, "UUID to path conversion not supported on this platform"); @@ -147,7 +147,7 @@ ox::Result uuidToPath(Context &ctx, ox::StringViewCR uuid) noex ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept { #ifndef OX_BARE_METAL - oxRequireM(out, ctx.uuidToPath.at(uuid.toString())); + OX_REQUIRE_M(out, ctx.uuidToPath.at(uuid.toString())); return ox::CStringView(*out); #else return ox::Error(1, "UUID to path conversion not supported on this platform"); @@ -158,7 +158,7 @@ ox::Error reloadAsset(keel::Context &ctx, ox::StringView assetId) noexcept { ox::UUIDStr uuidStr; if (beginsWith(assetId, "uuid://")) { assetId = substr(assetId, 7); - oxRequire(p, keel::uuidToPath(ctx, assetId)); + OX_REQUIRE(p, keel::uuidToPath(ctx, assetId)); } else { auto const [uuid, uuidErr] = getUuid(ctx, assetId); if (!uuidErr) { @@ -207,18 +207,18 @@ void unloadRom(char*) noexcept { } ox::Result getPreloadAddr(keel::Context &ctx, ox::StringViewCR path) noexcept { - oxRequire(stat, ctx.rom->stat(path)); - oxRequire(buff, static_cast(*ctx.rom).directAccess(path)); + OX_REQUIRE(stat, ctx.rom->stat(path)); + OX_REQUIRE(buff, static_cast(*ctx.rom).directAccess(path)); PreloadPtr p; - oxReturnError(ox::readMC({buff, static_cast(stat.size)}, p)); + OX_RETURN_ERROR(ox::readMC({buff, static_cast(stat.size)}, p)); return static_cast(p.preloadAddr) + ctx.preloadSectionOffset; } ox::Result getPreloadAddr(keel::Context &ctx, ox::FileAddress const&addr) noexcept { - oxRequire(stat, ctx.rom->stat(addr)); - oxRequire(buff, static_cast(*ctx.rom).directAccess(addr)); + OX_REQUIRE(stat, ctx.rom->stat(addr)); + OX_REQUIRE(buff, static_cast(*ctx.rom).directAccess(addr)); PreloadPtr p; - oxReturnError(ox::readMC({buff, static_cast(stat.size)}, p)); + OX_RETURN_ERROR(ox::readMC({buff, static_cast(stat.size)}, p)); return static_cast(p.preloadAddr) + ctx.preloadSectionOffset; } @@ -241,7 +241,7 @@ ox::Error setRomFs(Context &ctx, ox::UPtr &&fs) noexcept { ox::Result> loadRomFs(ox::StringViewCR path) noexcept { auto const lastDot = ox::lastIndexOf(path, '.'); if (!lastDot.error && substr(path, lastDot.value) == ".oxfs") { - oxRequire(rom, loadRom(path)); + OX_REQUIRE(rom, loadRom(path)); return {ox::make_unique(rom, 32 * ox::units::MB, unloadRom)}; } else { #ifdef OX_HAS_PASSTHROUGHFS diff --git a/src/olympic/keel/src/pack-applib.cpp b/src/olympic/keel/src/pack-applib.cpp index dc3bd74e..59e9aa70 100644 --- a/src/olympic/keel/src/pack-applib.cpp +++ b/src/olympic/keel/src/pack-applib.cpp @@ -43,7 +43,7 @@ static ox::Result readFileBuff(ox::StringView path) noexcept { static ox::Error generateTypes(ox::TypeStore &ts) noexcept { for (auto const mod : keel::modules()) { for (auto gen : mod->types()) { - oxReturnError(gen(ts)); + OX_RETURN_ERROR(gen(ts)); } } return {}; @@ -55,29 +55,29 @@ static ox::Error pack( ox::StringView argManifest, ox::StringView projectDataDir) noexcept { ox::Buffer dstBuff(32 * ox::units::MB); - oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); + OX_RETURN_ERROR(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); ox::FileSystem32 dst(dstBuff); - oxRequire(ctx, keel::init(ox::make_unique(argSrc), "keel-pack")); + OX_REQUIRE(ctx, keel::init(ox::make_unique(argSrc), "keel-pack")); keel::TypeStore ts(*ctx->rom, ox::sfmt("{}/type_descriptors", projectDataDir)); - oxReturnError(generateTypes(ts)); + OX_RETURN_ERROR(generateTypes(ts)); keel::Manifest manifest; - oxReturnError(keel::pack(manifest, *ctx, ts, dst)); - oxRequireM(pl, keel::GbaPreloader::make()); - oxReturnError(preload(manifest, ts, dst, *pl)); - oxReturnError(dst.resize()); + OX_RETURN_ERROR(keel::pack(manifest, *ctx, ts, dst)); + OX_REQUIRE_M(pl, keel::GbaPreloader::make()); + OX_RETURN_ERROR(preload(manifest, ts, dst, *pl)); + OX_RETURN_ERROR(dst.resize()); // resize buffer - oxRequire(dstSize, dst.size()); + OX_REQUIRE(dstSize, dst.size()); dstBuff.resize(dstSize); // concatenate ROM segments - oxRequireM(romBuff, readFileBuff(argRomBin)); + OX_REQUIRE_M(romBuff, readFileBuff(argRomBin)); oxOutf("Input exe size: {} bytes\n", romBuff.size()); oxOutf("Dest FS size: {} bytes\n", dstSize); oxOutf("Preload buff size: {} bytes\n", pl->buff().size()); - oxReturnError(appendBinary(romBuff, dstBuff, *pl)); + OX_RETURN_ERROR(appendBinary(romBuff, dstBuff, *pl)); oxOutf("Final ROM buff size: {} bytes\n", romBuff.size()); - oxReturnError(writeFileBuff(argRomBin, romBuff)); - oxRequire(manifestJson, ox::writeOCString(manifest)); - oxReturnError(writeFileBuff(argManifest, {manifestJson.data(), manifestJson.len()})); + OX_RETURN_ERROR(writeFileBuff(argRomBin, romBuff)); + OX_REQUIRE(manifestJson, ox::writeOCString(manifest)); + OX_RETURN_ERROR(writeFileBuff(argManifest, {manifestJson.data(), manifestJson.len()})); return {}; } diff --git a/src/olympic/keel/src/pack.cpp b/src/olympic/keel/src/pack.cpp index 3810f166..87144168 100644 --- a/src/olympic/keel/src/pack.cpp +++ b/src/olympic/keel/src/pack.cpp @@ -15,19 +15,19 @@ static ox::Error pathToInode( ox::FileSystem &dest, ox::ModelObject &obj) noexcept { auto &o = obj; - oxRequire(typeVal, o.at("type")); + OX_REQUIRE(typeVal, o.at("type")); auto const type = static_cast(typeVal->get()); - oxRequire(dataVal, o.at("data")); + OX_REQUIRE(dataVal, o.at("data")); auto &data = dataVal->get(); ox::String path; switch (type) { case ox::FileAddressType::Path: { - oxRequire(pathVal, data.at("path")); + OX_REQUIRE(pathVal, data.at("path")); path = pathVal->get(); break; } case ox::FileAddressType::ConstPath: { - oxRequire(pathVal, data.at("constPath")); + OX_REQUIRE(pathVal, data.at("constPath")); path = pathVal->get(); break; } @@ -37,10 +37,10 @@ static ox::Error pathToInode( } if (beginsWith(path, "uuid://")) { auto const uuid = ox::substr(path, 7); - oxReturnError(keel::uuidToPath(ctx, uuid).to().moveTo(path)); + OX_RETURN_ERROR(keel::uuidToPath(ctx, uuid).to().moveTo(path)); } - oxRequire(s, dest.stat(path)); - oxReturnError(typeVal->set(static_cast(ox::FileAddressType::Inode))); + OX_REQUIRE(s, dest.stat(path)); + OX_RETURN_ERROR(typeVal->set(static_cast(ox::FileAddressType::Inode))); oxOutf("\tpath to inode: {} => {}\n", path, s.inode); return data.set(2, s.inode); } @@ -69,7 +69,7 @@ static ox::Error transformFileAddressesVec( ox::FileSystem &dest, ox::ModelValueVector &v) noexcept { for (auto &f : v) { - oxReturnError(transformFileAddresses(ctx, dest, f)); + OX_RETURN_ERROR(transformFileAddresses(ctx, dest, f)); } return {}; } @@ -87,7 +87,7 @@ static ox::Error transformFileAddressesObj( } for (auto &f : obj) { auto &v = f->value; - oxReturnError(transformFileAddresses(ctx, dest, v)); + OX_RETURN_ERROR(transformFileAddresses(ctx, dest, v)); } return {}; } @@ -96,12 +96,12 @@ static ox::Error performPackTransforms( ManifestEntry &entry, Context &ctx, ox::Buffer &clawData) noexcept { - oxRequireM(typeId, readAssetTypeId(clawData)); + OX_REQUIRE_M(typeId, readAssetTypeId(clawData)); for (auto const tr : packTransforms(ctx)) { bool changed{}; - oxReturnError(tr(ctx, clawData, typeId).moveTo(changed)); + OX_RETURN_ERROR(tr(ctx, clawData, typeId).moveTo(changed)); if (changed) { - oxReturnError(readAssetTypeId(clawData).moveTo(typeId)); + OX_RETURN_ERROR(readAssetTypeId(clawData).moveTo(typeId)); } } entry.type = ox::String{typeId}; @@ -115,17 +115,17 @@ static ox::Error doTransformations( ox::FileSystem &dest, ox::StringViewCR filePath) noexcept { // load file - oxRequire(s, dest.stat(filePath)); + OX_REQUIRE(s, dest.stat(filePath)); // do transformations - oxRequireM(buff, dest.read(s.inode)); - oxReturnError(keel::performPackTransforms(manifest.files[filePath], ctx, buff)); + OX_REQUIRE_M(buff, dest.read(s.inode)); + OX_RETURN_ERROR(keel::performPackTransforms(manifest.files[filePath], ctx, buff)); // transform FileAddresses - oxRequireM(obj, keel::readAsset(ts, buff)); + OX_REQUIRE_M(obj, keel::readAsset(ts, buff)); oxOutf("transforming {}\n", filePath); - oxReturnError(transformFileAddressesObj(ctx, dest, obj)); - oxReturnError(ox::writeClaw(obj).moveTo(buff)); + OX_RETURN_ERROR(transformFileAddressesObj(ctx, dest, obj)); + OX_RETURN_ERROR(ox::writeClaw(obj).moveTo(buff)); // write file to dest - oxReturnError(dest.write(s.inode, buff)); + OX_RETURN_ERROR(dest.write(s.inode, buff)); return {}; } @@ -139,13 +139,13 @@ static ox::Error transformClaw( ox::StringViewCR path) noexcept { // copy oxTracef("pack.transformClaw", "path: {}", path); - oxRequire(fileList, dest.ls(path)); + OX_REQUIRE(fileList, dest.ls(path)); for (auto const&name : fileList) { auto const filePath = ox::sfmt("{}{}", path, name); - oxRequire(stat, dest.stat(filePath)); + OX_REQUIRE(stat, dest.stat(filePath)); if (stat.fileType == ox::FileType::Directory) { auto const dir = ox::sfmt("{}{}/", path, name); - oxReturnError(transformClaw(manifest, ctx, ts, dest, dir)); + OX_RETURN_ERROR(transformClaw(manifest, ctx, ts, dest, dir)); } else { auto const err = doTransformations(manifest, ctx, ts, dest, filePath); if (err) { @@ -166,28 +166,28 @@ static ox::Error copy( oxOutf("{}copying directory: {}\n", logPrefix, path); auto const childLogPrefix = ox::sfmt("{}\t", logPrefix); // copy - oxRequire(fileList, src.ls(path)); + OX_REQUIRE(fileList, src.ls(path)); for (auto const&name : fileList) { auto const currentFile = ox::sfmt("{}{}", path, name); if (beginsWith(name, ".")) { continue; } - oxRequire(srcStat, src.stat(currentFile)); + OX_REQUIRE(srcStat, src.stat(currentFile)); if (srcStat.fileType == ox::FileType::Directory) { - oxReturnError(dest.mkdir(currentFile, true)); - oxReturnError(copy(manifest, src, dest, currentFile + '/', childLogPrefix)); + OX_RETURN_ERROR(dest.mkdir(currentFile, true)); + OX_RETURN_ERROR(copy(manifest, src, dest, currentFile + '/', childLogPrefix)); } else { // load file oxOutf("{}copying file: {}...", childLogPrefix, currentFile); ox::StringView status = "failed"; - oxDefer [&status] { + OX_DEFER [&status] { oxOutf(" {}\n", status); }; - oxRequireM(buff, src.read(currentFile)); + OX_REQUIRE_M(buff, src.read(currentFile)); // write file to dest - oxReturnError(dest.write(currentFile, buff)); + OX_RETURN_ERROR(dest.write(currentFile, buff)); status = "OK"; - oxRequire(dstStat, dest.stat(currentFile)); + OX_REQUIRE(dstStat, dest.stat(currentFile)); manifest.files[currentFile] = { .inode = dstStat.inode, .type = ox::String{keel::readAssetTypeId(buff).or_value({})}, @@ -202,9 +202,9 @@ ox::Error pack( keel::Context &ctx, ox::TypeStore &ts, ox::FileSystem &dest) noexcept { - oxReturnError(copy(manifest, *ctx.rom, dest, "/")); + OX_RETURN_ERROR(copy(manifest, *ctx.rom, dest, "/")); oxOut("Doing transforms\n"); - oxReturnError(transformClaw(manifest, ctx, ts, dest, "/")); + OX_RETURN_ERROR(transformClaw(manifest, ctx, ts, dest, "/")); return {}; } diff --git a/src/olympic/keel/src/typeconv.cpp b/src/olympic/keel/src/typeconv.cpp index 561e9e53..cd6ff7fe 100644 --- a/src/olympic/keel/src/typeconv.cpp +++ b/src/olympic/keel/src/typeconv.cpp @@ -55,7 +55,7 @@ ox::Result> convert( ox::BufferView const&srcBuffer, ox::StringViewCR dstTypeName, int dstTypeVersion) noexcept { - oxRequire(hdr, readAssetHeader(srcBuffer)); + OX_REQUIRE(hdr, readAssetHeader(srcBuffer)); return convert( ctx, converters(ctx), diff --git a/src/olympic/keel/src/typestore.cpp b/src/olympic/keel/src/typestore.cpp index b5a79c74..f1714004 100644 --- a/src/olympic/keel/src/typestore.cpp +++ b/src/olympic/keel/src/typestore.cpp @@ -13,9 +13,9 @@ TypeStore::TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept: ox::Result> TypeStore::loadDescriptor(ox::StringView const typeId) noexcept { auto const path = ox::sfmt("{}/{}", m_descPath, typeId); - oxRequire(buff, m_fs.read(path)); + OX_REQUIRE(buff, m_fs.read(path)); auto dt = ox::make_unique(); - oxReturnError(ox::readClaw(buff, *dt)); + OX_RETURN_ERROR(ox::readClaw(buff, *dt)); return dt; } diff --git a/src/olympic/keel/test/tests.cpp b/src/olympic/keel/test/tests.cpp index f6768a36..c3ee316b 100644 --- a/src/olympic/keel/test/tests.cpp +++ b/src/olympic/keel/test/tests.cpp @@ -15,10 +15,10 @@ static std::map tests = { []() -> ox::Error { constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db"; constexpr ox::StringView hdr = "K1;8d814442-f46e-4cc3-8edc-ca3c01cc86db;"; - oxRequire(uuid, ox::UUID::fromString(uuidStr)); + OX_REQUIRE(uuid, ox::UUID::fromString(uuidStr)); ox::Array buff; ox::CharBuffWriter bw(buff); - oxReturnError(keel::writeUuidHeader(bw, uuid)); + OX_RETURN_ERROR(keel::writeUuidHeader(bw, uuid)); oxExpect(ox::StringView(buff.data(), buff.size()), hdr); return {}; } diff --git a/src/olympic/studio/applib/src/main.cpp b/src/olympic/studio/applib/src/main.cpp index 8479d824..6b229ce8 100644 --- a/src/olympic/studio/applib/src/main.cpp +++ b/src/olympic/studio/applib/src/main.cpp @@ -37,7 +37,7 @@ static ox::Error runApp( ox::StringViewCR appName, ox::StringViewCR projectDataDir, ox::UPtr &&fs) noexcept { - oxRequireM(ctx, turbine::init(std::move(fs), appName)); + OX_REQUIRE_M(ctx, turbine::init(std::move(fs), appName)); turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName); turbine::setKeyEventHandler(*ctx, keyEventHandler); turbine::setRefreshWithin(*ctx, 0); diff --git a/src/olympic/studio/applib/src/projectexplorer.cpp b/src/olympic/studio/applib/src/projectexplorer.cpp index 042dee5f..76ed4dc5 100644 --- a/src/olympic/studio/applib/src/projectexplorer.cpp +++ b/src/olympic/studio/applib/src/projectexplorer.cpp @@ -16,16 +16,16 @@ static ox::Result> buildProjectTreeModel( ox::StringView path, ProjectTreeModel *parent) noexcept { auto const fs = explorer.romFs(); - oxRequire(stat, fs->stat(path)); + OX_REQUIRE(stat, fs->stat(path)); auto out = ox::make_unique(explorer, ox::String(name), parent); if (stat.fileType == ox::FileType::Directory) { - oxRequireM(children, fs->ls(path)); + OX_REQUIRE_M(children, fs->ls(path)); std::sort(children.begin(), children.end()); ox::Vector> outChildren; for (auto const&childName : children) { if (childName[0] != '.') { auto const childPath = ox::sfmt("{}/{}", path, childName); - oxRequireM(child, buildProjectTreeModel(explorer, childName, childPath, out.get())); + OX_REQUIRE_M(child, buildProjectTreeModel(explorer, childName, childPath, out.get())); outChildren.emplace_back(std::move(child)); } } @@ -52,7 +52,7 @@ void ProjectExplorer::setModel(ox::UPtr &&model) noexcept { } ox::Error ProjectExplorer::refreshProjectTreeModel(ox::StringViewCR) noexcept { - oxRequireM(model, buildProjectTreeModel(*this, "Project", "/", nullptr)); + OX_REQUIRE_M(model, buildProjectTreeModel(*this, "Project", "/", nullptr)); setModel(std::move(model)); return ox::Error(0); } diff --git a/src/olympic/studio/applib/src/studioapp.cpp b/src/olympic/studio/applib/src/studioapp.cpp index 83decdc0..466518ed 100644 --- a/src/olympic/studio/applib/src/studioapp.cpp +++ b/src/olympic/studio/applib/src/studioapp.cpp @@ -36,12 +36,12 @@ struct StudioConfig { bool showProjectExplorer = true; }; -oxModelBegin(StudioConfig) - oxModelFieldRename(activeTabItemName, active_tab_item_name) - oxModelFieldRename(projectPath, project_path) - oxModelFieldRename(openFiles, open_files) - oxModelFieldRename(showProjectExplorer, show_project_explorer) -oxModelEnd() +OX_MODEL_BEGIN(StudioConfig) + OX_MODEL_FIELD_RENAME(activeTabItemName, active_tab_item_name) + OX_MODEL_FIELD_RENAME(projectPath, project_path) + OX_MODEL_FIELD_RENAME(openFiles, open_files) + OX_MODEL_FIELD_RENAME(showProjectExplorer, show_project_explorer) +OX_MODEL_END() StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept: m_sctx(*this, ctx), @@ -222,7 +222,7 @@ void StudioUI::drawTabs() noexcept { m_activeEditor = nullptr; } try { - oxThrowError(m_editors.erase(it).moveTo(it)); + OX_THROW_ERROR(m_editors.erase(it).moveTo(it)); } catch (ox::Exception const&ex) { oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line); } catch (std::exception const&ex) { @@ -323,15 +323,15 @@ void StudioUI::handleKeyInput() noexcept { ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept { std::error_code ec; std::filesystem::create_directories(toStdStringView(path), ec); - oxReturnError(ox::Error(ec.value() != 0, "Could not create project directory")); - oxReturnError(openProjectPath(path)); + OX_RETURN_ERROR(ox::Error(ec.value() != 0, "Could not create project directory")); + OX_RETURN_ERROR(openProjectPath(path)); return m_project->writeTypeStore(); } ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept { - oxRequireM(fs, keel::loadRomFs(path.view())); - oxReturnError(keel::setRomFs(keelCtx(m_ctx), std::move(fs))); - oxReturnError( + OX_REQUIRE_M(fs, keel::loadRomFs(path.view())); + OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_ctx), std::move(fs))); + OX_RETURN_ERROR( ox::make_unique_catch(keelCtx(m_ctx), std::move(path), m_projectDataDir) .moveTo(m_project)); auto const sctx = applicationData(m_ctx); @@ -366,7 +366,7 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) } return {}; } - oxRequire(ext, studio::fileExt(path)); + OX_REQUIRE(ext, studio::fileExt(path)); // create Editor BaseEditor *editor = nullptr; auto const err = m_editorMakers.contains(ext) ? diff --git a/src/olympic/studio/modlib/include/studio/configio.hpp b/src/olympic/studio/modlib/include/studio/configio.hpp index 0d101931..edf4dd8d 100644 --- a/src/olympic/studio/modlib/include/studio/configio.hpp +++ b/src/olympic/studio/modlib/include/studio/configio.hpp @@ -60,7 +60,7 @@ ox::Error writeConfig(keel::Context &ctx, ox::StringViewCR name, T const&data) n //oxErrf("Could not create config directory: {} - {}\n", path, toStr(err)); return err; } - oxRequireM(buff, ox::writeOC(data)); + OX_REQUIRE_M(buff, ox::writeOC(data)); *buff.back().value = '\n'; if (auto const err = fs.write(path, buff.data(), buff.size())) { //oxErrf("Could not read config file: {} - {}\n", path, toStr(err)); diff --git a/src/olympic/studio/modlib/include/studio/imguiutil.hpp b/src/olympic/studio/modlib/include/studio/imguiutil.hpp index 7fca3280..00f0ad9e 100644 --- a/src/olympic/studio/modlib/include/studio/imguiutil.hpp +++ b/src/olympic/studio/modlib/include/studio/imguiutil.hpp @@ -35,7 +35,7 @@ ox::Result getDragDropPayload(ox::CStringViewCR name) noexcept { } ox::Error setDragDropPayload(ox::CStringViewCR name, auto const&obj) noexcept { - oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal)); + OX_REQUIRE(buff, ox::writeClaw(obj, ox::ClawFormat::Metal)); ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size()); return {}; } @@ -223,7 +223,7 @@ bool ListBox( * @param selIdx * @return true if new value selected, false otherwise */ -bool ListBox(ox::CStringViewCR name, ox::Span const&list, size_t &selIdx) noexcept; +bool ListBox(ox::CStringViewCR name, ox::SpanView const&list, size_t &selIdx) noexcept; class FilePicker { private: diff --git a/src/olympic/studio/modlib/include/studio/itemmaker.hpp b/src/olympic/studio/modlib/include/studio/itemmaker.hpp index d386bfb2..e1647bec 100644 --- a/src/olympic/studio/modlib/include/studio/itemmaker.hpp +++ b/src/olympic/studio/modlib/include/studio/itemmaker.hpp @@ -79,7 +79,7 @@ class ItemMakerT: public ItemMaker { ox::Result write(studio::StudioContext &sctx, ox::StringView const pName) const noexcept override { auto const path = itemPath(pName); createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap()); - oxReturnError(sctx.project->writeObj(path, m_item, m_fmt)); + OX_RETURN_ERROR(sctx.project->writeObj(path, m_item, m_fmt)); return path; } }; diff --git a/src/olympic/studio/modlib/include/studio/project.hpp b/src/olympic/studio/modlib/include/studio/project.hpp index a13ec6a0..f2f88fbc 100644 --- a/src/olympic/studio/modlib/include/studio/project.hpp +++ b/src/olympic/studio/modlib/include/studio/project.hpp @@ -130,39 +130,39 @@ class Project { template ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat fmt) noexcept { - oxRequireM(buff, ox::writeClaw(obj, fmt)); + OX_REQUIRE_M(buff, ox::writeClaw(obj, fmt)); if (fmt == ox::ClawFormat::Organic) { buff.pop_back(); } // write to FS - oxReturnError(mkdir(parentDir(path))); - oxReturnError(writeBuff(path, buff)); + OX_RETURN_ERROR(mkdir(parentDir(path))); + OX_RETURN_ERROR(writeBuff(path, buff)); // write type descriptor if (m_typeStore.get().error) { - oxReturnError(ox::buildTypeDef(m_typeStore, obj)); + OX_RETURN_ERROR(ox::buildTypeDef(m_typeStore, obj)); } - oxRequire(desc, m_typeStore.get()); + OX_REQUIRE(desc, m_typeStore.get()); auto const descPath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*desc)); auto const descExists = m_fs.exists(descPath); if (!descExists) { - oxReturnError(writeTypeStore()); + OX_RETURN_ERROR(writeTypeStore()); } - oxReturnError(keel::reloadAsset(m_ctx, path)); - oxRequire(uuid, pathToUuid(m_ctx, path)); + OX_RETURN_ERROR(keel::reloadAsset(m_ctx, path)); + OX_REQUIRE(uuid, pathToUuid(m_ctx, path)); fileUpdated.emit(path, uuid); return {}; } template ox::Error Project::writeObj(ox::StringViewCR path, T const&obj) noexcept { - oxRequire(ext, fileExt(path)); + OX_REQUIRE(ext, fileExt(path)); auto const fmt = m_typeFmt[ext].or_value(ox::ClawFormat::Metal); return writeObj(path, obj, fmt); } template ox::Result Project::loadObj(ox::StringViewCR path) const noexcept { - oxRequire(buff, loadBuff(path)); + OX_REQUIRE(buff, loadBuff(path)); if constexpr(ox::is_same_v) { return keel::readAsset(m_typeStore, buff); } else { @@ -180,7 +180,7 @@ ox::Error Project::subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&s break; case ProjectEvent::FileRecognized: { - oxRequire(files, listFiles()); + OX_REQUIRE(files, listFiles()); for (auto const&f : files) { slot(f); } diff --git a/src/olympic/studio/modlib/include/studio/selectiontracker.hpp b/src/olympic/studio/modlib/include/studio/selectiontracker.hpp index e77d0abd..53f2d5f9 100644 --- a/src/olympic/studio/modlib/include/studio/selectiontracker.hpp +++ b/src/olympic/studio/modlib/include/studio/selectiontracker.hpp @@ -33,7 +33,7 @@ constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) { for (auto x = sel.a.x; x <= sel.b.x; ++x) { for (auto y = sel.a.y; y <= sel.b.y; ++y) { if constexpr(retErr) { - oxReturnError(cb(x, y)); + OX_RETURN_ERROR(cb(x, y)); } else { cb(x, y); } @@ -49,7 +49,7 @@ constexpr auto iterateSelectionRows(studio::Selection const&sel, auto const&cb) for (auto y = sel.a.y; y <= sel.b.y; ++y) { for (auto x = sel.a.x; x <= sel.b.x; ++x) { if constexpr(retErr) { - oxReturnError(cb(x, y)); + OX_RETURN_ERROR(cb(x, y)); } else { cb(x, y); } diff --git a/src/olympic/studio/modlib/src/imguiutil.cpp b/src/olympic/studio/modlib/src/imguiutil.cpp index 7a1f9fa1..b24fab7e 100644 --- a/src/olympic/studio/modlib/src/imguiutil.cpp +++ b/src/olympic/studio/modlib/src/imguiutil.cpp @@ -155,7 +155,7 @@ bool ListBox( return out; } -bool ListBox(ox::CStringViewCR name, ox::Span const&list, size_t &selIdx) noexcept { +bool ListBox(ox::CStringViewCR name, ox::SpanView const&list, size_t &selIdx) noexcept { return ListBox(name, [list](size_t i) -> ox::CStringView { return list[i]; }, list.size(), selIdx); diff --git a/src/olympic/studio/modlib/src/project.cpp b/src/olympic/studio/modlib/src/project.cpp index 65b1585e..15525c33 100644 --- a/src/olympic/studio/modlib/src/project.cpp +++ b/src/olympic/studio/modlib/src/project.cpp @@ -36,7 +36,7 @@ Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDa oxTracef("studio", "Project: {}", m_path); generateTypes(m_typeStore); if (ox::defines::Debug) { - oxThrowError(writeTypeStore()); + OX_THROW_ERROR(writeTypeStore()); } buildFileIndex(); } @@ -58,7 +58,7 @@ ox::FileSystem &Project::romFs() noexcept { ox::Error Project::mkdir(ox::StringViewCR path) const noexcept { auto const [stat, err] = m_fs.stat(path); if (err) { - oxReturnError(m_fs.mkdir(path, true)); + OX_RETURN_ERROR(m_fs.mkdir(path, true)); fileUpdated.emit(path, {}); } return stat.fileType == ox::FileType::Directory ? @@ -79,12 +79,12 @@ ox::Vector const&Project::fileList(ox::StringViewCR ext) noexcept { ox::Error Project::writeTypeStore() noexcept { // write all descriptors because we don't know which types T depends on - oxReturnError(mkdir(m_typeDescPath)); + OX_RETURN_ERROR(mkdir(m_typeDescPath)); for (auto const &t: m_typeStore.typeList()) { - oxRequire(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic)); + OX_REQUIRE(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic)); // write to FS auto const typePath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*t)); - oxReturnError(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1})); + OX_RETURN_ERROR(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1})); } return {}; } @@ -119,11 +119,11 @@ ox::Error Project::writeBuff(ox::StringViewCR path, ox::BufferView const&buff) n ox::BufferWriter writer(&outBuff); auto const [uuid, err] = pathToUuid(m_ctx, path); if (!err) { - oxReturnError(keel::writeUuidHeader(writer, uuid)); + OX_RETURN_ERROR(keel::writeUuidHeader(writer, uuid)); } - oxReturnError(writer.write(buff.data(), buff.size())); + OX_RETURN_ERROR(writer.write(buff.data(), buff.size())); auto const newFile = m_fs.stat(path).error != 0; - oxReturnError(m_fs.write(path, outBuff.data(), outBuff.size(), ox::FileType::NormalFile)); + OX_RETURN_ERROR(m_fs.write(path, outBuff.data(), outBuff.size(), ox::FileType::NormalFile)); if (newFile) { fileAdded.emit(path); indexFile(path); @@ -138,16 +138,16 @@ ox::Result Project::loadBuff(ox::StringViewCR path) const noexcept { } ox::Error Project::lsProcDir(ox::Vector *paths, ox::StringViewCR path) const noexcept { - oxRequire(files, m_fs.ls(path)); + OX_REQUIRE(files, m_fs.ls(path)); for (auto const&name : files) { auto fullPath = ox::sfmt("{}/{}", path, name); - oxRequire(stat, m_fs.stat(ox::StringView(fullPath))); + OX_REQUIRE(stat, m_fs.stat(ox::StringView(fullPath))); switch (stat.fileType) { case ox::FileType::NormalFile: paths->emplace_back(std::move(fullPath)); break; case ox::FileType::Directory: - oxReturnError(lsProcDir(paths, fullPath)); + OX_RETURN_ERROR(lsProcDir(paths, fullPath)); break; case ox::FileType::None: break; @@ -158,7 +158,7 @@ ox::Error Project::lsProcDir(ox::Vector *paths, ox::StringViewCR pat ox::Result> Project::listFiles(ox::StringViewCR path) const noexcept { ox::Vector paths; - oxReturnError(lsProcDir(&paths, path)); + OX_RETURN_ERROR(lsProcDir(&paths, path)); return paths; } diff --git a/src/olympic/studio/modlib/src/undostack.cpp b/src/olympic/studio/modlib/src/undostack.cpp index 1bcf209b..dc51354b 100644 --- a/src/olympic/studio/modlib/src/undostack.cpp +++ b/src/olympic/studio/modlib/src/undostack.cpp @@ -10,7 +10,7 @@ ox::Error UndoStack::push(ox::UPtr &&cmd) noexcept { for (auto const i = m_stackIdx; i < m_stack.size();) { std::ignore = m_stack.erase(i); } - oxReturnError(cmd->redo()); + OX_RETURN_ERROR(cmd->redo()); redoTriggered.emit(cmd.get()); changeTriggered.emit(cmd.get()); if (m_stack.empty() || !(*m_stack.back().value)->mergeWith(*cmd)) { @@ -27,7 +27,7 @@ ox::Error UndoStack::push(ox::UPtr &&cmd) noexcept { ox::Error UndoStack::redo() noexcept { if (m_stackIdx < m_stack.size()) { auto &c = m_stack[m_stackIdx]; - oxReturnError(c->redo()); + OX_RETURN_ERROR(c->redo()); ++m_stackIdx; redoTriggered.emit(c.get()); changeTriggered.emit(c.get()); @@ -38,7 +38,7 @@ ox::Error UndoStack::redo() noexcept { ox::Error UndoStack::undo() noexcept { if (m_stackIdx) { auto &c = m_stack[--m_stackIdx]; - oxReturnError(c->undo()); + OX_RETURN_ERROR(c->undo()); undoTriggered.emit(c.get()); changeTriggered.emit(c.get()); } diff --git a/src/olympic/turbine/include/turbine/clipboard.hpp b/src/olympic/turbine/include/turbine/clipboard.hpp index 20445151..2b88d867 100644 --- a/src/olympic/turbine/include/turbine/clipboard.hpp +++ b/src/olympic/turbine/include/turbine/clipboard.hpp @@ -38,7 +38,7 @@ ox::Result getClipboardData(Context &ctx, ox::StringView t template ox::Result getClipboardObject(Context &ctx) noexcept { - oxRequire(p, getClipboardData(ctx, ox::ModelTypeId_v)); + OX_REQUIRE(p, getClipboardData(ctx, ox::ModelTypeId_v)); return dynamic_cast(p); } diff --git a/src/olympic/turbine/src/gba/turbine.cpp b/src/olympic/turbine/src/gba/turbine.cpp index 1c881352..068ae4ed 100644 --- a/src/olympic/turbine/src/gba/turbine.cpp +++ b/src/olympic/turbine/src/gba/turbine.cpp @@ -61,11 +61,11 @@ OX_ALLOW_UNSAFE_BUFFERS_END ox::Result init( ox::UPtr &&fs, ox::StringViewCR appName) noexcept { auto ctx = ox::make_unique(); - oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName)); + OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName)); #ifdef OX_BARE_METAL - oxReturnError(findPreloadSection().moveTo(ctx->keelCtx.preloadSectionOffset)); + OX_RETURN_ERROR(findPreloadSection().moveTo(ctx->keelCtx.preloadSectionOffset)); #endif - oxReturnError(initGfx(*ctx)); + OX_RETURN_ERROR(initGfx(*ctx)); initTimer(); initIrq(); return ox::UPtr(std::move(ctx)); diff --git a/src/olympic/turbine/src/glfw/turbine.cpp b/src/olympic/turbine/src/glfw/turbine.cpp index 4ff6f089..91147c29 100644 --- a/src/olympic/turbine/src/glfw/turbine.cpp +++ b/src/olympic/turbine/src/glfw/turbine.cpp @@ -43,12 +43,12 @@ static void draw(GLFWwindow *window, int, int) noexcept { ox::Result init( ox::UPtr &&fs, ox::StringViewCR appName) noexcept { auto ctx = ox::make_unique(); - oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName)); + OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName)); using namespace std::chrono; ctx->startTime = static_cast( duration_cast(system_clock::now().time_since_epoch()).count()); glfwInit(); - oxReturnError(initGfx(*ctx)); + OX_RETURN_ERROR(initGfx(*ctx)); glfwSetWindowSizeCallback(ctx->window, draw); return ox::UPtr(ctx.release()); } diff --git a/src/olympic/turbine/src/turbine.cpp b/src/olympic/turbine/src/turbine.cpp index 74887512..56b24991 100644 --- a/src/olympic/turbine/src/turbine.cpp +++ b/src/olympic/turbine/src/turbine.cpp @@ -9,7 +9,7 @@ namespace turbine { ox::Result init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept { - oxRequireM(fs, keel::loadRomFs(fsPath)); + OX_REQUIRE_M(fs, keel::loadRomFs(fsPath)); return init(std::move(fs), appName); }