You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
1 year ago
|
/*
|
||
|
* 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"
|
||
1 year ago
|
#include "property.hpp"
|
||
1 year ago
|
#include "service_locator.hpp"
|
||
|
|
||
|
namespace lua {
|
||
|
|
||
1 year ago
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
1 year ago
|
class Bridge {
|
||
|
public:
|
||
1 year ago
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
1 year ago
|
static auto Get(lua_State* state) -> Bridge*;
|
||
|
|
||
1 year ago
|
Bridge(system_fsm::ServiceLocator& s);
|
||
1 year ago
|
|
||
1 year ago
|
system_fsm::ServiceLocator& services() { return services_; }
|
||
|
|
||
|
auto installBaseModules(lua_State* L) -> void;
|
||
|
auto installLvgl(lua_State* L) -> void;
|
||
|
auto installPropertyModule(
|
||
|
lua_State* L,
|
||
1 year ago
|
const std::string&,
|
||
1 year ago
|
std::vector<
|
||
1 year ago
|
std::pair<std::string, std::variant<LuaFunction, Property*>>>&)
|
||
1 year ago
|
-> void;
|
||
1 year ago
|
|
||
1 year ago
|
Bridge(const Bridge&) = delete;
|
||
|
Bridge& operator=(const Bridge&) = delete;
|
||
1 year ago
|
|
||
|
private:
|
||
|
system_fsm::ServiceLocator& services_;
|
||
1 year ago
|
PropertyBindings bindings_;
|
||
1 year ago
|
};
|
||
|
|
||
|
} // namespace lua
|