载入中...
搜索中...
未找到
ScriptProvider.cpp
浏览该文件的文档.
2
3#include "common/Assert.h"
4#include "common/Diagnostic.h"
8
9#include <simplesquirrel/simplesquirrel.hpp>
10
11#include <algorithm>
12#include <cstddef>
13#include <string>
14#include <unordered_map>
15#include <utility>
16#include <vector>
17
18namespace eve {
19
20namespace {
21
23struct ProviderEntry {
25 script::OwnedSquirrelObject instance;
28 std::uint64_t generation = 0;
30 std::string capability;
33};
34
36struct CapabilitySeam {
39};
40
41Diagnostic providerDiagnostic(DiagnosticCode code, std::string message, const std::string& path) {
42 return Diagnostic::error(code, std::move(message), path);
43}
44
52std::string lastScriptErrorText(HSQUIRRELVM vm) {
53 const script::ScriptErrorContext context = script::takeLastScriptError(vm);
54 if (context.empty()) return "unknown script error";
56}
57
66Result<void> retireEntry(ProviderEntry& entry, const std::string& name) {
67 const std::uint64_t retiredGeneration = entry.generation;
68 entry.instance = script::OwnedSquirrelObject{};
69 ++entry.generation;
70 entry.capability.clear();
71 ScriptCapabilityUnbinder unbinder = std::move(entry.unbinder);
72 entry.unbinder = {};
73 if (!unbinder) return Result<void>::success();
74 const ScriptProviderHandle retired{name, retiredGeneration};
75 return unbinder(retired);
76}
77
83Result<void> pushProviderMethod(HSQUIRRELVM vm, HSQOBJECT instance, const std::string& method) {
84 const SQInteger top = sq_gettop(vm);
85 sq_pushobject(vm, instance);
86 sq_pushstring(vm, method.c_str(), -1);
87 if (SQ_FAILED(sq_get(vm, -2))) {
88 sq_settop(vm, top);
90 providerDiagnostic(DiagnosticCode::Unsupported, "script provider has no method '" + method + "'", method));
91 }
92 const SQObjectType type = sq_gettype(vm, -1);
93 if (type != OT_CLOSURE && type != OT_NATIVECLOSURE) {
94 sq_settop(vm, top);
95 return Result<void>::failure(providerDiagnostic(
96 DiagnosticCode::Unsupported, "script provider member '" + method + "' is not a method", method));
97 }
98 return Result<void>::success();
99}
100
109Result<void> pushScriptArg(HSQUIRRELVM vm, const ScriptArg& arg) {
110 switch (arg.kind) {
111 case ScriptArg::Kind::Integer: sq_pushinteger(vm, SQInteger(arg.integer)); break;
112 case ScriptArg::Kind::Number: sq_pushfloat(vm, SQFloat(arg.number)); break;
113 case ScriptArg::Kind::Boolean: sq_pushbool(vm, arg.boolean ? SQTrue : SQFalse); break;
114 case ScriptArg::Kind::Text: sq_pushstring(vm, arg.text.c_str(), SQInteger(arg.text.size())); break;
116 auto pushed = script::pushValue(vm, Value::object(arg.table));
117 if (!pushed.ok()) return pushed;
118 break;
119 }
120 }
121 return Result<void>::success();
122}
123
125Result<double> readNumericResult(HSQUIRRELVM vm, const std::string& methodName) {
126 const SQObjectType resultType = sq_gettype(vm, -1);
127 if (resultType != OT_FLOAT && resultType != OT_INTEGER) {
129 providerDiagnostic(DiagnosticCode::InvalidArgument,
130 "script provider method '" + methodName + "' did not return a number", methodName));
131 }
132 if (resultType == OT_FLOAT) {
133 SQFloat value = 0.f;
134 if (SQ_FAILED(sq_getfloat(vm, -1, &value))) {
135 return Result<double>::failure(providerDiagnostic(
136 DiagnosticCode::InvalidArgument, "script provider returned an unreadable float", methodName));
137 }
138 return Result<double>::success(double(value));
139 }
140 SQInteger value = 0;
141 if (SQ_FAILED(sq_getinteger(vm, -1, &value))) {
142 return Result<double>::failure(providerDiagnostic(
143 DiagnosticCode::InvalidArgument, "script provider returned an unreadable integer", methodName));
144 }
145 return Result<double>::success(double(value));
146}
147
149constexpr SQInteger kMaxResultElements = 64;
150
152Result<double> readNumericElement(HSQUIRRELVM vm, SQInteger index, const std::string& methodName) {
153 const SQObjectType type = sq_gettype(vm, index);
154 if (type == OT_FLOAT) {
155 SQFloat value = 0.f;
156 if (SQ_FAILED(sq_getfloat(vm, index, &value))) {
157 return Result<double>::failure(providerDiagnostic(
158 DiagnosticCode::InvalidArgument, "script provider returned an unreadable float", methodName));
159 }
160 return Result<double>::success(double(value));
161 }
162 SQInteger value = 0;
163 if (SQ_FAILED(sq_getinteger(vm, index, &value))) {
164 return Result<double>::failure(providerDiagnostic(
165 DiagnosticCode::InvalidArgument, "script provider returned an unreadable integer", methodName));
166 }
167 return Result<double>::success(double(value));
168}
169
171Result<std::vector<double>> readNumericArray(HSQUIRRELVM vm, const std::string& methodName) {
172 if (sq_gettype(vm, -1) != OT_ARRAY) {
173 return Result<std::vector<double>>::failure(
174 providerDiagnostic(DiagnosticCode::InvalidArgument,
175 "script provider method '" + methodName + "' did not return an array", methodName));
176 }
177 const SQInteger count = sq_getsize(vm, -1);
178 if (count < 0 || count > kMaxResultElements) {
179 return Result<std::vector<double>>::failure(
180 providerDiagnostic(DiagnosticCode::InvalidArgument,
181 "script provider method '" + methodName + "' returned " + std::to_string(count) +
182 " elements; the limit is " + std::to_string(kMaxResultElements),
183 methodName));
184 }
185
186 std::vector<double> out;
187 out.reserve(std::size_t(count));
188 const SQInteger top = sq_gettop(vm);
189 for (SQInteger i = 0; i < count; ++i) {
190 sq_pushinteger(vm, i);
191 if (SQ_FAILED(sq_get(vm, -2))) break;
192 auto element = readNumericElement(vm, -1, methodName);
193 sq_settop(vm, top); // drop the element again
194 if (!element) return Result<std::vector<double>>::failure(element.status());
195 out.push_back(element.value());
196 }
197 return Result<std::vector<double>>::success(std::move(out));
198}
199
201Result<double> ignoreResult(HSQUIRRELVM, const std::string&) { return Result<double>::success(0.0); }
202
209Result<Value> readValueResult(HSQUIRRELVM vm, const std::string& methodName) {
210 auto converted =
211 script::valueFromSquirrel(vm, -1, script::SquirrelValueOptions{64, 100000, "script.provider." + methodName});
212 if (!converted.ok())
214 providerDiagnostic(DiagnosticCode::InvalidArgument,
215 "script provider method '" + methodName +
216 "' returned a value that cannot be converted: " + converted.status().describe(),
217 methodName));
218 return converted;
219}
220
234template <class Reader>
235auto invokeProvider(const ssq::Object& instance, std::string_view method, std::span<const ScriptArg> args,
236 Reader&& readResult) -> std::invoke_result_t<Reader, HSQUIRRELVM, const std::string&> {
237 using Outcome = std::invoke_result_t<Reader, HSQUIRRELVM, const std::string&>;
238
239 HSQUIRRELVM vm = instance.getHandle();
240 const std::string methodName(method);
241 if (!vm) {
242 return Outcome::failure(
243 providerDiagnostic(DiagnosticCode::Failed, "script provider has no live VM", methodName));
244 }
245
246 const HSQOBJECT raw = instance.getRaw();
247 auto pushed = pushProviderMethod(vm, raw, methodName);
248 if (!pushed) return Outcome::failure(pushed.status());
249
250 const SQInteger top = sq_gettop(vm);
251 sq_pushobject(vm, raw); // `this`
252 for (const ScriptArg& arg : args) {
253 auto pushed = pushScriptArg(vm, arg);
254 if (!pushed) {
255 sq_settop(vm, top);
256 return Outcome::failure(pushed.status());
257 }
258 }
259
260 const SQInteger argCount = SQInteger(args.size()) + 1;
261 if (SQ_FAILED(sq_call(vm, argCount, SQTrue, SQFalse))) {
262 const std::string detail = lastScriptErrorText(vm);
263 sq_settop(vm, top);
264 return Outcome::failure(providerDiagnostic(
265 DiagnosticCode::Failed, "script provider method '" + methodName + "' raised: " + detail, methodName));
266 }
267
268 auto outcome = std::invoke(readResult, vm, methodName);
269 sq_settop(vm, top);
270 return outcome;
271}
272
273} // namespace
274
276 std::unordered_map<std::string, ProviderEntry> entries;
277 std::unordered_map<std::string, CapabilitySeam> capabilities;
278};
279
281 ScriptArg arg;
282 arg.kind = Kind::Integer;
283 arg.integer = value;
284 return arg;
285}
286
288 ScriptArg arg;
289 arg.kind = Kind::Number;
290 arg.number = value;
291 return arg;
292}
293
295 ScriptArg arg;
296 arg.kind = Kind::Boolean;
297 arg.boolean = value;
298 return arg;
299}
300
302 ScriptArg arg;
303 arg.kind = Kind::Text;
304 arg.text = std::move(value);
305 return arg;
306}
307
309 ScriptArg arg;
310 arg.kind = Kind::Table;
311 arg.table = std::move(fields);
312 return arg;
313}
314
315ScriptProviderRegistry::ScriptProviderRegistry() : impl_(new Impl()) {}
316ScriptProviderRegistry::~ScriptProviderRegistry() = default;
317
319 // Function-local so the registry exists before any static module registration
320 // touches it. Runtime::shutdown clears it before the VM is destroyed.
322 return registry;
323}
324
325Result<ScriptProviderHandle> ScriptProviderRegistry::publish(std::string name, const ssq::Object& instance) {
326 if (name.empty()) {
328 providerDiagnostic(DiagnosticCode::InvalidArgument, "script provider name must not be empty", {}));
329 }
330 if (instance.isEmpty() || instance.getRaw()._type != OT_INSTANCE) {
332 providerDiagnostic(DiagnosticCode::InvalidArgument, "script provider must be a live class instance", name));
333 }
334
335 // Superseding a capability-bound provider must also remove its adapter; leaving
336 // it installed would keep routing native consumers into a dead script object.
337 auto previous = impl_->entries.find(name);
338 if (previous != impl_->entries.end() && previous->second.unbinder) {
339 auto retired = retireEntry(previous->second, name);
341 }
342
343 // Re-lookup: running the unbinder above may have rehashed the map.
344 ProviderEntry& entry = impl_->entries[name];
345 entry.instance = script::OwnedSquirrelObject(instance);
346 entry.capability.clear();
347 entry.unbinder = {};
348 const std::uint64_t generation = ++entry.generation;
350}
351
353 auto found = impl_->entries.find(handle.name);
354 if (found == impl_->entries.end() || !found->second.instance.isBound() ||
355 found->second.generation != handle.generation) {
356 return Result<void>::failure(providerDiagnostic(
357 DiagnosticCode::StaleHandle, "script provider generation is no longer published", handle.name));
358 }
359 // Keep the slot so the retired generation can never be resolved again, and so a
360 // later publish cannot hand an old handle a new instance.
361 return retireEntry(found->second, handle.name);
362}
363
364std::uint64_t ScriptProviderRegistry::generationOf(std::string_view name) const {
365 auto found = impl_->entries.find(std::string(name));
366 if (found == impl_->entries.end() || !found->second.instance.isBound()) return 0;
367 return found->second.generation;
368}
369
370bool ScriptProviderRegistry::contains(std::string_view name) const { return generationOf(name) != 0; }
371
372std::size_t ScriptProviderRegistry::size() const {
373 std::size_t count = 0;
374 for (const auto& [key, entry] : impl_->entries) {
375 (void)key;
376 if (entry.instance.isBound()) ++count;
377 }
378 return count;
379}
380
381std::vector<std::string> ScriptProviderRegistry::capabilities() const {
382 std::vector<std::string> names;
383 names.reserve(impl_->capabilities.size());
384 for (const auto& [name, seam] : impl_->capabilities) {
385 (void)seam;
386 names.push_back(name);
387 }
388 std::sort(names.begin(), names.end());
389 return names;
390}
391
392std::vector<ScriptProviderInfo> ScriptProviderRegistry::published() const {
393 std::vector<ScriptProviderInfo> entries;
394 entries.reserve(impl_->entries.size());
395 for (const auto& [name, entry] : impl_->entries) {
396 if (!entry.instance.isBound()) continue;
397 entries.push_back(ScriptProviderInfo{name, entry.generation, entry.capability});
398 }
399 std::sort(entries.begin(), entries.end(),
400 [](const ScriptProviderInfo& lhs, const ScriptProviderInfo& rhs) { return lhs.name < rhs.name; });
401 return entries;
402}
403
405 ScriptCapabilityUnbinder unbinder) {
406 const bool complete = !capability.empty() && binder && unbinder;
407 EV_PARAM_CHECK(complete, "declareCapability requires a capability name, a binder and an unbinder");
408 if (!complete) return;
409 impl_->capabilities[std::move(capability)] = CapabilitySeam{std::move(binder), std::move(unbinder)};
410}
411
412bool ScriptProviderRegistry::hasCapabilitySeam(std::string_view capability) const {
413 return impl_->capabilities.find(std::string(capability)) != impl_->capabilities.end();
414}
415
417 const std::string key(capability);
418 if (impl_->capabilities.erase(key) == 0) {
419 return Result<void>::failure(providerDiagnostic(
420 DiagnosticCode::NotFound, "capability '" + key + "' has no declared script binding seam", key));
421 }
422 return Result<void>::success();
423}
424
426 const ssq::Object& instance) {
427 auto seam = impl_->capabilities.find(std::string(capability));
428 if (seam == impl_->capabilities.end()) {
429 return Result<ScriptProviderHandle>::failure(providerDiagnostic(
431 "no script binding seam is declared for capability '" + std::string(capability) + "'", name));
432 }
433
434 // Copy the seam before publishing: the binder is user code and may redeclare
435 // capabilities, which can rehash the map and invalidate `seam`.
436 ScriptCapabilityBinder binder = seam->second.binder;
437 ScriptCapabilityUnbinder unbinder = seam->second.unbinder;
438
439 auto published = publish(std::move(name), instance);
441 auto handle = std::move(published).takeValue();
442
443 // Record the seam on the entry *before* running the binder. A binder that fails
444 // halfway has usually already installed part of its adapter, and the rollback
445 // below removes it through this unbinder -- so the entry has to hold it by then
446 // (`publish` clears both fields). Measured before the fix: the rollback ran with
447 // an empty unbinder, so nothing was undone (plan doc §9.50).
448 {
449 auto pending = impl_->entries.find(handle.name);
450 if (pending == impl_->entries.end() || pending->second.generation != handle.generation) {
451 return Result<ScriptProviderHandle>::failure(providerDiagnostic(
452 DiagnosticCode::Failed, "the published provider vanished before its binder ran", handle.name));
453 }
454 pending->second.capability = std::string(capability);
455 pending->second.unbinder = std::move(unbinder);
456 }
457
458 auto bound = binder(handle);
459 if (!bound) {
460 // Roll back so a caller never observes a published provider that serves
461 // nothing. `unload` also runs the unbinder, which is what a partial bind
462 // needs; its own outcome is secondary to the binder's.
463 auto rolledBack = unload(handle);
464 rolledBack.ignore("a failed bind is already reported; the rollback only has to retire the generation");
465 return Result<ScriptProviderHandle>::failure(bound.status());
466 }
467
468 // Re-lookup after the binder: it is user code and may have re-published this same
469 // name, which invalidates the iterator above.
470 auto entry = impl_->entries.find(handle.name);
471 if (entry == impl_->entries.end() || entry->second.generation != handle.generation) {
472 // The binder re-published the same name; that generation owns its own bind.
473 return Result<ScriptProviderHandle>::failure(providerDiagnostic(
474 DiagnosticCode::Failed, "the capability binder replaced the provider it was binding", handle.name));
475 }
477}
478
480 // Detach every adapter before invoking any unbinder: an unbinder is
481 // user-provided and may publish again, which would rehash the map under a live
482 // iterator. Declared capability seams survive, because they are composition-time
483 // declarations rather than published state.
484 std::vector<std::pair<std::string, ScriptProviderHandle>> retired;
485 std::vector<ScriptCapabilityUnbinder> unbinders;
486 for (auto& [name, entry] : impl_->entries) {
487 if (!entry.unbinder) continue;
488 retired.emplace_back(name, ScriptProviderHandle{name, entry.generation});
489 unbinders.push_back(std::move(entry.unbinder));
490 entry.unbinder = {};
491 entry.capability.clear();
492 }
493 impl_->entries.clear();
494
495 for (std::size_t i = 0; i < unbinders.size(); ++i) {
496 auto removed = unbinders[i](retired[i].second);
497 // Shutdown teardown: the adapter dies with the VM either way, so the only
498 // requirement is that the unbinder ran.
499 removed.ignore("clearAll cannot report per-adapter teardown failures");
500 }
501}
502
503Result<const ssq::Object*> ScriptProviderRegistry::resolve(const ScriptProviderHandle& handle) const {
504 auto found = impl_->entries.find(handle.name);
505 if (found == impl_->entries.end() || !found->second.instance.isBound() ||
506 found->second.generation != handle.generation) {
507 return Result<const ssq::Object*>::failure(providerDiagnostic(
508 DiagnosticCode::StaleHandle, "script provider generation is no longer published", handle.name));
509 }
510 const ssq::Object& instance = found->second.instance.get();
511 if (!instance.getHandle()) {
513 providerDiagnostic(DiagnosticCode::Failed, "script provider has no live VM", handle.name));
514 }
516}
517
519 auto instance = resolve(handle);
520 if (!instance) return Result<void>::failure(instance.status());
521 auto invoked = invokeProvider(*instance.value(), method, {}, ignoreResult);
522 if (!invoked) return Result<void>::failure(invoked.status());
523 return Result<void>::success();
524}
525
527 double dt) const {
528 const ScriptArg args[] = {ScriptArg::fromNumber(dt)};
529 auto instance = resolve(handle);
530 if (!instance) return Result<void>::failure(instance.status());
531 auto invoked = invokeProvider(*instance.value(), method, args, ignoreResult);
532 if (!invoked) return Result<void>::failure(invoked.status());
533 return Result<void>::success();
534}
535
537 std::span<const ScriptArg> args) const {
538 auto instance = resolve(handle);
539 if (!instance) return Result<void>::failure(instance.status());
540 auto invoked = invokeProvider(*instance.value(), method, args, ignoreResult);
541 if (!invoked) return Result<void>::failure(invoked.status());
542 return Result<void>::success();
543}
544
546 double dt) const {
547 const ScriptArg args[] = {ScriptArg::fromNumber(dt)};
548 auto instance = resolve(handle);
549 if (!instance) return Result<double>::failure(instance.status());
550 return invokeProvider(*instance.value(), method, args, readNumericResult);
551}
552
554 std::span<const ScriptArg> args) const {
555 auto instance = resolve(handle);
556 if (!instance) return Result<double>::failure(instance.status());
557 return invokeProvider(*instance.value(), method, args, readNumericResult);
558}
559
561 std::string_view method) const {
562 auto instance = resolve(handle);
563 if (!instance) return Result<std::vector<double>>::failure(instance.status());
564 return invokeProvider(*instance.value(), method, {}, readNumericArray);
565}
566
568 std::string_view method,
569 std::span<const ScriptArg> args) const {
570 auto instance = resolve(handle);
571 if (!instance) return Result<std::vector<double>>::failure(instance.status());
572 return invokeProvider(*instance.value(), method, args, readNumericArray);
573}
574
576 std::span<const ScriptArg> args) const {
577 auto instance = resolve(handle);
578 if (!instance) return Result<Value>::failure(instance.status());
579 return invokeProvider(*instance.value(), method, args, readValueResult);
580}
581
585
586} // namespace eve
EVEngine assertion entry point, backed by zeroerr.
#define EV_PARAM_CHECK(cond,...)
Validate a function parameter / public API precondition.
Definition Assert.h:30
std::vector< QuestEvent > pending
std::unordered_map< std::string, QuestRuntime > entries
std::vector< std::unique_ptr< ScriptClimbingEventSink > > retired
struct SQVM * HSQUIRRELVM
Stable, structured diagnostics shared by engine modules.
HSQUIRRELVM vm
Definition ECS.cpp:38
SQObjectPtr key
Definition ECS.cpp:155
Generation generation
Definition ECS.cpp:40
std::string name
Definition ECS.cpp:154
std::vector< std::string > fields
Definition ECS.cpp:42
double raw
std::uint16_t method
std::string message
DiagnosticCode code
bool seam
double dt
std::shared_ptr< const OceanSprayFrame > previous
std::string path
Definition PlayHost.cpp:111
PrimitiveHandle handle
const eve::script::BindingContractRegistry & registry
Object::Ptr value
int detail
bool found
int removed
ScriptStructure out
std::string element
int count
The single Squirrel projection for common Result, Status and Value.
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
uint32_t index
const VegetationPresetContext & context
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Named script objects that native systems drive through named methods.
Result< void > removeCapability(std::string_view capability)
Withdraw a declared seam when its owning module goes away.
static ScriptProviderRegistry & instance()
Process-lifetime registry; clearAll is the only reset.
Result< std::vector< double > > callNumbers(const ScriptProviderHandle &handle, std::string_view method) const
Call method() and read an array of numbers.
Result< double > callNumber(const ScriptProviderHandle &handle, std::string_view method, double dt) const
Call method(dt) and read a numeric result.
Result< void > unload(const ScriptProviderHandle &handle)
Retire exactly one published generation.
bool hasCapabilitySeam(std::string_view capability) const
Whether capability has a declared script binding seam.
std::vector< ScriptProviderInfo > published() const
Every currently published provider.
bool contains(std::string_view name) const
Whether name currently has a published provider.
std::vector< std::string > capabilities() const
Names of every capability that has a declared script binding seam.
void declareCapability(std::string capability, ScriptCapabilityBinder binder, ScriptCapabilityUnbinder unbinder)
Declare that one native capability may be served by a script provider.
std::size_t size() const
Number of published providers.
std::uint64_t generationOf(std::string_view name) const
Current published generation for name, or 0 when absent.
Result< ScriptProviderHandle > publish(std::string name, const ssq::Object &instance)
Publish one live script instance under a stable name.
Result< Value > callValue(const ScriptProviderHandle &handle, std::string_view method, std::span< const ScriptArg > args) const
Call method(...) and read the script result as an owning eve::Value.
Result< void > call(const ScriptProviderHandle &handle, std::string_view method) const
Call method() on a published provider.
Result< ScriptProviderHandle > publishForCapability(std::string_view capability, std::string name, const ssq::Object &instance)
Publish one script instance as the provider of a declared capability.
void clearAll()
Drop every published provider and release its VM reference.
std::map< std::string, Value > Object
Definition Value.h:34
static Value object(Object value)
Compatibility factory for an object value.
Definition Value.cpp:129
A rooted Squirrel reference owned by the C++ holder.
SQInteger top
Definition Snapshot.cpp:115
Outcome
Domain outcome, independent of reward and infrastructure errors.
Definition Agent.h:13
eve::Diagnostic Diagnostic
bool ignoreResult(const ssq::Object &result, const std::string &reason)
Mark a projected Result table as intentionally ignored by script.
std::string formatScriptError(const ScriptErrorContext &ctx)
Formats a context into a human-readable multi-line report.
ScriptErrorContext takeLastScriptError(HSQUIRRELVM vm)
Consumes and clears the last recorded error for a VM.
Result< void > pushValue(HSQUIRRELVM vm, const Value &value, const SquirrelValueOptions &options)
Push a canonical Value into the active Squirrel VM.
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
std::function< Result< void >(const ScriptProviderHandle &)> ScriptCapabilityUnbinder
Removes the binding a matching ScriptCapabilityBinder created.
std::function< Result< void >(const ScriptProviderHandle &)> ScriptCapabilityBinder
Binds one published provider to one native capability.
One argument passed to a script provider method.
static ScriptArg fromInteger(std::int64_t value)
static ScriptArg fromText(std::string value)
static ScriptArg fromBoolean(bool value)
std::string text
static ScriptArg fromTable(Value::Object fields)
One object argument (a table on the script side). @cost One Value tree copy.
static ScriptArg fromNumber(double value)
std::int64_t integer
Value::Object table
Object payload for Kind::Table; keys are the script side's field names.
Generation-qualified identity of one published script provider.
Read-only view of one published provider, for discovery and diagnostics.
std::unordered_map< std::string, CapabilitySeam > capabilities
std::unordered_map< std::string, ProviderEntry > entries