pub fn generate_s4_class(parsed_impl: &ParsedImpl) -> ClassWrapperExpand description
Generates the R wrapper of an S4-style class, in the parts the wrapper
writer merges per type (super::ClassWrapper, #1776).
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 Rust constructor and wraps the result withmethods::new("<class>", ptr = .val). A class without a constructor has noClassName(): its factories callmethods::new(), and a package may define its own (#2069). - S4 generics:
methods::setGeneric(...)for each instance method, guarded bys4_generic_guard - 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.
The class, its constructor and the field methods are the head; the S4 methods and the static methods are the members.