summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-10-21 19:30:44 +0200
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-10-29 22:25:19 +0200
commit801179c198d0870e207f49c91d7aa491be615710 (patch)
treee6743cd9f405e86e58ea90e8aab757ab7302f968
parent79407f3690f8488ec07fc310e885cba5b4e03162 (diff)
Pass the potential id to be used as the type wrapper id.
This should fix the MSVC problems. Signed-off-by: Emilio Cobos Álvarez <ecoal95@gmail.com>
-rw-r--r--src/ir/context.rs23
-rw-r--r--src/ir/item.rs7
-rw-r--r--src/ir/ty.rs3
3 files changed, 20 insertions, 13 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 77cd1182..65c62817 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -467,6 +467,7 @@ impl<'ctx> BindgenContext<'ctx> {
/// };
/// ```
fn build_template_wrapper(&mut self,
+ with_id: ItemId,
wrapping: ItemId,
parent_id: ItemId,
ty: &clang::Type,
@@ -474,7 +475,6 @@ impl<'ctx> BindgenContext<'ctx> {
use clangll::*;
let mut args = vec![];
let mut found_invalid_template_ref = false;
- let self_id = ItemId::next();
location.visit(|c, _| {
if c.kind() == CXCursor_TemplateRef &&
c.cur_type().kind() == CXType_Invalid {
@@ -482,7 +482,7 @@ impl<'ctx> BindgenContext<'ctx> {
}
if c.kind() == CXCursor_TypeRef {
let new_ty =
- Item::from_ty_or_ref(c.cur_type(), Some(*c), Some(self_id), self);
+ Item::from_ty_or_ref(c.cur_type(), Some(*c), Some(with_id), self);
args.push(new_ty);
}
CXChildVisit_Continue
@@ -528,17 +528,18 @@ impl<'ctx> BindgenContext<'ctx> {
let name = ty.spelling();
let name = if name.is_empty() { None } else { Some(name) };
let ty = Type::new(name, ty.fallible_layout().ok(), type_kind, ty.is_const());
- Item::new(self_id, None, None, parent_id, ItemKind::Type(ty))
+ Item::new(with_id, None, None, parent_id, ItemKind::Type(ty))
};
// Bypass all the validations in add_item explicitly.
- self.items.insert(self_id, item);
- self_id
+ self.items.insert(with_id, item);
+ with_id
}
/// Looks up for an already resolved type, either because it's builtin, or
/// because we already have it in the map.
pub fn builtin_or_resolved_ty(&mut self,
+ with_id: ItemId,
parent_id: Option<ItemId>,
ty: &clang::Type,
location: Option<clang::Cursor>) -> Option<ItemId> {
@@ -567,6 +568,7 @@ impl<'ctx> BindgenContext<'ctx> {
if let Some(id) = id {
debug!("Already resolved ty {:?}, {:?}, {:?} {:?}",
id, declaration, ty, location);
+
// If the declaration existed, we *might* be done, but it's not
// the case for class templates, where the template arguments
// may vary.
@@ -582,11 +584,12 @@ impl<'ctx> BindgenContext<'ctx> {
*ty != canonical_declaration.cur_type() &&
location.is_some() && parent_id.is_some() {
return Some(
- self.build_template_wrapper(id, parent_id.unwrap(), ty,
+ self.build_template_wrapper(with_id, id,
+ parent_id.unwrap(), ty,
location.unwrap()));
}
- return Some(self.build_ty_wrapper(id, parent_id, ty));
+ return Some(self.build_ty_wrapper(with_id, id, parent_id, ty));
}
}
@@ -602,19 +605,19 @@ impl<'ctx> BindgenContext<'ctx> {
// We should probably make the constness tracking separate, so it doesn't
// bloat that much, but hey, we already bloat the heck out of builtin types.
fn build_ty_wrapper(&mut self,
+ with_id: ItemId,
wrapped_id: ItemId,
parent_id: Option<ItemId>,
ty: &clang::Type) -> ItemId {
- let id = ItemId::next();
let spelling = ty.spelling();
let is_const = ty.is_const();
let layout = ty.fallible_layout().ok();
let type_kind = TypeKind::ResolvedTypeRef(wrapped_id);
let ty = Type::new(Some(spelling), layout, type_kind, is_const);
- let item = Item::new(id, None, None,
+ let item = Item::new(with_id, None, None,
parent_id.unwrap_or(self.current_module), ItemKind::Type(ty));
self.add_builtin_item(item);
- id
+ with_id
}
fn build_builtin_ty(&mut self,
diff --git a/src/ir/item.rs b/src/ir/item.rs
index c68ed5f7..5a419e06 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -717,7 +717,9 @@ impl ClangItemParser for Item {
.expect("Unable to resolve type");
}
- if let Some(ty) = context.builtin_or_resolved_ty(parent_id, &ty, location) {
+ if let Some(ty) = context.builtin_or_resolved_ty(potential_id,
+ parent_id, &ty,
+ location) {
debug!("{:?} already resolved: {:?}", ty, location);
return ty;
}
@@ -779,7 +781,8 @@ impl ClangItemParser for Item {
context.replace(replaced, id);
}
- if let Some(ty) = context.builtin_or_resolved_ty(parent_id, ty, location) {
+ if let Some(ty) = context.builtin_or_resolved_ty(id, parent_id,
+ ty, location) {
return Ok(ty);
}
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index bbb666bc..a883ea66 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -471,7 +471,8 @@ impl Type {
parent_id: Option<ItemId>,
ctx: &mut BindgenContext) -> Result<ParseResult<Self>, ParseError> {
use clangll::*;
- if let Some(ty) = ctx.builtin_or_resolved_ty(parent_id, ty, location) {
+ if let Some(ty) = ctx.builtin_or_resolved_ty(potential_id, parent_id,
+ ty, location) {
debug!("{:?} already resolved: {:?}", ty, location);
return Ok(ParseResult::AlreadyResolved(ty));
}