macro_rules! impl_managed_callback {
(
wrapper: $wrapper:ty,
info_ty: $info_ty:ty,
return_ty: $ret:ty,
default_ret: $default:expr,
invoker_static: $invoker_static:ident,
invoker_ty: $invoker_ty:ident,
thunk_fn: $thunk_fn:ident,
setter_fn: $setter_fn:ident,
from_handle_fn: $from_handle_fn:ident,
) => { ... };
(
wrapper: $wrapper:ty,
info_ty: $info_ty:ty,
return_ty: $ret:ty,
default_ret: $default:expr,
invoker_static: $invoker_static:ident,
invoker_ty: $invoker_ty:ident,
thunk_fn: $thunk_fn:ident,
setter_fn: $setter_fn:ident,
from_handle_fn: $from_handle_fn:ident,
extra_args: [ $( $extra_name:ident : $extra_ty:ty ),* $(,)? ] $(,)?
) => { ... };
}Expand description
Macro that expands to the per-callback-kind boilerplate: a static thunk
(compiled into libazul) that the framework calls with by-value args, a
<Wrapper>::create_from_host_handle(u64) constructor, and an
AzApp_set<Kind>Invoker setter the host calls once at module load.
All identifiers are passed in explicitly so we don’t need a proc-macro
dependency just to concatenate idents. Codegen emits invocations of this
macro from ir.callback_typedefs.
Caller responsibilities:
- The wrapper type must have public fields
cb: <typedef>andctx: OptionRefAny— that’s the standard shape every callback wrapper in the framework already follows. info_tymust expose a.get_ctx() -> OptionRefAnymethod (also standard for*CallbackInfotypes).default_retis returned when:- the framework invokes the thunk with
OptionRefAny::Nonectx (host called the typedef directly without going through this path), - the ctx isn’t a host-handle (host registered the wrapper but the ctx came from somewhere else),
- or no invoker has been registered yet for this kind. Pick a value that can’t be confused with a “real” return — typically the kind’s “do nothing” / “empty body” default.
- the framework invokes the thunk with