pub fn generate_s7_class(parsed_impl: &ParsedImpl) -> ClassWrapperExpand description
Generates the R wrapper of an S7-style class, in the parts the wrapper
writer merges per type (super::ClassWrapper, #1776).
Produces the following R code:
- Class definition:
ClassName <- S7::new_class("ClassName", ...)with a.ptrproperty ofclass_anyholding theExternalPtr, plus optional computed properties - Constructor: inline in
new_class(constructor = function(...) ...), supports.ptrshortcut parameter for wrapping pre-built ExternalPtr returns - Properties:
S7::new_property(...)for each getter/setter/validator annotated with#[miniextendr(s7(getter))]etc., with support for class constraints, defaults, required, frozen, and deprecated modifiers - Instance methods:
S7::new_generic(...)+S7::method(generic, class)pairs dispatching to Rust.Call()wrappers viax@.ptr(seeS7GenericTargetfor where the generic comes from) - External generics:
S7::new_external_generic("pkg", "name", dispatch_args)fors7(generic = "pkg::name") - Multiple dispatch: via
#[miniextendr(s7(dispatch = "x, other"))], and on(e1, e2)for theOpsoperators - Fallback methods:
S7::method(generic, S7::class_any)withtryCatchfor safe slot access on non-S7 objects - Static methods: regular functions named
ClassName_method(...) - Convert methods:
S7::method(convert, list(From, To))forconvert_fromandconvert_toannotations - S7 parent/abstract: optional
parentandabstract = TRUEin class definition
Roxygen2 documentation and @importFrom S7 ... tags are generated automatically.
The class definition, with its properties and constructor, is the head; the
methods, static methods and convert() methods are the members.