Skip to main content

Module wasm_registry_writer

Module wasm_registry_writer 

Source
Expand description

Host-time generator of wasm_registry.rs — the WASM-side replacement for linkme. See the module for full rationale.

Host-only — the writer reads the live linkme distributed slices to format wasm_registry.rs, and linkme isn’t available on wasm32 anyway. Host-time generator of wasm_registry.rs — the WASM-side replacement for linkme’s runtime distributed-slice gather.

On native builds, the cdylib runs [write_wasm_registry_to_file] to emit Rust source listing every MX_CALL_DEFS / MX_ALTREP_REGISTRATIONS / MX_TRAIT_DISPATCH entry as extern "C" {} declarations + ordinary &[T] static slices. On wasm32-* targets, the user crate compiles that file in place of the linkme distributed_slices (gating happens in step 5 of plans/webr-support.md).

The writer is intentionally pure-text-formatting — no syn, no proc-macro2, no template engine. Output is small, append-only, and deterministic so git diff --exit-code works as the regen check.

Structs§

AltrepRegRow
Pre-extracted view of one MX_ALTREP_REGISTRATIONS entry.
CallDefRow
Pre-extracted, cdylib-side view of one R_CallMethodDef.
TraitDispatchRow
Pre-extracted view of one MX_TRAIT_DISPATCH entry.

Constants§

GENERATOR_VERSION 🔒

Functions§

fnv1a_64 🔒
FNV-1a 64-bit hash. Matches the implementation in miniextendr-macros/src/miniextendr_impl_trait.rs::type_to_uppercase_name so a future build.rs check can recompute it portably.
format_altrep_regs_slice 🔒
format_body 🔒
format_call_defs_slice 🔒
format_extern_c_block 🔒
format_extern_unwind_block 🔒
format_trait_dispatch_slice 🔒
format_wasm_registry
Format a wasm_registry.rs source file from extracted runtime data.
read_runtime_slices 🔒
Read the live linkme distributed slices and return rows safe to pass to format_wasm_registry.
sexp_param_list 🔒
Comma-joined _: SEXP parameter list for an extern { fn ...; } decl.
sexp_type_list 🔒
Comma-joined SEXP type list for an extern fn(...) type expression (e.g. inside transmute::<...>). Function pointer types don’t carry parameter names, so _: would be invalid here.
write_wasm_registry_to_file
Read the live distributed slices, format wasm_registry.rs, and write it to path. No-op when content is unchanged (matches write_r_wrappers_to_file).