registerFunctionTypedef method
Registers a function typedef so it can be resolved as a type.
Function typedefs like typedef VoidCallback = void Function() are not
classes, but D4rt scripts may reference them as type arguments
(e.g., ObserverList<VoidCallback>()). This registers the name
as a BridgedClass with nativeType: Function so type resolution
succeeds.
name The typedef name (e.g., 'VoidCallback').
library The library path where this typedef is exported from.
SCD137 — requiredPositional / maxPositional carry the typedef's
POSITIONAL arity so FunctionRuntimeType.isSubtypeOf can refuse a
callable that provably cannot be invoked. Both are optional: a bridge
generated before the generator carried signatures through omits them, and
the interpreter then keeps scd136's arity-blind acceptance.
Implementation
void registerFunctionTypedef(
String name,
String library, {
int? requiredPositional,
int? maxPositional,
}) {
final typedef = (
name: name,
library: library,
requiredPositional: requiredPositional,
maxPositional: maxPositional,
);
_functionTypedefs.add(typedef);
// Step 7: dual-write into the process-global pool (see registerBridgedEnum).
_bundleFor().functionTypedefs.add(typedef);
}