Toast Engine
Loading...
Searching...
No Matches
script_context.hpp
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <atomic>
11#include <cstddef>
12#include <cstdint>
13#include <memory>
14#include <toast/world/box.hpp>
15
16namespace toast {
17class Node;
18}
19
20namespace scripting {
21
30 std::atomic<bool> alive {true};
31 uint32_t id = 0;
32 size_t vm_index = 0;
33};
34
38 std::shared_ptr<RuntimeToken> token;
39};
40
42[[nodiscard]]
43auto currentScriptNode() -> toast::Box<toast::Node>;
44
45[[nodiscard]]
46auto currentScriptContext() -> const ScriptContext&;
47
48class ScriptNodeContextScope {
49public:
50 explicit ScriptNodeContextScope(toast::Box<toast::Node> node, std::shared_ptr<RuntimeToken> token = {}) noexcept;
51 ~ScriptNodeContextScope() noexcept;
52
53 ScriptNodeContextScope(const ScriptNodeContextScope&) = delete;
54 auto operator=(const ScriptNodeContextScope&) -> ScriptNodeContextScope& = delete;
55 ScriptNodeContextScope(ScriptNodeContextScope&&) = delete;
56 auto operator=(ScriptNodeContextScope&&) -> ScriptNodeContextScope& = delete;
57
58private:
59 ScriptContext m_previous;
60};
61
62}
pseudo shared pointer for Nodes
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Definition node.hpp:81
Lifetime marker of one ScriptRuntime.
Definition script_context.hpp:29
The script that is executing on the current thread.
Definition script_context.hpp:36