Skip to main content

with_r_unwind_protect_shim

Function with_r_unwind_protect_shim 

Source
pub fn with_r_unwind_protect_shim<F>(f: F) -> SEXP
where F: FnOnce() -> SEXP,
Expand description

Like with_r_unwind_protect, but tailored for trait-ABI vtable shims.

Same tagged-SEXP behaviour as with_r_unwind_protect, but intended for shim functions that have no R wrapper of their own. The tagged SEXP is returned to the View method wrapper, which calls crate::condition::repanic_if_rust_error to re-panic with the reconstructed crate::condition::RCondition. The outer with_r_unwind_protect in the consumer’s C entry point then catches the re-panic and builds the final tagged SEXP for the consumer’s R wrapper.

R-origin errors (longjmp) still pass through via R_ContinueUnwind — the outer guard will catch them.

§PROTECT note

The returned SEXP is unprotected. The View method wrapper must not call any R API functions between receiving it and passing it to repanic_if_rust_error. repanic_if_rust_error reads the message/kind/class strings immediately and then panics (or returns), so the SEXP does not need protection beyond that window.