[olympic/keel] Finish east consting Keel

This commit is contained in:
Gary Talent 2023-12-15 00:22:56 -06:00
parent 4b824ddef4
commit f71d4d3efd
16 changed files with 74 additions and 96 deletions

View File

@ -11,18 +11,18 @@ namespace keel {
constexpr auto K1HdrSz = 40; constexpr auto K1HdrSz = 40;
ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept; ox::Result<ox::UUID> readUuidHeader(ox::Buffer const&buff) noexcept;
ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexcept; ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexcept;
ox::Error writeUuidHeader(ox::Writer_c auto &writer, const ox::UUID &uuid) noexcept { ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexcept {
oxReturnError(write(writer, "K1;")); oxReturnError(write(writer, "K1;"));
oxReturnError(uuid.toString(writer)); oxReturnError(uuid.toString(writer));
return writer.put(';'); return writer.put(';');
} }
template<typename T> template<typename T>
ox::Result<T> readAsset(const ox::Buffer &buff) noexcept { ox::Result<T> readAsset(ox::Buffer const&buff) noexcept {
std::size_t offset = 0; std::size_t offset = 0;
const auto err = readUuidHeader(buff).error; const auto err = readUuidHeader(buff).error;
if (!err) { if (!err) {
@ -31,15 +31,15 @@ ox::Result<T> readAsset(const ox::Buffer &buff) noexcept {
return ox::readClaw<T>(buff.data() + offset, buff.size() - offset); return ox::readClaw<T>(buff.data() + offset, buff.size() - offset);
} }
ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, const ox::Buffer &buff) noexcept; ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::Buffer const&buff) noexcept;
struct AssetHdr { struct AssetHdr {
ox::UUID uuid; ox::UUID uuid;
ox::ClawHeader clawHdr; ox::ClawHeader clawHdr;
}; };
ox::Result<AssetHdr> readAssetHeader(const char *buff, std::size_t buffLen) noexcept; ox::Result<AssetHdr> readAssetHeader(char const*buff, std::size_t buffLen) noexcept;
ox::Result<AssetHdr> readAssetHeader(const ox::Buffer &buff) noexcept; ox::Result<AssetHdr> readAssetHeader(ox::Buffer const&buff) noexcept;
} }

View File

