Expand description
Shared utilities for R class wrapper generation.
This module provides abstractions to reduce duplication across the 5 class system generators (Env, R6, S3, S4, S7). Each class system has different R idioms but shares common patterns:
- Class-level roxygen documentation
- Constructor generation
- Instance method iteration with
.Call()building - Static method handling
- Return strategy application
§Architecture
ParsedImpl
│
├─▶ ClassDocBuilder → roxygen header lines (#' @title, @name, etc.)
│
└─▶ MethodContext[] → pre-computed method data for each method
│
└─▶ ClassFormatter::format_constructor()
└─▶ ClassFormatter::format_instance_method()
└─▶ ClassFormatter::format_static_method()Structs§
- Class
DocBuilder - Builder for class-level roxygen documentation header.
- Method
Context - Pre-computed context for a method, holding all data needed for R wrapper generation.
- Method
DocBuilder - Builder for method-level roxygen documentation.
Traits§
- Parsed
Impl Ext - Extension trait for
ParsedImplto iterate over methods asMethodContext.
Functions§
- build_
match_ 🔒arg_ prelude - Build R prelude lines that validate
match_arg/choices/several_okparameters viabase::match.arg()before the.Call(). - build_
method_ 🔒precondition_ checks - Build R-side precondition
stopifnot()lines for a parameter list, given its match_arg/choices per-param map and whethercoerceis active for the whole method. - class_
ref_ 🔒or_ verbatim - Return a
.__MX_CLASS_REF_<name>__placeholder (for bare identifiers) so the resolver can look up the actual R class name at cdylib write time, ornameverbatim (for namespaced / non-identifier strings). - effective_
r_ 🔒defaults - Effective R-formal defaults for a method.
- emit_
s3_ 🔒generic_ guard - Emit the conditional S3 generic guard for a given generic name.
- is_
bare_ 🔒identifier - Check whether
sis a bare R identifier (only[A-Za-z_][A-Za-z0-9_]*). - match_
arg_ 🔒doc_ placeholder_ map - Build the R-param-name → @param placeholder map for a method’s match_arg and
choices params. Pass to
MethodDocBuilder::with_match_arg_doc_placeholdersin each class generator. - match_
arg_ 🔒skip_ set - Rust-side parameter names that are validated by R’s
match.arg()and therefore don’t needstopifnot()preconditions generated for them. Shared byMethodContextandTraitMethodContext. - should_
export_ 🔒from_ tags - Determine whether a class or method should be
@export-ed.