Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cargo fmt #471

Merged
merged 1 commit into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chooser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A public API for more fine-grained customization of bindgen behavior.

pub use ir::enum_ty::{EnumVariantCustomBehavior, EnumVariantValue};
pub use ir::int::IntKind;
pub use ir::enum_ty::{EnumVariantValue, EnumVariantCustomBehavior};
use std::fmt;

/// A trait to allow configuring different kinds of types in different
Expand Down
110 changes: 70 additions & 40 deletions src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ impl Cursor {
/// Is the referent a fully specialized template specialization without any
/// remaining free template arguments?
pub fn is_fully_specialized_template(&self) -> bool {
self.is_template_specialization() && self.num_template_args().unwrap_or(0) > 0
self.is_template_specialization() &&
self.num_template_args().unwrap_or(0) > 0
}

/// Is the referent a template specialization that still has remaining free
Expand Down Expand Up @@ -349,13 +350,11 @@ impl Cursor {
pub fn contains_cursor(&self, kind: CXCursorKind) -> bool {
let mut found = false;

self.visit(|c| {
if c.kind() == kind {
found = true;
CXChildVisit_Break
} else {
CXChildVisit_Continue
}
self.visit(|c| if c.kind() == kind {
found = true;
CXChildVisit_Break
} else {
CXChildVisit_Continue
});

found
Expand Down Expand Up @@ -846,8 +845,8 @@ impl SourceLocation {
&mut col,
&mut off);
(File {
x: file,
},
x: file,
},
line as usize,
col as usize,
off as usize)
Expand Down Expand Up @@ -1282,17 +1281,32 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {

fn print_cursor<S: AsRef<str>>(depth: isize, prefix: S, c: &Cursor) {
let prefix = prefix.as_ref();
print_indent(depth, format!(" {}kind = {}", prefix, kind_to_str(c.kind())));
print_indent(depth, format!(" {}spelling = \"{}\"", prefix, c.spelling()));
print_indent(depth,
format!(" {}kind = {}", prefix, kind_to_str(c.kind())));
print_indent(depth,
format!(" {}spelling = \"{}\"", prefix, c.spelling()));
print_indent(depth, format!(" {}location = {}", prefix, c.location()));
print_indent(depth, format!(" {}is-definition? {}", prefix, c.is_definition()));
print_indent(depth, format!(" {}is-declaration? {}", prefix, c.is_declaration()));
print_indent(depth, format!(" {}is-anonymous? {}", prefix, c.is_anonymous()));
print_indent(depth, format!(" {}is-inlined-function? {}", prefix, c.is_inlined_function()));
print_indent(depth,
format!(" {}is-definition? {}",
prefix,
c.is_definition()));
print_indent(depth,
format!(" {}is-declaration? {}",
prefix,
c.is_declaration()));
print_indent(depth,
format!(" {}is-anonymous? {}", prefix, c.is_anonymous()));
print_indent(depth,
format!(" {}is-inlined-function? {}",
prefix,
c.is_inlined_function()));

let templ_kind = c.template_kind();
if templ_kind != CXCursor_NoDeclFound {
print_indent(depth, format!(" {}template-kind = {}", prefix, kind_to_str(templ_kind)));
print_indent(depth,
format!(" {}template-kind = {}",
prefix,
kind_to_str(templ_kind)));
}
if let Some(usr) = c.usr() {
print_indent(depth, format!(" {}usr = \"{}\"", prefix, usr));
Expand All @@ -1301,38 +1315,53 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
print_indent(depth, format!(" {}number-of-args = {}", prefix, num));
}
if let Some(num) = c.num_template_args() {
print_indent(depth, format!(" {}number-of-template-args = {}", prefix, num));
print_indent(depth,
format!(" {}number-of-template-args = {}",
prefix,
num));
}
if let Some(width) = c.bit_width() {
print_indent(depth, format!(" {}bit-width = {}", prefix, width));
}
if let Some(ty) = c.enum_type() {
print_indent(depth, format!(" {}enum-type = {}", prefix, type_to_str(ty.kind())));
print_indent(depth,
format!(" {}enum-type = {}",
prefix,
type_to_str(ty.kind())));
}
if let Some(val) = c.enum_val_signed() {
print_indent(depth, format!(" {}enum-val = {}", prefix, val));
}
if let Some(ty) = c.typedef_type() {
print_indent(depth, format!(" {}typedef-type = {}", prefix, type_to_str(ty.kind())));
print_indent(depth,
format!(" {}typedef-type = {}",
prefix,
type_to_str(ty.kind())));
}

if let Some(refd) = c.referenced() {
if refd != *c {
println!();
print_cursor(depth, String::from(prefix) + "referenced.", &refd);
print_cursor(depth,
String::from(prefix) + "referenced.",
&refd);
}
}

let canonical = c.canonical();
if canonical != *c {
println!();
print_cursor(depth, String::from(prefix) + "canonical.", &canonical);
print_cursor(depth,
String::from(prefix) + "canonical.",
&canonical);
}

if let Some(specialized) = c.specialized() {
if specialized != *c {
println!();
print_cursor(depth, String::from(prefix) + "specialized.", &specialized);
print_cursor(depth,
String::from(prefix) + "specialized.",
&specialized);
}
}
}
Expand All @@ -1346,19 +1375,22 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
return;
}

print_indent(depth, format!(" {}spelling = \"{}\"", prefix, ty.spelling()));
let num_template_args = unsafe {
clang_Type_getNumTemplateArguments(ty.x)
};
print_indent(depth,
format!(" {}spelling = \"{}\"", prefix, ty.spelling()));
let num_template_args =
unsafe { clang_Type_getNumTemplateArguments(ty.x) };
if num_template_args >= 0 {
print_indent(depth, format!(" {}number-of-template-args = {}",
prefix,
num_template_args));
print_indent(depth,
format!(" {}number-of-template-args = {}",
prefix,
num_template_args));
}
if let Some(num) = ty.num_elements() {
print_indent(depth, format!(" {}number-of-elements = {}", prefix, num));
print_indent(depth,
format!(" {}number-of-elements = {}", prefix, num));
}
print_indent(depth, format!(" {}is-variadic? {}", prefix, ty.is_variadic()));
print_indent(depth,
format!(" {}is-variadic? {}", prefix, ty.is_variadic()));

let canonical = ty.canonical_type();
if canonical != *ty {
Expand Down Expand Up @@ -1449,14 +1481,12 @@ impl EvalResult {
// unexposed type. Our solution is to just flat out ban all
// `CXType_Unexposed` from evaluation.
let mut found_cant_eval = false;
cursor.visit(|c| {
if c.kind() == CXCursor_TypeRef &&
c.cur_type().kind() == CXType_Unexposed {
found_cant_eval = true;
CXChildVisit_Break
} else {
CXChildVisit_Recurse
}
cursor.visit(|c| if c.kind() == CXCursor_TypeRef &&
c.cur_type().kind() == CXType_Unexposed {
found_cant_eval = true;
CXChildVisit_Break
} else {
CXChildVisit_Recurse
});
if found_cant_eval {
return None;
Expand Down
Loading