wolfram-export
Unified #[export] runtime for Wolfram LibraryLink functions. Choose the
calling convention you need via Cargo features.
Calling conventions (features)
| Feature | Attribute | Transport |
|---|---|---|
native (default) |
#[export] |
Raw MArgument C ABI, marshaled via FromArg/IntoArg |
native (default) |
#[export(margs)] |
Same raw MArgument C ABI, marshaled by hand |
wstp |
#[export(wstp)] |
WSTP Link |
wxf |
#[export(wxf)] |
Typed WXF ByteArray |
[]
= { = "0.6", = ["wstp"] }
use export;
For full manual control over marshaling, use #[export(margs)] with an
args = (..)/ret = .. signature annotation (spliced into wolfram_expr::expr!
calls, so wolfram-expr must be a direct dependency to use them):
use ;
use FromArg;
Omitting args/ret still compiles, but defaults the generated
LibraryFunctionLoad type spec to LinkObject/LinkObject (which a raw
MArgument function doesn't actually accept) and emits a compile-time warning
telling you to annotate it.
#[export(margs)] is also how you reach types with no FromArg/IntoArg
impl, like SparseArray — read/write the raw MArgument.sparse
(MSparseArray) pointer and drive the WolframSparseLibrary_Functions C API
(exposed as rtl::MSparseArray_*/rtl::MTensor_* in wolfram-library-link)
directly. See margs_sparse_array_merge in
wolfram-examples-internal/src/margs.rs
for a worked example.
The automate-function-loading-boilerplate feature (on by default) emits the
__wolfram_manifest__ C-ABI symbol that lets the paclet loader discover all
exported functions automatically.
Changelog
See docs/CHANGELOG.md.