swift_bridge_macro/
lib.rs

1use quote::quote;
2use swift_bridge_ir::{SwiftBridgeModule, SwiftBridgeModuleAttr, SwiftBridgeModuleAttrs};
3use syn::parse_macro_input;
4
5#[proc_macro_attribute]
6pub fn bridge(
7    args: proc_macro::TokenStream,
8    input: proc_macro::TokenStream,
9) -> proc_macro::TokenStream {
10    let args = parse_macro_input!(args as SwiftBridgeModuleAttrs);
11    let mut module = parse_macro_input!(input as SwiftBridgeModule);
12
13    for arg in args.attributes {
14        match arg {
15            SwiftBridgeModuleAttr::SwiftBridgePath(path) => {
16                module.set_swift_bridge_path(path);
17            }
18        }
19    }
20
21    let tokens = quote! {
22        #module
23    };
24
25    tokens.into()
26}
27
28#[cfg(test)]
29mod ui_tests {
30    #[test]
31    fn ui() {
32        let t = trybuild::TestCases::new();
33        t.compile_fail("tests/ui/*.rs");
34    }
35}