载入中...
搜索中...
未找到
Emergence.cpp
浏览该文件的文档.
21 ~ScriptRuleEngine() noexcept { Emergence::release(reference).ignore("script emergence engine proxy destruction"); }
35 std::invoke(std::forward<Release>(release), ref).ignore("rollback failed owned emergence allocation");
39 auto result = eve::script::projectStatusResult(vm, eve::Status::success(eve::StatusCode::Applied));
68 eve::DiagnosticCode::StaleHandle, "Emergence module is no longer loaded", "engine", {}, "emergence"));
88 eve::DiagnosticCode::StaleHandle, "owned rule engine handle is stale", "engine", {}, "emergence")),
95 eve::DiagnosticCode::StaleHandle, "owned rule engine handle is stale", "engine", {}, "emergence")),
100 t.addClass<ScriptRuleEngine>("RuleEngine", std::function<ScriptRuleEngine*()>([]() { return nullptr; }), false);
102 owned.addFunc("isStale", [](ScriptRuleEngine* value) { return !value || Emergence::isStale(value->reference); });
110 owned.addFunc("replaceCatalogueJson", [vm, staleInt, asInt](ScriptRuleEngine* value, const std::string& json) {
119 owned.addFunc("setValue", [vm, staleBool, asBool](ScriptRuleEngine* value, const std::string& key,
124 if (!parsed) return eve::script::projectResult(vm, eve::Result<bool>::failure(parsed.status()), asBool);
125 return eve::script::projectResult(vm, view->setValue(key, std::move(parsed).takeValue()), asBool);
127 owned.addFunc("setTag", [vm, staleBool, asBool](ScriptRuleEngine* value, const std::string& tag, bool present) {
138 owned.addFunc("setState", [vm, staleBool, asBool](ScriptRuleEngine* value, const std::string& key,
143 if (!parsed) return eve::script::projectResult(vm, eve::Result<bool>::failure(parsed.status()), asBool);
144 return eve::script::projectResult(vm, view->setState(key, std::move(parsed).takeValue()), asBool);
149 return eve::script::projectResult(vm, view->drain(static_cast<std::uint64_t>(std::max<std::int64_t>(0, tick))),
168 return view.isBound() ? static_cast<std::int64_t>(view->lastDrainEvaluations()) : std::int64_t{0};
Stable, structured diagnostics shared by engine modules.
Script module factory for indexed emergent rule engines.
The single Squirrel projection for common Result, Status and Value.
Owning, renderer-independent dynamic values.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:537
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
Script-facing module that owns RuleEngine instances.
Definition Emergence.h:23
static eve::Result< RuleEngineHandleRef > newEngine()
Allocate a module-owned rule engine.
Definition Emergence.cpp:53
static eve::script::Borrowed< RuleEngine > resolve(RuleEngineHandleRef reference) noexcept
Resolve a live engine as a non-owning observation. @ownership Borrowed from the module registry....
Definition Emergence.cpp:58
static bool isStale(RuleEngineHandleRef reference) noexcept
Report whether a handle is stale.
Definition Emergence.cpp:72
static eve::Result< void > release(RuleEngineHandleRef reference)
Release a module-owned engine.
Definition Emergence.cpp:64
Non-owning C++ observation with no implicit lifetime extension.
Definition RuntimeRegistry.h:42
Definition ConditionCodec.cpp:10
eve::script::RuntimeHandleRef< RuleEngineHandleTag > RuleEngineHandleRef
Generation-qualified reference to a module-owned RuleEngine.
Definition RuleEngine.h:27
@ Borrowed
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
Definition SquirrelBinding.cpp:454
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:470
@ InvalidArgument
@ StaleHandle
@ Applied
Definition Container.h:602
Handle plus owner-lifetime epoch for a non-ECS registry object.
Definition RuntimeRegistry.h:91