pub fn generate_s4_r_wrapper(parsed_impl: &ParsedImpl) -> StringExpand description
Generates the complete R wrapper string for an S4-style class.
Produces the following R code:
- Class definition:
methods::setClass("<class>", slots = c(ptr = "externalptr"))with a singleptrslot holding theExternalPtrto the Rust struct - Constructor function:
ClassName(...)that calls the Rustnewconstructor and wraps the result withmethods::new("<class>", ptr = .val) - S4 generics:
methods::setGeneric(...)for each instance method (idempotent, always emitted rather than using conditionalisGeneric()checks) - S4 methods:
methods::setMethod("<generic>", "<class>", function(x, ...) ...)dispatching to the Rust.Call()wrapper, extracting the ptr viax@ptr - Static methods: regular functions named
<class>_<method>(...)
Roxygen2 @exportMethod, @importFrom methods, and @slot tags are generated
as appropriate.