[nostalgia] Integrate Ox Preloader

This commit is contained in:
2022-11-30 01:47:33 -06:00
parent cbb496c59f
commit 090fe28b44
41 changed files with 404 additions and 159 deletions
+8 -4
View File
@@ -57,7 +57,8 @@ class NOSTALGIASTUDIO_EXPORT Project {
/**
* Writes a MetalClaw object to the project at the given path.
*/
ox::Error writeObj(const ox::String &path, auto *obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept;
template<typename T>
ox::Error writeObj(const ox::String &path, const T *obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept;
template<typename T>
ox::Result<ox::UniquePtr<T>> loadObj(const ox::String &path) const noexcept;
@@ -99,13 +100,16 @@ class NOSTALGIASTUDIO_EXPORT Project {
};
ox::Error Project::writeObj(const ox::String &path, auto *obj, ox::ClawFormat fmt) noexcept {
template<typename T>
ox::Error Project::writeObj(const ox::String &path, const T *obj, ox::ClawFormat fmt) noexcept {
// write MetalClaw
oxRequireM(buff, ox::writeClaw(obj, fmt));
// write to FS
oxReturnError(writeBuff(path, buff));
// write type descriptor
oxReturnError(ox::buildTypeDef(&m_typeStore, obj));
if (m_typeStore.get<T>().error) {
oxReturnError(ox::buildTypeDef(&m_typeStore, obj));
}
// write out type store
static constexpr auto descPath = "/.nostalgia/type_descriptors";
oxReturnError(mkdir(descPath));
@@ -114,7 +118,7 @@ ox::Error Project::writeObj(const ox::String &path, auto *obj, ox::ClawFormat fm
// replace garbage last character with new line
typeOut.back().value = '\n';
// write to FS
const auto typePath = ox::sfmt("{}/{};{}", descPath, t->typeName, t->typeVersion);
const auto typePath = ox::sfmt("{}/{}", descPath, buildTypeId(*t));
oxReturnError(writeBuff(typePath, typeOut));
}
fileUpdated.emit(path);