Toast Engine
Toggle main menu visibility
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
16
namespace
toast {
17
class
Node
;
18
}
19
20
namespace
scripting {
21
29
struct
RuntimeToken
{
30
std::atomic<bool> alive {
true
};
31
uint32_t
id
= 0;
32
size_t
vm_index = 0;
33
};
34
36
struct
ScriptContext
{
37
toast::Box<toast::Node>
node;
38
std::shared_ptr<RuntimeToken> token;
39
};
40
42
[[nodiscard]]
43
auto
currentScriptNode() ->
toast::Box<toast::Node>
;
44
45
[[nodiscard]]
46
auto
currentScriptContext() ->
const
ScriptContext
&;
47
48
class
ScriptNodeContextScope {
49
public
:
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
58
private
:
59
ScriptContext
m_previous;
60
};
61
62
}
box.hpp
pseudo shared pointer for Nodes
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::Node
Definition
node.hpp:81
scripting::RuntimeToken
Lifetime marker of one ScriptRuntime.
Definition
script_context.hpp:29
scripting::ScriptContext
The script that is executing on the current thread.
Definition
script_context.hpp:36
engine
src
toast
scripting
script_context.hpp
Generated by
1.17.0