This commit is contained in:
@@ -13,7 +13,7 @@ namespace keel {
|
||||
|
||||
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;
|
||||
|
||||
@@ -35,15 +35,15 @@ ox::Result<T> readAsset(ox::BufferView buff) noexcept {
|
||||
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 {
|
||||
ox::UUID uuid;
|
||||
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;
|
||||
|
||||
}
|
||||
|
@@ -147,7 +147,7 @@ template<typename T>
|
||||
ox::Result<AssetRef<T>> readObj(
|
||||
Context &ctx,
|
||||
ox::StringViewCR assetId,
|
||||
[[maybe_unused]] bool forceLoad = false) noexcept {
|
||||
[[maybe_unused]] bool const forceLoad = false) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
return readObjFile<T>(ctx, assetId, forceLoad);
|
||||
#else
|
||||
@@ -159,7 +159,7 @@ template<typename T>
|
||||
ox::Result<AssetRef<T>> readObj(
|
||||
Context &ctx,
|
||||
ox::FileAddress const &file,
|
||||
[[maybe_unused]] bool forceLoad = false) noexcept {
|
||||
[[maybe_unused]] bool const forceLoad = false) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
OX_REQUIRE(assetId, file.getPath());
|
||||
return readObj<T>(ctx, ox::StringView(assetId), forceLoad);
|
||||
@@ -178,7 +178,7 @@ ox::Error writeObj(
|
||||
Context &ctx,
|
||||
ox::FileAddress const &file,
|
||||
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));
|
||||
return ctx.rom->write(file, objBuff.data(), objBuff.size());
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class TypeStore: public ox::TypeStore {
|
||||
ox::String m_descPath;
|
||||
|
||||
public:
|
||||
explicit TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept;
|
||||
explicit TypeStore(ox::FileSystem &fs, ox::StringViewCR descPath) noexcept;
|
||||
|
||||
protected:
|
||||
ox::Result<ox::UPtr<ox::DescriptorType>> loadDescriptor(ox::StringView typeId) noexcept override;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
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]] {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (!readUuidHeader(buff).error) {
|
||||
offset = K1HdrSz;
|
||||
}
|
||||
buff += offset;
|
||||
return ox::readClaw(ts, buff);
|
||||
return ox::readClaw(ts, buff + offset);
|
||||
}
|
||||
|
||||
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 offset = err ? 0u : K1HdrSz;
|
||||
if (offset >= buff.size()) [[unlikely]] {
|
||||
@@ -45,15 +44,14 @@ ox::Result<ox::StringView> readAssetTypeId(ox::BufferView const buff) noexcept {
|
||||
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;
|
||||
auto const err = readUuidHeader(buff).moveTo(out.value.uuid);
|
||||
auto const offset = err ? 0u : K1HdrSz;
|
||||
if (offset >= buff.size()) [[unlikely]] {
|
||||
return ox::Error(1, "Buffer too small for expected data");
|
||||
}
|
||||
buff += offset;
|
||||
OX_RETURN_ERROR(ox::readClawHeader(buff).moveTo(out.value.clawHdr));
|
||||
OX_RETURN_ERROR(ox::readClawHeader(buff + offset).moveTo(out.value.clawHdr));
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace keel {
|
||||
|
||||
TypeStore::TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept:
|
||||
TypeStore::TypeStore(ox::FileSystem &fs, ox::StringViewCR descPath) noexcept:
|
||||
m_fs(fs),
|
||||
m_descPath(descPath) {
|
||||
}
|
||||
|
@@ -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;
|
||||
if (argc > 0) {
|
||||
auto const args = ox::Span{argv, static_cast<size_t>(argc)};
|
||||
|
Reference in New Issue
Block a user