@@ -26,7 +26,6 @@ use crate::codegen::utils::{fnsig_argument_type, fnsig_return_ty_internal};
26
26
use crate :: codegen:: CodegenError ;
27
27
use crate :: BindgenOptions ;
28
28
use crate :: { Entry , HashMap , HashSet } ;
29
- use clang_sys;
30
29
use proc_macro2:: { Ident , Span , TokenStream } ;
31
30
use quote:: ToTokens ;
32
31
use std:: borrow:: Cow ;
@@ -1495,6 +1494,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1495
1494
self . resolve_item ( func_id) . kind ( ) . expect_function ( )
1496
1495
}
1497
1496
1497
+ /// Resolve a function signature with the given ID.
1498
+ ///
1499
+ /// Panics if there is no type for the given `TypeId` or if the resolved
1500
+ /// `Type` is not a function.
1498
1501
pub ( crate ) fn resolve_sig ( & self , sig_id : TypeId ) -> & FunctionSig {
1499
1502
let signature = self . resolve_type ( sig_id) . canonical_type ( self ) ;
1500
1503
match * signature. kind ( ) {
@@ -2009,32 +2012,39 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2009
2012
type_id
2010
2013
}
2011
2014
2015
+ /// Add a function signature in order to look it up when generating macros.
2012
2016
pub ( crate ) fn add_function ( & mut self , name : & str , sig : Function ) {
2013
2017
self . functions . insert ( name. to_owned ( ) , sig) ;
2014
2018
}
2015
2019
2020
+ /// Get a function signature by its name.
2016
2021
pub ( crate ) fn function ( & self , name : & str ) -> Option < & Function > {
2017
2022
self . functions . get ( name)
2018
2023
}
2019
2024
2025
+ /// Add a function-like macro.
2020
2026
pub ( crate ) fn add_fn_macro ( & mut self , fn_macro : cmacro:: FnMacro ) {
2021
2027
self . function_macros
2022
2028
. insert ( fn_macro. name . to_owned ( ) , fn_macro) ;
2023
2029
}
2024
2030
2031
+ /// Get a function-like macro by its name.
2025
2032
pub ( crate ) fn fn_macro ( & self , name : & str ) -> Option < & cmacro:: FnMacro > {
2026
2033
self . function_macros . get ( name)
2027
2034
}
2028
2035
2036
+ /// Add a variable-like macro.
2029
2037
pub ( crate ) fn add_var_macro ( & mut self , var_macro : cmacro:: VarMacro ) {
2030
2038
self . variable_macros
2031
2039
. insert ( var_macro. name . to_owned ( ) , var_macro) ;
2032
2040
}
2033
2041
2042
+ /// Get a variable-like macro by its name.
2034
2043
pub ( crate ) fn var_macro ( & self , name : & str ) -> Option < & cmacro:: VarMacro > {
2035
2044
self . variable_macros . get ( name)
2036
2045
}
2037
2046
2047
+ /// Get a type by its name.
2038
2048
pub ( crate ) fn type_by_name ( & self , name : & str ) -> Option < & TypeId > {
2039
2049
self . type_names . get ( name)
2040
2050
}
0 commit comments