Expand description
Cached R class attribute SEXPs.
Frequently-used class vectors (like c("POSIXct", "POSIXt")) and attribute
values are allocated once and preserved permanently. This avoids repeated
Rf_mkCharLenCE hash lookups on hot paths.
Two declarative macros handle the boilerplate:
β
// Cache a symbol (Rf_install result):
cached_symbol!(pub(crate) fn tzone_symbol() = c"tzone");
// Cache a STRSXP vector (class, names, etc.):
cached_strsxp!(pub(crate) fn posixct_class_sexp() = [c"POSIXct", c"POSIXt"]);
cached_strsxp!(pub(crate) fn date_class_sexp() = [c"Date"]);Both expand to a function with a static OnceLock<SEXP> inside.
First call initializes; subsequent calls are a single atomic load.
CHARSXPs are obtained via Rf_install + PRINTNAME β symbols are never
collected, so the CHARSXP is permanently valid. STRSXP vectors are kept
alive via R_PreserveObject.
MacrosΒ§
- cached_
strsxp π - Cache a STRSXP vector built from permanent CHARSXPs.
- cached_
symbol π - Cache an
Rf_installsymbol result.
FunctionsΒ§
- altstring_
written_ πsymbol - Cached
miniextendr_writtensymbol: the attribute a string ALTREPβs data2 cache carries once R has stored a value into it. - condition_
names_ πsexp - Cached
c("error", "kind", "class", "call", "data")names STRSXP for condition values. - data_
frame_ πclass_ sexp - Cached
"data.frame"class STRSXP. - permanent_
charsxp ππ» - Get a permanent CHARSXP for a string by going through
Rf_install+PRINTNAME. - rust_
condition_ πattr_ symbol - Cached
__rust_condition__symbol β the marker attribute on tagged panic-transport SEXPs. Wrapper code asserts this isTRUEin addition to the class check before re-raising via.miniextendr_raise_condition. - rust_
condition_ πclass_ sexp - Cached
"rust_condition_value"class STRSXP β applied to every tagged SEXP produced bymake_rust_condition_valueto identify panic-transport values to the generated R wrappers.