[keel,studio] Update for Ox changes

This commit is contained in:
Gary Talent 2023-06-08 21:18:30 -05:00
parent 2c8e073172
commit e0289ee7e0
6 changed files with 15 additions and 12 deletions

View File

@ -131,7 +131,7 @@ ox::Error writeObj(
const ox::FileAddress &file, const ox::FileAddress &file,
const T &obj, const T &obj,
ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept { ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept {
oxRequire(objBuff, ox::writeClaw(&obj, fmt)); oxRequire(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

@ -87,7 +87,7 @@ static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::Fi
// transform FileAddresses // transform FileAddresses
oxRequireM(obj, keel::readAsset(ts, buff)); oxRequireM(obj, keel::readAsset(ts, buff));
oxReturnError(transformFileAddressesObj(ctx, dest, &obj)); oxReturnError(transformFileAddressesObj(ctx, dest, &obj));
oxReturnError(ox::writeClaw(&obj).moveTo(&buff)); oxReturnError(ox::writeClaw(obj).moveTo(&buff));
// write file to dest // write file to dest
oxReturnError(dest->write(s.inode, buff.data(), buff.size())); oxReturnError(dest->write(s.inode, buff.data(), buff.size()));
return {}; return {};

View File

@ -172,7 +172,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.get()), fmt); return ox::writeClaw<DstType>(*wrapCast<DstType>(out.get()), 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

@ -48,7 +48,7 @@ ox::Error writeConfig(keel::Context *ctx, ox::CRStringView name, T *data) noexce
oxErrf("Could not create config directory: {}\n", toStr(err)); oxErrf("Could not create config directory: {}\n", toStr(err));
return err; return err;
} }
oxRequireM(buff, ox::writeOC(data)); oxRequireM(buff, ox::writeOC(*data));
buff.back().value = '\n'; buff.back().value = '\n';
if (const auto err = fs.write(path, buff.data(), buff.size())) { if (const auto err = fs.write(path, buff.data(), buff.size())) {
oxErrf("Could not read config file: {}\n", toStr(err)); oxErrf("Could not read config file: {}\n", toStr(err));

View File

@ -59,10 +59,13 @@ class Project {
* Writes a MetalClaw object to the project at the given path. * Writes a MetalClaw object to the project at the given path.
*/ */
template<typename T> template<typename T>
ox::Error writeObj(const ox::String &path, const T *obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept; ox::Error writeObj(
const ox::StringView &path,
const T *obj,
ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept;
template<typename T> template<typename T>
ox::Result<T> loadObj(const ox::String &path) const noexcept; ox::Result<T> loadObj(const ox::StringView &path) const noexcept;
ox::Result<ox::FileStat> stat(ox::CRStringView path) const noexcept; ox::Result<ox::FileStat> stat(ox::CRStringView path) const noexcept;
@ -82,7 +85,7 @@ class Project {
ox::Error writeBuff(const ox::StringView &path, const ox::Buffer &buff) noexcept; ox::Error writeBuff(const ox::StringView &path, const ox::Buffer &buff) noexcept;
ox::Result<ox::Buffer> loadBuff(const ox::String &path) const noexcept; ox::Result<ox::Buffer> loadBuff(const ox::StringView &path) const noexcept;
ox::Error lsProcDir(ox::Vector<ox::String> *paths, ox::CRStringView path) const noexcept; ox::Error lsProcDir(ox::Vector<ox::String> *paths, ox::CRStringView path) const noexcept;
@ -102,9 +105,9 @@ class Project {
}; };
template<typename T> template<typename T>
ox::Error Project::writeObj(const ox::String &path, const T *obj, ox::ClawFormat fmt) noexcept { ox::Error Project::writeObj(const ox::StringView &path, const T *obj, ox::ClawFormat fmt) noexcept {
// write MetalClaw // write MetalClaw
oxRequireM(buff, ox::writeClaw(obj, fmt)); oxRequireM(buff, ox::writeClaw(*obj, fmt));
// write to FS // write to FS
oxReturnError(writeBuff(path, buff)); oxReturnError(writeBuff(path, buff));
// write type descriptor // write type descriptor
@ -115,7 +118,7 @@ ox::Error Project::writeObj(const ox::String &path, const T *obj, ox::ClawFormat
const auto descPath = ox::sfmt("/.{}/type_descriptors", m_projectDataDir); const auto descPath = ox::sfmt("/.{}/type_descriptors", m_projectDataDir);
oxReturnError(mkdir(descPath)); oxReturnError(mkdir(descPath));
for (const auto &t : m_typeStore.typeList()) { for (const auto &t : m_typeStore.typeList()) {
oxRequireM(typeOut, ox::writeClaw(t, ox::ClawFormat::Organic)); oxRequireM(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
// replace garbage last character with new line // replace garbage last character with new line
typeOut.back().value = '\n'; typeOut.back().value = '\n';
// write to FS // write to FS
@ -127,7 +130,7 @@ ox::Error Project::writeObj(const ox::String &path, const T *obj, ox::ClawFormat
} }
template<typename T> template<typename T>
ox::Result<T> Project::loadObj(const ox::String &path) const noexcept { ox::Result<T> Project::loadObj(const ox::StringView &path) const noexcept {
oxRequire(buff, loadBuff(path)); oxRequire(buff, loadBuff(path));
if constexpr (ox::is_same_v<T, ox::ModelObject>) { if constexpr (ox::is_same_v<T, ox::ModelObject>) {
return keel::readAsset(&m_typeStore, buff); return keel::readAsset(&m_typeStore, buff);

View File

@ -104,7 +104,7 @@ ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff)
return {}; return {};
} }
ox::Result<ox::Buffer> Project::loadBuff(const ox::String &path) const noexcept { ox::Result<ox::Buffer> Project::loadBuff(const ox::StringView &path) const noexcept {
return m_fs->read(path); return m_fs->read(path);
} }