Skip to main content

Module altrep_impl

Module altrep_impl 

Source
Expand description

ALTREP implementation utilities.

This module provides helper functions used by the declarative macros generated for ALTREP classes. The proc-macro derives (#[derive(AltrepInteger)] etc.) lower to invocations of impl_alt*_from_data! macros which expand to code that references items in this module via $crate::altrep_impl::* paths.

Use crate::altrep_data1_as (re-exported from externalptr) to extract data from an ALTREP’s data1 slot.

§Layout

  • macros — #[macro_export] declarative macros (impl_alt*_from_data! and their __impl_* helpers).
  • builtins — crate-private meta-macro + invocations for Vec<T> / Box<[T]> / Cow<T> / Range<T> ALTREP families.
  • arrays — const-generic [T; N] ALTREP impls.
  • static_slices — hand-written &'static [T] ALTREP impls.

Modules§

arrays
ALTREP for owned const-generic arrays.
buffers
Registered native buffers with value duplication and retained allocations.
builtins
Built-in ALTREP class instantiations for Vec<T>, Box<[T]>, Cow<T>, and Range<T>.
macros
Declarative macros generating ALTREP trait implementations.
shared_slices
Shared slice owners with coordinated COW and duplicate policies.
static_slices
ALTREP impls for &'static [T].

Functions§

altlist_set_elt 👻 ⚠
Set_elt for bridge-generated list ALTREPs; R’s default raises an error.
altrep_region_buf⚠
Create a mutable slice from an ALTREP get_region output buffer pointer.
altstring_cache 🔒 ⚠
Return a bridge string ALTREP’s data2 element cache, allocating it on first use.
altstring_cache_written 🔒 ⚠
Whether R has stored a value into a string ALTREP’s cache.
altstring_cached_elt 🔒 ⚠
Read cache slot i, computing it from the Rust data on first use.
altstring_dataptr 👻 ⚠
Dataptr for bridge-generated string ALTREPs: fill every cache slot and return the cache’s pointer. A writable request marks the cache written first (see altstring_cache_written), since R writes through it.
altstring_elt 👻 ⚠
Elt for bridge-generated string ALTREPs: each element is computed once.
altstring_set_elt 👻 ⚠
Set_elt for bridge-generated string ALTREPs; R’s default raises an error.
checked_mkchar⚠
Create a CHARSXP from a Rust string, with checked length conversion.
duplicate_altrep_data2 👻 ⚠
Copy a bridge ALTREP’s data2 for a Duplicate callback.
duplicate_altrep_owner 👻 ⚠
Clone a derive-generated ALTREP owner while preserving its current R cache. R’s default DuplicateEX copies attributes and object flags after this hook.
mark_altstring_written 🔒 ⚠
Mark a string ALTREP’s cache written; see altstring_cache_written.
new_altstring_cache 🔒 ⚠
Allocate a string cache of length n with every slot empty (C NULL).