summaryrefslogtreecommitdiff
path: root/src/lua/include/lua_thread.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/include/lua_thread.hpp')
-rw-r--r--src/lua/include/lua_thread.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lua/include/lua_thread.hpp b/src/lua/include/lua_thread.hpp
new file mode 100644
index 00000000..381b1bdb
--- /dev/null
+++ b/src/lua/include/lua_thread.hpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include "lua.hpp"
+#include "lvgl.h"
+
+#include "bridge.hpp"
+#include "service_locator.hpp"
+
+namespace lua {
+
+class Allocator;
+
+class LuaThread {
+ public:
+ static auto Start(system_fsm::ServiceLocator&, lv_obj_t* lvgl_root = nullptr)
+ -> LuaThread*;
+ ~LuaThread();
+
+ auto RunScript(const std::string& path) -> bool;
+
+ private:
+ LuaThread(std::unique_ptr<Allocator>&, std::unique_ptr<Bridge>&, lua_State*);
+
+ std::unique_ptr<Allocator> alloc_;
+ std::unique_ptr<Bridge> bridge_;
+ lua_State* state_;
+};
+
+} // namespace lua