[nostalgia/studio] Use Nostalgia TypeStore for Project

This commit is contained in:
Gary Talent 2022-05-29 01:28:21 -05:00
parent 285a0f9b24
commit 3834de3318
2 changed files with 7 additions and 5 deletions

View File

@ -18,7 +18,7 @@ ox::String filePathToName(const ox::String &path, const ox::String &prefix, cons
} }
Project::Project(ox::FileSystem *fs, const ox::String &path) noexcept: m_fs(fs) { Project::Project(ox::FileSystem *fs, const ox::String &path) noexcept: m_typeStore(fs), m_fs(fs) {
oxTracef("nostalgia::studio", "Project: {}", path); oxTracef("nostalgia::studio", "Project: {}", path);
m_path = path; m_path = path;
buildFileIndex(); buildFileIndex();

View File

@ -12,6 +12,8 @@
#include <ox/model/descwrite.hpp> #include <ox/model/descwrite.hpp>
#include <ox/std/hashmap.hpp> #include <ox/std/hashmap.hpp>
#include <nostalgia/core/typestore.hpp>
#include "nostalgiastudio_export.h" #include "nostalgiastudio_export.h"
namespace nostalgia::studio { namespace nostalgia::studio {
@ -40,7 +42,8 @@ ox::String filePathToName(const ox::String &path, const ox::String &prefix, cons
class NOSTALGIASTUDIO_EXPORT Project { class NOSTALGIASTUDIO_EXPORT Project {
private: private:
ox::String m_path = ""; ox::String m_path;
mutable core::TypeStore m_typeStore;
mutable ox::FileSystem *m_fs = nullptr; mutable ox::FileSystem *m_fs = nullptr;
ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap; ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap;
@ -103,12 +106,11 @@ ox::Error Project::writeObj(const ox::String &path, auto *obj) const noexcept {
// write to FS // write to FS
oxReturnError(writeBuff(path, buff)); oxReturnError(writeBuff(path, buff));
// write type descriptor // write type descriptor
ox::TypeStore typeStore; oxReturnError(ox::buildTypeDef(&m_typeStore, obj));
oxReturnError(ox::buildTypeDef(&typeStore, obj));
// write out type store // write out type store
static constexpr auto descPath = "/.nostalgia/type_descriptors"; static constexpr auto descPath = "/.nostalgia/type_descriptors";
oxReturnError(mkdir(descPath)); oxReturnError(mkdir(descPath));
for (const auto t : typeStore.typeList()) { for (const auto t : m_typeStore.typeList()) {
if (t->typeName.beginsWith("B:")) { if (t->typeName.beginsWith("B:")) {
continue; continue;
} }