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
//! Procedural macros that turn safe, annotated Rust into the WeaveFFI C ABI.
//!
//! A producer annotates an ordinary Rust module with `#[weaveffi::module]` and
//! tags the items it wants to export. The macro lowers the module to the
//! WeaveFFI IR (through [`weaveffi_bridge`]), builds the canonical
//! [`BindingModel`](weaveffi_core::model::BindingModel), and emits the
//! `#[no_mangle] extern "C"` thunks every generated language binding calls.
//! All of the `unsafe` marshalling lives in the `weaveffi-abi` runtime, so the
//! producer writes only safe Rust.
//!
//! ```ignore
//! #[weaveffi::module]
//! pub mod calculator {
//! /// Add two integers.
//! #[weaveffi::export]
//! pub fn add(a: i32, b: i32) -> i32 {
//! a + b
//! }
//! }
//!
//! weaveffi::export_runtime!();
//! ```
//!
//! The same IR the macro lowers is what `weaveffi generate path/to/lib.rs`
//! reads, so the generated bindings and the producer cannot drift.
//!
//! # Attributes
//!
//! * [`macro@module`] marks an exported namespace (the driver attribute).
//! * [`macro@export`] exports a function; [`macro@record`] a by-value struct;
//! [`macro@enumeration`] a `#[repr(i32)]` C-style enum.
//! * [`macro@interface`] declares an opaque object type whose `impl` block's
//! `pub fn`s become constructors, methods, and statics.
//! * [`macro@error`] declares the module's error domain from a unit-variant
//! enum with explicit discriminants.
//! * [`macro@callback`] / [`macro@listener`] declare a callback and an event
//! listener; [`macro@cancellable`] marks an async function as cancellable.
//!
//! The item-level attributes are inert markers that [`macro@module`] reads; on
//! their own they expand to the item unchanged.
use TokenStream;
/// Mark an inline `mod` as an exported WeaveFFI namespace.
///
/// The macro re-emits the module unchanged and appends the generated C ABI
/// thunks for every tagged item it contains (functions, records, enums). Apply
/// it to a `mod foo { ... }` whose items carry the item-level markers.
/// Generate `#[doc(hidden)]` no-op marker attributes that [`macro@module`]
/// reads. Each expands to the annotated item unchanged.
marker_attr!
marker_attr!
marker_attr!
marker_attr!
marker_attr!
marker_attr!
marker_attr!
marker_attr!
marker_attr!