Skip to main content

Module registry

Module registry 

Source
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_call as a bare function(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§

AllEqualEntry
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, which collect_r_wrappers adds.
AltrepRegistration
ALTREP class registration entry: fn pointer + #[no_mangle] symbol name.
ClassBlockEntry
One #[miniextendr] impl block’s share of its Rust type’s R class (#1776).
ClassNameEntry
Entry mapping a Rust type name to its R-visible class name and class system.
ConversionErrorClassEntry
The package crate’s conversion_error_class, registered by miniextendr_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. default marks a generated line (CLASS_DEFAULT_PREFIX, stripped from lines).
MatchArgChoicesEntry
Entry for replacing match_arg placeholder defaults with actual choices.
MatchArgParamDocEntry
Entry for replacing match_arg @param doc placeholders with human-readable choice descriptions.
RWrapperEntry
R wrapper code with priority for ordering.
ReexportEntry
One pkg::name item of a reexport! invocation (#1910): name, an export of the R package package, which this package exports too. The macro has checked both names.
SidecarAccessorsEntry
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_wrappers writes 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.
SidecarPropEntry
Entry documenting a sidecar (#[r_data]) property on an S7 ExternalPtr type.
StandaloneFragment 🔒
A standalone function’s wrapper fragment and the stem of its source file (None for lib.rs / mod.rs, see source_file_stem).
StandalonePage 🔒
Where a standalone function’s block lands, read from its own tags.
TraitDispatchEntry
Trait dispatch entry mapping (concrete_tag, trait_tag) → vtable.
WrapperFragment 🔒
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).
WrapperName 🔒
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§

RWrapperPriority
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_several and .miniextendr_match_arg, with their comment blocks, as written by write_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_call helper, with its comment block, as written into the wrappers preamble by write_r_wrappers_to_file: the call a call = caller wrapper reports (#1450, #1548, #1552), including the frame or call a hand-written helper passed as the wrapper’s .call formal (#1613), and the frame or call a call_arg wrapper was passed (own = TRUE, #1834).
CLASS_DEFAULT_PREFIX
Opens a generated line of a class’s roxygen block, in ClassBlockEntry::head or ClassBlockEntry::class_doc_lines, that a doc tag on another impl block of the type replaces: @title, @name, @rdname, @export, a constructor’s @param or an R6 @field. The writer drops the line when another block’s class_docs have the tag (for @param and @field, for the same name), and otherwise writes it without the prefix. Spelled the same as miniextendr_macros’s CLASS_DEFAULT_PREFIX.
CLASS_DOCS_MARKER
The line of ClassBlockEntry::head where the class’s roxygen block takes the ClassBlockEntry::class_docs of every impl block of the type, the defining block’s first. Spelled the same as miniextendr_macros’s CLASS_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 closing NULL, only when the type’s class_docs or class_doc_lines say something beyond the page and export tags, so a readers-only impl adds no page (#1918). Spelled the same as miniextendr_macros’s CLASS_DOCS_ONLY_MARKER.
CLASS_DOC_LINES_MARKER
The line of ClassBlockEntry::head where the class’s roxygen block takes the ClassBlockEntry::class_doc_lines of every impl block of the type. Spelled the same as miniextendr_macros’s CLASS_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 as if (...length()) .miniextendr_check_dots(...names(), ...length(), <formals>, allow = .., forward = TRUE, class = .., call = ..), the statement miniextendr-macros’ dots_policy::DotsPolicy::r_check writes (forward = TRUE for forward only). The [[, as.list() and [[<- field methods of s3(r_data_accessors) and an env class’s [[ make the empty check 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_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).
FRAME_CALL_HELPER 🔒
The preamble’s .miniextendr_frame_call binding of frame_call_helper_fn!, with its comment block, as written by write_r_wrappers_to_file.
MATCH_ARG_HELPER 🔒
MATCH_ARG_SEVERAL_HELPER 🔒
ORDER_AFTER_TOPIC_BLOCKS 🔒
The @order line for a block on an author topic. Spelled the same as miniextendr_macros::roxygen::ORDER_AFTER_TOPIC_BLOCKS, which documents why NaN sorts the block after the topic’s own block.
PARAM_FILLER_MARKER 🔒
Prefix of a generated @param line in a standalone function’s fragment, after the #' roxygen lead. Spelled the same as miniextendr_macros::roxygen::PARAM_FILLER_MARKER, which emits it.
RAISE_CONDITION_HELPER_FN 🔒
R source of the .miniextendr_raise_condition helper as a bare function(.val, .call_default) expression.
WRAPPERS_FILE_MARKER 🔒
Returns true when a and b are 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_condition binding, as written by write_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_wrappers names and registers each for the type’s R class, which the type’s impl block gives in its ClassNameEntry: 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 .Call method 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 @param doc entries for R wrapper post-processing. Host-only.
MX_REEXPORTS
The pkg::name items of every reexport! (#1910). Host-only. collect_r_wrappers writes roxygen2’s re-export block for each pkg::name once, however many items name it, and write_r_wrappers_to_file refuses 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_wrappers writes each as exported or internal, from the type’s ClassNameEntry::field_syntax (#1900).
MX_TRAIT_DISPATCH
Trait dispatch entries for universal_query.

Traits§

ClassConstructor 👻
Implemented by #[miniextendr] for each type with an impl block that declares its class constructor (#[miniextendr(<system>(constructor))], or a receiver-less new returning Self). Block is 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 named all.equal.<Class> for the R class of the type’s ClassNameEntry, on its own page, and registered with S3method(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 of base::all.equal() such as testthat, where an S4 method would not). An S7 object’s class attribute is pkg::Class, so an S7 class also registers the method with S7::method(all.equal, Class), followed by the unbinding every such replacement call on a base generic needs (see miniextendr_macros’s s7_base_operator_unbind).
all_equal_method 🔒
The text of one #[derive(AllEqual)] method: see all_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_docs as tags, the defining block’s first, then the others’ in source order.
build_class_name_index 🔒
Build the rust_type → ClassNameEntry lookup used by every placeholder resolver in write_r_wrappers_to_file.
call_defs 🔒
Native: read directly from the linkme distributed slice. wasm32: read from a OnceLock populated by install_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 @name or @rdname other 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 ClassBlockEntry part 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_class binding that closes the wrappers preamble: the classes .miniextendr_arg_error puts on every R-side argument error, from the [MX_CONVERSION_ERROR_CLASS] entry that miniextendr_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 needle in haystack[from..]. Returns the absolute index in haystack, or None.
format_conversion_error_class_binding 🔒
conversion_error_class_binding for 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 / @source line, else after the last roxygen line.
is_syntactic_r_name 🔒
Whether name is 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_arg parameter’s check passes to .miniextendr_match_arg / .miniextendr_match_arg_several for the type’s MatchArg::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::c is spelled out because the argument is written after the shadowing pass, which would otherwise qualify it for a parameter named c.
match_arg_formal 👻
The R formal of a match_arg parameter, c("a", "b"), that the wrappers writer splices in place of its placeholder: choices (the type’s MatchArg::CHOICES), each quoted and escaped for an R string literal (escape_r_string).
memchr 🔒
Find the first byte equal to needle in haystack[from..]. Returns the absolute index, or None.
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.rs generation.
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_formatter and 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 / @noRd classes 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 match r_namespace_name in miniextendr-macros’ naming module, 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 @rawNamespace tag’s text export: export(a, "[[") gives a and [[. exportPattern(...), exportClasses(...) and the like are not export(.
reexport_conflicts 🔒
Refuse the re-exports of entries that 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 that content, the assembled wrappers, also binds at top level or exports. The package’s own binding would hide the imported one inside its namespace, so export(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, None without any: for each pkg::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 T has 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 content for .__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 for Vec<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 content for <prefix><RustName>__(<expr>) markers and replace each with whatever emit pushes for the resolved class entry (or None when RustName is 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, or None if there are no digits at from (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 @rdname names to group the file’s functions on one page (see StandaloneFragment). None for lib.rs / mod.rs, whose stems name no page of their own.
splice_match_arg_entry 🔒
content with one match_arg parameter’s placeholders resolved from its MatchArgChoicesEntry: every choices placeholder (the formal and the check) by match_arg_formal, and the check’s , <aliases placeholder> by match_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 🔒
name without the double quotes, single quotes or backticks around it.
wrapper_names 🔒
The names of the assembled wrappers content in file order: see WrapperName. Read by detect_duplicate_wrapper_defs and reexport_conflicts.
wrappers_file_content 🔒
The complete wrappers file for a finished body: the marker line, a line naming the miniextendr-api version 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-.rs patterns are left untouched.
write_r_wrappers_to_file
Write all R wrapper entries to a file.