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