@@ -370,7 +370,7 @@ pub struct Item {
370
370
/// This item's id.
371
371
id : ItemId ,
372
372
373
- /// The item's local id, unique only amongst its siblings. Only used for
373
+ /// The item's local id, unique only amongst its siblings. Only used for
374
374
/// anonymous items.
375
375
///
376
376
/// Lazily initialized in local_id().
@@ -379,7 +379,7 @@ pub struct Item {
379
379
/// case this is an implementation detail.
380
380
local_id : Cell < Option < usize > > ,
381
381
382
- /// The next local id to use for a child. .
382
+ /// The next local id to use for a child or template instantiation .
383
383
next_child_local_id : Cell < usize > ,
384
384
385
385
/// A cached copy of the canonical name, as returned by `canonical_name`.
@@ -490,13 +490,23 @@ impl Item {
490
490
pub fn local_id ( & self , ctx : & BindgenContext ) -> usize {
491
491
if self . local_id . get ( ) . is_none ( ) {
492
492
let parent = ctx. resolve_item ( self . parent_id ) ;
493
- let local_id = parent. next_child_local_id . get ( ) ;
494
- parent. next_child_local_id . set ( local_id + 1 ) ;
495
- self . local_id . set ( Some ( local_id) ) ;
493
+ self . local_id . set ( Some ( parent. next_child_local_id ( ) ) ) ;
496
494
}
497
495
self . local_id . get ( ) . unwrap ( )
498
496
}
499
497
498
+ /// Get an identifier that differentiates a child of this item of other
499
+ /// related items.
500
+ ///
501
+ /// This is currently used for anonymous items, and template instantiation
502
+ /// tests, in both cases in order to reduce noise when system headers are at
503
+ /// place.
504
+ pub fn next_child_local_id ( & self ) -> usize {
505
+ let local_id = self . next_child_local_id . get ( ) ;
506
+ self . next_child_local_id . set ( local_id + 1 ) ;
507
+ local_id
508
+ }
509
+
500
510
/// Returns whether this item is a top-level item, from the point of view of
501
511
/// bindgen.
502
512
///
@@ -777,13 +787,16 @@ impl Item {
777
787
ctx. rust_mangle ( & name) . into_owned ( )
778
788
}
779
789
780
- fn exposed_id ( & self , ctx : & BindgenContext ) -> String {
790
+ /// The exposed id that represents an unique id among the siblings of a
791
+ /// given item.
792
+ pub fn exposed_id ( & self , ctx : & BindgenContext ) -> String {
781
793
// Only use local ids for enums, classes, structs and union types. All
782
794
// other items use their global id.
783
795
let ty_kind = self . kind ( ) . as_type ( ) . map ( |t| t. kind ( ) ) ;
784
796
if let Some ( ty_kind) = ty_kind {
785
797
match * ty_kind {
786
798
TypeKind :: Comp ( ..) |
799
+ TypeKind :: TemplateInstantiation ( ..) |
787
800
TypeKind :: Enum ( ..) => return self . local_id ( ctx) . to_string ( ) ,
788
801
_ => { }
789
802
}
0 commit comments