载入中...
搜索中...
未找到

#include <Runtime.h>

class  Scope
 Pushes this Runtime on the current thread's runtime stack. 更多...
 
struct  ScriptRecord
 
class  StackGuard
 Restores the native Squirrel stack when a binding operation leaves scope. 更多...
 

Public 类型

using ScriptId = uint64_t
 
using ErrorHandler = std::function< void(const ScriptException &)>
 
using LifecycleHandler = std::function< void(const ScriptInfo &)>
 

Public 成员函数

 Runtime (size_t stackSize=2048, ssq::Libs::Flag libraries=ssq::Libs::ALL)
 Creates a script runtime with its own Squirrel VM.
 
 ~Runtime ()
 
 Runtime (Runtime &&)=delete
 
Runtimeoperator= (Runtime &&)=delete
 
 Runtime (const Runtime &)=delete
 
Runtimeoperator= (const Runtime &)=delete
 
void initialize ()
 Exposes registered engine modules into the script root table. Safe to call more than once.
 
void shutdown () noexcept
 Tears down the VM and detaches the runtime; idempotent and noexcept.
 
bool initialized () const noexcept
 True once initialize() has completed successfully.
 
ssq::VM & vm () noexcept
 Underlying SimpleSquirrel VM (requires a live, initialized runtime).
 
const ssq::VM & vm () const noexcept
 
HSQUIRRELVM handle () const noexcept
 Raw Squirrel VM handle; nullptr after shutdown.
 
ssq::Table root () const
 Root script table of the VM.
 
ssq::Table table (const char *name) const
 Looks up a named global table.
 
StackGuard guard () noexcept
 RAII guard that restores the Squirrel stack top on scope exit.
 
Scope enter ()
 Pushes this runtime on the thread-local runtime stack (RAII pop).
 
ScriptId compileSource (std::string source, std::string sourceName="buffer")
 Compiles script source without running it.
 
ScriptId compileFile (const std::string &path)
 Compiles a script file without running it.
 
const ScriptInfoexecute (ScriptId id)
 Runs a previously compiled script; throws ScriptException on failure.
 
ScriptId runSource (std::string source, std::string sourceName="buffer")
 Convenience: compileSource() then execute().
 
ScriptId runFile (const std::string &path)
 Convenience: compileFile() then execute().
 
ScriptId reflectFile (const std::string &path)
 Alias of runFile(); reflects classes declared by the file.
 
const ReflectedClassreflectClass (const std::string &name, const std::string &source={})
 Reflects a class by name, storing its inspected members.
 
ScriptId reload (ScriptId id)
 Recompiles and re-runs a script from its original source.
 
bool unload (ScriptId id)
 Unloads a script and removes its declared classes; false if unknown/unloaded.
 
void unloadAll () noexcept
 Unloads every script.
 
bool contains (ScriptId id) const noexcept
 True if a script with the given id is tracked.
 
const ScriptInfoscript (ScriptId id) const noexcept
 Script metadata for an id, or nullptr if unknown.
 
std::vector< ScriptInfoscripts () const
 Metadata for all tracked scripts, sorted by id.
 
const ReflectedClassreflectedClass (const std::string &name) const noexcept
 Reflected class by name, or nullptr.
 
std::vector< ReflectedClassreflectedClasses () const
 All reflected classes, sorted by name.
 
ssq::Class findClass (const std::string &name) const
 Finds a script class by name (throws if it does not exist).
 
void setErrorHandler (ErrorHandler handler)
 Replaces the handler invoked for script errors at the Runtime boundary.
 
void setLifecycleHandler (LifecycleHandler handler)
 Replaces the handler notified on every script lifecycle change.
 

静态 Public 成员函数

static Runtimecurrent () noexcept
 The runtime currently at the top of this thread's runtime stack, or nullptr.
 
static size_t stackDepth () noexcept
 Depth of the thread-local runtime stack.
 

详细描述

在文件 Runtime.h105 行定义.

成员类型定义说明

◆ ErrorHandler

using eve::Runtime::ErrorHandler = std::function<void(const ScriptException&)>

在文件 Runtime.h108 行定义.

◆ LifecycleHandler

using eve::Runtime::LifecycleHandler = std::function<void(const ScriptInfo&)>

在文件 Runtime.h109 行定义.

◆ ScriptId

using eve::Runtime::ScriptId = uint64_t

在文件 Runtime.h107 行定义.

构造及析构函数说明

◆ Runtime() [1/3]

