blob: c85ccb91b472dc1367d84c5928055a4c43e9427c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* 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;
auto CallProtected(lua_State*, int nargs, int nresults) -> int;
class LuaThread {
public:
static auto Start(system_fsm::ServiceLocator&, lv_obj_t* lvgl_root = nullptr)
-> LuaThread*;
~LuaThread();
auto RunScript(const std::string& path) -> bool;
auto RunString(const std::string& path) -> bool;
auto bridge() -> Bridge& { return *bridge_; }
auto state() -> lua_State* { return state_; }
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
|