fn generate_getter_body(struct_name: &Ident, slot: &SidecarSlot) -> TokenStreamExpand description
Generate the token stream for a sidecar getter function body.
Reads the slot and returns it as an R SEXP. The strategy depends on the slot kind:
Sidecar: returns the value from the external pointer’s protection list, after flushing a live struct’s pending value for the field. It needs no live address, so withoutrequire_liveit also reads a pointer thatreadRDSbrought back; with it (the field methods ofr_data_accessors, #1891) a restored pointer is refused.- Scalar kinds: reads the struct field (accessed via the external pointer
address) and wraps it with
Rf_Scalar*. Conversion: clones the struct field and callsIntoR::into_sexp.Computed: calls thegetfunction on the live struct and converts its value withIntoR::into_sexp.
The body runs inside with_r_unwind_protect (see the emission site in
generate_sidecar_accessors). The receiver is the pointer or an object
carrying it in .ptr, as for an instance method; an argument carrying no
pointer, a null pointer address, or a wrong stored type panics with the
same expected ExternalPtr<T> message the main class-method path uses.
The panic is transported as a tagged condition and re-raised by the R
wrapper.