diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-10-16 21:20:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-16 21:20:13 -0500 |
commit | 29e5e24ef02aef40775cdee062a5cf50db57b206 (patch) | |
tree | a8519ed266aa593ef09d34064cee39849df13fb9 | |
parent | fca27e2d13ecafd6b4f658b89567a7244e64a897 (diff) | |
parent | 0d00d742ada49f1c94b1ade0d361d97eeacf2871 (diff) |
Auto merge of #91 - mgjc:remove-typeresolver, r=emilio
Removed TypeResolver
Hope you like it.
-rw-r--r-- | src/ir/comp.rs | 17 | ||||
-rw-r--r-- | src/ir/context.rs | 6 | ||||
-rw-r--r-- | src/ir/ty.rs | 21 |
3 files changed, 18 insertions, 26 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs index d31b7adf..1f8a0292 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -1,6 +1,5 @@ use super::annotations::Annotations; use super::context::BindgenContext; -use super::context::TypeResolver; use super::layout::Layout; use super::item::{Item, ItemId}; use super::ty::{Type, RUST_DERIVE_IN_ARRAY_LIMIT}; @@ -206,7 +205,7 @@ impl CompInfo { } } - pub fn can_derive_debug(&self, type_resolver: &TypeResolver, layout: Option<Layout>) -> bool { + pub fn can_derive_debug(&self, type_resolver: &BindgenContext, layout: Option<Layout>) -> bool { // We can reach here recursively via template parameters of a member, // for example. if self.detect_derive_debug_cycle.get() { @@ -249,7 +248,7 @@ impl CompInfo { can_derive_debug } - pub fn is_unsized(&self, type_resolver: &TypeResolver) -> bool { + pub fn is_unsized(&self, type_resolver: &BindgenContext) -> bool { !self.has_vtable(type_resolver) && self.fields.is_empty() && self.base_members.iter().all(|base| { type_resolver @@ -262,7 +261,7 @@ impl CompInfo { }) } - pub fn has_destructor(&self, type_resolver: &TypeResolver) -> bool { + pub fn has_destructor(&self, type_resolver: &BindgenContext) -> bool { if self.detect_has_destructor_cycle.get() { warn!("Cycle detected looking for destructors"); // Assume no destructor, since we don't have an explicit one. @@ -299,7 +298,7 @@ impl CompInfo { has_destructor } - pub fn can_derive_copy(&self, type_resolver: &TypeResolver, item: &Item) -> bool { + pub fn can_derive_copy(&self, type_resolver: &BindgenContext, item: &Item) -> bool { // NOTE: Take into account that while unions in C and C++ are copied by // default, the may have an explicit destructor in C++, so we can't // defer this check just for the union case. @@ -349,7 +348,7 @@ impl CompInfo { // If we're a union without known layout, we try to compute it from our // members. This is not ideal, but clang fails to report the size for // these kind of unions, see test/headers/template_union.hpp - pub fn layout(&self, type_resolver: &TypeResolver) -> Option<Layout> { + pub fn layout(&self, type_resolver: &BindgenContext) -> Option<Layout> { use std::cmp; // We can't do better than clang here, sorry. @@ -384,7 +383,7 @@ impl CompInfo { self.has_non_type_template_params } - pub fn has_vtable(&self, type_resolver: &TypeResolver) -> bool { + pub fn has_vtable(&self, type_resolver: &BindgenContext) -> bool { self.has_vtable || self.base_members().iter().any(|base| { type_resolver .resolve_type(*base) @@ -688,7 +687,7 @@ impl CompInfo { } pub fn signature_contains_named_type(&self, - type_resolver: &TypeResolver, + type_resolver: &BindgenContext, ty: &Type) -> bool { // We don't generate these, so rather don't make the codegen step to // think we got it covered. @@ -719,7 +718,7 @@ impl CompInfo { /// Returns whether this type needs an explicit vtable because it has /// virtual methods and none of its base classes has already a vtable. - pub fn needs_explicit_vtable(&self, type_resolver: &TypeResolver) -> bool { + pub fn needs_explicit_vtable(&self, type_resolver: &BindgenContext) -> bool { self.has_vtable(type_resolver) && !self.base_members.iter().any(|base| { // NB: Ideally, we could rely in all these types being `comp`, and // life would be beautiful. diff --git a/src/ir/context.rs b/src/ir/context.rs index 4842eb94..07e93359 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -713,9 +713,3 @@ impl<'ctx> BindgenContext<'ctx> { self.current_module = previous_id; } } - -/// This was originally a type that only exposes the resolve_type operation to -/// its consumers. -/// -/// Later a made resolve_type public, so... meh. It should go away soon. -pub type TypeResolver<'ctx> = BindgenContext<'ctx>; diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 8227a786..bae2fd88 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -5,7 +5,6 @@ use super::item::{Item, ItemId}; use super::int::IntKind; use super::layout::Layout; use super::context::BindgenContext; -use super::context::TypeResolver; use parse::{ClangItemParser, ParseResult, ParseError}; use clang::{self, Cursor}; @@ -117,7 +116,7 @@ impl Type { self.is_const } - pub fn layout(&self, type_resolver: &TypeResolver) -> Option<Layout> { + pub fn layout(&self, type_resolver: &BindgenContext) -> Option<Layout> { use std::mem; self.layout.or_else(|| { @@ -136,11 +135,11 @@ impl Type { }) } - pub fn is_opaque(&self, _type_resolver: &TypeResolver) -> bool { + pub fn is_opaque(&self, _type_resolver: &BindgenContext) -> bool { self.opaque } - pub fn can_derive_debug(&self, type_resolver: &TypeResolver) -> bool { + pub fn can_derive_debug(&self, type_resolver: &BindgenContext) -> bool { !self.is_opaque(type_resolver) && match self.kind { TypeKind::Array(t, len) => { len <= RUST_DERIVE_IN_ARRAY_LIMIT && @@ -175,7 +174,7 @@ impl Type { // is an error. // // That's the point of the existence of can_derive_copy_in_array(). - pub fn can_derive_copy_in_array(&self, type_resolver: &TypeResolver, item: &Item) -> bool { + pub fn can_derive_copy_in_array(&self, type_resolver: &BindgenContext, item: &Item) -> bool { match self.kind { TypeKind::ResolvedTypeRef(t) | TypeKind::Alias(_, t) | @@ -188,7 +187,7 @@ impl Type { } } - pub fn can_derive_copy(&self, type_resolver: &TypeResolver, item: &Item) -> bool { + pub fn can_derive_copy(&self, type_resolver: &BindgenContext, item: &Item) -> bool { !self.is_opaque(type_resolver) && match self.kind { TypeKind::Array(t, len) => { len <= RUST_DERIVE_IN_ARRAY_LIMIT && @@ -206,7 +205,7 @@ impl Type { } } - pub fn has_vtable(&self, type_resolver: &TypeResolver) -> bool { + pub fn has_vtable(&self, type_resolver: &BindgenContext) -> bool { // FIXME: Can we do something about template parameters? Huh... match self.kind { TypeKind::TemplateRef(t, _) | @@ -223,7 +222,7 @@ impl Type { } - pub fn has_destructor(&self, type_resolver: &TypeResolver) -> bool { + pub fn has_destructor(&self, type_resolver: &BindgenContext) -> bool { self.is_opaque(type_resolver) || match self.kind { TypeKind::TemplateRef(t, _) | TypeKind::Alias(_, t) | @@ -239,7 +238,7 @@ impl Type { } pub fn signature_contains_named_type(&self, - type_resolver: &TypeResolver, + type_resolver: &BindgenContext, ty: &Type) -> bool { debug_assert!(ty.is_named()); let name = match *ty.kind() { @@ -276,7 +275,7 @@ impl Type { } } - pub fn canonical_type<'tr>(&'tr self, type_resolver: &'tr TypeResolver) -> &'tr Type { + pub fn canonical_type<'tr>(&'tr self, type_resolver: &'tr BindgenContext) -> &'tr Type { match self.kind { TypeKind::Named(..) | TypeKind::Array(..) | @@ -362,7 +361,7 @@ pub enum TypeKind { } impl Type { - pub fn is_unsized(&self, type_resolver: &TypeResolver) -> bool { + pub fn is_unsized(&self, type_resolver: &BindgenContext) -> bool { match self.kind { TypeKind::Void => true, TypeKind::Comp(ref ci) => ci.is_unsized(type_resolver), |