Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:10:31.177Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

register_action.rs

48 lines · 1.8 KB · rust
1use proc_macro::TokenStream;
2use proc_macro2::{Ident, TokenStream as TokenStream2};
3use quote::{format_ident, quote};
4use syn::parse_macro_input;
5
6pub(crate) fn register_action(ident: TokenStream) -> TokenStream {
7    let name = parse_macro_input!(ident as Ident);
8    let registration = generate_register_action(&name);
9
10    TokenStream::from(quote! {
11        #registration
12    })
13}
14
15pub(crate) fn generate_register_action(type_name: &Ident) -> TokenStream2 {
16    let action_builder_fn_name = format_ident!(
17        "__gpui_actions_builder_{}",
18        type_name.to_string().to_lowercase()
19    );
20
21    quote! {
22        impl #type_name {
23            /// This is an auto generated function, do not use.
24            #[automatically_derived]
25            #[doc(hidden)]
26            fn __autogenerated() {
27                /// This is an auto generated function, do not use.
28                #[doc(hidden)]
29                fn #action_builder_fn_name() -> gpui::MacroActionData {
30                    gpui::MacroActionData {
31                        name: <#type_name as gpui::Action>::name_for_type(),
32                        type_id: ::std::any::TypeId::of::<#type_name>(),
33                        build: <#type_name as gpui::Action>::build,
34                        json_schema: <#type_name as gpui::Action>::action_json_schema,
35                        deprecated_aliases: <#type_name as gpui::Action>::deprecated_aliases(),
36                        deprecation_message: <#type_name as gpui::Action>::deprecation_message(),
37                        documentation: <#type_name as gpui::Action>::documentation(),
38                    }
39                }
40
41                gpui::private::inventory::submit! {
42                    gpui::MacroActionBuilder(#action_builder_fn_name)
43                }
44            }
45        }
46    }
47}
48
Served at tenant.openagents/omega Member data and write actions are omitted.