1mod derive_into_element;
2mod derive_path_static_str;
3mod derive_render;
4mod register_action;
5mod styles;
6mod test;
7
8use proc_macro::TokenStream;
9
10/// register_action! can be used to register an action with the GPUI runtime.
11/// You should typically use `gpui::actions!` or `gpui::impl_actions!` instead,
12/// but this can be used for fine grained customization.
13#[proc_macro]
14pub fn register_action(ident: TokenStream) -> TokenStream {
15 register_action::register_action_macro(ident)
16}
17
18/// #[derive(IntoElement)] is used to create a Component out of anything that implements
19/// the `RenderOnce` trait.
20#[proc_macro_derive(IntoElement)]
21pub fn derive_into_element(input: TokenStream) -> TokenStream {
22 derive_into_element::derive_into_element(input)
23}
24
25#[proc_macro_derive(Render)]
26#[doc(hidden)]
27pub fn derive_render(input: TokenStream) -> TokenStream {
28 derive_render::derive_render(input)
29}
30
31#[proc_macro_derive(PathStaticStr)]
32#[doc(hidden)]
33pub fn derive_path_static_str(input: TokenStream) -> TokenStream {
34 derive_path_static_str::derive_path_static_str(input)
35}
36
37/// Used by GPUI to generate the style helpers.
38#[proc_macro]
39#[doc(hidden)]
40pub fn style_helpers(input: TokenStream) -> TokenStream {
41 styles::style_helpers(input)
42}
43
44/// Generates methods for visibility styles.
45#[proc_macro]
46pub fn visibility_style_methods(input: TokenStream) -> TokenStream {
47 styles::visibility_style_methods(input)
48}
49
50/// Generates methods for margin styles.
51#[proc_macro]
52pub fn margin_style_methods(input: TokenStream) -> TokenStream {
53 styles::margin_style_methods(input)
54}
55
56/// Generates methods for padding styles.
57#[proc_macro]
58pub fn padding_style_methods(input: TokenStream) -> TokenStream {
59 styles::padding_style_methods(input)
60}
61
62/// Generates methods for position styles.
63#[proc_macro]
64pub fn position_style_methods(input: TokenStream) -> TokenStream {
65 styles::position_style_methods(input)
66}
67
68/// Generates methods for overflow styles.
69#[proc_macro]
70pub fn overflow_style_methods(input: TokenStream) -> TokenStream {
71 styles::overflow_style_methods(input)
72}
73
74/// Generates methods for cursor styles.
75#[proc_macro]
76pub fn cursor_style_methods(input: TokenStream) -> TokenStream {
77 styles::cursor_style_methods(input)
78}
79
80/// Generates methods for border styles.
81#[proc_macro]
82pub fn border_style_methods(input: TokenStream) -> TokenStream {
83 styles::border_style_methods(input)
84}
85
86/// Generates methods for box shadow styles.
87#[proc_macro]
88pub fn box_shadow_style_methods(input: TokenStream) -> TokenStream {
89 styles::box_shadow_style_methods(input)
90}
91
92/// #[gpui::test] can be used to annotate test functions that run with GPUI support.
93/// it supports both synchronous and asynchronous tests, and can provide you with
94/// as many `TestAppContext` instances as you need.
95/// The output contains a `#[test]` annotation so this can be used with any existing
96/// test harness (`cargo test` or `cargo-nextest`).
97///
98/// ```
99/// #[gpui::test]
100/// async fn test_foo(mut cx: &TestAppContext) { }
101/// ```
102///
103/// In addition to passing a TestAppContext, you can also ask for a `StdRnd` instance.
104/// this will be seeded with the `SEED` environment variable and is used internally by
105/// the ForegroundExecutor and BackgroundExecutor to run tasks deterministically in tests.
106/// Using the same `StdRng` for behavior in your test will allow you to exercise a wide
107/// variety of scenarios and interleavings just by changing the seed.
108///
109/// #[gpui::test] also takes three different arguments:
110/// - `#[gpui::test(iterations=10)]` will run the test ten times with a different initial SEED.
111/// - `#[gpui::test(retries=3)]` will run the test up to four times if it fails to try and make it pass.
112/// - `#[gpui::test(on_failure="crate::test::report_failure")]` will call the specified function after the
113/// tests fail so that you can write out more detail about the failure.
114#[proc_macro_attribute]
115pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
116 test::test(args, function)
117}