eve::Runtime::Runtime ( size_t  stackSize = 2048,
ssq::Libs::Flag  libraries = ssq::Libs::ALL 
)
explicit

Creates a script runtime with its own Squirrel VM.

参数
stackSizeInitial Squirrel stack size in slots (must be > 0).
librariesSquirrel standard libraries to register (default: all).

在文件 Runtime.cpp148 行定义.

◆ ~Runtime()

eve::Runtime::~Runtime ( )

在文件 Runtime.cpp153 行定义.

引用了 shutdown().

◆ Runtime() [2/3]

eve::Runtime::Runtime ( Runtime &&  )
delete

◆ Runtime() [3/3]

eve::Runtime::Runtime ( const Runtime )
delete

成员函数说明

◆ compileFile()

Runtime::ScriptId eve::Runtime::compileFile ( const std::string &  path)

Compiles a script file without running it.

参数
pathFile path (must be non-empty).
返回
New script id.
异常
ScriptExceptionon compile failure.

在文件 Runtime.cpp233 行定义.

引用了 eve::Compile, enter(), error, EV_PARAM_CHECK, guard(), id , 以及 scope.

被这些函数引用 runFile().

◆ compileSource()

Runtime::ScriptId eve::Runtime::compileSource ( std::string  source,
std::string  sourceName = "buffer" 
)

Compiles script source without running it.

参数
sourceScript source text.
sourceNameName used in errors and lifecycle events ("buffer" if omitted).
返回
New script id.
异常
ScriptExceptionon compile failure.

在文件 Runtime.cpp211 行定义.

引用了 eve::Compile, enter(), error, guard(), id , 以及 scope.

被这些函数引用 runSource().

◆ contains()

bool eve::Runtime::contains ( ScriptId  id) const
noexcept

True if a script with the given id is tracked.

在文件 Runtime.cpp399 行定义.

◆ current()

Runtime * eve::Runtime::current ( )
staticnoexcept

The runtime currently at the top of this thread's runtime stack, or nullptr.

在文件 Runtime.cpp205 行定义.

◆ enter()

Scope eve::Runtime::enter ( )
inline

Pushes this runtime on the thread-local runtime stack (RAII pop).

在文件 Runtime.h178 行定义.

被这些函数引用 compileFile(), compileSource(), execute(), eve::ModuleManager::expose_pending(), initialize(), reflectClass() , 以及 unload().

◆ execute()

const ScriptInfo & eve::Runtime::execute ( ScriptId  id)

◆ findClass()

ssq::Class eve::Runtime::findClass ( const std::string &  name) const

Finds a script class by name (throws if it does not exist).

在文件 Runtime.cpp431 行定义.

引用了 EV_PARAM_CHECK , 以及 name.

◆ guard()

StackGuard eve::Runtime::guard ( )
inlinenoexcept

RAII guard that restores the Squirrel stack top on scope exit.

在文件 Runtime.h176 行定义.

被这些函数引用 compileFile(), compileSource(), execute(), initialize(), reflectClass() , 以及 unload().

◆ handle()

HSQUIRRELVM eve::Runtime::handle ( ) const
noexcept

Raw Squirrel VM handle; nullptr after shutdown.

在文件 Runtime.cpp197 行定义.

被这些函数引用 execute(), shutdown() , 以及 unload().

◆ initialize()

void eve::Runtime::initialize ( )

Exposes registered engine modules into the script root table. Safe to call more than once.

在文件 Runtime.cpp155 行定义.

引用了 eve::ModuleManager::detach(), enter(), error, eve::Execute, eve::ModuleManager::expose(), guard() , 以及 scope.

被这些函数引用 eve::cmd::Cmdline::McpHost() , 以及 eve::cmd::Cmdline::Run().

◆ initialized()

bool eve::Runtime::initialized ( ) const
noexcept

True once initialize() has completed successfully.

在文件 Runtime.cpp194 行定义.

◆ operator=() [1/2]

Runtime & eve::Runtime::operator= ( const Runtime )
delete

◆ operator=() [2/2]

Runtime & eve::Runtime::operator= ( Runtime &&  )
delete

◆ reflectClass()

const ReflectedClass & eve::Runtime::reflectClass ( const std::string &  name,
const std::string &  source = {} 
)

Reflects a class by name, storing its inspected members.

参数
nameClass name (must be non-empty).
sourceOptional source label used in errors.

在文件 Runtime.cpp323 行定义.

