Skip to main content

mx_meth

Type Alias mx_meth 

Source
pub type mx_meth = unsafe extern "C" fn(data: *mut c_void, argc: i32, argv: *const SEXP) -> SEXP;
Expand description

Method signature for trait vtable entries.

All trait methods are erased to this uniform signature:

  • data: Pointer to the concrete object data
  • argc: Number of arguments in argv
  • argv: Array of SEXP arguments from R
  • Returns: SEXP result to R

§Argument Handling

The shim generated by #[miniextendr] on a trait is responsible for:

  1. Checking argc matches expected arity
  2. Converting each argv[i] via TryFromSexp
  3. Calling the actual method
  4. Converting the result via IntoR
  5. Catching panics and converting to R errors

§Safety

This function pointer is unsafe because:

  • data must point to valid, properly-aligned data of the expected type
  • argv must point to argc valid SEXP values
  • Must be called on R’s main thread