Skip to main content

Module externalptr_args

Module externalptr_args 

Source
Expand description

Borrowed external arguments (#2106): &T / &mut T for a TypedExternal type, the views ExternalPtrRef<'_, T> / ExternalPtrMut<'_, T>, and an Option of either.

The wrapper converts the argument to its ExternalPtr<T> handle with the other arguments (from_r::__mx_external_arg, which unwraps and roots a class handle), then borrows the value’s RefCell the way a method receiver is borrowed: shared for &T and ExternalPtrRef, exclusive for &mut T and ExternalPtrMut. The borrow is taken after every conversion and held through return conversion, and the body gets the plain reference (or the view). One object passed twice with a &mut T, or a callback into R that reaches the object while the function runs, then raises the miniextendr_borrow_conflict error instead of making a second reference.

An ExternalPtr<T> parameter is a handle the body keeps or consumes: it takes no borrow, and reads through it are borrow() / borrow_mut().

A borrowed argument keeps the call on R’s main thread (crate::type_inspect::is_main_thread_bound_input), like a &self receiver.

Structs§

ExternalArg 🔒
A borrowed external argument’s type, taken apart.

Enums§

Mode 🔒
How a borrowed external argument holds its value.

Constants§

NOT_EXTERNAL 🔒
Names that are never an external value behind & / &mut: R’s native borrows, &str / &Path, the dots, the RNG guard an rng wrapper passes (#2002), and containers with conversions of their own.

Functions§

arg_borrows 🔒
The borrows of the borrowed external parameters of inputs, except those unborrowed names (a parameter marker rebinds them to another type). Each binds the parameter to its reference or view, holding the value’s RefCell until the wrapper’s closure ends, after return conversion.
external_arg 🔒
The borrowed external argument ty describes, if any: &T / &mut T where T names a type with no R-side conversion of its own (no type check, not in NOT_EXTERNAL), or an ExternalPtrRef<'_, T> / ExternalPtrMut<'_, T> view, either one optionally under Option. Matched on the written type: a &T whose T isn’t TypedExternal is a compile error at the type (ExternalPtr<T> requires it).
handle_conversion 🔒
The statement converting the borrowed argument ident (of type arg) to its handle, given its R-facing failure arm (err_arm, an Err(e) => match arm). self_ty replaces Self.
handle_ident 🔒
The binding of the handle a borrowed argument param converts to. Mixed-site: user parameters may use any spelling.
is_external_value 🔒
replace_self 🔒
ty with Self replaced by self_ty (an impl method’s wrapper is a free function, where Self names nothing).