1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
//! Unified runtime for `#[export]`-marked Wolfram LibraryLink functions.
//!
//! Pick modes via Cargo features:
//!
//! ```toml
//! wolfram-export = { version = "0.5", features = ["wxf"] } # typed WXF
//! wolfram-export = { version = "0.5", features = ["wstp"] } # WSTP Link
//! wolfram-export = "0.5" # native + margs (default)
//! ```
//!
//! `#[export(margs)]` (raw `MArgument`, manual marshaling) rides on the
//! `native` feature — there's no separate feature flag for it.
//!
//! Then in your code (shown here with every mode enabled):
//!
//! ```
//! # // Compiled and tested only when all three feature-gated modes are enabled
//! # // (e.g. `cargo test --all-features`); a no-op otherwise.
//! # #[cfg(all(feature = "wstp", feature = "wxf"))]
//! # mod scope {
//! use wolfram_export::{export, sys::MArgument, wstp::Link};
//!
//! #[export] fn add(a: f64, b: f64) -> f64 { a + b }
//! #[export(margs)] fn raw_add(args: &[MArgument], ret: MArgument) {
//! unsafe { *ret.real = *args[0].real + *args[1].real; }
//! }
//! #[export(wstp)] fn echo(link: &mut Link) { let _ = link; }
//! #[export(wxf)] fn dot(a: Vec<f64>, b: Vec<f64>) -> f64 {
//! a.iter().zip(&b).map(|(x, y)| x * y).sum()
//! }
//! # }
//! ```
//!
//! Each mode's wire shape, runtime, and Cargo dep set live in its own
//! feature-gated submodule below. The `ExportEntry` inventory and the
//! `__wolfram_manifest__` C symbol are always on (they're tiny and how the
//! `cargo wl build` tool discovers exports).
//==============================================================================
// Always-on: shared inventory + manifest plumbing. The actual definitions live
// in the `wolfram-export-core` workspace-internal crate (so `wolfram-library-link`
// can depend on them without creating a cycle through `wolfram-export`).
//==============================================================================
pub use ExportEntry;
pub use exported_library_functions_association;
pub use inventory;
//==============================================================================
// Mode-gated submodules.
//==============================================================================
/// Runtime support for native-mode exports (`#[export]`), which are called
/// over the raw `MArgument` C ABI.
/// Runtime support for WSTP-mode exports (`#[export(wstp)]`), which are
/// called over a WSTP `Link`.
/// Runtime support for WXF-mode exports (`#[export(wxf)]`), which exchange
/// typed values as a WXF `ByteArray`.
//==============================================================================
// Proc-macro re-exports — `wolfram_export::export` works in user code without
// a separate `wolfram-export-macros` dep.
//==============================================================================
/// Export a function as a Wolfram LibraryLink function. See
/// [`export`][macro@export] for the four wire-format modes (native, `margs`,
/// `wstp`, `wxf`) and the Cargo features each one needs.
pub use export;
/// Designate a one-time library-load initialization function. See
/// [`init`][macro@init].
pub use init;
//==============================================================================
// Macro-emission surface.
//
// The proc-macro emits code that names `wolfram_export::sys::*` and
// `wolfram_export::macro_utils::*`. These resolve via the mode submodules
// below, gated on the matching feature.
//==============================================================================
pub use NativeFunction;
/// Macro-runtime helpers. Re-exports of the per-mode `macro_utils` modules
/// behind a single `wolfram_export::macro_utils::*` namespace so the
/// proc-macro can emit one consistent path regardless of mode.
//==============================================================================
// Feature-presence asserts.
//
// The proc-macro emits a `const _: () = wolfram_export::__assert_<mode>_enabled();`
// at the top of each generated wrapper. When the matching feature is OFF, the
// const fn body is `panic!(...)` — evaluating it in a const context becomes a
// compile-time error with a friendly, actionable message instead of a generic
// path-resolution failure.
//==============================================================================
pub const
pub const
pub const
pub const
pub const
pub const
pub const
pub const