Skip to main content

wavecraft_macros/
lib.rs

1//! Wavecraft procedural macros for plugin development.
2//!
3//! This crate provides derive macros and procedural macros that simplify
4//! audio plugin creation by automatically generating boilerplate code.
5
6extern crate proc_macro;
7
8mod plugin;
9mod processor_params;
10
11use proc_macro::TokenStream;
12
13/// Derive macro for implementing `ProcessorParams` trait.
14///
15/// This macro automatically generates parameter metadata from struct fields
16/// annotated with `#[param(...)]` attributes.
17///
18/// # Example
19///
20/// ```text
21/// use wavecraft_macros::ProcessorParams;
22///
23/// #[derive(ProcessorParams, Default)]
24/// struct GainParams {
25///     #[param(range = "0.0..=2.0", default = 1.0, unit = "x")]
26///     level: f32,
27/// }
28/// ```
29#[proc_macro_derive(ProcessorParams, attributes(param))]
30pub fn derive_processor_params(input: TokenStream) -> TokenStream {
31    processor_params::derive(input)
32}
33
34/// Procedural macro for generating complete plugin implementations.
35///
36/// This macro parses a simple DSL and generates all the boilerplate code for
37/// a working VST3/CLAP plugin.
38///
39/// # Syntax
40///
41/// ```text
42/// wavecraft_plugin! {
43///     name: "My Plugin",
44///     vendor: "My Company",
45///     url: "https://example.com",  // optional
46///     email: "info@example.com",   // optional
47///     signal: Chain![
48///         MyGain { level: 0.0 },
49///     ],
50/// }
51/// ```
52///
53/// # Phase 6 Status
54///
55/// This is a work-in-progress implementation. Current status:
56/// - [x] Step 6.1: Basic input parsing (name, vendor, signal)
57/// - [ ] Step 6.2: Generate Plugin struct (partially done)
58/// - [ ] Step 6.3: Generate Params struct from processor chain
59/// - [ ] Step 6.4: Generate Plugin trait impl (partially done)
60/// - [ ] Step 6.5: Generate format impls & exports (done)
61/// - [ ] Step 6.6: Add error messages
62#[proc_macro]
63pub fn wavecraft_plugin(input: TokenStream) -> TokenStream {
64    plugin::wavecraft_plugin_impl(input)
65}