[nostalgia/core] Make Context never move

This commit is contained in:
2021-07-18 16:11:23 -05:00
parent 70fd56ce0b
commit bed8c35218
5 changed files with 19 additions and 22 deletions
+3 -6
View File
@@ -32,12 +32,9 @@ class Context {
public:
constexpr Context() noexcept = default;
constexpr Context(const Context &&other) noexcept {
rom = ox::move(other.rom);
drawers = ox::move(other.drawers);
m_windowerData = ox::move(other.m_windowerData);
m_rendererData = ox::move(other.m_rendererData);
}
Context(Context &other) noexcept = delete;
Context(const Context &other) noexcept = delete;
Context(const Context &&other) noexcept = delete;
constexpr void setWindowerData(void *windowerData) noexcept {
m_windowerData = windowerData;
+1 -1
View File
@@ -20,7 +20,7 @@ namespace nostalgia::core {
using event_handler = int(*)(Context*);
ox::Result<Context> init(ox::FileSystem *fs) noexcept;
ox::Result<ox::UniquePtr<Context>> init(ox::FileSystem *fs) noexcept;
ox::Error run(Context *ctx) noexcept;
+4 -4
View File
@@ -40,10 +40,10 @@ static void initTimer() noexcept {
REG_IE = REG_IE | Int_timer0;
}
ox::Result<Context> init(ox::FileSystem *fs) noexcept {
Context ctx;
ctx.rom = fs;
oxReturnError(initGfx(&ctx));
ox::Result<ox::UniquePtr<Context>> init(ox::FileSystem *fs) noexcept {
auto ctx = ox::make_unique<Context>();
ctx->rom = fs;
oxReturnError(initGfx(ctx.get()));
initTimer();
initIrq();
return ctx;
+5 -5
View File
@@ -37,15 +37,15 @@ static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int
}
}
ox::Result<Context> init(ox::FileSystem *fs) noexcept {
Context ctx;
ctx.rom = fs;
ox::Result<ox::UniquePtr<Context>> init(ox::FileSystem *fs) noexcept {
auto ctx = ox::make_unique<Context>();
ctx->rom = fs;
const auto id = new GlfwImplData;
ctx.setWindowerData(id);
ctx->setWindowerData(id);
using namespace std::chrono;
id->startTime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
glfwInit();
oxReturnError(initGfx(&ctx));
oxReturnError(initGfx(ctx.get()));
glfwSetKeyCallback(id->window, handleGlfwKeyEvent);
return ctx;
}