[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
pack.cpp
typeconv.cpp
typestore.cpp
)
target_link_libraries(
@ -28,6 +29,7 @@ install(
module.hpp
pack.hpp
typeconv.hpp
typestore.hpp
DESTINATION
include/keel
)

View File

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

View File

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

View File

@ -8,14 +8,17 @@
#include <ox/fs/fs.hpp>
#include <ox/model/typestore.hpp>
namespace nostalgia::core {
namespace keel {
class TypeStore: public ox::TypeStore {
private:
ox::FileSystem *m_fs = nullptr;
ox::String m_descPath;
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:

View File

@ -5,7 +5,6 @@ add_library(
module.cpp
tilesheet.cpp
typeconv.cpp
typestore.cpp
)
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
@ -40,7 +39,6 @@ install(
ptidxconv.hpp
tilesheet.hpp
typeconv.hpp
typestore.hpp
DESTINATION
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:
m_path(std::move(path)),
m_typeStore(ctx->rom.get()),
m_typeStore(ctx->rom.get(), "/.nostalgia/type_descriptors"),
m_fs(ctx->rom.get()),
m_ctx(ctx) {
oxTracef("nostalgia::studio", "Project: {}", m_path);

View File

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

View File

@ -11,7 +11,6 @@
#include <keel/keel.hpp>
#include <nostalgia/appmodules/appmodules.hpp>
#include <nostalgia/core/typestore.hpp>
using namespace nostalgia;
@ -68,7 +67,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
oxReturnError(ox::FileSystem32::format(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"));
core::TypeStore ts(ctx->rom.get());
keel::TypeStore ts(ctx->rom.get(), "/.nostalgia/type_descriptors");
oxReturnError(generateTypes(&ts));
oxReturnError(keel::pack(ctx.get(), &ts, &dst));
oxRequireM(pl, keel::GbaPreloader::make());