@@ -433,22 +433,22 @@ impl<'ctx> BindgenContext<'ctx> {
433
433
/// };
434
434
/// ```
435
435
fn build_template_wrapper ( & mut self ,
436
+ with_id : ItemId ,
436
437
wrapping : ItemId ,
437
438
parent_id : ItemId ,
438
439
ty : & clang:: Type ,
439
440
location : clang:: Cursor ) -> ItemId {
440
441
use clangll:: * ;
441
442
let mut args = vec ! [ ] ;
442
443
let mut found_invalid_template_ref = false ;
443
- let self_id = ItemId :: next ( ) ;
444
444
location. visit ( |c, _| {
445
445
if c. kind ( ) == CXCursor_TemplateRef &&
446
446
c. cur_type ( ) . kind ( ) == CXType_Invalid {
447
447
found_invalid_template_ref = true ;
448
448
}
449
449
if c. kind ( ) == CXCursor_TypeRef {
450
450
let new_ty =
451
- Item :: from_ty_or_ref ( c. cur_type ( ) , Some ( * c) , Some ( self_id ) , self ) ;
451
+ Item :: from_ty_or_ref ( c. cur_type ( ) , Some ( * c) , Some ( with_id ) , self ) ;
452
452
args. push ( new_ty) ;
453
453
}
454
454
CXChildVisit_Continue
@@ -494,17 +494,18 @@ impl<'ctx> BindgenContext<'ctx> {
494
494
let name = ty. spelling ( ) ;
495
495
let name = if name. is_empty ( ) { None } else { Some ( name) } ;
496
496
let ty = Type :: new ( name, ty. fallible_layout ( ) . ok ( ) , type_kind, ty. is_const ( ) ) ;
497
- Item :: new ( self_id , None , None , parent_id, ItemKind :: Type ( ty) )
497
+ Item :: new ( with_id , None , None , parent_id, ItemKind :: Type ( ty) )
498
498
} ;
499
499
500
500
// Bypass all the validations in add_item explicitly.
501
- self . items . insert ( self_id , item) ;
502
- self_id
501
+ self . items . insert ( with_id , item) ;
502
+ with_id
503
503
}
504
504
505
505
/// Looks up for an already resolved type, either because it's builtin, or
506
506
/// because we already have it in the map.
507
507
pub fn builtin_or_resolved_ty ( & mut self ,
508
+ with_id : ItemId ,
508
509
parent_id : Option < ItemId > ,
509
510
ty : & clang:: Type ,
510
511
location : Option < clang:: Cursor > ) -> Option < ItemId > {
@@ -533,6 +534,7 @@ impl<'ctx> BindgenContext<'ctx> {
533
534
if let Some ( id) = id {
534
535
debug ! ( "Already resolved ty {:?}, {:?}, {:?} {:?}" ,
535
536
id, declaration, ty, location) ;
537
+
536
538
// If the declaration existed, we *might* be done, but it's not
537
539
// the case for class templates, where the template arguments
538
540
// may vary.
@@ -548,11 +550,12 @@ impl<'ctx> BindgenContext<'ctx> {
548
550
* ty != canonical_declaration. cur_type ( ) &&
549
551
location. is_some ( ) && parent_id. is_some ( ) {
550
552
return Some (
551
- self . build_template_wrapper ( id, parent_id. unwrap ( ) , ty,
553
+ self . build_template_wrapper ( with_id, id,
554
+ parent_id. unwrap ( ) , ty,
552
555
location. unwrap ( ) ) ) ;
553
556
}
554
557
555
- return Some ( self . build_ty_wrapper ( id, parent_id, ty) ) ;
558
+ return Some ( self . build_ty_wrapper ( with_id , id, parent_id, ty) ) ;
556
559
}
557
560
}
558
561
@@ -568,19 +571,19 @@ impl<'ctx> BindgenContext<'ctx> {
568
571
// We should probably make the constness tracking separate, so it doesn't
569
572
// bloat that much, but hey, we already bloat the heck out of builtin types.
570
573
fn build_ty_wrapper ( & mut self ,
574
+ with_id : ItemId ,
571
575
wrapped_id : ItemId ,
572
576
parent_id : Option < ItemId > ,
573
577
ty : & clang:: Type ) -> ItemId {
574
- let id = ItemId :: next ( ) ;
575
578
let spelling = ty. spelling ( ) ;
576
579
let is_const = ty. is_const ( ) ;
577
580
let layout = ty. fallible_layout ( ) . ok ( ) ;
578
581
let type_kind = TypeKind :: ResolvedTypeRef ( wrapped_id) ;
579
582
let ty = Type :: new ( Some ( spelling) , layout, type_kind, is_const) ;
580
- let item = Item :: new ( id , None , None ,
583
+ let item = Item :: new ( with_id , None , None ,
581
584
parent_id. unwrap_or ( self . current_module ) , ItemKind :: Type ( ty) ) ;
582
585
self . add_builtin_item ( item) ;
583
- id
586
+ with_id
584
587
}
585
588
586
589
fn build_builtin_ty ( & mut self ,
0 commit comments