|
Bicameral Engine
GPU-resident engine for a magic-research open-world game
|
#include <luau_sandbox.h>
Public Member Functions | |
| ~LuauSandbox () | |
| LuauSandbox (const LuauSandbox &)=delete | |
| LuauSandbox & | operator= (const LuauSandbox &)=delete |
| std::expected< void, ScriptError > | RegisterFunction (const char *tableName, const char *name, HostFunction function, void *context) |
| void | Seal () |
| std::expected< RunResult, ScriptError > | Run (std::string_view chunkName, std::string_view source, const RunOptions &options={}) |
| bool | IsSealed () const |
| uint64_t | MemoryBytes () const |
Static Public Member Functions | |
| static std::expected< std::unique_ptr< LuauSandbox >, std::string > | Create (SandboxLimits limits) |
| static void * | HostContext (lua_State *state) |
Private Member Functions | |
| LuauSandbox (SandboxLimits limits) | |
| std::expected< void, std::string > | OpenLibraries () |
| void | ReseedRandom () |
| std::expected< RunResult, ScriptError > | RunThread (lua_State *thread, std::string_view chunkName, const char *bytecode, size_t bytecodeSize, const RunOptions &options) |
| std::expected< RunResult, ScriptError > | CollectResults (lua_State *thread, std::string_view chunkName, const RunOptions &options) |
| void | BeginModules (lua_State *thread, const ModuleResolver *modules) |
| void | EndModules () |
| std::expected< void, std::string > | LoadModule (lua_State *state, std::string_view name) |
| std::expected< void, std::string > | RunModule (lua_State *state, const std::string &chunkName, std::string_view source) |
Static Private Member Functions | |
| static void * | Allocate (void *userData, void *pointer, size_t oldSize, size_t newSize) |
| static void | Interrupt (lua_State *state, int gc) |
| static int | Print (lua_State *state) |
| static int | Require (lua_State *state) |
Private Attributes | |
| SandboxLimits | m_limits |
| lua_State * | m_state = nullptr |
| bool | m_sealed = false |
| uint64_t | m_memoryBytes = 0 |
| uint64_t | m_safepointCount = 0 |
| bool | m_safepointExceeded = false |
| bool | m_memoryExceeded = false |
| std::string | m_currentChunk |
| const ModuleResolver * | m_modules = nullptr |
| int | m_moduleCacheRef = 0 |
| std::vector< std::string > | m_moduleLoading |
Definition at line 82 of file luau_sandbox.h.
| bicameral::script::LuauSandbox::~LuauSandbox | ( | ) |
Definition at line 175 of file luau_sandbox.cpp.
References m_state.
|
delete |
References LuauSandbox().
Referenced by Allocate(), Create(), Interrupt(), LuauSandbox(), operator=(), Print(), and Require().
|
explicitprivate |
Definition at line 173 of file luau_sandbox.cpp.
References m_limits.
|
staticprivate |
Definition at line 480 of file luau_sandbox.cpp.
References LuauSandbox().
Referenced by Create().
|
private |
Definition at line 355 of file luau_sandbox.cpp.
References m_moduleCacheRef, m_moduleLoading, m_modules, m_state, and Require().
Referenced by Run().
|
nodiscardprivate |
Definition at line 328 of file luau_sandbox.cpp.
References bicameral::script::RunOptions::captureValues, m_safepointCount, bicameral::script::RunResult::returns, bicameral::script::Runtime, bicameral::script::RunResult::safepointCount, and bicameral::script::RunResult::values.
Referenced by RunThread().
|
staticnodiscard |
Definition at line 180 of file luau_sandbox.cpp.
References Allocate(), Interrupt(), and LuauSandbox().
Referenced by bicameral::script::anonymous_namespace{reaction_table_loader.cpp}::LoadPackageSet().
|
private |
Definition at line 370 of file luau_sandbox.cpp.
References m_moduleCacheRef, m_moduleLoading, m_modules, and m_state.
Referenced by Run().
|
staticnodiscard |
Definition at line 258 of file luau_sandbox.cpp.
|
staticprivate |
Definition at line 508 of file luau_sandbox.cpp.
References LuauSandbox().
Referenced by Create().
|
inlinenodiscard |
Definition at line 106 of file luau_sandbox.h.
References m_sealed.
Referenced by bicameral::script::LoadPackages().
|
nodiscardprivate |
Definition at line 399 of file luau_sandbox.cpp.
References m_moduleCacheRef, m_moduleLoading, m_modules, and RunModule().
|
inlinenodiscard |
Definition at line 107 of file luau_sandbox.h.
References m_memoryBytes.
|
nodiscardprivate |
Definition at line 197 of file luau_sandbox.cpp.
References m_state, and Print().
|
delete |
|
staticprivate |
Definition at line 523 of file luau_sandbox.cpp.
References bicameral::Info, bicameral::Log(), LuauSandbox(), and bicameral::Tool.
Referenced by OpenLibraries().
|
nodiscard |
Definition at line 224 of file luau_sandbox.cpp.
References m_sealed, m_state, and bicameral::script::Usage.
|
staticprivate |
Definition at line 379 of file luau_sandbox.cpp.
References LuauSandbox().
Referenced by BeginModules().
|
private |
Definition at line 264 of file luau_sandbox.cpp.
References m_limits, and m_state.
Referenced by Run().
|
nodiscard |
Definition at line 275 of file luau_sandbox.cpp.
References BeginModules(), bicameral::script::Compile, EndModules(), m_currentChunk, m_memoryExceeded, m_safepointCount, m_safepointExceeded, m_sealed, m_state, bicameral::script::Memory, bicameral::script::RunOptions::modules, ReseedRandom(), RunThread(), and bicameral::script::Usage.
Referenced by bicameral::script::anonymous_namespace{luau_package.cpp}::ReadManifest(), and bicameral::script::anonymous_namespace{luau_package.cpp}::RunEntry().
|
nodiscardprivate |
Definition at line 429 of file luau_sandbox.cpp.
References bicameral::script::Compile, and m_moduleLoading.
Referenced by LoadModule().
|
nodiscardprivate |
Definition at line 311 of file luau_sandbox.cpp.
References CollectResults(), bicameral::script::Compile, m_memoryExceeded, and m_safepointExceeded.
Referenced by Run().
| void bicameral::script::LuauSandbox::Seal | ( | ) |
Definition at line 250 of file luau_sandbox.cpp.
|
private |
Definition at line 145 of file luau_sandbox.h.
Referenced by Run().
|
private |
Definition at line 136 of file luau_sandbox.h.
Referenced by LuauSandbox(), and ReseedRandom().
|
private |
Definition at line 141 of file luau_sandbox.h.
Referenced by MemoryBytes().
|
private |
Definition at line 144 of file luau_sandbox.h.
Referenced by Run(), and RunThread().
|
private |
Definition at line 149 of file luau_sandbox.h.
Referenced by BeginModules(), EndModules(), and LoadModule().
|
private |
Definition at line 150 of file luau_sandbox.h.
Referenced by BeginModules(), EndModules(), LoadModule(), and RunModule().
|
private |
Definition at line 148 of file luau_sandbox.h.
Referenced by BeginModules(), EndModules(), and LoadModule().
|
private |
Definition at line 142 of file luau_sandbox.h.
Referenced by CollectResults(), and Run().
|
private |
Definition at line 143 of file luau_sandbox.h.
Referenced by Run(), and RunThread().
|
private |
Definition at line 138 of file luau_sandbox.h.
Referenced by IsSealed(), RegisterFunction(), Run(), and Seal().
|
private |
Definition at line 137 of file luau_sandbox.h.
Referenced by BeginModules(), EndModules(), OpenLibraries(), RegisterFunction(), ReseedRandom(), Run(), Seal(), and ~LuauSandbox().