33use crate :: {
44 builder,
55 callbacks:: {
6- AttributeInfo , DeriveInfo , ItemInfo , ParseCallbacks , TypeKind ,
6+ AttributeInfo , AttributeItemKind , DeriveInfo , ItemInfo , ParseCallbacks , TypeKind ,
77 } ,
88 features:: { RustEdition , EARLIEST_STABLE_RUST } ,
99 regex_set:: RegexSet ,
@@ -477,7 +477,7 @@ struct BindgenCommand {
477477 /// Derive custom traits on a `union`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a coma-separated list of derive macros.
478478 #[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_derive) ]
479479 with_derive_custom_union : Vec < ( Vec < String > , String ) > ,
480- /// Add custom attributes on any kind of type . The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes.
480+ /// Add custom attributes on any item . The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes.
481481 #[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_attribute) ]
482482 with_attribute_custom : Vec < ( Vec < String > , String ) > ,
483483 /// Add custom attributes on a `struct`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes.
@@ -489,6 +489,9 @@ struct BindgenCommand {
489489 /// Add custom attributes on a `union`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes.
490490 #[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_attribute) ]
491491 with_attribute_custom_union : Vec < ( Vec < String > , String ) > ,
492+ /// Add custom attributes on an `fn`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes.
493+ #[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_attribute) ]
494+ with_attribute_custom_function : Vec < ( Vec < String > , String ) > ,
492495 /// Generate wrappers for `static` and `static inline` functions.
493496 #[ arg( long) ]
494497 wrap_static_fns : bool ,
@@ -645,6 +648,7 @@ where
645648 with_attribute_custom_struct,
646649 with_attribute_custom_enum,
647650 with_attribute_custom_union,
651+ with_attribute_custom_function,
648652 wrap_static_fns,
649653 wrap_static_fns_path,
650654 wrap_static_fns_suffix,
@@ -745,7 +749,7 @@ where
745749 #[ derive( Debug ) ]
746750 struct CustomAttributeCallback {
747751 attributes : Vec < String > ,
748- kind : Option < TypeKind > ,
752+ kind : Option < AttributeItemKind > ,
749753 regex_set : RegexSet ,
750754 }
751755
@@ -755,9 +759,10 @@ where
755759
756760 let flag = match & self . kind {
757761 None => "--with-attribute-custom" ,
758- Some ( TypeKind :: Struct ) => "--with-attribute-custom-struct" ,
759- Some ( TypeKind :: Enum ) => "--with-attribute-custom-enum" ,
760- Some ( TypeKind :: Union ) => "--with-attribute-custom-union" ,
762+ Some ( AttributeItemKind :: Struct ) => "--with-attribute-custom-struct" ,
763+ Some ( AttributeItemKind :: Enum ) => "--with-attribute-custom-enum" ,
764+ Some ( AttributeItemKind :: Union ) => "--with-attribute-custom-union" ,
765+ Some ( AttributeItemKind :: Function ) => "--with-attribute-custom-function" ,
761766 } ;
762767
763768 let attributes = self . attributes . join ( "," ) ;
@@ -1010,19 +1015,24 @@ where
10101015 ( with_attribute_custom, None , "--with-attribute-custom" ) ,
10111016 (
10121017 with_attribute_custom_struct,
1013- Some ( TypeKind :: Struct ) ,
1018+ Some ( AttributeItemKind :: Struct ) ,
10141019 "--with-attribute-custom-struct" ,
10151020 ) ,
10161021 (
10171022 with_attribute_custom_enum,
1018- Some ( TypeKind :: Enum ) ,
1023+ Some ( AttributeItemKind :: Enum ) ,
10191024 "--with-attribute-custom-enum" ,
10201025 ) ,
10211026 (
10221027 with_attribute_custom_union,
1023- Some ( TypeKind :: Union ) ,
1028+ Some ( AttributeItemKind :: Union ) ,
10241029 "--with-attribute-custom-union" ,
10251030 ) ,
1031+ (
1032+ with_attribute_custom_function,
1033+ Some ( AttributeItemKind :: Function ) ,
1034+ "--with-attribute-custom-function" ,
1035+ ) ,
10261036 ] {
10271037 #[ cfg( feature = "experimental" ) ]
10281038 let name = emit_diagnostics. then_some ( _name) ;
0 commit comments