Expand description
Automatic registration for miniextendr.
Every #[miniextendr] item self-registers at link time. package_init()
(generated by miniextendr_init!) calls miniextendr_register_routines
during R_init_* to finalize registration with R. Users never interact
with this module.
Re-exports§
pub use _linkme_macro_MX_CALL_DEFS as MX_CALL_DEFS;👻pub use _linkme_macro_MX_R_WRAPPERS as MX_R_WRAPPERS;👻pub use _linkme_macro_MX_ALTREP_REGISTRATIONS as MX_ALTREP_REGISTRATIONS;👻pub use _linkme_macro_MX_TRAIT_DISPATCH as MX_TRAIT_DISPATCH;👻pub use _linkme_macro_MX_MATCH_ARG_CHOICES as MX_MATCH_ARG_CHOICES;👻pub use _linkme_macro_MX_MATCH_ARG_PARAM_DOCS as MX_MATCH_ARG_PARAM_DOCS;👻pub use _linkme_macro_MX_CLASS_NAMES as MX_CLASS_NAMES;👻pub use _linkme_macro_MX_CLASS_BLOCKS as MX_CLASS_BLOCKS;👻pub use _linkme_macro_MX_S7_SIDECAR_PROPS as MX_S7_SIDECAR_PROPS;👻pub use _linkme_macro_MX_SIDECAR_ACCESSORS as MX_SIDECAR_ACCESSORS;👻pub use _linkme_macro_MX_ALL_EQUAL as MX_ALL_EQUAL;👻pub use _linkme_macro_MX_REEXPORTS as MX_REEXPORTS;👻pub use _linkme_macro_MX_CONVERSION_ERROR_CLASS as MX_CONVERSION_ERROR_CLASS;👻
Macros§
- frame_
call_ 🔒helper_ fn - R source of
.miniextendr_frame_callas a barefunction(env)expression: the call a generated S3 method’s conditions report, resolved from the method’s frame (#1851). - raise_
condition_ 🔒helper_ fn - One condition-transport body for the package and standalone Rust helpers. The resolver is a package binding or a self-contained function expression.
Structs§
- AllEqual
Entry - The
all.equal()method#[derive(AllEqual)]generates for a type (#2149), without the parts that depend on the type’s R class: its name, its title and its registration, whichcollect_r_wrappersadds. - Altrep
Registration - ALTREP class registration entry: fn pointer +
#[no_mangle]symbol name. - Class
Block Entry - One
#[miniextendr]impl block’s share of its Rust type’s R class (#1776). - Class
Name Entry - Entry mapping a Rust type name to its R-visible class name and class system.
- Conversion
Error Class Entry - The package crate’s
conversion_error_class, registered byminiextendr_init!in [MX_CONVERSION_ERROR_CLASS]. - DocTag 🔒
- One roxygen tag of a class’s docs: its
#'lines, the first opening the tag (#' @name ...), or the lines before the first tag.defaultmarks a generated line (CLASS_DEFAULT_PREFIX, stripped fromlines). - Match
ArgChoices Entry - Entry for replacing match_arg placeholder defaults with actual choices.
- Match
ArgParam DocEntry - Entry for replacing match_arg
@paramdoc placeholders with human-readable choice descriptions. - RWrapper
Entry - R wrapper code with priority for ordering.
- Reexport
Entry - One
pkg::nameitem of areexport!invocation (#1910):name, an export of the R packagepackage, which this package exports too. The macro has checked both names. - Sidecar
Accessors Entry - The standalone R accessors
#[derive(ExternalPtr)]generates for a type’s public#[r_data]fields,Type_get_f(x)/Type_set_f(x, value), in two renderings: exported on a “Type Sidecar Accessors” page, or internal (@noRd, no export).collect_r_wrapperswrites the internal one for a type whose class has field syntax (ClassNameEntry::field_syntax): the class’s$/[[are its R interface to the fields there, and the setters would write in place through every copy (#1900). The internal rendering also carries the field helpers that those methods call. Written with the sidecar fragments. - Sidecar
Prop Entry - Entry documenting a sidecar (
#[r_data]) property on an S7 ExternalPtr type. - Standalone
Fragment 🔒 - A standalone function’s wrapper fragment and the stem of its source file
(
Noneforlib.rs/mod.rs, seesource_file_stem). - Standalone
Page 🔒 - Where a standalone function’s block lands, read from its own tags.
- Trait
Dispatch Entry - Trait dispatch entry mapping (concrete_tag, trait_tag) → vtable.
- Wrapper
Fragment 🔒 - A wrapper fragment to write: an
RWrapperEntry’s text, or a fragment assembled at write time (a class merged from its impl blocks, a type’s sidecar accessors). - Wrapper
Name 🔒 - A name the assembled wrappers bind at top level or export, and the
fragment that does, as the
# Generated from Rust …header opening each fragment names it.
Enums§
- RWrapper
Priority - Ordering priority for R wrapper code fragments.
Constants§
- ARG_
CHECK_ 👻HELPERS - R source blocks for the argument-check helpers of the wrappers preamble,
.miniextendr_arg_error,.miniextendr_match_arg_severaland.miniextendr_match_arg, with their comment blocks, as written bywrite_r_wrappers_to_file(they read.miniextendr_conversion_error_class, bound after them, and.miniextendr_frame_call, bound before). Each block is emitted only when needed; this ordered array lets the equivalence tests evaluate the same source as the wrapper writer. - ARG_
ERROR_ 🔒HELPER - CALLER_
CALL_ 🔒HELPER - R source of the
.miniextendr_caller_callhelper, with its comment block, as written into the wrappers preamble bywrite_r_wrappers_to_file: the call acall = callerwrapper reports (#1450, #1548, #1552), including the frame or call a hand-written helper passed as the wrapper’s.callformal (#1613), and the frame or call acall_argwrapper was passed (own = TRUE, #1834). - CLASS_
DEFAULT_ PREFIX - Opens a generated line of a class’s roxygen block, in
ClassBlockEntry::headorClassBlockEntry::class_doc_lines, that a doc tag on another impl block of the type replaces:@title,@name,@rdname,@export, a constructor’s@paramor an R6@field. The writer drops the line when another block’sclass_docshave the tag (for@paramand@field, for the same name), and otherwise writes it without the prefix. Spelled the same asminiextendr_macros’sCLASS_DEFAULT_PREFIX. - CLASS_
DOCS_ MARKER - The line of
ClassBlockEntry::headwhere the class’s roxygen block takes theClassBlockEntry::class_docsof every impl block of the type, the defining block’s first. Spelled the same asminiextendr_macros’sCLASS_DOCS_MARKER. - CLASS_
DOCS_ ONLY_ MARKER - Opens a class’s roxygen block, in
ClassBlockEntry::head, that only carries the impl docs: the block of an S3 or vctrs class without a constructor that the package names and builds itself (class = "..."). The writer writes the block, up to its closingNULL, only when the type’sclass_docsorclass_doc_linessay something beyond the page and export tags, so a readers-only impl adds no page (#1918). Spelled the same asminiextendr_macros’sCLASS_DOCS_ONLY_MARKER. - CLASS_
DOC_ LINES_ MARKER - The line of
ClassBlockEntry::headwhere the class’s roxygen block takes theClassBlockEntry::class_doc_linesof every impl block of the type. Spelled the same asminiextendr_macros’sCLASS_DOC_LINES_MARKER. - CLASS_
MEMBER_ DEFAULT_ PREFIX - Generated member page/parameter/prose defaults. The class assembler resolves
these against the defining impl’s topic, preserving explicit member tags.
Spelled the same as the proc-macro’s
CLASS_MEMBER_DEFAULT_PREFIX. - DOTS_
CHECK_ 🔒HELPER - The check of
#[miniextendr(dots = empty | empty(allow = ..) | forward(allow = ..))](#2157): a wrapper with such an attribute calls it asif (...length()) .miniextendr_check_dots(...names(), ...length(), <formals>, allow = .., forward = TRUE, class = .., call = ..), the statementminiextendr-macros’dots_policy::DotsPolicy::r_checkwrites (forward = TRUEforforwardonly). The[[,as.list()and[[<-field methods ofs3(r_data_accessors)and an env class’s[[make theemptycheck on a bare pointer (#2174). It builds its own condition, an argument error with two more fields, and depends only on the helpers every preamble has. - ENV_
METHOD_ 🔒HELPER - Shared method lookup for environment classes. Each returned closure gets its own receiver-binding frame. An inherent method keeps its original enclosure behind that frame, so native symbols and author-supplied R code never resolve through the lookup helper’s locals (#1677). Field lookup and its condition call stay in the S3 method. Flat trait lookup must find a unique method; inherent methods and explicit trait namespaces take priority.
- FIELD_
AT_ 🔒HELPER - R source of the
.miniextendr_field_athelper, with its comment block, as written into the wrappers preamble bywrite_r_wrappers_to_file: the field a position picks in the generated[[.Classof an S3 class withs3(r_data_accessors), on the bare classed pointer (#1891). The method checks forNAfirst (a list’s[[NA]]isNULL, a character vector’s isNA). 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) raisessubscriptOutOfBoundsErrorwith 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 underlookup = "strict"of a non-whole number, a logical orNA(#1921). - FRAME_
CALL_ 🔒HELPER - The preamble’s
.miniextendr_frame_callbinding offrame_call_helper_fn!, with its comment block, as written bywrite_r_wrappers_to_file. - MATCH_
ARG_ 🔒HELPER - MATCH_
ARG_ 🔒SEVERAL_ HELPER - ORDER_
AFTER_ 🔒TOPIC_ BLOCKS - The
@orderline for a block on an author topic. Spelled the same asminiextendr_macros::roxygen::ORDER_AFTER_TOPIC_BLOCKS, which documents whyNaNsorts the block after the topic’s own block. - PARAM_
FILLER_ 🔒MARKER - Prefix of a generated
@paramline in a standalone function’s fragment, after the#'roxygen lead. Spelled the same asminiextendr_macros::roxygen::PARAM_FILLER_MARKER, which emits it. - RAISE_
CONDITION_ 🔒HELPER_ FN - R source of the
.miniextendr_raise_conditionhelper as a barefunction(.val, .call_default)expression. - WRAPPERS_
FILE_ 🔒MARKER - Returns
truewhenaandbare equal after normalising away(<file>.rs:LINE:COL)positional suffixes in source-attribution comments. - WRAPPERS_
PREAMBLE_ 🔒HEADER - The comment block that opens the wrappers preamble, ahead of the
.miniextendr_raise_conditionbinding, as written bywrite_r_wrappers_to_file. - WRAPPER_
RAISE_ 🔒CONDITION_ HELPER_ FN - The package preamble already binds the resolver; reuse it there.
Statics§
- MX_
ALL_ EQUAL - The
all.equal()methods#[derive(AllEqual)]generates (#2149). Host-only.collect_r_wrappersnames and registers each for the type’s R class, which the type’s impl block gives in itsClassNameEntry: the derive sits on the struct, a separate expansion. - MX_
ALTREP_ REGISTRATIONS - ALTREP class registration entries, called once at package init.
- MX_
CALL_ DEFS - R
.Callmethod registrations (function + method C wrappers). - MX_
CLASS_ BLOCKS - The R class parts of every
#[miniextendr(env|r6|s3|s4|s7|vctrs)]impl block. Host-only. - MX_
CLASS_ NAMES - Class name entries mapping Rust type names to R-visible class names. Host-only.
- MX_
CONVERSION_ ERROR_ CLASS - The package crate’s
conversion_error_class. Host-only. - MX_
MATCH_ ARG_ CHOICES - Match-arg choices entries for R wrapper post-processing. Host-only.
- MX_
MATCH_ ARG_ PARAM_ DOCS - Match-arg
@paramdoc entries for R wrapper post-processing. Host-only. - MX_
REEXPORTS - The
pkg::nameitems of everyreexport!(#1910). Host-only.collect_r_wrapperswrites roxygen2’s re-export block for eachpkg::nameonce, however many items name it, andwrite_r_wrappers_to_filerefuses a name re-exported from two packages or bound by the package’s own wrappers (reexport_conflicts). - MX_
R_ WRAPPERS - R wrapper code fragments with priority for ordering. Host-only.
- MX_
S7_ SIDECAR_ PROPS - S7 sidecar property documentation entries. Host-only.
- MX_
SIDECAR_ ACCESSORS - The standalone sidecar accessors of each
#[derive(ExternalPtr)]type with public#[r_data]fields. Host-only.collect_r_wrapperswrites each as exported or internal, from the type’sClassNameEntry::field_syntax(#1900). - MX_
TRAIT_ DISPATCH - Trait dispatch entries for
universal_query.
Traits§
- Class
Constructor 👻 - Implemented by
#[miniextendr]for each type with an impl block that declares its class constructor (#[miniextendr(<system>(constructor))], or a receiver-lessnewreturningSelf).Blockis a type private to that impl block, so two such blocks don’t conflict here; the wrapper writer refuses them (merge_class_blocks).
Functions§
- all_
equal_ 🔒fragments - The
all.equal()methods of#[derive(AllEqual)]as fragments (#2149): each namedall.equal.<Class>for the R class of the type’sClassNameEntry, on its own page, and registered withS3method(all.equal, <Class>), which an env, R6, S3 or S4 object dispatches on (S4 through R’s S3 dispatch on the S4 class, which also reaches callers ofbase::all.equal()such as testthat, where an S4 method would not). An S7 object’s class attribute ispkg::Class, so an S7 class also registers the method withS7::method(all.equal, Class), followed by the unbinding every such replacement call on a base generic needs (seeminiextendr_macros’ss7_base_operator_unbind). - all_
equal_ 🔒method - The text of one
#[derive(AllEqual)]method: seeall_equal_fragments. - altrep_
regs 🔒 - append_
used_ 🔒wrapper_ helpers - Emit an optional preamble helper only when a collected fragment names it.
- block_
docs 🔒 - Every block’s
class_docsas tags, the defining block’s first, then the others’ in source order. - build_
class_ 🔒name_ index - Build the
rust_type → ClassNameEntrylookup used by every placeholder resolver inwrite_r_wrappers_to_file. - call_
defs 🔒 - Native: read directly from the linkme distributed slice.
wasm32: read from a
OnceLockpopulated byinstall_wasm_runtime_slices. - class_
block_ 🔒name - How a merge error names an impl block:
`impl Counter` (lib.rs:12). - class_
doc_ 🔒conflicts - The problems the doc comments of a type’s impl blocks make for its merged
roxygen block (#1776): every block’s doc tags are written, so two
different
@titles give the class two titles (roxygen2 silently keeps the first), and a@nameor@rdnameother than the defining block’s would move the class block to a page the defining block’s generated documentation was not written for. - class_
part 🔒 - A
ClassBlockEntrypart without the newline its raw string literal adds at each end. - collect_
r_ wrappers - Collect all R wrapper entries, sorted and deduplicated.
- conversion_
error_ 🔒class - The package crate’s
conversion_error_class(empty when it sets none). - conversion_
error_ 🔒class_ binding - The
.miniextendr_conversion_error_classbinding that closes the wrappers preamble: the classes.miniextendr_arg_errorputs on every R-side argument error, from the [MX_CONVERSION_ERROR_CLASS] entry thatminiextendr_init!registers for the package crate (#1591). - detect_
duplicate_ 🔒wrapper_ defs - Detect conflicting top-level function and class/namespace definitions in the assembled R wrapper text.
- find_
substr 🔒 - Find the first occurrence of
needleinhaystack[from..]. Returns the absolute index inhaystack, orNone. - format_
conversion_ 🔒error_ class_ binding conversion_error_class_bindingfor an explicit class list.- has_
no_ 🔒rd_ tag - Check if an R wrapper fragment has
@noRd. - has_
page_ 🔒assignment_ tag - Check if an R wrapper fragment already assigns itself to a documentation
page:
@rdname <topic>,@describeIn <topic> <desc>, or@name <topic>. - insert_
roxygen_ 🔒line - Insert a roxygen line into a fragment at a tag boundary: before the first
@export/@keywords/@sourceline, else after the last roxygen line. - is_
syntactic_ 🔒r_ name - Whether
nameis a syntactic R name (letters, digits,.and_; starts with a letter or a.not followed by a digit; not a reserved word). - match_
arg_ 👻aliases_ arg - The trailing arguments a
match_argparameter’s check passes to.miniextendr_match_arg/.miniextendr_match_arg_severalfor the type’sMatchArg::ALIASES(#1843), which the wrappers writer splices in place of, <placeholder>:, aliases = base::c("grey" = "gray"), each alias and choice escaped for an R string literal. For a type without aliases it is empty, so that wrapper keeps the text it had before aliases existed.base::cis spelled out because the argument is written after the shadowing pass, which would otherwise qualify it for a parameter namedc. - match_
arg_ 👻formal - The R formal of a
match_argparameter,c("a", "b"), that the wrappers writer splices in place of its placeholder:choices(the type’sMatchArg::CHOICES), each quoted and escaped for an R string literal (escape_r_string). - memchr 🔒
- Find the first byte equal to
needleinhaystack[from..]. Returns the absolute index, orNone. - merge_
class_ 🔒blocks - Merge the impl blocks of each Rust type into one class fragment (#1776).
- merged_
class_ 🔒content - The text of a type’s merged class: see
merge_class_blocks. - miniextendr_
register_ ⚠routines - Register all
#[miniextendr]routines and ALTREP classes with R. - miniextendr_
write_ ⚠wasm_ registry - C-callable entry point for
wasm_registry.rsgeneration. - miniextendr_
write_ ⚠wrappers - C-callable entry point for R wrapper generation.
- normalize_
source_ 🔒locs - Replace every
(<stem>.rs:LINE:COL)occurrence with(<stem>.rs:_:_). - parse_
generic_ 🔒doc_ marker - Parse the payload of a
.__MX_GENERIC_DOC__(...)marker line. - parse_
guarded_ 🔒generic - Recognize the generic guards emitted by
r_class_formatterand the S4/S7 inherent/trait generators. This is a scan of generated forms, not an R parser: the guard must start at column zero and its first statement must create a generic. Never scan arbitrary indented assignments inside function bodies. Documentation markers cannot stand in for this:noexport/@noRdclasses and trait implementations still declare generics without generic-doc markers. - parse_
inherited_ 🔒param_ marker - Parse a
.__MX_INHERITED_PARAM__(...)marker line. - parse_
top_ 🔒level_ assignment - Parse a bare top-level assignment, returning its name and trimmed RHS.
- parse_
top_ 🔒level_ fn_ def_ name - Parse a top-level
name <- function(...)definition. Used both by the duplicate scan and by standalone-function documentation grouping. - r_
namespace_ 🔒name - The argument of a raw
export(...)NAMESPACE directive: bare for a syntactic name, a double-quoted string for an operator such as[[(export([[)does not parse). Must matchr_namespace_nameinminiextendr-macros’namingmodule, which writes the method blocks’ directive for the same generic; roxygen2 only merges identical lines. - raw_
namespace_ 🔒exports - The names the
export(...)directives of an@rawNamespacetag’s text export:export(a, "[[")givesaand[[.exportPattern(...),exportClasses(...)and the like are notexport(. - reexport_
conflicts 🔒 - Refuse the re-exports of
entriesthat can’t be written, all in one message: a name re-exported from two packages (a package exports one object under a name), and a name thatcontent, the assembled wrappers, also binds at top level or exports. The package’s own binding would hide the imported one inside its namespace, soexport(name)would export it instead; an export alone repeats the one the re-export writes. - reexport_
fragment 🔒 - The re-exports of every
reexport!as one fragment,Nonewithout any: for eachpkg::name, roxygen2’s re-export block - reexport_
sites 🔒 - The sites of
entries,(file.rs:line:column)each, in source order. - require_
class_ 👻constructor - Compiles only when
Thas an impl block that declares its class constructor (ClassConstructor). Never called. - resolve_
class_ 🔒constructor - Decide a type’s class constructor across its impl blocks: the blocks to merge, each in the rendering that agrees with the decision.
- resolve_
class_ 🔒member_ docs - Resolve each member’s generated page after the defining impl is known.
A default page follows that impl’s
@rdname; explicit member pages do not. On an inherited author topic, its block supplies the title and parameter docs, so generated prose/parameters are removed and the member sorts last. - resolve_
generic_ 🔒doc_ markers - Scan
contentfor.__MX_GENERIC_DOC__(...)marker lines, group by generic name, replace the first marker per generic with a synthesised standalone doc block, and delete all remaining markers. - resolve_
inherited_ 🔒param_ markers - Resolve
.__MX_INHERITED_PARAM__(...)markers. - resolve_
list_ 🔒return_ wrappers - Resolve list-shaped
.__MX_WRAP_LIST_RETURN_<RustName>__(<expr>)placeholders emitted forVec<Class>-returning class methods (#1284). - resolve_
scalar_ 🔒return_ wrappers - Resolve scalar
.__MX_WRAP_RETURN_<RustName>__(<expr>)placeholders emitted by class-method wrappers whose Rust return type may name a different ExternalPtr-backed class. - resolve_
standalone_ 🔒pages - Resolve the standalone functions’ fragments, in emission order (#1590):
- resolve_
wrap_ 🔒return_ markers - Scan
contentfor<prefix><RustName>__(<expr>)markers and replace each with whateveremitpushes for the resolved class entry (orNonewhenRustNameis not registered). - roxygen_
tag_ 🔒value - The value of a fragment’s first
#' @<tag> <value>line (its first word). - scan_
digits 🔒 - Advance past a run of ASCII digits starting at
haystack[from]. Returns the absolute index of the first non-digit byte, orNoneif there are no digits atfrom(empty run is not valid). - sidecar_
accessor_ 🔒fragments - The standalone sidecar accessors as sidecar fragments: each type’s internal rendering when one of its impl blocks gives its class field syntax, else the exported one (#1900).
- sidecar_
accessor_ 🔒names - Compute the sidecar accessor function names a
#[derive(ExternalPtr)]emits for each#[r_data]field, resolving the R-visible prefix through the class-name registry. - sort_
s7_ 🔒classes - Sort S7 class definitions so parents come before children.
- sort_
wrapper_ 🔒entries - Order wrapper entries for emission: by priority (the load-order dependencies between sidecar accessors, classes, functions, trait impls and vctrs methods), then by source file, then by the line the item starts on.
- source_
file_ 🔒stem - The stem of a standalone function’s source file: the topic an explicit
@rdnamenames to group the file’s functions on one page (seeStandaloneFragment).Noneforlib.rs/mod.rs, whose stems name no page of their own. - splice_
match_ 🔒arg_ entry contentwith onematch_argparameter’s placeholders resolved from itsMatchArgChoicesEntry: every choices placeholder (the formal and the check) bymatch_arg_formal, and the check’s, <aliases placeholder>bymatch_arg_aliases_arg, which is empty for a type without aliases.- standalone_
page 🔒 - synthesise_
generic_ 🔒doc_ block - Synthesise a standalone roxygen doc block for a generic.
- trait_
dispatch 🔒 - universal_
query ⚠ - Universal query function for trait dispatch.
- unquote_
r_ 🔒name namewithout the double quotes, single quotes or backticks around it.- wrapper_
names 🔒 - The names of the assembled wrappers
contentin file order: seeWrapperName. Read bydetect_duplicate_wrapper_defsandreexport_conflicts. - wrappers_
file_ 🔒content - The complete wrappers file for a finished
body: the marker line, a line naming theminiextendr-apiversion that generated it and an FNV-1a 64 digest of the body, then the body (#1552). - wrappers_
semantically_ 🔒equal - A match requires
(+ one or more non-()/non-newline chars +.rs:+ ASCII digits +:+ ASCII digits +). Malformed or non-.rspatterns are left untouched. - write_
r_ wrappers_ to_ file - Write all R wrapper entries to a file.