diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-12-07 18:54:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-07 18:54:19 -0800 |
commit | bddd464e6150738469ac5c8c99878d5edfd5f5fe (patch) | |
tree | b5694d8ed88afd87efd92f3e1f90f2b06346e1c9 /libbindgen/src/codegen/mod.rs | |
parent | 47e4ec7477a110265117a07bc290987b532861f9 (diff) | |
parent | c3685effcee7c49a747b2e149432f4113bc22713 (diff) |
Auto merge of #321 - emilio:coherent-replacement-and-whitelisting, r=fitzgen
Coherent replacement and whitelisting
This is on top of the last few PRs.
This moves us to take modules into account when whitelisting and replacing.
This also fixes a few issues with replacements, and simplifies our handling of template aliases.
r? @fitzgen
Diffstat (limited to 'libbindgen/src/codegen/mod.rs')
-rw-r--r-- | libbindgen/src/codegen/mod.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs index d2e2b96c..95a6f611 100644 --- a/libbindgen/src/codegen/mod.rs +++ b/libbindgen/src/codegen/mod.rs @@ -467,12 +467,9 @@ impl CodeGenerator for Type { TypeKind::Comp(ref ci) => { ci.codegen(ctx, result, whitelisted_items, item) } - // NB: The inner Alias will be generated and pick the correct + // NB: The code below will pick the correct // applicable_template_args. - TypeKind::TemplateAlias(inner, _) => { - ctx.resolve_item(inner) - .codegen(ctx, result, whitelisted_items, &()) - }, + TypeKind::TemplateAlias(ref spelling, inner, _) | TypeKind::Alias(ref spelling, inner) => { let inner_item = ctx.resolve_item(inner); let name = item.canonical_name(ctx); @@ -1777,10 +1774,9 @@ impl ToRustTy for Type { aster::ty::TyBuilder::new().array(len).build(inner) } TypeKind::Enum(..) => { - let path = item.canonical_path(ctx); + let path = item.namespace_aware_canonical_path(ctx); aster::AstBuilder::new().ty().path().ids(path).build() } - TypeKind::TemplateAlias(inner, ref template_args) | TypeKind::TemplateRef(inner, ref template_args) => { // PS: Sorry for the duplication here. let mut inner_ty = inner.to_rust_ty(ctx).unwrap(); @@ -1803,6 +1799,7 @@ impl ToRustTy for Type { P(inner_ty) } TypeKind::ResolvedTypeRef(inner) => inner.to_rust_ty(ctx), + TypeKind::TemplateAlias(ref spelling, inner, _) | TypeKind::Alias(ref spelling, inner) => { if item.is_opaque(ctx) { // Pray if there's no available layout. @@ -2141,7 +2138,7 @@ mod utils { ctx: &BindgenContext, only_named: bool) -> P<ast::Ty> { - let path = item.canonical_path(ctx); + let path = item.namespace_aware_canonical_path(ctx); let builder = aster::AstBuilder::new().ty().path(); let template_args = if only_named { |