Skip to main content

cached_strsxp

Macro cached_strsxp 

Source
macro_rules! cached_strsxp {
    ($(#[$meta:meta])* $vis:vis fn $name:ident() = [$($cstr:expr),+ $(,)?]) => { ... };
}
Expand description

Cache a STRSXP vector built from permanent CHARSXPs.

Each element is a &CStr literal routed through Rf_install + PRINTNAME for a never-GC’d CHARSXP. The STRSXP itself is kept alive via R_PreserveObject.

// Single-element class:
cached_strsxp!(pub(crate) fn date_class_sexp() = [c"Date"]);

// Multi-element class:
cached_strsxp!(pub(crate) fn posixct_class_sexp() = [c"POSIXct", c"POSIXt"]);

// With feature gate:
cached_strsxp!(
    #[cfg(any(feature = "time", feature = "arrow"))]
    pub(crate) fn posixct_class_sexp() = [c"POSIXct", c"POSIXt"]
);