Skip to content
New issue

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

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

Already on GitHub? # to your account

Some cargo-fmt corrections. #206

Merged
merged 1 commit into from
Nov 4, 2016
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
12 changes: 9 additions & 3 deletions src/bin/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern crate log;
extern crate clang_sys;
extern crate rustc_serialize;

use bindgen::{BindgenOptions, Bindings, LinkType, ClangVersion, clang_version};
use bindgen::{BindgenOptions, Bindings, ClangVersion, LinkType, clang_version};
use std::default::Default;
use std::env;
use std::fs;
Expand Down Expand Up @@ -233,14 +233,20 @@ pub fn main() {
let mut bind_args: Vec<_> = env::args().collect();

let version = clang_version();
let expected_version = if cfg!(feature = "llvm_stable") { (3,8) } else { (3,9) };
let expected_version = if cfg!(feature = "llvm_stable") {
(3, 8)
} else {
(3, 9)
};

info!("Clang Version: {}", version.full);

match version.parsed {
None => warn!("Couldn't parse libclang version"),
Some(version) if version != expected_version => {
error!("Using clang {:?}, expected {:?}", version, expected_version);
error!("Using clang {:?}, expected {:?}",
version,
expected_version);
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl Cursor {
pub fn specialized(&self) -> Option<Cursor> {
unsafe {
let ret = Cursor {
x: clang_getSpecializedCursorTemplate(self.x)
x: clang_getSpecializedCursorTemplate(self.x),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! My fault :(

};
if ret.is_valid() { Some(ret) } else { None }
}
Expand Down
4 changes: 3 additions & 1 deletion src/ir/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ pub trait ItemCanonicalPath {
/// up to (but not including) the implicit root module.
pub trait ItemAncestors {
/// Get an iterable over this item's ancestors.
fn ancestors<'a, 'b>(&self, ctx: &'a BindgenContext<'b>) -> ItemAncestorsIter<'a, 'b>;
fn ancestors<'a, 'b>(&self,
ctx: &'a BindgenContext<'b>)
-> ItemAncestorsIter<'a, 'b>;
}

/// An iterator over an item and its ancestors.
Expand Down
27 changes: 16 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,32 +496,37 @@ fn parse(context: &mut BindgenContext) {
#[derive(Debug)]
pub struct ClangVersion {
/// Major and minor semvar, if parsing was successful
pub parsed: Option<(u32,u32)>,
pub parsed: Option<(u32, u32)>,
/// full version string
pub full: String,
}

/// Get the major and the minor semvar numbers of Clang's version
pub fn clang_version() -> ClangVersion {
let raw_v: String = clang::extract_clang_version();
let split_v: Option<Vec<&str>> = raw_v
.split_whitespace()
let split_v: Option<Vec<&str>> = raw_v.split_whitespace()
.nth(2)
.map(|v| v.split('.').collect());
match split_v {
Some(v) => {
if v.len() >= 2 {
let maybe_major = v[0].parse::<u32>();
let maybe_minor = v[1].parse::<u32>();
match (maybe_major,maybe_minor) {
(Ok(major),Ok(minor)) => return ClangVersion { parsed: Some((major,minor)), full: raw_v.clone() },
_ => {},
match (maybe_major, maybe_minor) {
(Ok(major), Ok(minor)) => {
return ClangVersion {
parsed: Some((major, minor)),
full: raw_v.clone(),
}
}
_ => {}
}
}
},
None => {},
}
None => {}
};
ClangVersion { parsed: None, full: raw_v.clone() }
ClangVersion {
parsed: None,
full: raw_v.clone(),
}
}