Skip to main content

frame_call_helper_fn

Macro frame_call_helper_fn 

Source
macro_rules! frame_call_helper_fn {
    () => { ... };
}
Expand description

R source of .miniextendr_frame_call as a bare function(env) expression: the call a generated S3 method’s conditions report, resolved from the method’s frame (#1851).

A generated S3 method passes environment() as its .call and as the raise fallback (CallAttribution::Generic in the macros), so the success path pays no more than for sys.call(), and the frame becomes a call only when a condition is raised. write_r_wrappers_to_file binds the expression under that name in the preamble (FRAME_CALL_HELPER) for the package’s raise helper, the R-side checks (.miniextendr_arg_error) and a method with a Call parameter, which resolves it up front; RAISE_CONDITION_HELPER_FN inlines it, because that copy of the raise helper signals deferred conditions from the base namespace, where the preamble’s binding is not visible.

The frame is looked up among the live frames (sys.frames()), newest first, so the helper works from the method itself, from the raise helper the method calls, and from the deferred-condition path, which R runs from C while the method’s .Call() is still on the stack (a .Call context is not a function frame, so the frame numbers line up). .Generic is bound in the frame of a method R dispatched (UseMethod(), an internal generic such as [[, NextMethod(), a group generic such as Ops) and not in a method called by name, so a direct call keeps the method’s name. For a replacement generic R’s call is `$<-.cls`(`*tmp*`, name, value = <value>): the result is the assignment as written, x$name <- value, which never deparses the value. No comment inside: the text is inlined into another function. A macro, not a const, because concat! takes literals only.