@ -47,7 +47,7 @@ class AssetContainer {
} }
[[nodiscard]] [[nodiscard]]
constexpr const T *get() const noexcept { constexpr T const*get() const noexcept {
return &m_obj; return &m_obj;
} }
@ -78,12 +78,12 @@ class AssetContainer {
template<typename T> template<typename T>
class AssetRef: public ox::SignalHandler { class AssetRef: public ox::SignalHandler {
private: private:
const AssetContainer<T> *m_ctr = nullptr; AssetContainer<T> const*m_ctr = nullptr;
public: public:
ox::Signal<ox::Error()> updated; ox::Signal<ox::Error()> updated;
explicit constexpr AssetRef(const AssetContainer<T> *c = nullptr) noexcept; explicit constexpr AssetRef(AssetContainer<T> const*c = nullptr) noexcept;
constexpr AssetRef(AssetRef const&h) noexcept; constexpr AssetRef(AssetRef const&h) noexcept;
@ -96,18 +96,18 @@ class AssetRef: public ox::SignalHandler {
} }
[[nodiscard]] [[nodiscard]]
constexpr const T *get() const noexcept { constexpr T const*get() const noexcept {
if (m_ctr) { if (m_ctr) {
return m_ctr->get(); return m_ctr->get();
} }
return nullptr; return nullptr;
} }
constexpr const T &operator*() const noexcept { constexpr T const&operator*() const noexcept {
return *m_ctr->get(); return *m_ctr->get();
} }
constexpr const T *operator->() const noexcept { constexpr T const*operator->() const noexcept {
return m_ctr->get(); return m_ctr->get();
} }
@ -153,7 +153,7 @@ class AssetRef: public ox::SignalHandler {
}; };
template<typename T> template<typename T>
constexpr AssetRef<T>::AssetRef(const AssetContainer<T> *c) noexcept: m_ctr(c) { constexpr AssetRef<T>::AssetRef(AssetContainer<T> const*c) noexcept: m_ctr(c) {
if (c) { if (c) {
c->updated.connect(this, &AssetRef::emitUpdated); c->updated.connect(this, &AssetRef::emitUpdated);
} }
@ -219,7 +219,7 @@ class AssetManager {
} }
void gc() noexcept final { void gc() noexcept final {
for (const auto &ack : m_cache.keys()) { for (auto const&ack : m_cache.keys()) {
auto &ac = m_cache[ack]; auto &ac = m_cache[ack];
if (!ac->references()) { if (!ac->references()) {
m_cache.erase(ack); m_cache.erase(ack);
@ -249,7 +249,7 @@ class AssetManager {
} }
template<typename T> template<typename T>
ox::Result<AssetRef<T>> setAsset(ox::CRStringView assetId, const T &obj) noexcept { ox::Result<AssetRef<T>> setAsset(ox::CRStringView assetId, T const&obj) noexcept {
auto m = getTypeManager<T>(); auto m = getTypeManager<T>();
return m->setAsset(assetId, obj); return m->setAsset(assetId, obj);
} }
@ -265,27 +265,27 @@ class AssetManager {
template<typename T> template<typename T>
class AssetRef { class AssetRef {
private: private:
const T *const m_obj = nullptr; T const*const m_obj = nullptr;
public: public:
constexpr AssetRef() noexcept = default; constexpr AssetRef() noexcept = default;
explicit constexpr AssetRef(const T *obj) noexcept: m_obj(obj) { explicit constexpr AssetRef(T const*obj) noexcept: m_obj(obj) {
} }
constexpr const T *get() const noexcept { constexpr T const*get() const noexcept {
return m_obj; return m_obj;
} }
constexpr const T &operator*() const & noexcept { constexpr T const&operator*() const & noexcept {
return *m_obj; return *m_obj;
} }
constexpr const T &&operator*() const && noexcept { constexpr T const&&operator*() const && noexcept {
return *m_obj; return *m_obj;
} }
constexpr const T *operator->() const noexcept { constexpr T const*operator->() const noexcept {
return m_obj; return m_obj;
} }

View File

@ -22,7 +22,7 @@ class Context {
AssetManager assetManager; AssetManager assetManager;
ox::HashMap<ox::String, ox::UUID> pathToUuid; ox::HashMap<ox::String, ox::UUID> pathToUuid;
ox::HashMap<ox::UUIDStr, ox::String> uuidToPath; ox::HashMap<ox::UUIDStr, ox::String> uuidToPath;
ox::Vector<const class BaseConverter*> converters; ox::Vector<class BaseConverter const*> converters;
ox::Vector<PackTransform> packTransforms; ox::Vector<PackTransform> packTransforms;
#else #else
std::size_t preloadSectionOffset = 0; std::size_t preloadSectionOffset = 0;

View File

@ -81,7 +81,7 @@ ox::Result<keel::AssetRef<T>> readObjNoCache(
ox::CRStringView assetId) noexcept { ox::CRStringView assetId) noexcept {
if constexpr(ox::preloadable<T>::value) { if constexpr(ox::preloadable<T>::value) {
oxRequire(addr, getPreloadAddr(ctx, assetId)); oxRequire(addr, getPreloadAddr(ctx, assetId));
return keel::AssetRef<T>(std::bit_cast<const T*>(uintptr_t{addr})); return keel::AssetRef<T>(std::bit_cast<T const*>(uintptr_t{addr}));
} else { } else {
return OxError(1); return OxError(1);
} }
@ -107,7 +107,7 @@ ox::Result<AssetRef<T>> setAsset(keel::Context &ctx, ox::StringView assetId, T c
} }
ox::UUIDStr idStr; ox::UUIDStr idStr;
if (assetId[0] == '/') { if (assetId[0] == '/') {
const auto [id, err] = ctx.pathToUuid.at(assetId); auto const [id, err] = ctx.pathToUuid.at(assetId);
oxReturnError(err); oxReturnError(err);
idStr = id->toString(); idStr = id->toString();
assetId = idStr; assetId = idStr;
@ -141,7 +141,7 @@ ox::Result<keel::AssetRef<T>> readObj(
#else #else
if constexpr(ox::preloadable<T>::value) { if constexpr(ox::preloadable<T>::value) {
oxRequire(addr, getPreloadAddr(ctx, file)); oxRequire(addr, getPreloadAddr(ctx, file));
return keel::AssetRef<T>(std::bit_cast<const T*>(uintptr_t{addr})); return keel::AssetRef<T>(std::bit_cast<T const*>(uintptr_t{addr}));
} else { } else {
return OxError(1); return OxError(1);
} }

View File

@ -37,9 +37,9 @@ class Module {
virtual ox::Vector<PackTransform> packTransforms() const noexcept; virtual ox::Vector<PackTransform> packTransforms() const noexcept;
}; };
void registerModule(const Module *mod) noexcept; void registerModule(Module const*mod) noexcept;
[[nodiscard]] [[nodiscard]]
ox::Vector<const keel::Module*> const&modules() noexcept; ox::Vector<keel::Module const*> const&modules() noexcept;
} }

View File

@ -66,7 +66,7 @@ struct GbaPlatSpec {
} }
[[nodiscard]] [[nodiscard]]
static constexpr std::size_t alignOf(const auto*) noexcept { static constexpr std::size_t alignOf(auto const*) noexcept {
return 4; return 4;
} }
@ -94,10 +94,10 @@ ox::Error preloadObj(
oxOutf("preloading {}\n", path); oxOutf("preloading {}\n", path);
// preload // preload
oxRequire(a, pl.startAlloc(ox::sizeOf<GbaPlatSpec>(&obj))); oxRequire(a, pl.startAlloc(ox::sizeOf<GbaPlatSpec>(&obj)));
const auto err = ox::preload<GbaPlatSpec, decltype(obj)>(&pl, &obj); auto const err = ox::preload<GbaPlatSpec, decltype(obj)>(&pl, &obj);
oxReturnError(pl.endAlloc()); oxReturnError(pl.endAlloc());
oxReturnError(err); oxReturnError(err);
const keel::PreloadPtr p{.preloadAddr = static_cast<uint32_t>(a)}; keel::PreloadPtr const p{.preloadAddr = static_cast<uint32_t>(a)};
oxReturnError(ox::writeMC(p).moveTo(buff)); oxReturnError(ox::writeMC(p).moveTo(buff));
} else { } else {
// strip the Claw header (it is not needed after preloading) and write back out to dest fs // strip the Claw header (it is not needed after preloading) and write back out to dest fs
@ -118,11 +118,11 @@ ox::Error preloadDir(
// copy // copy
oxTracef("pack.preload", "path: {}", path); oxTracef("pack.preload", "path: {}", path);
oxRequire(fileList, romFs.ls(path)); oxRequire(fileList, romFs.ls(path));
for (const auto &name : fileList) { for (auto const&name : fileList) {
const auto filePath = ox::sfmt("{}{}", path, name); auto const filePath = ox::sfmt("{}{}", path, name);
oxRequire(stat, romFs.stat(filePath)); oxRequire(stat, romFs.stat(filePath));
if (stat.fileType == ox::FileType::Directory) { if (stat.fileType == ox::FileType::Directory) {
const auto dir = ox::sfmt("{}{}/", path, name); auto const dir = ox::sfmt("{}{}/", path, name);
oxReturnError(preloadDir(ts, romFs, pl, dir)); oxReturnError(preloadDir(ts, romFs, pl, dir));
} else { } else {
oxReturnError(preloadObj(ts, romFs, pl, filePath)); oxReturnError(preloadObj(ts, romFs, pl, filePath));
@ -150,7 +150,7 @@ ox::Error appendBinary(ox::Buffer &binBuff, ox::SpanView<char> const&fsBuff, ox:
oxReturnError(padbin(w, hdrSize)); oxReturnError(padbin(w, hdrSize));
oxReturnError(w.write(preloadHdr.data(), preloadHdr.bytes())); oxReturnError(w.write(preloadHdr.data(), preloadHdr.bytes()));
oxReturnError(pl.offsetPtrs(binBuff.size())); oxReturnError(pl.offsetPtrs(binBuff.size()));
const auto &plBuff = pl.buff(); auto const&plBuff = pl.buff();
oxReturnError(w.write(plBuff.data(), plBuff.size())); oxReturnError(w.write(plBuff.data(), plBuff.size()));
return {}; return {};
} }

View File

@ -20,28 +20,6 @@ class Wrap {
virtual ~Wrap() = default; virtual ~Wrap() = default;
}; };
template<typename T>
class WrapIndirect: public Wrap {
private:
T *m_obj = nullptr;
public:
template<typename... Args>
constexpr explicit WrapIndirect(Args &&...args): m_obj(ox::forward<Args>(args)...) {
}
[[nodiscard]]
constexpr auto obj() const noexcept {
return &m_obj;
}
[[nodiscard]]
constexpr auto obj() noexcept {
return &m_obj;
}
};
template<typename T> template<typename T>
class WrapInline: public Wrap { class WrapInline: public Wrap {
private: private:
@ -55,8 +33,8 @@ class WrapInline: public Wrap {
} }
[[nodiscard]] [[nodiscard]]
constexpr auto obj() noexcept { constexpr T &obj() noexcept {
return &m_obj; return m_obj;
} }
}; };
@ -67,7 +45,7 @@ constexpr auto makeWrap(Args &&...args) noexcept {
} }
template<typename T> template<typename T>
constexpr T *wrapCast(Wrap &ptr) noexcept { constexpr T &wrapCast(Wrap &ptr) noexcept {
return static_cast<WrapInline<T>&>(ptr).obj(); return static_cast<WrapInline<T>&>(ptr).obj();
} }
@ -89,7 +67,7 @@ class BaseConverter {
virtual ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept = 0; virtual ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept = 0;
virtual ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context &ctx, const ox::Buffer &srcBuff) const noexcept = 0; virtual ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context &ctx, ox::Buffer const&srcBuff) const noexcept = 0;
[[nodiscard]] [[nodiscard]]
inline bool matches( inline bool matches(
@ -132,14 +110,14 @@ class Converter: public BaseConverter {
ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept final { ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept final {
auto dst = makeWrap<DstType>(); auto dst = makeWrap<DstType>();
oxReturnError(convert(ctx, *wrapCast<SrcType>(src), *wrapCast<DstType>(*dst))); oxReturnError(convert(ctx, wrapCast<SrcType>(src), wrapCast<DstType>(*dst)));
return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst)); return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst));
} }
ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context &ctx, ox::Buffer const&srcBuff) const noexcept final { ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context &ctx, ox::Buffer const&srcBuff) const noexcept final {
oxRequireM(src, readAsset<SrcType>(srcBuff)); oxRequireM(src, readAsset<SrcType>(srcBuff));
auto dst = makeWrap<DstType>(); auto dst = makeWrap<DstType>();
oxReturnError(convert(ctx, src, *wrapCast<DstType>(*dst))); oxReturnError(convert(ctx, src, wrapCast<DstType>(*dst)));
return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst)); return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst));
} }
@ -149,24 +127,24 @@ class Converter: public BaseConverter {
}; };
ox::Result<ox::UniquePtr<Wrap>> convert( ox::Result<ox::UniquePtr<Wrap>> convert(
keel::Context &ctx, const ox::Buffer &srcBuffer, keel::Context &ctx, ox::Buffer const&srcBuffer,
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept; ox::CRStringView dstTypeName, int dstTypeVersion) noexcept;
template<typename DstType> template<typename DstType>
ox::Result<DstType> convert(keel::Context &ctx, const ox::Buffer &srcBuffer) noexcept { ox::Result<DstType> convert(keel::Context &ctx, ox::Buffer const&srcBuffer) noexcept {
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>(); static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
return wrapCast<DstType>(out); return std::move(wrapCast<DstType>(out));
} }
template<typename DstType> template<typename DstType>
ox::Error convert(keel::Context &ctx, const ox::Buffer &buff, DstType *outObj) noexcept { ox::Error convert(keel::Context &ctx, ox::Buffer const&buff, DstType *outObj) noexcept {
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>(); static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion)); oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion));
*outObj = std::move(*wrapCast<DstType>(*outPtr)); *outObj = std::move(wrapCast<DstType>(*outPtr));
return OxError(0); return {};
} }
template<typename DstType> template<typename DstType>
@ -174,7 +152,7 @@ ox::Result<ox::Buffer> convertBuffToBuff(keel::Context &ctx, const ox::Buffer &s
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>(); static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
return ox::writeClaw<DstType>(*wrapCast<DstType>(*out), fmt); return ox::writeClaw<DstType>(wrapCast<DstType>(*out), fmt);
} }
template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal> template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal>

