-
Notifications
You must be signed in to change notification settings - Fork 0
API Host BondingFunction
Script callable wrapper for a ClrDatumDelegate.
Namespace: AuroraScript.Runtime.Types. Kind: class.
Back to .NET Host API Reference
BondingFunction turns a raw ClrDatumDelegate into a value that scripts can call like any other function. It is the advanced path: the delegate receives the script context, the owning module, the argument span, and a ref result slot.
Tip
For simple host functions, passing a normal CLR delegate to ScriptGlobal.Define is usually easier.
A minimal use of BondingFunction.
ClrDatumDelegate answer = (
ScriptContext ctx,
ScriptObject module,
Span<ScriptDatum> args,
ref ScriptDatum result) =>
{
result = ScriptDatum.FromNumber(42);
};
var function = new BondingFunction(answer);BondingFunction(ClrDatumDelegate callback)Wraps a host delegate as a script-callable function.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
callback |
ClrDatumDelegate |
Yes | Callback invoked by the runtime. |
Returns
A new BondingFunction instance.
var function = new BondingFunction(answer);string NameFunction name reported to scripts.
Parameters
None.
Returns
Returns string.
Console.WriteLine(function.Name);ScriptObject TargetObject the function is bound to, or null when unbound.
Parameters
None.
Returns
Returns ScriptObject.
var target = function.Target;ClrDatumDelegate DatumMethodUnderlying host delegate the function invokes.
Parameters
None.
Returns
Returns ClrDatumDelegate.
var callback = function.DatumMethod;BondingFunction Bind(ScriptObject target)Returns a function bound to the supplied target object.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target |
ScriptObject |
Yes | Object to bind as the call target. |
Returns
Returns BondingFunction.
var bound = function.Bind(hostService);AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License