const FIELD_AT_HELPER: &str = r#"# Internal helper: the field a position picks on a bare classed pointer, as
# `[[` picks a list element: `2.9` is the second field, `TRUE` the first. A
# position that picks no field (past the last one, `0`, a negative one)
# raises `subscriptOutOfBoundsError`, with the type's own classes (`class`)
# in front, reporting the generic's call, `x[[9]]`, resolved from the
# method's frame (`env`).
.miniextendr_field_at <- function(fields, i, env, class = NULL) {
k <- trunc(i)
if (k < 1 || k > length(fields)) stop(errorCondition("subscript out of bounds", class = c(class, "subscriptOutOfBoundsError"), call = .miniextendr_frame_call(env)))
fields[[k]]
}
# Internal helper: refuses a `[[` index on a bare classed pointer that is
# neither one field name nor one position (`x[[1:2]]`, `x[[list(1)]]`, and
# under strict lookup `x[[TRUE]]`, `x[[NA]]` or `x[[1.5]]` too), where R's
# `[[.default` would report itself. The type's own classes (`class`) go in
# front of R's `notSubsettableError`; the call is the generic's, `x[[1:2]]`,
# resolved from the method's frame (`env`). `cls` is the R class.
.miniextendr_field_index_error <- function(cls, env, class = NULL, strict = FALSE) {
stop(errorCondition(sprintf("`[[` on a `%s` object takes one field name or one %sposition", cls, if (strict) "whole-number " else ""), class = c(class, "notSubsettableError"), call = .miniextendr_frame_call(env)))
}
"#;Expand description
R source of the .miniextendr_field_at helper, with its comment block,
as written into the wrappers preamble by write_r_wrappers_to_file: the
field a position picks in the generated [[.Class of an S3 class with
s3(r_data_accessors), on the bare classed pointer (#1891). The method
checks for NA first (a list’s [[NA]] is NULL, a character vector’s
is NA). A position is truncated and a logical is taken, as by a list’s
[[; every position that picks no field (past the last one, 0, a
negative one) raises subscriptOutOfBoundsError with the type’s
field-error classes in front (class, the derive’s
.rdata_error_class_<Type>, #1899), on the generic’s call. Also
.miniextendr_field_index_error, the same method’s refusal of an index
that is neither one name nor one position (#1920), and under
lookup = "strict" of a non-whole number, a logical or NA (#1921).