[keel] Cleanup
All checks were successful
Build / build (push) Successful in 1m19s

This commit is contained in:
2025-08-12 22:57:13 -05:00
parent e59382dd60
commit 8a430faf4c
17 changed files with 65 additions and 67 deletions

View File

@@ -13,7 +13,7 @@ namespace keel {
constexpr auto K1HdrSz = 40; constexpr auto K1HdrSz = 40;
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept; ox::Result<ox::UUID> readUuidHeader(ox::BufferView const &buff) noexcept;
ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept; ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept;
@@ -35,15 +35,15 @@ ox::Result<T> readAsset(ox::BufferView buff) noexcept {
return out; return out;
} }
ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) noexcept; ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView const &buff) noexcept;
struct AssetHdr { struct AssetHdr {
ox::UUID uuid; ox::UUID uuid;
ox::ClawHeader clawHdr; ox::ClawHeader clawHdr;
}; };
ox::Result<ox::StringView> readAssetTypeId(ox::BufferView buff) noexcept; ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const &buff) noexcept;
ox::Result<AssetHdr> readAssetHeader(ox::BufferView buff) noexcept; ox::Result<AssetHdr> readAssetHeader(ox::BufferView const &buff) noexcept;
} }

View File

@@ -147,7 +147,7 @@ template<typename T>
ox::Result<AssetRef<T>> readObj( ox::Result<AssetRef<T>> readObj(
Context &ctx, Context &ctx,
ox::StringViewCR assetId, ox::StringViewCR assetId,
[[maybe_unused]] bool forceLoad = false) noexcept { [[maybe_unused]] bool const forceLoad = false) noexcept {
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
return readObjFile<T>(ctx, assetId, forceLoad); return readObjFile<T>(ctx, assetId, forceLoad);
#else #else
@@ -159,7 +159,7 @@ template<typename T>
ox::Result<AssetRef<T>> readObj( ox::Result<AssetRef<T>> readObj(
Context &ctx, Context &ctx,
ox::FileAddress const &file, ox::FileAddress const &file,
[[maybe_unused]] bool forceLoad = false) noexcept { [[maybe_unused]] bool const forceLoad = false) noexcept {
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
OX_REQUIRE(assetId, file.getPath()); OX_REQUIRE(assetId, file.getPath());
return readObj<T>(ctx, ox::StringView(assetId), forceLoad); return readObj<T>(ctx, ox::StringView(assetId), forceLoad);
@@ -178,7 +178,7 @@ ox::Error writeObj(
Context &ctx, Context &ctx,
ox::FileAddress const &file, ox::FileAddress const &file,
T const &obj, T const &obj,
ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept { ox::ClawFormat const fmt = ox::ClawFormat::Metal) noexcept {
OX_REQUIRE(objBuff, ox::writeClaw(obj, fmt)); OX_REQUIRE(objBuff, ox::writeClaw(obj, fmt));
return ctx.rom->write(file, objBuff.data(), objBuff.size()); return ctx.rom->write(file, objBuff.data(), objBuff.size());
} }

View File

@@ -16,7 +16,7 @@ class TypeStore: public ox::TypeStore {
ox::String m_descPath; ox::String m_descPath;
public: public:
explicit TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept; explicit TypeStore(ox::FileSystem &fs, ox::StringViewCR descPath) noexcept;
protected: protected:
ox::Result<ox::UPtr<ox::DescriptorType>> loadDescriptor(ox::StringView typeId) noexcept override; ox::Result<ox::UPtr<ox::DescriptorType>> loadDescriptor(ox::StringView typeId) noexcept override;

View File

@@ -6,7 +6,7 @@
namespace keel { namespace keel {
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept { ox::Result<ox::UUID> readUuidHeader(ox::BufferView const &buff) noexcept {
if (buff.size() < K1HdrSz) [[unlikely]] { if (buff.size() < K1HdrSz) [[unlikely]] {
return ox::Error{1, "Insufficient data to contain complete Keel header"}; return ox::Error{1, "Insufficient data to contain complete Keel header"};
} }
@@ -27,16 +27,15 @@ ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept {
return id; return id;
} }
ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) noexcept { ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView const &buff) noexcept {
std::size_t offset = 0; std::size_t offset = 0;
if (!readUuidHeader(buff).error) { if (!readUuidHeader(buff).error) {
offset = K1HdrSz; offset = K1HdrSz;
} }
buff += offset; return ox::readClaw(ts, buff + offset);
return ox::readClaw(ts, buff);
} }
ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept { ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const &buff) noexcept {
auto const err = readUuidHeader(buff).error; auto const err = readUuidHeader(buff).error;
auto const offset = err ? 0u : K1HdrSz; auto const offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] { if (offset >= buff.size()) [[unlikely]] {
@@ -45,15 +44,14 @@ ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept {
return ox::readClawTypeId(buff + offset); return ox::readClawTypeId(buff + offset);
} }
ox::Result<AssetHdr> readAssetHeader(ox::BufferView buff) noexcept { ox::Result<AssetHdr> readAssetHeader(ox::BufferView const &buff) noexcept {
ox::Result<AssetHdr> out; ox::Result<AssetHdr> out;
auto const err = readUuidHeader(buff).moveTo(out.value.uuid); auto const err = readUuidHeader(buff).moveTo(out.value.uuid);
auto const offset = err ? 0u : K1HdrSz; auto const offset = err ? 0u : K1HdrSz;
if (offset >= buff.size()) [[unlikely]] { if (offset >= buff.size()) [[unlikely]] {
return ox::Error(1, "Buffer too small for expected data"); return ox::Error(1, "Buffer too small for expected data");
} }
buff += offset; OX_RETURN_ERROR(ox::readClawHeader(buff + offset).moveTo(out.value.clawHdr));
OX_RETURN_ERROR(ox::readClawHeader(buff).moveTo(out.value.clawHdr));
return out; return out;
} }

View File

@@ -6,7 +6,7 @@
namespace keel { namespace keel {
TypeStore::TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept: TypeStore::TypeStore(ox::FileSystem &fs, ox::StringViewCR descPath) noexcept:
m_fs(fs), m_fs(fs),
m_descPath(descPath) { m_descPath(descPath) {
} }

View File

@@ -25,7 +25,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
}, },
}; };
int main(int argc, char const **argv) { int main(int const argc, char const **argv) {
int retval = -1; int retval = -1;
if (argc > 0) { if (argc > 0) {
auto const args = ox::Span{argv, static_cast<size_t>(argc)}; auto const args = ox::Span{argv, static_cast<size_t>(argc)};