Skip to content

Commit

Permalink
upstream rust changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfager committed Feb 17, 2015
1 parent f43729e commit 3cfa3c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const LINUX_CLANG_DIRS: &'static [&'static str] = &["/usr/lib", "/usr/lib/llvm",
const MAC_CLANG_DIR: &'static str = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib";

fn main() {
let possible_clang_dirs = if let Ok(dir) = env::var_string("LIBCLANG_PATH") {
let possible_clang_dirs = if let Ok(dir) = env::var("LIBCLANG_PATH") {
vec![dir]
} else if cfg!(any(target_os = "linux", target_os = "freebsd")) {
LINUX_CLANG_DIRS.iter().map(ToString::to_string).collect()
Expand Down
16 changes: 8 additions & 8 deletions src/bgmacro.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::default::Default;
use std::os;
use std::env;

use syntax::ast;
use syntax::codemap;
Expand Down Expand Up @@ -29,12 +29,12 @@ pub fn bindgen_macro(cx: &mut base::ExtCtxt, sp: codemap::Span, tts: &[ast::Toke
// Set the working dir to the directory containing the invoking rs file so
// that clang searches for headers relative to it rather than the crate root
let mod_dir = Path::new(cx.codemap().span_to_filename(sp)).dirname().to_vec();
let cwd = match os::getcwd() {
let cwd = match env::current_dir() {
Ok(d) => d,
Err(e) => panic!("Invalid current working directory: {}", e),
};
let p = Path::new(mod_dir);
if let Err(e) = os::change_dir(&p) {
if let Err(e) = env::set_current_dir(&p) {
panic!("Failed to change to directory {}: {}", p.display(), e);
};

Expand All @@ -53,7 +53,7 @@ pub fn bindgen_macro(cx: &mut base::ExtCtxt, sp: codemap::Span, tts: &[ast::Toke
};

let p = Path::new(cwd);
if let Err(e) = os::change_dir(&p) {
if let Err(e) = env::set_current_dir(&p) {
panic!("Failed to return to directory {}: {}", p.display(), e);
}

Expand Down Expand Up @@ -124,7 +124,7 @@ fn parse_macro_opts(cx: &mut base::ExtCtxt, tts: &[ast::TokenTree], visit: &mut
match parser.bump_and_get() {
token::Ident(ident, _) => {
let ident = parser.id_to_interned_str(ident);
name = Some((*ident).to_string());
name = Some(ident.to_string());
parser.expect(&token::Eq);
},
_ => {
Expand All @@ -140,9 +140,9 @@ fn parse_macro_opts(cx: &mut base::ExtCtxt, tts: &[ast::TokenTree], visit: &mut
let val = parser.id_to_interned_str(val);
span.hi = parser.span.hi;
parser.bump();

// Bools are simply encoded as idents
let ret = match (*val).as_slice() {
let ret = match &*val {
"true" => visit.visit_bool(as_str(&name), true),
"false" => visit.visit_bool(as_str(&name), false),
val => visit.visit_ident(as_str(&name), val)
Expand All @@ -159,7 +159,7 @@ fn parse_macro_opts(cx: &mut base::ExtCtxt, tts: &[ast::TokenTree], visit: &mut
match expr.node {
ast::ExprLit(ref lit) => {
let ret = match lit.node {
ast::LitStr(ref s, _) => visit.visit_str(as_str(&name), (*s).as_slice()),
ast::LitStr(ref s, _) => visit.visit_str(as_str(&name), &*s),
ast::LitBool(b) => visit.visit_bool(as_str(&name), b),
ast::LitInt(i, ast::SignedIntLit(_, sign)) |
ast::LitInt(i, ast::UnsuffixedIntLit(sign)) => {
Expand Down
22 changes: 11 additions & 11 deletions src/bin/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern crate syntax;

use bindgen::{Bindings, BindgenOptions, LinkType, Logger};
use std::old_io as io;
use std::os;
use std::old_path as path;
use std::env;
use std::default::Default;
use std::old_io::fs;

Expand Down Expand Up @@ -42,11 +42,11 @@ fn parse_args(args: &[String]) -> ParseResult {

let mut ix = 0us;
while ix < args_len {
if args[ix].len() > 2 && args[ix].as_slice().slice_to(2) == "-l" {
options.links.push((args[ix].as_slice().slice_from(2).to_string(), LinkType::Default));
if args[ix].len() > 2 && &args[ix][..2] == "-l" {
options.links.push((args[ix][2..].to_string(), LinkType::Default));
ix += 1;
} else {
match args[ix].as_slice() {
match &args[ix][] {
"--help" | "-h" => {
return ParseResult::CmdUsage;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ fn parse_args(args: &[String]) -> ParseResult {
}

fn print_usage(bin: String) {
let mut s = format!("Usage: {} [options] input.h", bin.as_slice());
let mut s = format!("Usage: {} [options] input.h", &bin[]);
s.push_str(
"
Options:
Expand Down Expand Up @@ -154,14 +154,14 @@ Options:
Options other than stated above are passed to clang.
"
);
io::stdio::print(s.as_slice());
io::stdio::print(&s[]);
}

pub fn main() {
let mut bind_args = os::args();
let mut bind_args: Vec<_> = env::args().collect();
let bin = bind_args.remove(0);

match parse_args(bind_args.as_slice()) {
match parse_args(&bind_args[]) {
ParseResult::ParseErr(e) => panic!(e),
ParseResult::CmdUsage => print_usage(bin),
ParseResult::ParseOk(options, mut out) => {
Expand All @@ -170,11 +170,11 @@ pub fn main() {
Ok(bindings) => match bindings.write(&mut out) {
Ok(()) => (),
Err(e) => {
logger.error(format!("Unable to write bindings to file. {}", e).as_slice());
os::set_exit_status(-1);
logger.error(&format!("Unable to write bindings to file. {}", e)[]);
env::set_exit_status(-1);
}
},
Err(()) => os::set_exit_status(-1)
Err(()) => env::set_exit_status(-1)
}
}
}
Expand Down

0 comments on commit 3cfa3c2

Please sign in to comment.