[nostalgia] Integrate Ox Preloader
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user