pub fn generate_method_c_wrapper(
parsed_impl: &ParsedImpl,
method: &ParsedMethod,
) -> TokenStreamExpand description
Generate a C-callable wrapper function for a single method in an impl block.
Produces a #[no_mangle] extern "C-unwind" function named C_{crate}_{Type}__{method} that:
- Accepts SEXP arguments (including
self_sexpfor instance methods) - Extracts
&self/&mut selffrom anErasedExternalPtrfor instance methods - Converts SEXP arguments to Rust types
- Calls the actual Rust method
- Converts the return value back to SEXP
Thread strategy is determined automatically: instance methods always run on the main
thread (because self_ref is a non-Send borrow), as do methods taking .... Other
static methods use the main thread unless worker or worker-default selects
worker dispatch; unsafe(main_thread) keeps one on main regardless, and so do the
requirements that keep a standalone function there (R values in or out,
check_interrupt).
Also emits an R_CallMethodDef constant for R routine registration.
ยงArguments
parsed_impl- The parsed impl block providing type identity, cfg attrs, and optionsmethod- The parsed method to generate a wrapper for