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
//! C-ABI FFI contract for dev-mode audio processing.
//!
//! This module defines the shared interface between the `wavecraft_plugin!` macro
//! (which generates FFI exports in the user's cdylib) and the CLI consumer
//! (`wavecraft start`) that loads and calls them.
//!
//! # Design Principles
//!
//! - **`#[repr(C)]`** struct with `extern "C"` function pointers for ABI stability
//! - **`*mut c_void`** instance pointers for type erasure across the dylib boundary
//! - **Version field** for forward-compatible ABI evolution
//! - All memory alloc/dealloc stays inside the dylib (no cross-allocator issues)
use c_void;
/// C-ABI stable vtable for dev-mode audio processing.
///
/// This struct is returned by the `wavecraft_dev_create_processor` FFI symbol
/// exported from user plugins. It provides function pointers for creating,
/// using, and destroying a processor instance across the dylib boundary.
///
/// # ABI Stability
///
/// This struct uses `#[repr(C)]` and only `extern "C"` function pointers,
/// making it safe across separately compiled Rust binaries. All data passes
/// through primitive types (`f32`, `u32`, `*mut c_void`, `*mut *mut f32`).
///
/// # Versioning
///
/// A `version` field allows the CLI to detect incompatible vtable changes
/// and provide clear upgrade guidance instead of undefined behavior.
///
/// # Memory Ownership
///
/// ```text
/// create() → Box::into_raw(Box::new(Processor)) [dylib allocates]
/// process() → &mut *(ptr as *mut Processor) [dylib borrows]
/// drop() → Box::from_raw(ptr as *mut Processor) [dylib deallocates]
/// ```
///
/// The CLI never allocates or frees the processor memory; it only passes the
/// opaque pointer back into vtable functions.
/// Current vtable version.
///
/// v2 adds `apply_plain_values` to support block-boundary parameter injection
/// in dev FFI mode.
pub const DEV_PROCESSOR_VTABLE_VERSION: u32 = 2;
/// FFI symbol name exported by `wavecraft_plugin!` macro.
pub const DEV_PROCESSOR_SYMBOL: & = b"wavecraft_dev_create_processor\0";