summaryrefslogtreecommitdiff
path: root/src/lua/registry.cpp
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2024-05-03 04:48:17 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-05-03 04:48:17 +0000
commit3ceb8025ee4330c177101ed30ec17dfb0002f41e (patch)
tree58350210f15df7d00d967cac6f30eeceeb031a3c /src/lua/registry.cpp
parent964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (diff)
parent9fafd797a5504f458b5fcae4a1d28a68da936315 (diff)
downloadtangara-fw-3ceb8025ee4330c177101ed30ec17dfb0002f41e.tar.gz
Merge pull request 'Break dependency cycles with our components by merging co-dependent components together' (#68) from jqln/component-merge into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/68
Diffstat (limited to 'src/lua/registry.cpp')
-rw-r--r--src/lua/registry.cpp73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/lua/registry.cpp b/src/lua/registry.cpp
deleted file mode 100644
index a6487858..00000000
--- a/src/lua/registry.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#include "lua_registry.hpp"
-
-#include <iostream>
-#include <memory>
-
-#include "esp_heap_caps.h"
-#include "esp_log.h"
-#include "lua.hpp"
-
-#include "bridge.hpp"
-#include "event_queue.hpp"
-#include "memory_resource.hpp"
-#include "service_locator.hpp"
-#include "ui_events.hpp"
-
-namespace lua {
-
-[[maybe_unused]] static constexpr char kTag[] = "lua";
-
-auto Registry::instance(system_fsm::ServiceLocator& s) -> Registry& {
- static Registry sRegistry{s};
- return sRegistry;
-}
-
-Registry::Registry(system_fsm::ServiceLocator& services)
- : services_(services), bridge_(new Bridge(services)) {}
-
-auto Registry::uiThread() -> std::shared_ptr<LuaThread> {
- if (!ui_thread_) {
- ui_thread_ = newThread();
- bridge_->installLvgl(ui_thread_->state());
- }
- return ui_thread_;
-}
-
-auto Registry::newThread() -> std::shared_ptr<LuaThread> {
- std::shared_ptr<LuaThread> thread{LuaThread::Start(services_)};
- bridge_->installBaseModules(thread->state());
- for (auto& module : modules_) {
- bridge_->installPropertyModule(thread->state(), module.first,
- module.second);
- }
- threads_.push_back(thread);
- return thread;
-}
-
-auto Registry::AddPropertyModule(
- const std::string& name,
- std::vector<std::pair<std::string, std::variant<LuaFunction, Property*>>>
- properties) -> void {
- modules_.push_back(std::make_pair(name, properties));
-
- // Any live threads will need to be updated to include the new module.
- auto it = threads_.begin();
- while (it != threads_.end()) {
- auto thread = it->lock();
- if (!thread) {
- // Thread has been destroyed; stop tracking it.
- it = threads_.erase(it);
- } else {
- bridge_->installPropertyModule(thread->state(), name, properties);
- it++;
- }
- }
-}
-
-} // namespace lua