Skip to main content

generate_trait_s4_r_wrapper

Function generate_trait_s4_r_wrapper 

Source
fn generate_trait_s4_r_wrapper(
    type_ident: &Ident,
    trait_name: &Ident,
    methods: &[TraitMethod],
    consts: &[TraitConst],
) -> String
Expand description

Generate S4-style R wrapper code.

For impl Counter for SimpleCounter, generates:

  • setOldClass("SimpleCounter") to register the S3 class for S4 dispatch
  • S4 generic s4_trait_Counter_value(x, ...) via setGeneric()
  • S4 method via setMethod("s4_trait_Counter_value", "SimpleCounter", ...)

Generic names are prefixed with s4_trait_{Trait}_ to avoid collisions with user-defined S4 generics. Static methods and constants are generated as standalone exported functions: {Type}_{Trait}_{method}().