Skip to main content

generate_r_wrapper_for_slot

Function generate_r_wrapper_for_slot 

Source
fn generate_r_wrapper_for_slot(
    class_system: ClassSystem,
    type_name: &str,
    field_name: &str,
    getter_c_name: &str,
    setter_c_name: Option<&str>,
    setter_invisible: bool,
    exported: bool,
) -> String
Expand description

Generate R wrapper code (roxygen-annotated R functions) for a single sidecar slot.

Produces getter and setter R functions that call the corresponding C entry points via .Call. The generated R code includes roxygen tags (@rdname, @param, @return, @export) for documentation.

All class systems generate the same standalone function pattern (Type_get_field / Type_set_field); only the roxygen title suffix differs. Class-specific integration (e.g., R6 active bindings, S7 properties) is handled separately by generate_class_integration_r_code.

Each wrapper body carries the shared tagged-condition guard (crate::method_return_builder::standalone_body) so Rust-origin panics/conversion failures are re-raised as structured R conditions. Note the sidecar C functions have no .call slot — the .Call() passes no .call argument (#344/#348); sys.call() inside the guard supplies fallback attribution instead. The last .Call() argument is the require_live flag: FALSE here, so the standalone accessors keep reading a save’s Sidecar values (#1891).

field_name is the field’s R name (Type_get_<name>()). A Computed field (setter_c_name is None) gets the getter only.

exported writes them on the type’s page with @export; otherwise they are internal (@noRd, no export), the rendering a type whose class has $ / [[ field syntax gets (#1900).