Skip to main content

generate_erased_wrapper

Function generate_erased_wrapper 

Source
fn generate_erased_wrapper(input: &DeriveInput) -> TokenStream
Expand description

Generate the type-erased wrapper infrastructure for trait ABI dispatch.

For #[derive(ExternalPtr)] struct MyCounter { ... } generates:

  • __MxWrapperMyCounter - repr(C) wrapper with mx_erased header + data
  • __MX_TAG_MYCOUNTER - concrete type tag (FNV-1a hash of module_path + type)
  • __mx_drop_mycounter - destructor for R GC
  • __MX_BASE_VTABLE_MYCOUNTER - base vtable with universal_query
  • __mx_wrap_mycounter - constructor returning *mut mx_erased