Skip to main content

fallback_c_entries

Function fallback_c_entries 

Source
pub(super) fn fallback_c_entries(parsed_impl: &ParsedImpl) -> TokenStream
Expand description

The .Call entries of the impl’s field fallback (#2150): fallback = "Self::f" as C_<crate>__mx_rdata_fallback_<Type>(x, name, none), and fallback_names = "Self::g" as C_<crate>__mx_rdata_names_<Type>(x). Nothing without a fallback.

They are the sidecar getters’ kind (externalptr_derive): no call slot (#344, #348), the body under with_r_unwind_protect, so a panic or the function’s own rust_error!(class = ...) reaches R as a tagged condition the method raises on its call, and the deferred conditions signalled at the call. They borrow the value through sidecar_r_struct, as a struct field’s getter does: a restored pointer raises the type’s restored error before the function runs, a pointer of another type the receiver error, and a running method holding the value mutably miniextendr_borrow_conflict.

none is the value of None: the method passes its own frame, which the entry returns untouched, so the entry holds no R value across an allocation and the method tells None from any value with identical(). Some(v) converts v with IntoR, so Some(None) of an Option<Option<i32>> reads NA. The names entry gives character(0) for a pointer without its Rust value, since .DollarNames() never raises; a live one calls the function on the value.

The paths resolve a leading Self to the impl’s type, since the entries are free functions; a function of the wrong signature is reported at the attribute’s string.