Skip to main content

generate_getter_body

Function generate_getter_body 

Source
fn generate_getter_body(
    struct_name: &Ident,
    slot: &SidecarSlot,
    _prot_index_lit: &LitInt,
) -> TokenStream
Expand description

Generate the token stream for a sidecar getter function body.

Reads the field value from the Rust struct (accessed via the external pointer address) and converts it to an R SEXP. The conversion strategy depends on the slot kind:

  • RawSexp: returns the SEXP field directly.
  • Scalar kinds: wraps in Rf_Scalar* for zero-overhead conversion.
  • Conversion: clones the value and calls IntoR::into_sexp.

Returns R_NilValue if the external pointer address is null.