引用了 cls, enter(), error, EV_PARAM_CHECK, guard(), name, eve::Reflect , 以及 scope.

◆ reflectedClass()

const ReflectedClass * eve::Runtime::reflectedClass ( const std::string &  name) const
noexcept

Reflected class by name, or nullptr.

在文件 Runtime.cpp416 行定义.

引用了 name.

◆ reflectedClasses()

std::vector< ReflectedClass > eve::Runtime::reflectedClasses ( ) const

All reflected classes, sorted by name.

在文件 Runtime.cpp421 行定义.

引用了 a , 以及 b.

◆ reflectFile()

ScriptId eve::Runtime::reflectFile ( const std::string &  path)
inline

Alias of runFile(); reflects classes declared by the file.

在文件 Runtime.h206 行定义.

◆ reload()

Runtime::ScriptId eve::Runtime::reload ( ScriptId  id)

Recompiles and re-runs a script from its original source.

在文件 Runtime.cpp337 行定义.

引用了 eve::Compile, id, runFile(), runSource(), eve::ScriptException::source() , 以及 unload().

◆ root()

ssq::Table eve::Runtime::root ( ) const

Root script table of the VM.

在文件 Runtime.cpp198 行定义.

被这些函数引用 eve::cmd::Cmdline::Run().

◆ runFile()

Runtime::ScriptId eve::Runtime::runFile ( const std::string &  path)

Convenience: compileFile() then execute().

在文件 Runtime.cpp317 行定义.

引用了 compileFile(), execute() , 以及 id.

被这些函数引用 reload().

◆ runSource()

Runtime::ScriptId eve::Runtime::runSource ( std::string  source,
std::string  sourceName = "buffer" 
)

Convenience: compileSource() then execute().

在文件 Runtime.cpp311 行定义.

引用了 compileSource(), execute() , 以及 id.

被这些函数引用 reload() , 以及 eve::cmd::Cmdline::Run().

◆ script()

const ScriptInfo * eve::Runtime::script ( ScriptId  id) const
noexcept

Script metadata for an id, or nullptr if unknown.

在文件 Runtime.cpp401 行定义.

◆ scripts()

std::vector< ScriptInfo > eve::Runtime::scripts ( ) const

Metadata for all tracked scripts, sorted by id.

在文件 Runtime.cpp406 行定义.

引用了 a , 以及 b.

◆ setErrorHandler()

void eve::Runtime::setErrorHandler ( ErrorHandler  handler)
inline

Replaces the handler invoked for script errors at the Runtime boundary.

在文件 Runtime.h235 行定义.

◆ setLifecycleHandler()

void eve::Runtime::setLifecycleHandler ( LifecycleHandler  handler)
inline

Replaces the handler notified on every script lifecycle change.

在文件 Runtime.h237 行定义.

◆ shutdown()

void eve::Runtime::shutdown ( )
noexcept

Tears down the VM and detaches the runtime; idempotent and noexcept.

在文件 Runtime.cpp175 行定义.

引用了 eve::script::clearLastScriptError(), eve::ModuleManager::detach(), handle() , 以及 unloadAll().

被这些函数引用 ~Runtime().

◆ stackDepth()

size_t eve::Runtime::stackDepth ( )
staticnoexcept

Depth of the thread-local runtime stack.

在文件 Runtime.cpp209 行定义.

◆ table()

ssq::Table eve::Runtime::table ( const char *  name) const

Looks up a named global table.

参数
nameName of the global table (must be non-null and non-empty).

在文件 Runtime.cpp199 行定义.

引用了 EV_PARAM_CHECK , 以及 name.

被这些函数引用 eve::cmd::Cmdline::Run().

◆ unload()

bool eve::Runtime::unload ( ScriptId  id)

◆ unloadAll()

void eve::Runtime::unloadAll ( )
noexcept

Unloads every script.

在文件 Runtime.cpp385 行定义.

引用了 unload().

被这些函数引用 shutdown().

◆ vm() [1/2]

const ssq::VM & eve::Runtime::vm ( ) const
noexcept

在文件 Runtime.cpp196 行定义.

◆ vm() [2/2]

ssq::VM & eve::Runtime::vm ( )
noexcept

Underlying SimpleSquirrel VM (requires a live, initialized runtime).

在文件 Runtime.cpp195 行定义.

被这些函数引用 execute(), eve::ModuleManager::expose(), eve::cmd::Cmdline::McpHost() , 以及 eve::cmd::Cmdline::Run().


该类的文档由以下文件生成: