3
3
use crate :: {
4
4
builder,
5
5
callbacks:: {
6
- AttributeInfo , DeriveInfo , ItemInfo , ParseCallbacks , TypeKind ,
6
+ AttributeInfo , AttributeItemKind , DeriveInfo , ItemInfo , ParseCallbacks , TypeKind ,
7
7
} ,
8
8
features:: { RustEdition , EARLIEST_STABLE_RUST } ,
9
9
regex_set:: RegexSet ,
@@ -477,7 +477,7 @@ struct BindgenCommand {
477
477
/// 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.
478
478
#[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_derive) ]
479
479
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.
481
481
#[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_attribute) ]
482
482
with_attribute_custom : Vec < ( Vec < String > , String ) > ,
483
483
/// 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 {
489
489
/// 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.
490
490
#[ arg( long, value_name = "CUSTOM" , value_parser = parse_custom_attribute) ]
491
491
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 ) > ,
492
495
/// Generate wrappers for `static` and `static inline` functions.
493
496
#[ arg( long) ]
494
497
wrap_static_fns : bool ,
@@ -645,6 +648,7 @@ where
645
648
with_attribute_custom_struct,
646
649
with_attribute_custom_enum,
647
650
with_attribute_custom_union,
651
+ with_attribute_custom_function,
648
652
wrap_static_fns,
649
653
wrap_static_fns_path,
650
654
wrap_static_fns_suffix,
@@ -745,7 +749,7 @@ where
745
749
#[ derive( Debug ) ]
746
750
struct CustomAttributeCallback {
747
751
attributes : Vec < String > ,
748
- kind : Option < TypeKind > ,
752
+ kind : Option < AttributeItemKind > ,
749
753
regex_set : RegexSet ,
750
754
}
751
755
@@ -755,9 +759,10 @@ where
755
759
756
760
let flag = match & self . kind {
757
761
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" ,
761
766
} ;
762
767
763
768
let attributes = self . attributes . join ( "," ) ;
@@ -1010,19 +1015,24 @@ where
1010
1015
( with_attribute_custom, None , "--with-attribute-custom" ) ,
1011
1016
(
1012
1017
with_attribute_custom_struct,
1013
- Some ( TypeKind :: Struct ) ,
1018
+ Some ( AttributeItemKind :: Struct ) ,
1014
1019
"--with-attribute-custom-struct" ,
1015
1020
) ,
1016
1021
(
1017
1022
with_attribute_custom_enum,
1018
- Some ( TypeKind :: Enum ) ,
1023
+ Some ( AttributeItemKind :: Enum ) ,
1019
1024
"--with-attribute-custom-enum" ,
1020
1025
) ,
1021
1026
(
1022
1027
with_attribute_custom_union,
1023
- Some ( TypeKind :: Union ) ,
1028
+ Some ( AttributeItemKind :: Union ) ,
1024
1029
"--with-attribute-custom-union" ,
1025
1030
) ,
1031
+ (
1032
+ with_attribute_custom_function,
1033
+ Some ( AttributeItemKind :: Function ) ,
1034
+ "--with-attribute-custom-function" ,
1035
+ ) ,
1026
1036
] {
1027
1037
#[ cfg( feature = "experimental" ) ]
1028
1038
let name = emit_diagnostics. then_some ( _name) ;
0 commit comments