View File

@ -19,7 +19,7 @@ class TypeStore: public ox::TypeStore {
explicit TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept; explicit TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept;
protected: protected:
ox::Result<ox::UniquePtr<ox::DescriptorType>> loadDescriptor(ox::CRStringView typeId) noexcept override; ox::Result<ox::UPtr<ox::DescriptorType>> loadDescriptor(ox::CRStringView typeId) noexcept override;
}; };
} }

View File

@ -10,7 +10,7 @@ ox::Result<ox::UUID> readUuidHeader(ox::Buffer const&buff) noexcept {
return readUuidHeader(buff.data(), buff.size()); return readUuidHeader(buff.data(), buff.size());
} }
ox::Result<ox::UUID> readUuidHeader(const char *buff, std::size_t buffLen) noexcept { ox::Result<ox::UUID> readUuidHeader(char const*buff, std::size_t buffLen) noexcept {
if (buffLen < K1HdrSz) { if (buffLen < K1HdrSz) {
return OxError(1, "Insufficient data to contain complete Keel header"); return OxError(1, "Insufficient data to contain complete Keel header");
} }
@ -29,7 +29,7 @@ ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::Buffer const&buff)
return ox::readClaw(ts, buff.data() + offset, buff.size() - offset); return ox::readClaw(ts, buff.data() + offset, buff.size() - offset);
} }
ox::Result<AssetHdr> readAssetHeader(const char *buff, std::size_t buffLen) noexcept { ox::Result<AssetHdr> readAssetHeader(char const*buff, std::size_t buffLen) noexcept {
AssetHdr out; AssetHdr out;
const auto err = readUuidHeader(buff, buffLen).moveTo(out.uuid); const auto err = readUuidHeader(buff, buffLen).moveTo(out.uuid);
const auto offset = err ? 0u : K1HdrSz; const auto offset = err ? 0u : K1HdrSz;

View File

@ -13,7 +13,7 @@ ox::Error init(
ctx.appName = appName; ctx.appName = appName;
oxIgnoreError(setRomFs(ctx, std::move(fs))); oxIgnoreError(setRomFs(ctx, std::move(fs)));
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
const auto &mods = modules(); auto const&mods = modules();
for (auto &mod : mods) { for (auto &mod : mods) {
// register type converters // register type converters
for (auto c : mod->converters()) { for (auto c : mod->converters()) {

View File

@ -19,7 +19,7 @@ ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
return OxError(1, "Could not find ROM file"); return OxError(1, "Could not find ROM file");
} }
try { try {
const auto size = file.tellg(); auto const size = file.tellg();
file.seekg(0, std::ios::beg); file.seekg(0, std::ios::beg);
auto buff = new char[static_cast<std::size_t>(size)]; auto buff = new char[static_cast<std::size_t>(size)];
file.read(buff, size); file.read(buff, size);
@ -49,12 +49,12 @@ void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uui
static ox::Error buildUuidMap(Context &ctx, ox::CRStringView path) noexcept { static ox::Error buildUuidMap(Context &ctx, ox::CRStringView path) noexcept {
oxRequire(files, ctx.rom->ls(path)); oxRequire(files, ctx.rom->ls(path));
for (const auto &f : files) { for (auto const&f : files) {
oxRequireM(filePath, ox::join("/", ox::Array<ox::StringView, 2>{path, f})); oxRequireM(filePath, ox::join("/", ox::Array<ox::StringView, 2>{path, f}));
oxRequire(stat, ctx.rom->stat(filePath)); oxRequire(stat, ctx.rom->stat(filePath));
if (stat.fileType == ox::FileType::NormalFile) { if (stat.fileType == ox::FileType::NormalFile) {
oxRequire(data, ctx.rom->read(filePath)); oxRequire(data, ctx.rom->read(filePath));
const auto [hdr, err] = readAssetHeader(data); auto const [hdr, err] = readAssetHeader(data);
if (!err) { if (!err) {
createUuidMapping(ctx, filePath, hdr.uuid); createUuidMapping(ctx, filePath, hdr.uuid);
} }
@ -157,7 +157,7 @@ ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::CRStringView path
return static_cast<std::size_t>(p.preloadAddr) + ctx.preloadSectionOffset; return static_cast<std::size_t>(p.preloadAddr) + ctx.preloadSectionOffset;
} }
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, const ox::FileAddress &file) noexcept { ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::FileAddress const&file) noexcept {
oxRequire(stat, ctx.rom->stat(file)); oxRequire(stat, ctx.rom->stat(file));
oxRequire(buff, static_cast<ox::MemFS*>(ctx.rom.get())->directAccess(file)); oxRequire(buff, static_cast<ox::MemFS*>(ctx.rom.get())->directAccess(file));
PreloadPtr p; PreloadPtr p;

View File

@ -6,14 +6,14 @@
namespace keel { namespace keel {
static ox::Vector<const Module*> mods; static ox::Vector<Module const*> mods;
void registerModule(const Module *mod) noexcept { void registerModule(Module const*mod) noexcept {
mods.emplace_back(mod); mods.emplace_back(mod);
} }
[[nodiscard]] [[nodiscard]]
ox::Vector<const Module*> const&modules() noexcept { ox::Vector<Module const*> const&modules() noexcept {
return mods; return mods;
} }
@ -22,7 +22,7 @@ ox::Vector<TypeDescGenerator> Module::types() const noexcept {
return {}; return {};
} }
ox::Vector<const keel::BaseConverter*> Module::converters() const noexcept { ox::Vector<keel::BaseConverter const*> Module::converters() const noexcept {
return {}; return {};
} }

View File

@ -28,7 +28,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
return OxError(1, "Could not find OxFS file"); return OxError(1, "Could not find OxFS file");
} }
try { try {
const auto size = static_cast<std::size_t>(file.tellg()); auto const size = static_cast<std::size_t>(file.tellg());
ox::Buffer buff(size); ox::Buffer buff(size);
file.seekg(0, std::ios::beg); file.seekg(0, std::ios::beg);
file.read(buff.data(), static_cast<std::streamsize>(buff.size())); file.read(buff.data(), static_cast<std::streamsize>(buff.size()));
@ -40,7 +40,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
} }
static ox::Error generateTypes(ox::TypeStore *ts) noexcept { static ox::Error generateTypes(ox::TypeStore *ts) noexcept {
for (const auto mod : keel::modules()) { for (auto const mod : keel::modules()) {
for (auto gen : mod->types()) { for (auto gen : mod->types()) {
oxReturnError(gen(*ts)); oxReturnError(gen(*ts));
} }
@ -74,10 +74,10 @@ static ox::Error pack(ox::StringView argSrc, ox::StringView argRomBin, ox::Strin
return {}; return {};
} }
static ox::Error run(int argc, const char **argv, ox::StringView projectDataDir) noexcept { static ox::Error run(int argc, char const**argv, ox::StringView projectDataDir) noexcept {
ox::ClArgs const args(argc, argv); ox::ClArgs const args(argc, argv);
const auto argSrc = args.getString("src", ""); auto const argSrc = args.getString("src", "");
const auto argRomBin = args.getString("rom-bin", ""); auto const argRomBin = args.getString("rom-bin", "");
if (argSrc == "") { if (argSrc == "") {
oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n"); oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n");
return OxError(1, "must specify a source directory"); return OxError(1, "must specify a source directory");
@ -96,7 +96,7 @@ ox::Error run(
[[maybe_unused]] ox::StringView appName, [[maybe_unused]] ox::StringView appName,
ox::StringView projectDataDir, ox::StringView projectDataDir,
int argc, int argc,
const char **argv) noexcept { char const**argv) noexcept {
return ::run(argc, argv, projectDataDir); return ::run(argc, argv, projectDataDir);
} }

View File

@ -29,7 +29,7 @@ static ox::Error pathToInode(
return {}; return {};
} }
if (beginsWith(path, "uuid://")) { if (beginsWith(path, "uuid://")) {
const auto uuid = substr<ox::StringView>(path, 7); auto const uuid = substr<ox::StringView>(path, 7);
oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path)); oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path));
} }
oxRequire(s, dest.stat(path)); oxRequire(s, dest.stat(path));
@ -113,11 +113,11 @@ static ox::Error transformClaw(
// copy // copy
oxTracef("pack.transformClaw", "path: {}", path); oxTracef("pack.transformClaw", "path: {}", path);
oxRequire(fileList, dest.ls(path)); oxRequire(fileList, dest.ls(path));
for (const auto &name : fileList) { for (auto const&name : fileList) {
const auto filePath = ox::sfmt("{}{}", path, name); auto const filePath = ox::sfmt("{}{}", path, name);
oxRequire(stat, dest.stat(filePath)); oxRequire(stat, dest.stat(filePath));
if (stat.fileType == ox::FileType::Directory) { if (stat.fileType == ox::FileType::Directory) {
const auto dir = ox::sfmt("{}{}/", path, name); auto const dir = ox::sfmt("{}{}/", path, name);
oxReturnError(transformClaw(ctx, ts, dest, dir)); oxReturnError(transformClaw(ctx, ts, dest, dir));
} else { } else {
oxReturnError(doTransformations(ctx, ts, dest, filePath)); oxReturnError(doTransformations(ctx, ts, dest, filePath));
@ -133,7 +133,7 @@ static ox::Error copy(
oxOutf("copying directory: {}\n", path); oxOutf("copying directory: {}\n", path);
// copy // copy
oxRequire(fileList, src.ls(path)); oxRequire(fileList, src.ls(path));
for (const auto &name : fileList) { for (auto const&name : fileList) {
auto currentFile = ox::sfmt("{}{}", path, name); auto currentFile = ox::sfmt("{}{}", path, name);
if (beginsWith(name, ".")) { if (beginsWith(name, ".")) {
continue; continue;

View File

@ -27,7 +27,7 @@ static ox::Result<const BaseConverter*> findConverter(
static ox::Result<ox::UniquePtr<Wrap>> convert( static ox::Result<ox::UniquePtr<Wrap>> convert(
[[maybe_unused]] keel::Context &ctx, [[maybe_unused]] keel::Context &ctx,
ox::Vector<const BaseConverter*> const&converters, ox::Vector<const BaseConverter*> const&converters,
[[maybe_unused]] const ox::Buffer &srcBuffer, [[maybe_unused]] ox::Buffer const&srcBuffer,
[[maybe_unused]] ox::CRStringView srcTypeName, [[maybe_unused]] ox::CRStringView srcTypeName,
[[maybe_unused]] int srcTypeVersion, [[maybe_unused]] int srcTypeVersion,
[[maybe_unused]] ox::CRStringView dstTypeName, [[maybe_unused]] ox::CRStringView dstTypeName,
@ -54,7 +54,7 @@ static ox::Result<ox::UniquePtr<Wrap>> convert(
ox::Result<ox::UniquePtr<Wrap>> convert( ox::Result<ox::UniquePtr<Wrap>> convert(
[[maybe_unused]] keel::Context &ctx, [[maybe_unused]] keel::Context &ctx,
[[maybe_unused]] const ox::Buffer &srcBuffer, [[maybe_unused]] ox::Buffer const&srcBuffer,
[[maybe_unused]] ox::CRStringView dstTypeName, [[maybe_unused]] ox::CRStringView dstTypeName,
[[maybe_unused]] int dstTypeVersion) noexcept { [[maybe_unused]] int dstTypeVersion) noexcept {
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL

View File

@ -8,10 +8,10 @@ namespace keel {
TypeStore::TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept: TypeStore::TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept:
m_fs(fs), m_fs(fs),
m_descPath(std::move(descPath)) { m_descPath(descPath) {
} }
ox::Result<ox::UniquePtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::CRStringView typeId) noexcept { ox::Result<ox::UPtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::CRStringView typeId) noexcept {
auto path = ox::sfmt("{}/{}", m_descPath, typeId); auto path = ox::sfmt("{}/{}", m_descPath, typeId);
oxRequire(buff, m_fs.read(path)); oxRequire(buff, m_fs.read(path));
auto dt = ox::make_unique<ox::DescriptorType>(); auto dt = ox::make_unique<ox::DescriptorType>();