summaryrefslogtreecommitdiff
path: root/src/lua/bridge.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/bridge.cpp')
-rw-r--r--src/lua/bridge.cpp37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/lua/bridge.cpp b/src/lua/bridge.cpp
index a45f2b27..070dee98 100644
--- a/src/lua/bridge.cpp
+++ b/src/lua/bridge.cpp
@@ -5,13 +5,19 @@
*/
#include "bridge.hpp"
+#include <sys/_stdint.h>
#include <memory>
#include <string>
+#include "database.hpp"
#include "esp_log.h"
+#include "index.hpp"
#include "lauxlib.h"
+#include "lua.h"
#include "lua.hpp"
+#include "lua_database.hpp"
+#include "lua_queue.hpp"
#include "lvgl.h"
#include "event_queue.hpp"
@@ -22,6 +28,7 @@
namespace lua {
[[maybe_unused]] static constexpr char kTag[] = "lua_bridge";
+
static constexpr char kBridgeKey[] = "bridge";
static auto open_settings_fn(lua_State* state) -> int {
@@ -54,32 +61,6 @@ static auto lua_legacy_ui(lua_State* state) -> int {
return 1;
}
-static auto get_indexes(lua_State* state) -> int {
- Bridge* instance = Bridge::Get(state);
-
- lua_newtable(state);
-
- auto db = instance->services().database().lock();
- if (!db) {
- return 1;
- }
-
- for (const auto& i : db->GetIndexes()) {
- lua_pushstring(state, i.name.c_str());
- lua_rawseti(state, -2, i.id);
- }
-
- return 1;
-}
-
-static const struct luaL_Reg kDatabaseFuncs[] = {{"get_indexes", get_indexes},
- {NULL, NULL}};
-
-static auto lua_database(lua_State* state) -> int {
- luaL_newlib(state, kDatabaseFuncs);
- return 1;
-}
-
auto Bridge::Get(lua_State* state) -> Bridge* {
lua_pushstring(state, kBridgeKey);
lua_gettable(state, LUA_REGISTRYINDEX);
@@ -95,8 +76,8 @@ Bridge::Bridge(system_fsm::ServiceLocator& services, lua_State& s)
luaL_requiref(&s, "legacy_ui", lua_legacy_ui, true);
lua_pop(&s, 1);
- luaL_requiref(&s, "database", lua_database, true);
- lua_pop(&s, 1);
+ RegisterDatabaseModule(&s);
+ RegisterQueueModule(&s);
}
static auto new_property_module(lua_State* state) -> int {