@@ -41,7 +41,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
4141 let mut fields = parse_fields ( named_fields, struct_cfg. init_strategy ) ?;
4242
4343 if struct_cfg. is_editor_plugin ( ) {
44- modifiers. push ( quote ! { with_editor_plugin } )
44+ modifiers. push ( quote ! { with_editor_plugin( ) } )
4545 }
4646
4747 let mut deprecations = std:: mem:: take ( & mut struct_cfg. deprecations ) ;
@@ -58,7 +58,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
5858 let class_name_allocation = quote ! { ClassId :: __alloc_next_unicode( #class_name_str) } ;
5959
6060 if struct_cfg. is_internal {
61- modifiers. push ( quote ! { with_internal } )
61+ modifiers. push ( quote ! { with_internal( ) } )
6262 }
6363 let base_ty = & struct_cfg. base_ty ;
6464 let prv = quote ! { :: godot:: private } ;
@@ -113,7 +113,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
113113 match struct_cfg. init_strategy {
114114 InitStrategy :: Generated => {
115115 godot_init_impl = make_godot_init_impl ( class_name, & fields) ;
116- modifiers. push ( quote ! { with_generated:: <#class_name> } ) ;
116+ modifiers. push ( quote ! { with_generated:: <#class_name>( ) } ) ;
117117 }
118118 InitStrategy :: UserDefined => {
119119 let fn_name = format_ident ! ( "class_{}_must_have_an_init_method" , class_name) ;
@@ -131,19 +131,24 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
131131
132132 // Workaround for https://github.com/godot-rust/gdext/issues/874 before Godot 4.5.
133133 #[ cfg( before_api = "4.5" ) ]
134- modifiers. push ( quote ! { with_generated_no_default:: <#class_name> } ) ;
134+ modifiers. push ( quote ! { with_generated_no_default:: <#class_name>( ) } ) ;
135135 }
136136 } ;
137137 if is_instantiable {
138- modifiers. push ( quote ! { with_instantiable } ) ;
138+ modifiers. push ( quote ! { with_instantiable( ) } ) ;
139139 }
140140
141141 if has_default_virtual {
142- modifiers. push ( quote ! { with_default_get_virtual_fn:: <#class_name> } ) ;
142+ modifiers. push ( quote ! { with_default_get_virtual_fn:: <#class_name>( ) } ) ;
143143 }
144144
145145 if struct_cfg. is_tool {
146- modifiers. push ( quote ! { with_tool } )
146+ modifiers. push ( quote ! { with_tool( ) } )
147+ }
148+
149+ #[ cfg( since_api = "4.4" ) ]
150+ if let Some ( icon) = & struct_cfg. icon {
151+ modifiers. push ( quote ! { with_icon( #icon) } )
147152 }
148153
149154 // Declares a "funcs collection" struct that, for holds a constant for each #[func].
@@ -198,8 +203,9 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
198203 #struct_docs_registration
199204 :: godot:: sys:: plugin_add!( #prv:: __GODOT_PLUGIN_REGISTRY; #prv:: ClassPlugin :: new:: <#class_name>(
200205 #prv:: PluginItem :: Struct (
201- #prv:: Struct :: new:: <#class_name>( ) #( . #modifiers( ) ) *
206+ #prv:: Struct :: new:: <#class_name>( ) #( . #modifiers) *
202207 )
208+
203209 ) ) ;
204210
205211 #prv:: class_macros:: #inherits_macro_ident!( #class_name) ;
@@ -303,6 +309,7 @@ struct ClassAttributes {
303309 is_tool : bool ,
304310 is_internal : bool ,
305311 rename : Option < Ident > ,
312+ icon : Option < TokenStream > ,
306313 deprecations : Vec < TokenStream > ,
307314}
308315
@@ -510,6 +517,7 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
510517 let mut is_tool = false ;
511518 let mut is_internal = false ;
512519 let mut rename: Option < Ident > = None ;
520+ let mut icon: Option < TokenStream > = None ;
513521 let mut deprecations = vec ! [ ] ;
514522
515523 // #[class] attribute on struct
@@ -542,6 +550,11 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
542550 // #[class(rename = NewName)]
543551 rename = parser. handle_ident ( "rename" ) ?;
544552
553+ // #[class(icon = "PATH")]
554+ if let Some ( expr) = parser. handle_expr ( "icon" ) ? {
555+ icon = Some ( expr) ;
556+ }
557+
545558 // #[class(internal)]
546559 // Named "internal" following Godot terminology: https://github.com/godotengine/godot-cpp/blob/master/include/godot_cpp/core/class_db.hpp#L327
547560 if parser. handle_alone ( "internal" ) ? {
@@ -583,6 +596,7 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
583596 is_tool,
584597 is_internal,
585598 rename,
599+ icon,
586600 deprecations,
587601 } )
588602}
0 commit comments