[keel,nostalgia,studio,turbine] Make turbine::Context have a keel::Context instead of being one

This commit is contained in:
2023-06-20 00:56:55 -05:00
parent d4eaade326
commit c5233e0d1d
24 changed files with 134 additions and 79 deletions

View File

@ -2,6 +2,7 @@
add_library(
Keel
asset.cpp
keel.cpp
media.cpp
module.cpp
pack.cpp

31
src/keel/keel.cpp Normal file
View File

@ -0,0 +1,31 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include "keel.hpp"
namespace keel {
ox::Error init(
keel::Context *ctx,
ox::UPtr<ox::FileSystem> &&fs,
ox::CRStringView appName) noexcept {
ctx->appName = appName;
oxIgnoreError(setRomFs(ctx, std::move(fs)));
#ifndef OX_BARE_METAL
const auto &mods = modules();
for (auto &mod : mods) {
// register type converters
for (auto c : mod->converters()) {
ctx->converters.emplace_back(c);
}
// register pack transforms
for (auto c : mod->packTransforms()) {
ctx->packTransforms.emplace_back(c);
}
}
#endif
return {};
}
}

View File

@ -14,24 +14,15 @@
namespace keel {
ox::Error init(
keel::Context *ctx,
ox::UPtr<ox::FileSystem> &&fs,
ox::CRStringView appName) noexcept;
template<typename Ctx = keel::Context>
ox::Result<ox::UPtr<Ctx>> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept {
auto ctx = ox::make_unique<Ctx>();
ctx->appName = appName;
oxIgnoreError(setRomFs(ctx.get(), std::move(fs)));
#ifndef OX_BARE_METAL
const auto &mods = modules();
for (auto &mod : mods) {
// register type converters
for (auto c : mod->converters()) {
ctx->converters.emplace_back(c);
}
// register pack transforms
for (auto c : mod->packTransforms()) {
ctx->packTransforms.emplace_back(c);
}
}
#endif
oxReturnError(keel::init(ctx.get(), std::move(fs), appName));
return ctx;
}