CustomCallable

gdext.internal.engine.CustomCallable

Builds a Godot Callable backed by a Scala closure (a custom callable), via the GDExtension callable_custom_create2 interface. This lets game code connect a signal to a lambda directly — no registered @func method and no string method name.

How the closure survives the FFI boundary: Scala Native CFuncPtrs must be non-capturing, so the trampolines below are static and the closure lives in a registry keyed by a generated id. That id is what we hand Godot as the opaque callable_userdata pointer (packed via Tokens, exactly like the class/instance tokens — the GC never chases a fabricated pointer because the closure is kept alive by the registry, not the pointer). Each trampoline reads the id back to find its closure; free_func drops the registry entry when Godot frees the Callable, so the closure is reachable for exactly as long as the engine holds it.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def of(f: () => Unit, dest: Ptr[Byte]): Callable

Build a Callable invoking f into caller storage dest (at least gdext.builtin.BuiltinSizes.Callable bytes). The returned Callable owns a registry slot freed when Godot frees the Callable.

Build a Callable invoking f into caller storage dest (at least gdext.builtin.BuiltinSizes.Callable bytes). The returned Callable owns a registry slot freed when Godot frees the Callable.

Attributes