blob: 64f14e0eada0a1eb69263663d8d89882e7ef94de (
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
45
46
47
48
49
50
51
52
53
54
|
/*
* 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 "property.hpp"
#include "service_locator.hpp"
namespace lua {
/*
* Responsible for adding C/C++ module bindings to Lua threads. This class
* keeps no thread-specific internal state, and instead uses the LUA_REGISTRY
* table of its host threads to store data.
*/
class Bridge {
public:
/*
* Utility for retrieving the Bridge from a Lua thread in which the Bridge's
* bindings have been installed. Use by Lua's C callbacks to access the rest
* of the system.
*/
static auto Get(lua_State* state) -> Bridge*;
Bridge(system_fsm::ServiceLocator& s);
system_fsm::ServiceLocator& services() { return services_; }
auto installBaseModules(lua_State* L) -> void;
auto installLvgl(lua_State* L) -> void;
auto installPropertyModule(
lua_State* L,
const std::string&,
std::vector<
std::pair<std::string, std::variant<LuaFunction, Property*>>>&)
-> void;
Bridge(const Bridge&) = delete;
Bridge& operator=(const Bridge&) = delete;
private:
system_fsm::ServiceLocator& services_;
PropertyBindings bindings_;
};
} // namespace lua
|