Callable
A C# value representing a method or .NET delegate for engine API calls.
A C# struct representing a method or delegate. Callable.From(...) creates a .NET-delegate representation; Callable(target, method) stores an object and method name. Call(...) passes Variant arguments, so their count and types must match the target method.
Representations differ: a delegate can populate Delegate while Target is null, and an object-method representation can populate Target and Method while Delegate is null. One field is not a universal callability check. Constructing the value does not prove method existence or target lifetime.
Callable has no C# conversion to bool. default(Callable) is not a null reference either. Use normal C# event syntax for ordinary event subscriptions; use Callable where the API requires this type.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
CallableConstructor
public Callable(ReckfellObject target, StringName method);Stores target and method without invoking the method. Construction neither verifies method existence nor guarantees the native object’s lifetime. Use Callable.From for a delegate or lambda. The name is stored as the same managed StringName wrapper: do not dispose it while the Callable is in use.
| Name | Type | Default |
|---|---|---|
target | ReckfellObject | — |
method | StringName | — |
targetLive object whose method will be invoked. Callable does not replace object lifetime management.
methodExact registered method name; case-sensitive. Use nameof or an available MethodName constant for a C# method.
Properties4
DelegateProperty
public Delegate Delegate { get; }Returns the stored .NET delegate for From/CreateWithUnsafeTrampoline. Object/method representations and default(Callable) return null. A delegate does not validate captured native-object lifetimes; absence of a delegate does not invalidate an object/method Callable.
MethodProperty
public StringName Method { get; }Returns the stored method-name wrapper for an object/method representation. Callable.From and default(Callable) can yield null. This is not a name derived from Delegate.Method. The returned reference is borrowed: do not dispose it separately while the Callable is in use.
TargetProperty
public ReckfellObject Target { get; }For Callable(target, method), returns the stored object. For a delegate, returns Delegate.Target only when it is a ReckfellObject; a static delegate or ordinary managed closure can yield null. This is neither a universal callability check nor a native lifetime guarantee. Reading does not transfer object ownership.
TrampolineProperty
public unsafe delegate*<object, Reckfell.NativeInterop.NativeVariantPtrArgs, out Reckfell.NativeInterop.reckfell_variant, void> Trampoline { get; }Low-level managed function pointer that invokes the stored Delegate through native Variant arguments. From supplies an SDK trampoline; CreateWithUnsafeTrampoline uses the caller’s pointer. Use Call for ordinary invocation. An object/method representation has a null pointer; this property is not a universal validity check.
Methods25
Call2 overloads
public Variant Call(params Variant[] args);Synchronously invokes the stored method or delegate. Arguments pass as Variant values and the SDK converts them to the expected types; this is not an ordinary compiler-checked C# call signature. Ensure the argument count, supported types and live target beforehand.
Action returns Variant.Type.Nil; Func results are converted to Variant. Nil does not prove success: call errors or delegate exceptions can be logged. The current bridge does not guarantee that every such exception is rethrown to the calling C# code.
In the example, Twice(21) returns 42. The local argument and returned Variant have separate using lifetimes.
using System.Threading.Tasks;
using Reckfell;
public static class CallableSignalExamples
{
public static int Twice(int value)
{
var callback = Callable.From<int, int>(static number => number * 2);
using var argument = Variant.From(value);
using var result = callback.Call(argument);
return result.AsInt32();
}
public static void SetLabelLater(Label label, string text)
{
var callback = Callable.From<string>(value =>
{
if (ReckfellObject.IsInstanceValid(label)) label.Text = value;
});
using var argument = Variant.From(text);
callback.CallDeferred(argument);
}
public static async Task WaitNextProcess(EntityTree tree)
{
Variant[] arguments = await new Signal(tree, EntityTree.SignalName.ProcessFrame);
foreach (var argument in arguments) argument.Dispose();
}
}| Name | Type | Default |
|---|---|---|
args | Variant[] | — |
argsArguments in method or delegate parameter order. Callable.From requires exactly the Action/Func input count; an empty set is appropriate for a zero-argument function.
VariantResult as a caller-owned Variant; dispose after reading. Void/Action yields Nil, but Nil can also accompany an error.
public Variant Call(ReadOnlySpan<Variant> args);Synchronously invokes the stored method or delegate. Arguments pass as Variant values and the SDK converts them to the expected types; this is not an ordinary compiler-checked C# call signature. Ensure the argument count, supported types and live target beforehand.
Action returns Variant.Type.Nil; Func results are converted to Variant. Nil does not prove success: call errors or delegate exceptions can be logged. The current bridge does not guarantee that every such exception is rethrown to the calling C# code.
In the example, Twice(21) returns 42. The local argument and returned Variant have separate using lifetimes.
using System.Threading.Tasks;
using Reckfell;
public static class CallableSignalExamples
{
public static int Twice(int value)
{
var callback = Callable.From<int, int>(static number => number * 2);
using var argument = Variant.From(value);
using var result = callback.Call(argument);
return result.AsInt32();
}
public static void SetLabelLater(Label label, string text)
{
var callback = Callable.From<string>(value =>
{
if (ReckfellObject.IsInstanceValid(label)) label.Text = value;
});
using var argument = Variant.From(text);
callback.CallDeferred(argument);
}
public static async Task WaitNextProcess(EntityTree tree)
{
Variant[] arguments = await new Signal(tree, EntityTree.SignalName.ProcessFrame);
foreach (var argument in arguments) argument.Dispose();
}
}| Name | Type | Default |
|---|---|---|
args | ReadOnlySpan<Variant> | — |
argsArguments in method or delegate parameter order. Callable.From requires exactly the Action/Func input count; an empty set is appropriate for a zero-argument function.
VariantResult as a caller-owned Variant; dispose after reading. Void/Action yields Nil, but Nil can also accompany an error.
CallDeferred2 overloads
public void CallDeferred(params Variant[] args);Queues the call for deferred execution and returns immediately. Arguments are copied into the queue; local Variant arguments can be disposed after queuing. The method’s result cannot be obtained here.
The queue is processed during idle/flush, not after a guaranteed frame count or as a timer. Avoid an endless chain in which each deferred call queues itself again. The target can be freed before execution: SetLabelLater in the Call example checks IsInstanceValid before changing the Label.
| Name | Type | Default |
|---|---|---|
args | Variant[] | — |
argsArguments for the future call in parameter order. Validate count and type convertibility beforehand.
public void CallDeferred(ReadOnlySpan<Variant> args);Queues the call for deferred execution and returns immediately. Arguments are copied into the queue; local Variant arguments can be disposed after queuing. The method’s result cannot be obtained here.
The queue is processed during idle/flush, not after a guaranteed frame count or as a timer. Avoid an endless chain in which each deferred call queues itself again. The target can be freed before execution: SetLabelLater in the Call example checks IsInstanceValid before changing the Label.
| Name | Type | Default |
|---|---|---|
args | ReadOnlySpan<Variant> | — |
argsArguments for the future call in parameter order. Validate count and type convertibility beforehand.
CreateWithUnsafeTrampolineCallable
public static unsafe Callable CreateWithUnsafeTrampoline(Delegate @delegate, delegate*<object, Reckfell.NativeInterop.NativeVariantPtrArgs, out Reckfell.NativeInterop.reckfell_variant, void> trampoline);Low-level Callable creation for a custom managed trampoline. Use From for ordinary Action/Func callbacks: it checks argument count and performs Variant conversions.
The trampoline receives the delegate as object, a native argument view and an out reckfell_variant result. It must validate inputs, cast the delegate to its concrete type and initialize the result on every branch; use default for no result. Ownership of the returned native value transfers to the bridge. The managed function pointer must exactly match the SDK signature, including out; it is not an unmanaged-ABI pointer.
| Name | Type | Default |
|---|---|---|
delegate | Delegate | — |
trampoline | delegate*<object, Reckfell.NativeInterop.NativeVariantPtrArgs, out Reckfell.NativeInterop.reckfell_variant, void> | — |
delegateNon-null delegate the trampoline knows how to cast and invoke.
trampolineValid managed function pointer with the exact SDK signature; the third parameter is out reckfell_variant.
CallableCallable value storing the delegate and pointer. Construction does not establish the custom trampoline’s safety.
From20 overloads
public static Callable From(Action action);Creates a Callable from Action with 0 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0>(Action<T0> action);Creates a Callable from Action with 1 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<TResult>(Func<TResult> func);Creates a Callable from Func with 0 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult> func);Creates a Callable from Func with 9 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1>(Action<T0, T1> action);Creates a Callable from Action with 2 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, TResult>(Func<T0, TResult> func);Creates a Callable from Func with 1 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2>(Action<T0, T1, T2> action);Creates a Callable from Action with 3 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, TResult>(Func<T0, T1, TResult> func);Creates a Callable from Func with 2 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3>(Action<T0, T1, T2, T3> action);Creates a Callable from Action with 4 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2, T3> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, TResult>(Func<T0, T1, T2, TResult> func);Creates a Callable from Func with 3 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4>(Action<T0, T1, T2, T3, T4> action);Creates a Callable from Action with 5 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2, T3, T4> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, TResult>(Func<T0, T1, T2, T3, TResult> func);Creates a Callable from Func with 4 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, T3, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5>(Action<T0, T1, T2, T3, T4, T5> action);Creates a Callable from Action with 6 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2, T3, T4, T5> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, TResult>(Func<T0, T1, T2, T3, T4, TResult> func);Creates a Callable from Func with 5 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, T3, T4, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, T6>(Action<T0, T1, T2, T3, T4, T5, T6> action);Creates a Callable from Action with 7 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2, T3, T4, T5, T6> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, TResult>(Func<T0, T1, T2, T3, T4, T5, TResult> func);Creates a Callable from Func with 6 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, T3, T4, T5, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7>(Action<T0, T1, T2, T3, T4, T5, T6, T7> action);Creates a Callable from Action with 8 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2, T3, T4, T5, T6, T7> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, T6, TResult>(Func<T0, T1, T2, T3, T4, T5, T6, TResult> func);Creates a Callable from Func with 7 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, T3, T4, T5, T6, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7, T8>(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> action);Creates a Callable from Action with 9 input arguments. Pass exactly that many Variant arguments to Call in the same order. Every input type must support the SDK’s Variant conversions; calling Action returns Nil.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
action | Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> | — |
actionNon-null delegate with the stated inputs and no return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.
public static Callable From<T0, T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T0, T1, T2, T3, T4, T5, T6, T7, TResult> func);Creates a Callable from Func with 8 input arguments. Pass exactly that many Variant arguments to Call in the same order. TResult and every input type must support the SDK’s Variant conversions; the Func result is converted to Variant.
This is a delegate representation rather than an object/name pair. A closure retains captured data and observes later changes; it does not keep a captured native object alive forever. Keep handlers and manage unsubscription separately for repeated subscriptions.
| Name | Type | Default |
|---|---|---|
func | Func<T0, T1, T2, T3, T4, T5, T6, T7, TResult> | — |
funcNon-null delegate with the stated inputs and TResult return value.
CallableCallable value storing the delegate and a trampoline for the stated signature.