Skip to main content

scan_raw_r_eval_calls

Function scan_raw_r_eval_calls 

Source
fn scan_raw_r_eval_calls(lines: &[&str], data: &mut FileData)
Expand description

Scan the FileData::miniextendr_bodies for calls to Rf_eval, R_forceAndCall, Rf_applyClosure and R_CheckUserInterrupt, and their _unchecked forms, through any path (sys::Rf_eval(, miniextendr_api::sys::Rf_eval(, an imported Rf_eval().

The generated wrapper runs such a body inside one R_UnwindProtect, holding the receiver’s borrow guard. An R error or interrupt raised by one of these calls jumps to that R_UnwindProtect over every Rust frame of the body: no destructor runs, and the receiver stays borrowed for the rest of the session (#2093). Wrapping the call in with_r_unwind_protect (or its _or_raise form) doesn’t help: it resumes the R exit with R_ContinueUnwind, which jumps over the body’s frames all the same. So no context inside a body is exempt; the expression evaluators (RCall::eval, eval_with_handlers, …) are the way to run R code there.

Raw text, like MXL304: a call inside a macro invocation is seen, a helper fn the body calls is not (only the bodies themselves are scanned).