Skip to main content

Module utils

Module utils 

Source
Expand description

Shared text helpers for the generators: C symbol naming, the standard generated-file prelude/trailer, and cross-module type-name resolution.

These are the small string-building routines every backend reaches for when stamping the “generated by WeaveFFI” banner onto a file or turning a qualified module.Type reference into its flattened C symbol. Centralizing them keeps the banner, the symbol-prefixing rule, and the dotted-path flattening identical across all of the language generators.

Enums§

CommentStyle
Comment syntax used to emit the standard prelude/trailer in generated files.

Constants§

ABI_RUNTIME_SYMBOLS
Runtime symbols (functions and types) that consumer code links against from the weaveffi-abi runtime: the weaveffi_error/weaveffi_handle_t/ weaveffi_cancel_token types and every #[no_mangle] entry point that weaveffi_abi::export_runtime! emits into the consumer cdylib.

Functions§

c_abi_struct_name
Build the C ABI struct name, resolving cross-module qualified references.
c_symbol_name
Build the C symbol name for a function: <prefix>_<module>_<func>.
local_type_name
Extract the local type name from a potentially qualified module.TypeName.
render_abi_prefix_aliases
Render a #define {prefix}_{name} weaveffi_{name} block for runtime ABI symbols. Returns an empty string when prefix == "weaveffi".
render_json_prelude
Renders the JSON-friendly prelude as "//" key/value pairs (recognised by npm). Each line is two-space-indented and comma-terminated so it can be embedded at the top of any JSON object literal that opens with { on the previous line.
render_prelude
Renders the standard Generated by WeaveFFI {VERSION} from {input} prelude followed by the DO NOT EDIT warning and a regenerate command. Trailing blank line included so generators can append their content directly.
render_trailer
Renders the closing END {filename} marker. Caller is responsible for any preceding newline; the returned string ends with \n.
wrapper_name
Build the wrapper function name exposed to the foreign language.