pub(crate) struct MiniextendrFunctionParsed {
item: ItemFn,
inputs: Punctuated<FnArg, Comma>,
param_markers: Vec<(String, Vec<ParamMarker>)>,
dots: Option<Ident>,
per_param: HashMap<String, ParamAttrs>,
}Expand description
Parsed + normalized Rust function item for #[miniextendr].
This performs signature normalization that the wrapper generator depends on:
...→ a final&miniextendr_api::dots::Dotsargument_wildcard patterns → synthetic identifiers (__unused0,__unused1, …)- Destructuring patterns (tuple, struct) → synthetic identifiers with let-binding in body
- consumes
#[miniextendr(coerce)]parameter attributes and records which params had it
Fields§
§item: ItemFnThe normalized function item (with dots transformed, wildcards renamed). Re-emitted for the user, so it keeps the parameter markers.
inputs: Punctuated<FnArg, Comma>item’s parameters with the parameter markers (Checked<T> /
Unchecked<T>, #1566) peeled: what the R wrapper, the preconditions
and the C wrapper’s conversions see.
param_markers: Vec<(String, Vec<ParamMarker>)>The markers peeled off each marked parameter (Rust name), in signature order: the C wrapper wraps the converted value in them.
dots: Option<Ident>Rust binding of the &Dots parameter (R’s ...), from Rust ... or
an explicit &Dots parameter at any position (see
find_dots_param).
per_param: HashMap<String, ParamAttrs>All per-parameter #[miniextendr(...)] options (coerce, match_arg,
default, choices, several_ok), keyed by the (possibly synthesized) Rust
parameter name. Replaces five parallel HashSet / HashMap fields.
Implementations§
Source§impl MiniextendrFunctionParsed
Accessors and codegen helpers for MiniextendrFunctionParsed.
impl MiniextendrFunctionParsed
Accessors and codegen helpers for MiniextendrFunctionParsed.
Accessors are split into two groups:
- Parsed metadata: dots, coerce, match_arg, choices, and defaults from
per-parameter
#[miniextendr(...)]attributes. - Signature components: attrs, vis, abi, ident, generics, inputs, output
from the normalized
syn::ItemFn.
Codegen helpers produce identifiers and perform mutations needed by the
#[miniextendr] expansion pipeline.
Sourcepub(crate) fn has_dots(&self) -> bool
pub(crate) fn has_dots(&self) -> bool
Whether the function takes ...: Rust ... or an explicit &Dots
parameter, at any position.
Sourcepub(crate) fn dots_ident(&self) -> Option<&Ident>
pub(crate) fn dots_ident(&self) -> Option<&Ident>
The Rust binding of the dots: the user’s name (args: ...,
rest: &Dots), or __miniextendr_dots for _: ....
Sourcepub(crate) fn is_dots_param(&self, ident: &Ident) -> bool
pub(crate) fn is_dots_param(&self, ident: &Ident) -> bool
Check if a parameter is the dots (...) param, whose R formal is ....
Sourcepub(crate) fn has_param_attrs(&self, param_name: &str) -> bool
pub(crate) fn has_param_attrs(&self, param_name: &str) -> bool
Whether a parameter carried any per-parameter #[miniextendr(...)]
option. A Call / CallerCall marker (#1566) is bound from the call
slot, not from an R argument, so none of them apply to it.
Sourcepub(crate) fn has_coerce_attr(&self, param_name: &str) -> bool
pub(crate) fn has_coerce_attr(&self, param_name: &str) -> bool
Check if a parameter name had #[miniextendr(coerce)] attribute.
Sourcepub(crate) fn has_match_arg_attr(&self, param_name: &str) -> bool
pub(crate) fn has_match_arg_attr(&self, param_name: &str) -> bool
Check if a parameter name had #[miniextendr(match_arg)] attribute.
Sourcepub(crate) fn match_arg_params(&self) -> impl Iterator<Item = &String>
pub(crate) fn match_arg_params(&self) -> impl Iterator<Item = &String>
Iterator over parameter names annotated with #[miniextendr(match_arg)],
in signature order.
Sourcepub(crate) fn choices_params(
&self,
) -> impl Iterator<Item = (&String, &Vec<String>)>
pub(crate) fn choices_params( &self, ) -> impl Iterator<Item = (&String, &Vec<String>)>
Iterator over parameter names annotated with #[miniextendr(choices(…))],
together with their choice lists, in signature order.
Sourcepub(crate) fn has_several_ok(&self, param_name: &str) -> bool
pub(crate) fn has_several_ok(&self, param_name: &str) -> bool
Check if a parameter has several_ok (multi-value match.arg).
Sourcepub(crate) fn param_attrs(&self, param_name: &str) -> Option<&ParamAttrs>
pub(crate) fn param_attrs(&self, param_name: &str) -> Option<&ParamAttrs>
The per-parameter attribute state of param_name, if it carried any
#[miniextendr(...)] option. Choice parameters read their layers
(Option / Missing, #1473 / #1551) from here.
Sourcepub(crate) fn formals(&self) -> Formals
pub(crate) fn formals(&self) -> Formals
The R formal of each parameter (#1842), from the declared
formal = ".." options.
Sourcepub(crate) fn absent_formals(&self, c_ident: &str) -> HashMap<String, String>
pub(crate) fn absent_formals(&self, c_ident: &str) -> HashMap<String, String>
The parameters that read a value identical() to their formal as
omitted, keyed by R formal (see absent_formals_by_r_name).
Sourcepub(crate) fn missing_default_param_docs(&self) -> HashMap<String, String>
pub(crate) fn missing_default_param_docs(&self) -> HashMap<String, String>
The generated @param text of each Missing<..> parameter with a
default, keyed by R formal (see missing_default_param_docs).
Sourcepub(crate) fn explicit_checks(&self) -> HashMap<String, ExplicitChecks>
pub(crate) fn explicit_checks(&self) -> HashMap<String, ExplicitChecks>
The inherits / not_inherits / no_na checks of every parameter,
keyed by R name (see explicit_checks_by_r_name).
Sourcepub(crate) fn precondition_skip_params(&self) -> HashSet<String>
pub(crate) fn precondition_skip_params(&self) -> HashSet<String>
R names of the match_arg and choices(...) parameters, whose
type-derived preconditions are skipped because match.arg() already
validates them. The method paths build the same set.
Sourcepub(crate) fn param_defaults(&self) -> HashMap<String, String>
pub(crate) fn param_defaults(&self) -> HashMap<String, String>
Returns all parameter defaults as an owned map from Rust parameter
name to default value string (the raw R expression used in the wrapper
formals, e.g. "NULL", "TRUE", "\"Safe\""). The R wrapper keys
them by formal (crate::r_wrapper_builder::Formals::rekey), so a
default on _seed is the formal seed’s.
Sourcepub(crate) fn attrs(&self) -> &[Attribute]
pub(crate) fn attrs(&self) -> &[Attribute]
Original attributes on the function item (doc comments, cfgs, etc.).
Sourcepub(crate) fn vis(&self) -> &Visibility
pub(crate) fn vis(&self) -> &Visibility
Visibility of the function (pub, pub(crate), or private).
Sourcepub(crate) fn abi(&self) -> Option<&Abi>
pub(crate) fn abi(&self) -> Option<&Abi>
Explicit ABI, if the function was declared extern "C-unwind".
Sourcepub(crate) fn inputs(&self) -> &Punctuated<FnArg, Comma>
pub(crate) fn inputs(&self) -> &Punctuated<FnArg, Comma>
Function inputs after normalization (dots rewritten, wildcards
renamed), with the parameter markers peeled (see Self::param_markers).
Sourcepub(crate) fn param_markers(&self) -> &[(String, Vec<ParamMarker>)]
pub(crate) fn param_markers(&self) -> &[(String, Vec<ParamMarker>)]
The Checked<T> / Unchecked<T> markers peeled off the parameters
(Rust name → markers, outermost first), in signature order.
Sourcepub(crate) fn output(&self) -> &ReturnType
pub(crate) fn output(&self) -> &ReturnType
Function return type.
Sourcepub(crate) fn item(&self) -> &ItemFn
pub(crate) fn item(&self) -> &ItemFn
The normalized function item (with original doc comments).
Sourcepub(crate) fn item_without_roxygen(&self) -> ItemFn
pub(crate) fn item_without_roxygen(&self) -> ItemFn
The normalized function item with roxygen tags stripped from doc comments.
This is used for emitting the Rust function without R-specific documentation
tags (e.g., @param, @examples) that don’t belong in rustdoc.
Sourcepub(crate) fn uses_internal_c_wrapper(&self) -> bool
pub(crate) fn uses_internal_c_wrapper(&self) -> bool
Returns true if this function needs an internal C wrapper (C_<crate>_<name> function).
Rust-ABI functions (no explicit extern) need a generated extern "C-unwind" wrapper
that handles SEXP conversion and error propagation. Functions already declared as
extern "C-unwind" are passed through directly without wrapping.
Sourcepub(crate) fn r_wrapper_const_ident(&self) -> Ident
pub(crate) fn r_wrapper_const_ident(&self) -> Ident
Returns the identifier for the generated const &str holding the R wrapper code.
The R wrapper is a string constant containing the R function definition that
calls .Call(C_<crate>_<name>, ...). It is collected via linkme distributed slices to
produce the R/miniextendr-wrappers.R file.
Sourcepub(crate) fn c_wrapper_ident(&self) -> Ident
pub(crate) fn c_wrapper_ident(&self) -> Ident
Returns the identifier for the C-callable entry point.
- Rust ABI functions: Returns
C_<crate>_<name>(the generated wrapper function, crate-prefixed for webR cross-package symbol uniqueness — #1273). extern "C-unwind"functions: Returns the function’s own name, or the value from#[export_name = "..."]if present. The user owns these symbols, including their cross-package uniqueness under webR.
Sourcepub(crate) fn export_name_ident(&self) -> Option<Ident>
pub(crate) fn export_name_ident(&self) -> Option<Ident>
Extracts the custom symbol name from #[export_name = "..."], if present.
Only meaningful for extern "C-unwind" functions, where #[export_name] is
allowed as an alternative to #[no_mangle]. Returns None if no such attribute exists.
Sourcepub(crate) fn add_inline_never_if_needed(&mut self)
pub(crate) fn add_inline_never_if_needed(&mut self)
Add #[inline(never)] if no #[inline(...)] attribute is present.
Only for Rust ABI functions - extern “C-unwind” functions are passed through as-is.
Preventing inlining ensures:
- Worker-dispatched functions retain a distinct call frame
- Panic handling and unwinding retain the intended boundary
- Stack traces show the actual function name
Trait Implementations§
Source§impl Parse for MiniextendrFunctionParsed
Parses a Rust fn item from a token stream, performing all normalizations
required by the #[miniextendr] codegen pipeline.
impl Parse for MiniextendrFunctionParsed
Parses a Rust fn item from a token stream, performing all normalizations
required by the #[miniextendr] codegen pipeline.
§Normalizations performed
- Variadic (
...) rewriting: Replaces Rust variadic syntax with a typed&miniextendr_api::dots::Dotsparameter. Named dots (my_dots: ...) preserve the user’s identifier;_: ...becomes__miniextendr_dots. - Wildcard pattern renaming:
_parameter patterns become__unused0,__unused1, etc., so they can be passed by name to the C wrapper. - Destructuring expansion: Tuple/struct destructuring patterns are replaced
with synthetic identifiers (
__param_0, …) and aletbinding is prepended to the function body. - Per-parameter attribute consumption:
#[miniextendr(coerce)],#[miniextendr(match_arg)],#[miniextendr(default = "...")], and#[miniextendr(choices(...))]are consumed from parameters and recorded in the correspondingper_param_*fields. - Validation: Rejects
#[export_name]on non-extern functions, rejects unsupported parameter patterns, and validates that defaults reference existing parameter names.
fn parse(input: ParseStream<'_>) -> Result<Self>
Auto Trait Implementations§
impl !Send for MiniextendrFunctionParsed
impl !Sync for MiniextendrFunctionParsed
impl Freeze for MiniextendrFunctionParsed
impl RefUnwindSafe for MiniextendrFunctionParsed
impl Unpin for MiniextendrFunctionParsed
impl UnsafeUnpin for MiniextendrFunctionParsed
impl UnwindSafe for MiniextendrFunctionParsed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 600 bytes