diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-05-02 19:12:26 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-05-02 19:12:26 +1000 |
| commit | 1573a8c4cde1cd9528b422b2dcc598e37ffe94a7 (patch) | |
| tree | d162822b8fd7054f81bace0c7a65ab4d5e6f93ef /src/tangara/lua/lua_thread.hpp | |
| parent | a231fd1c8afedbeb14b0bc77d76bad61db986059 (diff) | |
| download | tangara-fw-1573a8c4cde1cd9528b422b2dcc598e37ffe94a7.tar.gz | |
WIP merge cyclically dependent components into one big component
Diffstat (limited to 'src/tangara/lua/lua_thread.hpp')
| -rw-r--r-- | src/tangara/lua/lua_thread.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tangara/lua/lua_thread.hpp b/src/tangara/lua/lua_thread.hpp new file mode 100644 index 00000000..384de61d --- /dev/null +++ b/src/tangara/lua/lua_thread.hpp @@ -0,0 +1,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 "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&) -> LuaThread*; + ~LuaThread(); + + auto RunScript(const std::string& path) -> bool; + auto RunString(const std::string& path) -> bool; + + auto DumpStack() -> void; + + auto state() -> lua_State* { return state_; } + + LuaThread(const LuaThread&) = delete; + LuaThread& operator=(const LuaThread&) = delete; + + private: + LuaThread(std::unique_ptr<Allocator>&, lua_State*); + + std::unique_ptr<Allocator> alloc_; + lua_State* state_; +}; + +} // namespace lua |
