Expand description
Shared per-method context for trait-impl R wrapper generation.
Parallels r_class_formatter::MethodContext (used by the 6 inherent-impl
class generators) so the 5 trait generators (env/s3/s4/s7/r6) build
.Call() invocations and method preludes the same way instead of each
hand-rolling its own version. See
audit/2026-07-03-dogfooding-macros-codegen.md finding #1: the trait path
previously shared nothing above DotCallBuilder, which caused a
substring-corruption bug in the receiver-ptr extraction (S4/S7/R6) and a
silent 3-of-6-step prelude omission (missing precondition_checks /
match_arg_prelude) relative to inherent methods.
Re-exportsΒ§
use super::TraitMethod;πuse super::trait_method_body_lines;πuse crate::miniextendr_impl::ClassSystem;π
StructsΒ§
- Trait
Method πContext - Pre-computed context for a trait method, mirroring
MethodContext(r_class_formatter.rs) for inherent-impl methods. Holds the C wrapper name, R formals (with defaults), and.Call()argument string so all 5 trait generators build calls identically.
FunctionsΒ§
- class_
ref π - How the trait wrappers of
class_systemname the class oftype_ident: its R name, which aclass = "..."rename on the typeβs impl block sets, resolved when the wrappers are written (#2266,class_ref_for). Used for every R object the trait impl attaches to or wraps in (S3 method suffixes and registrations, theClass$Traitnamespace, the S4 method signature, the S7 class object, aSelfreturn). Rust-side names (C symbols, the S7 and S4 flat member names) and the@rdnamepage keep the Rust identifier. - s7_
trait_ πmember_ access - How R code reaches an S7 trait static or const:
attr(Type, "Trait")$member, also the topic alias of its documentation block. The trait namespace is an attribute of the class object, andType$Trait$memberdoes not reach it: an S7 class object is a function, and S7βs$method stops on any S7 object that is not a list or an environment (βCanβt get S7 properties with$β). - trait_
namespace_ πenv - The trait namespace environment,
Class$Trait, of Env, S3, R6 and vctrs classes; its members aretrait_namespace_targets. - trait_
namespace_ πenv_ var - The local environment variable S7 trait wrappers assign members into before
attaching it to the class object via
attr(). One owner sotrait_namespace_targetβs S7 arm and the generatorβsnew.env/attr()lines canβt drift apart. - trait_
namespace_ πsymbol trait_namespace_targetin R code position (the left of<-, the argument ofattr()). A non-syntactic member (an operatorr_name, #1475) is backtick-quoted:Type$Trait$[[, orType_Trait_[[`` for S4. Roxygen@namekeeps the baretrait_namespace_targetspelling.- trait_
namespace_ πtarget - R-visible assignment target for a trait member (method or const) placed in
the per-class trait namespace β the single owner of the namespace-shape
policy the 5 generators previously hand-rolled independently (audit
2026-07-03-dogfooding-macros-codegen.mdfinding #1; #1141).memberis the R-facing method/const name.