Skip to main content

derive_external_ptr

Function derive_external_ptr 

Source
pub fn derive_external_ptr(
    input: DeriveInput,
    emit_into_r_marker: bool,
) -> Result<TokenStream>
Expand description

Main entry point for #[derive(ExternalPtr)].

Orchestrates the full derive expansion:

  1. Parses #[externalptr(...)] attributes for class system selection.
  2. Analyzes struct fields for #[r_data] sidecar slots.
  3. Generates TypedExternal impl (type identity for ExternalPtr<T>).
  4. Generates IntoExternalPtr marker impl (enables IntoR blanket impl) and a concrete IntoRVecElement impl (enables the IntoR for Vec<T> blanket, so -> Vec<MyType> returns a VECSXP of external pointers — #1284). Both are suppressed when emit_into_r_marker is false, which the struct-level #[miniextendr(prefer = "native")] path uses so its concrete AsRNative IntoR does not collide with the blanket IntoExternalPtr IntoR (E0119, #1283).
  5. Generates sidecar accessor FFI functions, registration constants, and R wrappers.

Returns the combined token stream of all generated items.