载入中...
搜索中...
未找到
SquirrelBinding.cpp
浏览该文件的文档.
22Diagnostic conversionError(const ConversionContext& context, DiagnosticCode code, std::string message,
32 if (!key.empty() && (std::isalpha(static_cast<unsigned char>(key.front())) != 0 || key.front() == '_') &&
44 conversionError(context, DiagnosticCode::InvalidArgument, "Squirrel stack value is unavailable", path);
62 if (identity && std::find(context.activeContainers.begin(), context.activeContainers.end(), identity) !=
73 if ((object._type != OT_ARRAY && object._type != OT_TABLE) || context.activeContainers.empty()) return;
87bool convertAt(HSQUIRRELVM vm, SQInteger index, ConversionContext& context, const std::string& path, Value& output,
158 conversionError(context, DiagnosticCode::ParseError, "failed to read Squirrel array size", path);
197 conversionError(context, DiagnosticCode::ParseError, "failed to read Squirrel table key", path);
216bool validateValue(const Value& value, const SquirrelValueOptions& options, std::size_t depth, std::size_t& elements,
219 diagnostic = Diagnostic::error(DiagnosticCode::InvalidArgument, "Value exceeds maximum Squirrel element count",
225 diagnostic = Diagnostic::error(DiagnosticCode::InvalidArgument, "non-finite Value cannot be pushed to Squirrel",
237 if (!validateValue(value.at(index), options, depth + 1, elements, childPath(path, index), diagnostic))
245 if (!validateValue(*member, options, depth + 1, elements, memberPath(path, key), diagnostic)) return false;
250bool pushImpl(HSQUIRRELVM vm, const Value& value, const SquirrelValueOptions& options, std::size_t depth,
264 diagnostic = Diagnostic::error(DiagnosticCode::InvalidArgument, "Int64 value does not fit Squirrel integer",
288 if (!pushImpl(vm, value.at(index), options, depth + 1, childPath(path, index), diagnostic)) return false;
303 if (!pushImpl(vm, *member, options, depth + 1, memberPath(path, key), diagnostic)) return false;
305 diagnostic = Diagnostic::error(DiagnosticCode::Failed, "failed to add Value object member to Squirrel",
342Result<Value> valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions& options) {
344 return Result<Value>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Squirrel VM must not be null",
356Result<Value> valueFromSquirrel(const ssq::Object& object, const SquirrelValueOptions& options) {
360 Diagnostic::error(DiagnosticCode::InvalidArgument, "Squirrel object is empty", "$", {}, options.source));
369Result<void> pushValue(HSQUIRRELVM vm, const Value& value, const SquirrelValueOptions& options) {
371 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Squirrel VM must not be null",
412 for (const Diagnostic& diagnostic : status.diagnostics()) diagnostics.push(projectDiagnostic(vm, diagnostic));
417ssq::Table buildStatusTable(HSQUIRRELVM vm, const Status& status, const ssq::Array& diagnostics) {
454ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status& status) { return buildResultTable(vm, status, false); }
507 result.addFunc("ignore", [](ssq::Object value, const std::string& reason) { return ignoreResult(value, reason); });
EVEngine assertion entry point, backed by zeroerr.
The single Squirrel projection for common Result, Status and Value.
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
const std::string & path() const noexcept
Optional field, property, URI, or logical path.
Definition Diagnostic.h:149
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
const DiagnosticDetails & details() const noexcept
Structured context in insertion order.
Definition Diagnostic.h:151
const std::string & source() const noexcept
Optional producer or subsystem that emitted the diagnostic.
Definition Diagnostic.h:153
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
Definition BindingContracts.h:5
bool ignoreResult(const ssq::Object &result, const std::string &reason)
Mark a projected Result table as intentionally ignored by script.
Definition SquirrelBinding.cpp:475
ssq::Table projectDiagnostic(HSQUIRRELVM vm, const Diagnostic &diagnostic)
Project one Diagnostic using the common script table schema.
Definition SquirrelBinding.cpp:386
Result< void > pushValue(HSQUIRRELVM vm, const Value &value, const SquirrelValueOptions &options)
Push a canonical Value into the active Squirrel VM.
Definition SquirrelBinding.cpp:369
void markResultHasValue(ssq::Table &result)
Declare that a projected table received a payload the caller attached itself.
Definition SquirrelBinding.cpp:468
ssq::Table projectStatus(HSQUIRRELVM vm, const Status &status)
Project one Status using the common script table schema.
Definition SquirrelBinding.cpp:450
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
void exposeResultBindings(ssq::Table &eveTable)
Expose the common script helpers under eve.result.
Definition SquirrelBinding.cpp:505
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.
Definition SquirrelBinding.cpp:342
@ InvalidArgument
@ Unsupported
@ Failed
@ ParseError
constexpr std::string_view statusCodeName(StatusCode code) noexcept
Return the stable protocol spelling of a status code.
Definition Status.h:45
constexpr std::string_view diagnosticCodeName(DiagnosticCode code) noexcept
Return a stable, compact spelling useful for logs and diagnostics.
Definition Diagnostic.h:176
Limits and provenance used by the Squirrel ↔ Value adapter.
Definition SquirrelBinding.h:35
std::size_t maxElements
Definition SquirrelBinding.h:37