[olympic/keel] Finish east consting Keel
This commit is contained in:
parent
4b824ddef4
commit
f71d4d3efd
@ -11,18 +11,18 @@ namespace keel {
|
||||
|
||||
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::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(uuid.toString(writer));
|
||||
return writer.put(';');
|
||||
}
|
||||
|
||||
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;
|
||||
const auto err = readUuidHeader(buff).error;
|
||||
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);
|
||||
}
|
||||
|
||||
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 {
|
||||
ox::UUID uuid;
|
||||
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;
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class AssetContainer {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr const T *get() const noexcept {
|
||||
constexpr T const*get() const noexcept {
|
||||
return &m_obj;
|
||||
}
|
||||
|
||||
@ -78,12 +78,12 @@ class AssetContainer {
|
||||
template<typename T>
|
||||
class AssetRef: public ox::SignalHandler {
|
||||
private:
|
||||
const AssetContainer<T> *m_ctr = nullptr;
|
||||
AssetContainer<T> const*m_ctr = nullptr;
|
||||
|
||||
public:
|
||||
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;
|
||||
|
||||
@ -96,18 +96,18 @@ class AssetRef: public ox::SignalHandler {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr const T *get() const noexcept {
|
||||
constexpr T const*get() const noexcept {
|
||||
if (m_ctr) {
|
||||
return m_ctr->get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constexpr const T &operator*() const noexcept {
|
||||
constexpr T const&operator*() const noexcept {
|
||||
return *m_ctr->get();
|
||||
}
|
||||
|
||||
constexpr const T *operator->() const noexcept {
|
||||
constexpr T const*operator->() const noexcept {
|
||||
return m_ctr->get();
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class AssetRef: public ox::SignalHandler {
|
||||
};
|
||||
|
||||
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) {
|
||||
c->updated.connect(this, &AssetRef::emitUpdated);
|
||||
}
|
||||
@ -219,7 +219,7 @@ class AssetManager {
|
||||
}
|
||||
|
||||
void gc() noexcept final {
|
||||
for (const auto &ack : m_cache.keys()) {
|
||||
for (auto const&ack : m_cache.keys()) {
|
||||
auto &ac = m_cache[ack];
|
||||
if (!ac->references()) {
|
||||
m_cache.erase(ack);
|
||||
@ -249,7 +249,7 @@ class AssetManager {
|
||||
}
|
||||
|
||||
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>();
|
||||
return m->setAsset(assetId, obj);
|
||||
}
|
||||
@ -265,27 +265,27 @@ class AssetManager {
|
||||
template<typename T>
|
||||
class AssetRef {
|
||||
private:
|
||||
const T *const m_obj = nullptr;
|
||||
T const*const m_obj = nullptr;
|
||||
|
||||
public:
|
||||
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;
|
||||
}
|
||||
|
||||
constexpr const T &operator*() const & noexcept {
|
||||
constexpr T const&operator*() const & noexcept {
|
||||
return *m_obj;
|
||||
}
|
||||
|
||||
constexpr const T &&operator*() const && noexcept {
|
||||
constexpr T const&&operator*() const && noexcept {
|
||||
return *m_obj;
|
||||
}
|
||||
|
||||
constexpr const T *operator->() const noexcept {
|
||||
constexpr T const*operator->() const noexcept {
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class Context {
|
||||
AssetManager assetManager;
|
||||
ox::HashMap<ox::String, ox::UUID> pathToUuid;
|
||||
ox::HashMap<ox::UUIDStr, ox::String> uuidToPath;
|
||||
ox::Vector<const class BaseConverter*> converters;
|
||||
ox::Vector<class BaseConverter const*> converters;
|
||||
ox::Vector<PackTransform> packTransforms;
|
||||
#else
|
||||
std::size_t preloadSectionOffset = 0;
|
||||
|
@ -81,7 +81,7 @@ ox::Result<keel::AssetRef<T>> readObjNoCache(
|
||||
ox::CRStringView assetId) noexcept {
|
||||
if constexpr(ox::preloadable<T>::value) {
|
||||
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 {
|
||||
return OxError(1);
|
||||
}
|
||||
@ -107,7 +107,7 @@ ox::Result<AssetRef<T>> setAsset(keel::Context &ctx, ox::StringView assetId, T c
|
||||
}
|
||||
ox::UUIDStr idStr;
|
||||
if (assetId[0] == '/') {
|
||||
const auto [id, err] = ctx.pathToUuid.at(assetId);
|
||||
auto const [id, err] = ctx.pathToUuid.at(assetId);
|
||||
oxReturnError(err);
|
||||
idStr = id->toString();
|
||||
assetId = idStr;
|
||||
@ -141,7 +141,7 @@ ox::Result<keel::AssetRef<T>> readObj(
|
||||
#else
|
||||
if constexpr(ox::preloadable<T>::value) {
|
||||
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 {
|
||||
return OxError(1);
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ class Module {
|
||||
virtual ox::Vector<PackTransform> packTransforms() const noexcept;
|
||||
};
|
||||
|
||||
void registerModule(const Module *mod) noexcept;
|
||||
void registerModule(Module const*mod) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<const keel::Module*> const&modules() noexcept;
|
||||
ox::Vector<keel::Module const*> const&modules() noexcept;
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ struct GbaPlatSpec {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static constexpr std::size_t alignOf(const auto*) noexcept {
|
||||
static constexpr std::size_t alignOf(auto const*) noexcept {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@ -94,10 +94,10 @@ ox::Error preloadObj(
|
||||
oxOutf("preloading {}\n", path);
|
||||
// preload
|
||||
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(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));
|
||||
} else {
|
||||
// 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
|
||||
oxTracef("pack.preload", "path: {}", path);
|
||||
oxRequire(fileList, romFs.ls(path));
|
||||
for (const auto &name : fileList) {
|
||||
const auto filePath = ox::sfmt("{}{}", path, name);
|
||||
for (auto const&name : fileList) {
|
||||
auto const filePath = ox::sfmt("{}{}", path, name);
|
||||
oxRequire(stat, romFs.stat(filePath));
|
||||
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));
|
||||
} else {
|
||||
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(w.write(preloadHdr.data(), preloadHdr.bytes()));
|
||||
oxReturnError(pl.offsetPtrs(binBuff.size()));
|
||||
const auto &plBuff = pl.buff();
|
||||
auto const&plBuff = pl.buff();
|
||||
oxReturnError(w.write(plBuff.data(), plBuff.size()));
|
||||
return {};
|
||||
}
|
||||
|
@ -20,28 +20,6 @@ class Wrap {
|
||||
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>
|
||||
class WrapInline: public Wrap {
|
||||
private:
|
||||
@ -55,8 +33,8 @@ class WrapInline: public Wrap {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto obj() noexcept {
|
||||
return &m_obj;
|
||||
constexpr T &obj() noexcept {
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
};
|
||||
@ -67,7 +45,7 @@ constexpr auto makeWrap(Args &&...args) noexcept {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T *wrapCast(Wrap &ptr) noexcept {
|
||||
constexpr T &wrapCast(Wrap &ptr) noexcept {
|
||||
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>> 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]]
|
||||
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 {
|
||||
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));
|
||||
}
|
||||
|
||||
ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context &ctx, ox::Buffer const&srcBuff) const noexcept final {
|
||||
oxRequireM(src, readAsset<SrcType>(srcBuff));
|
||||
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));
|
||||
}
|
||||
|
||||
@ -149,24 +127,24 @@ class Converter: public BaseConverter {
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
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 DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
|
||||
return wrapCast<DstType>(out);
|
||||
return std::move(wrapCast<DstType>(out));
|
||||
}
|
||||
|
||||
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 DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion));
|
||||
*outObj = std::move(*wrapCast<DstType>(*outPtr));
|
||||
return OxError(0);
|
||||
*outObj = std::move(wrapCast<DstType>(*outPtr));
|
||||
return {};
|
||||
}
|
||||
|
||||
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 DstTypeVersion = ox::requireModelTypeVersion<DstType>();
|
||||
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>
|
||||
|
@ -19,7 +19,7 @@ class TypeStore: public ox::TypeStore {
|
||||
explicit TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ ox::Result<ox::UUID> readUuidHeader(ox::Buffer const&buff) noexcept {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
const auto err = readUuidHeader(buff, buffLen).moveTo(out.uuid);
|
||||
const auto offset = err ? 0u : K1HdrSz;
|
||||
|
@ -13,7 +13,7 @@ ox::Error init(
|
||||
ctx.appName = appName;
|
||||
oxIgnoreError(setRomFs(ctx, std::move(fs)));
|
||||
#ifndef OX_BARE_METAL
|
||||
const auto &mods = modules();
|
||||
auto const&mods = modules();
|
||||
for (auto &mod : mods) {
|
||||
// register type converters
|
||||
for (auto c : mod->converters()) {
|
||||
|
@ -19,7 +19,7 @@ ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
|
||||
return OxError(1, "Could not find ROM file");
|
||||
}
|
||||
try {
|
||||
const auto size = file.tellg();
|
||||
auto const size = file.tellg();
|
||||
file.seekg(0, std::ios::beg);
|
||||
auto buff = new char[static_cast<std::size_t>(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 {
|
||||
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}));
|
||||
oxRequire(stat, ctx.rom->stat(filePath));
|
||||
if (stat.fileType == ox::FileType::NormalFile) {
|
||||
oxRequire(data, ctx.rom->read(filePath));
|
||||
const auto [hdr, err] = readAssetHeader(data);
|
||||
auto const [hdr, err] = readAssetHeader(data);
|
||||
if (!err) {
|
||||
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;
|
||||
}
|
||||
|
||||
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(buff, static_cast<ox::MemFS*>(ctx.rom.get())->directAccess(file));
|
||||
PreloadPtr p;
|
||||
|
@ -6,14 +6,14 @@
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<const Module*> const&modules() noexcept {
|
||||
ox::Vector<Module const*> const&modules() noexcept {
|
||||
return mods;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ ox::Vector<TypeDescGenerator> Module::types() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Vector<const keel::BaseConverter*> Module::converters() const noexcept {
|
||||
ox::Vector<keel::BaseConverter const*> Module::converters() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::StringView path) noexcept {
|
||||
return OxError(1, "Could not find OxFS file");
|
||||
}
|
||||
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);
|
||||
file.seekg(0, std::ios::beg);
|
||||
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 {
|
||||
for (const auto mod : keel::modules()) {
|
||||
for (auto const mod : keel::modules()) {
|
||||
for (auto gen : mod->types()) {
|
||||
oxReturnError(gen(*ts));
|
||||
}
|
||||
@ -74,10 +74,10 @@ static ox::Error pack(ox::StringView argSrc, ox::StringView argRomBin, ox::Strin
|
||||
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);
|
||||
const auto argSrc = args.getString("src", "");
|
||||
const auto argRomBin = args.getString("rom-bin", "");
|
||||
auto const argSrc = args.getString("src", "");
|
||||
auto const argRomBin = args.getString("rom-bin", "");
|
||||
if (argSrc == "") {
|
||||
oxErr("\033[31;1;1merror:\033[0m must specify a source directory\n");
|
||||
return OxError(1, "must specify a source directory");
|
||||
@ -96,7 +96,7 @@ ox::Error run(
|
||||
[[maybe_unused]] ox::StringView appName,
|
||||
ox::StringView projectDataDir,
|
||||
int argc,
|
||||
const char **argv) noexcept {
|
||||
char const**argv) noexcept {
|
||||
return ::run(argc, argv, projectDataDir);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ static ox::Error pathToInode(
|
||||
return {};
|
||||
}
|
||||
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));
|
||||
}
|
||||
oxRequire(s, dest.stat(path));
|
||||
@ -113,11 +113,11 @@ static ox::Error transformClaw(
|
||||
// copy
|
||||
oxTracef("pack.transformClaw", "path: {}", path);
|
||||
oxRequire(fileList, dest.ls(path));
|
||||
for (const auto &name : fileList) {
|
||||
const auto filePath = ox::sfmt("{}{}", path, name);
|
||||
for (auto const&name : fileList) {
|
||||
auto const filePath = ox::sfmt("{}{}", path, name);
|
||||
oxRequire(stat, dest.stat(filePath));
|
||||
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));
|
||||
} else {
|
||||
oxReturnError(doTransformations(ctx, ts, dest, filePath));
|
||||
@ -133,7 +133,7 @@ static ox::Error copy(
|
||||
oxOutf("copying directory: {}\n", path);
|
||||
// copy
|
||||
oxRequire(fileList, src.ls(path));
|
||||
for (const auto &name : fileList) {
|
||||
for (auto const&name : fileList) {
|
||||
auto currentFile = ox::sfmt("{}{}", path, name);
|
||||
if (beginsWith(name, ".")) {
|
||||
continue;
|
||||
|
@ -27,7 +27,7 @@ static ox::Result<const BaseConverter*> findConverter(
|
||||
static ox::Result<ox::UniquePtr<Wrap>> convert(
|
||||
[[maybe_unused]] keel::Context &ctx,
|
||||
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]] int srcTypeVersion,
|
||||
[[maybe_unused]] ox::CRStringView dstTypeName,
|
||||
@ -54,7 +54,7 @@ static ox::Result<ox::UniquePtr<Wrap>> convert(
|
||||
|
||||
ox::Result<ox::UniquePtr<Wrap>> convert(
|
||||
[[maybe_unused]] keel::Context &ctx,
|
||||
[[maybe_unused]] const ox::Buffer &srcBuffer,
|
||||
[[maybe_unused]] ox::Buffer const&srcBuffer,
|
||||
[[maybe_unused]] ox::CRStringView dstTypeName,
|
||||
[[maybe_unused]] int dstTypeVersion) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
|
@ -8,10 +8,10 @@ namespace keel {
|
||||
|
||||
TypeStore::TypeStore(ox::FileSystem &fs, ox::StringView descPath) noexcept:
|
||||
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);
|
||||
oxRequire(buff, m_fs.read(path));
|
||||
auto dt = ox::make_unique<ox::DescriptorType>();
|
||||
|
Loading…
Reference in New Issue
Block a user