Skip to main content

generate_s7_r_wrapper

Function generate_s7_r_wrapper 

Source
pub fn generate_s7_r_wrapper(parsed_impl: &ParsedImpl) -> String
Expand description

Generates the complete R wrapper string for an S7-style class.

Produces the following R code:

  • Class definition: ClassName <- S7::new_class("ClassName", ...) with a .ptr property of class_any holding the ExternalPtr, plus optional computed properties
  • Constructor: inline in new_class(constructor = function(...) ...), supports .ptr shortcut parameter for factory methods returning Self
  • 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 via x@.ptr
  • External generics: S7::new_external_generic("pkg", "name") for overriding generics from other packages
  • Multiple dispatch: via #[miniextendr(s7(dispatch = "x,y"))]
  • Fallback methods: S7::method(generic, S7::class_any) with tryCatch for safe slot access on non-S7 objects
  • Static methods: regular functions named ClassName_method(...)
  • Convert methods: S7::method(convert, list(From, To)) for convert_from and convert_to annotations
  • S7 parent/abstract: optional parent and abstract = TRUE in class definition

Roxygen2 documentation and @importFrom S7 ... tags are generated automatically.