style: Apply rustfmt on build_gecko.rs.

Bug: 1499359
Reviewed-by: emilio
This commit is contained in:
Benjamin Bouvier 2018-10-16 15:18:26 +02:00 committed by Emilio Cobos Álvarez
parent ff34daa384
commit ecb9de4acd
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -260,8 +260,7 @@ mod bindings {
fn get_types(filename: &str, macro_pat: &str) -> Vec<(String, String)> { fn get_types(filename: &str, macro_pat: &str) -> Vec<(String, String)> {
// Read the file // Read the file
let path = DISTDIR_PATH.join("include/mozilla/").join(filename); let path = DISTDIR_PATH.join("include/mozilla/").join(filename);
let mut list_file = File::open(path) let mut list_file = File::open(path).expect(&format!("Unable to open {}", filename));
.expect(&format!("Unable to open {}", filename));
let mut content = String::new(); let mut content = String::new();
list_file list_file
.read_to_string(&mut content) .read_to_string(&mut content)
@ -279,12 +278,9 @@ mod bindings {
.map(|line| line.trim()) .map(|line| line.trim())
.filter(|line| !line.is_empty()) .filter(|line| !line.is_empty())
.map(|line| { .map(|line| {
let captures = re.captures(&line) let captures = re
.expect(&format!( .captures(&line)
"Unrecognized line in {}: '{}'", .expect(&format!("Unrecognized line in {}: '{}'", filename, line));
filename,
line
));
let macro_name = captures.get(1).unwrap().as_str().to_string(); let macro_name = captures.get(1).unwrap().as_str().to_string();
let type_name = captures.get(2).unwrap().as_str().to_string(); let type_name = captures.get(2).unwrap().as_str().to_string();
(macro_name, type_name) (macro_name, type_name)
@ -294,9 +290,7 @@ mod bindings {
fn get_borrowed_types() -> Vec<(bool, String)> { fn get_borrowed_types() -> Vec<(bool, String)> {
get_types("BorrowedTypeList.h", "GECKO_BORROWED_TYPE(?:_MUT)?") get_types("BorrowedTypeList.h", "GECKO_BORROWED_TYPE(?:_MUT)?")
.into_iter() .into_iter()
.map(|(macro_name, type_name)| { .map(|(macro_name, type_name)| (macro_name.ends_with("MUT"), type_name))
(macro_name.ends_with("MUT"), type_name)
})
.collect() .collect()
} }
@ -535,11 +529,17 @@ mod bindings {
for ty in get_boxed_types().iter() { for ty in get_boxed_types().iter() {
builder = builder builder = builder
.blacklist_type(format!("{}Owned", ty)) .blacklist_type(format!("{}Owned", ty))
.raw_line(format!("pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;", ty)) .raw_line(format!(
.blacklist_type(format!("{}OwnedOrNull", ty)) "pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;",
.raw_line(format!(concat!("pub type {0}OwnedOrNull = ", ty
"::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"), ty)) )).blacklist_type(format!("{}OwnedOrNull", ty))
.mutable_borrowed_type(ty) .raw_line(format!(
concat!(
"pub type {0}OwnedOrNull = ",
"::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"
),
ty
)).mutable_borrowed_type(ty)
.zero_size_type(ty, &structs_types); .zero_size_type(ty, &structs_types);
} }
write_binding_file(builder, BINDINGS_FILE, &fixups); write_binding_file(builder, BINDINGS_FILE, &fixups);