[nostalgia,keel] Move core::TypeStore to Keel

This commit is contained in:
Gary Talent 2023-06-01 23:43:19 -05:00
parent 1d35f6ce70
commit 4364911229
8 changed files with 14 additions and 12 deletions

View File

@ -6,6 +6,7 @@ add_library(
module.cpp module.cpp
pack.cpp pack.cpp
typeconv.cpp typeconv.cpp
typestore.cpp
) )
target_link_libraries( target_link_libraries(
@ -28,6 +29,7 @@ install(
module.hpp module.hpp
pack.hpp pack.hpp
typeconv.hpp typeconv.hpp
typestore.hpp
DESTINATION DESTINATION
include/keel include/keel
) )

View File

@ -10,6 +10,7 @@
#include "media.hpp" #include "media.hpp"
#include "module.hpp" #include "module.hpp"
#include "pack.hpp" #include "pack.hpp"
#include "typestore.hpp"
namespace keel { namespace keel {

View File

@ -4,11 +4,10 @@
#include "typestore.hpp" #include "typestore.hpp"
namespace nostalgia::core { namespace keel {
ox::Result<ox::UniquePtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::CRStringView typeId) noexcept { ox::Result<ox::UniquePtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::CRStringView typeId) noexcept {
constexpr auto descPath = "/.nostalgia/type_descriptors"; auto path = ox::sfmt("{}/{}", m_descPath, typeId);
auto path = ox::sfmt("{}/{}", descPath, typeId);
oxRequire(buff, m_fs->read(path)); oxRequire(buff, m_fs->read(path));
auto dt = ox::make_unique<ox::DescriptorType>(); auto dt = ox::make_unique<ox::DescriptorType>();
oxReturnError(ox::readClaw<ox::DescriptorType>(buff, dt.get())); oxReturnError(ox::readClaw<ox::DescriptorType>(buff, dt.get()));

View File

@ -8,14 +8,17 @@
#include <ox/fs/fs.hpp> #include <ox/fs/fs.hpp>
#include <ox/model/typestore.hpp> #include <ox/model/typestore.hpp>
namespace nostalgia::core { namespace keel {
class TypeStore: public ox::TypeStore { class TypeStore: public ox::TypeStore {
private: private:
ox::FileSystem *m_fs = nullptr; ox::FileSystem *m_fs = nullptr;
ox::String m_descPath;
public: public:
constexpr explicit TypeStore(ox::FileSystem *fs) noexcept: m_fs(fs) { constexpr explicit TypeStore(ox::FileSystem *fs, ox::String descPath = "/.keel/type_descriptors") noexcept:
m_fs(fs),
m_descPath(std::move(descPath)) {
} }
protected: protected:

View File

@ -5,7 +5,6 @@ add_library(
module.cpp module.cpp
tilesheet.cpp tilesheet.cpp
typeconv.cpp typeconv.cpp
typestore.cpp
) )
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
@ -40,7 +39,6 @@ install(
ptidxconv.hpp ptidxconv.hpp
tilesheet.hpp tilesheet.hpp
typeconv.hpp typeconv.hpp
typestore.hpp
DESTINATION DESTINATION
include/nostalgia/core include/nostalgia/core
) )

View File

@ -23,7 +23,7 @@ static void generateTypes(ox::TypeStore *ts) noexcept {
Project::Project(keel::Context *ctx, ox::String path) noexcept: Project::Project(keel::Context *ctx, ox::String path) noexcept:
m_path(std::move(path)), m_path(std::move(path)),
m_typeStore(ctx->rom.get()), m_typeStore(ctx->rom.get(), "/.nostalgia/type_descriptors"),
m_fs(ctx->rom.get()), m_fs(ctx->rom.get()),
m_ctx(ctx) { m_ctx(ctx) {
oxTracef("nostalgia::studio", "Project: {}", m_path); oxTracef("nostalgia::studio", "Project: {}", m_path);

View File

@ -12,7 +12,7 @@
#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 <keel/typestore.hpp>
#include <keel/media.hpp> #include <keel/media.hpp>
#include "nostalgiastudio_export.h" #include "nostalgiastudio_export.h"
@ -41,7 +41,7 @@ constexpr ox::Result<ox::StringView> fileExt(ox::CRStringView path) noexcept {
class NOSTALGIASTUDIO_EXPORT Project { class NOSTALGIASTUDIO_EXPORT Project {
private: private:
ox::String m_path; ox::String m_path;
mutable core::TypeStore m_typeStore; mutable keel::TypeStore m_typeStore;
mutable ox::FileSystem *m_fs = nullptr; mutable ox::FileSystem *m_fs = nullptr;
keel::Context *m_ctx = nullptr; keel::Context *m_ctx = nullptr;
ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap; ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap;

View File

@ -11,7 +11,6 @@
#include <keel/keel.hpp> #include <keel/keel.hpp>
#include <nostalgia/appmodules/appmodules.hpp> #include <nostalgia/appmodules/appmodules.hpp>
#include <nostalgia/core/typestore.hpp>
using namespace nostalgia; using namespace nostalgia;
@ -68,7 +67,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size())); ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size()));
oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack")); oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack"));
core::TypeStore ts(ctx->rom.get()); keel::TypeStore ts(ctx->rom.get(), "/.nostalgia/type_descriptors");
oxReturnError(generateTypes(&ts)); oxReturnError(generateTypes(&ts));
oxReturnError(keel::pack(ctx.get(), &ts, &dst)); oxReturnError(keel::pack(ctx.get(), &ts, &dst));
oxRequireM(pl, keel::GbaPreloader::make()); oxRequireM(pl, keel::GbaPreloader::make());