fn generate_method_shim(
trait_name: &Ident,
method: &MethodInfo,
extra_bounds: &ExtraBounds,
trait_param_idents: &[&Ident],
trait_type_params: &[&GenericParam],
trait_where_clause: &Option<WhereClause>,
) -> TokenStreamExpand description
Generate a method shim function for a trait method.
The shim is an extern "C" function that:
- Checks argument arity
- Wraps everything in
with_r_unwind_protectto prevent unwinding across FFI - Converts SEXP arguments to Rust types
- Calls the actual method on the concrete type
- Converts the result back to SEXP
- On panic, converts to R error via
with_r_unwind_protect
For generic traits, the shim carries the trait’s type parameters plus __ImplT.