@@ -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 ;
@@ -1479,22 +1478,26 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1479
1478
self . root_module
1480
1479
}
1481
1480
1482
- /// Resolve a type with the given id .
1481
+ /// Resolve a type with the given ID .
1483
1482
///
1484
1483
/// Panics if there is no item for the given `TypeId` or if the resolved
1485
1484
/// item is not a `Type`.
1486
1485
pub ( crate ) fn resolve_type ( & self , type_id : TypeId ) -> & Type {
1487
1486
self . resolve_item ( type_id) . kind ( ) . expect_type ( )
1488
1487
}
1489
1488
1490
- /// Resolve a function with the given id .
1489
+ /// Resolve a function with the given ID .
1491
1490
///
1492
1491
/// Panics if there is no item for the given `FunctionId` or if the resolved
1493
1492
/// item is not a `Function`.
1494
1493
pub ( crate ) fn resolve_func ( & self , func_id : FunctionId ) -> & Function {
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 ( ) {
@@ -1504,9 +1507,9 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1504
1507
}
1505
1508
1506
1509
/// Resolve the given `ItemId` as a type, or `None` if there is no item with
1507
- /// the given id .
1510
+ /// the given ID .
1508
1511
///
1509
- /// Panics if the id resolves to an item that is not a type.
1512
+ /// Panics if the ID resolves to an item that is not a type.
1510
1513
pub ( crate ) fn safe_resolve_type ( & self , type_id : TypeId ) -> Option < & Type > {
1511
1514
self . resolve_item_fallible ( type_id)
1512
1515
. map ( |t| t. kind ( ) . expect_type ( ) )
@@ -1523,7 +1526,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1523
1526
1524
1527
/// Resolve the given `ItemId` into an `Item`.
1525
1528
///
1526
- /// Panics if the given id does not resolve to any item.
1529
+ /// Panics if the given ID does not resolve to any item.
1527
1530
pub ( crate ) fn resolve_item < Id : Into < ItemId > > ( & self , item_id : Id ) -> & Item {
1528
1531
let item_id = item_id. into ( ) ;
1529
1532
match self . resolve_item_fallible ( item_id) {
@@ -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