From 8f03af99a72fe10d80b373243af103ff96455b7f Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 17 Apr 2025 21:36:24 -0500 Subject: [PATCH] [keel] Style updates --- src/olympic/keel/src/asset.cpp | 2 +- src/olympic/keel/src/pack-applib.cpp | 24 +++++++++--------- src/olympic/keel/src/pack.cpp | 37 +++++++++++++++------------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/olympic/keel/src/asset.cpp b/src/olympic/keel/src/asset.cpp index b7b9023f..fb640078 100644 --- a/src/olympic/keel/src/asset.cpp +++ b/src/olympic/keel/src/asset.cpp @@ -36,7 +36,7 @@ ox::Result readAsset(ox::TypeStore &ts, ox::BufferView buff) no return ox::readClaw(ts, buff); } -ox::Result readAssetTypeId(ox::BufferView buff) noexcept { +ox::Result readAssetTypeId(ox::BufferView const buff) noexcept { const auto err = readUuidHeader(buff).error; const auto offset = err ? 0u : K1HdrSz; if (offset >= buff.size()) [[unlikely]] { diff --git a/src/olympic/keel/src/pack-applib.cpp b/src/olympic/keel/src/pack-applib.cpp index 15832133..08597cfe 100644 --- a/src/olympic/keel/src/pack-applib.cpp +++ b/src/olympic/keel/src/pack-applib.cpp @@ -6,13 +6,11 @@ #include #include -#include -#include #include #include -static ox::Error writeFileBuff(ox::StringView path, ox::BufferView const buff) noexcept { +static ox::Error writeFileBuff(ox::StringViewCR path, ox::BufferView const &buff) noexcept { try { std::ofstream f(std::string(toStdStringView(path)), std::ios::binary); f.write(buff.data(), static_cast(buff.size())); @@ -22,7 +20,7 @@ static ox::Error writeFileBuff(ox::StringView path, ox::BufferView const buff) n return {}; } -static ox::Result readFileBuff(ox::StringView path) noexcept { +static ox::Result readFileBuff(ox::StringViewCR path) noexcept { std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate); if (!file.good()) { oxErrorf("Could not find OxFS file: {}", path); @@ -42,7 +40,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()) { + for (auto const gen : mod->types()) { OX_RETURN_ERROR(gen(ts)); } } @@ -50,10 +48,10 @@ static ox::Error generateTypes(ox::TypeStore &ts) noexcept { } static ox::Error pack( - ox::StringView argSrc, - ox::StringView argRomBin, - ox::StringView argManifest, - ox::StringView projectDataDir) noexcept { + ox::StringViewCR argSrc, + ox::StringViewCR argRomBin, + ox::StringViewCR argManifest, + ox::StringViewCR projectDataDir) noexcept { ox::Buffer dstBuff(32 * ox::units::MB); OX_RETURN_ERROR(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); ox::FileSystem32 dst(dstBuff); @@ -82,10 +80,10 @@ static ox::Error pack( } ox::Error run( - [[maybe_unused]] ox::StringView project, - [[maybe_unused]] ox::StringView appName, - ox::StringView projectDataDir, - ox::SpanView argv) noexcept { + [[maybe_unused]] ox::StringView const project, + [[maybe_unused]] ox::StringView const appName, + ox::StringView const projectDataDir, + ox::SpanView const argv) noexcept { ox::ClArgs const args(argv); auto const argSrc = args.getString("src", ""); auto const argRomBin = args.getString("rom-bin", ""); diff --git a/src/olympic/keel/src/pack.cpp b/src/olympic/keel/src/pack.cpp index 1b88bdb4..5017626a 100644 --- a/src/olympic/keel/src/pack.cpp +++ b/src/olympic/keel/src/pack.cpp @@ -11,13 +11,12 @@ namespace keel { static ox::Error pathToInode( - keel::Context &ctx, - ox::FileSystem &dest, + Context &ctx, + ox::FileSystem const &dest, ox::ModelObject &obj) noexcept { - auto &o = obj; - OX_REQUIRE(typeVal, o.at("type")); + OX_REQUIRE(typeVal, obj.at("type")); auto const type = static_cast(typeVal->get()); - OX_REQUIRE(dataVal, o.at("data")); + OX_REQUIRE(dataVal, obj.at("data")); auto &data = dataVal->get(); ox::String path; switch (type) { @@ -47,13 +46,17 @@ static ox::Error pathToInode( } static ox::Error transformFileAddressesObj( - keel::Context &ctx, ox::FileSystem &dest, ox::ModelObject &obj) noexcept; + Context &ctx, + ox::FileSystem const &dest, + ox::ModelObject &obj) noexcept; static ox::Error transformFileAddressesVec( - keel::Context &ctx, ox::FileSystem &dest, ox::ModelValueVector &v) noexcept; + Context &ctx, + ox::FileSystem const &dest, + ox::ModelValueVector &v) noexcept; static ox::Error transformFileAddresses( - keel::Context &ctx, - ox::FileSystem &dest, + Context &ctx, + ox::FileSystem const &dest, ox::ModelValue &v) noexcept { if (v.type() == ox::ModelValue::Type::Object) { auto &obj = v.get(); @@ -66,8 +69,8 @@ static ox::Error transformFileAddresses( } static ox::Error transformFileAddressesVec( - keel::Context &ctx, - ox::FileSystem &dest, + Context &ctx, + ox::FileSystem const &dest, ox::ModelValueVector &v) noexcept { for (auto &f : v) { OX_RETURN_ERROR(transformFileAddresses(ctx, dest, f)); @@ -80,13 +83,13 @@ static ox::Error transformFileAddressesVec( * @return error */ static ox::Error transformFileAddressesObj( - keel::Context &ctx, - ox::FileSystem &dest, + Context &ctx, + ox::FileSystem const &dest, ox::ModelObject &obj) noexcept { if (obj.typeName() == "net.drinkingtea.ox.FileAddress" && obj.typeVersion() == 1) { return pathToInode(ctx, dest, obj); } - for (auto &f : obj) { + for (auto const &f : obj) { auto &v = f->value; OX_RETURN_ERROR(transformFileAddresses(ctx, dest, v)); } @@ -111,7 +114,7 @@ static ox::Error performPackTransforms( static ox::Error doTransformations( Manifest &manifest, - keel::Context &ctx, + Context &ctx, ox::TypeStore &ts, ox::FileSystem &dest, ox::StringViewCR filePath) noexcept { @@ -134,7 +137,7 @@ static ox::Error doTransformations( // transformations need to be done after the copy to the new FS is complete static ox::Error transformClaw( Manifest &manifest, - keel::Context &ctx, + Context &ctx, ox::TypeStore &ts, ox::FileSystem &dest, ox::StringViewCR path) noexcept { @@ -200,7 +203,7 @@ static ox::Error copy( ox::Error pack( Manifest &manifest, - keel::Context &ctx, + Context &ctx, ox::TypeStore &ts, ox::FileSystem &dest) noexcept { OX_RETURN_ERROR(copy(manifest, *ctx.rom, dest, "/"));