style: Simplify Owned FFI types.

And make them actually sound. We're defining functions on Rust-land that get
structs as arguments, but declaring them in C++ as getting pointers.

This is another step in order to be able to autogenerate ServoBindings.h and
remove bindings.rs altogether.

We remove FooOwned in favor of Owned<Foo>, which is generated via cbindgen.

It'd be good to actually mark Owned and such as MOZ_MUST_USE_TYPE, so I sent
https://github.com/eqrion/cbindgen/pull/307 for that.

Differential Revision: https://phabricator.services.mozilla.com/D24681
This commit is contained in:
Emilio Cobos Álvarez 2019-03-26 13:25:42 +00:00
parent 64f19ae34d
commit 02bc29a11b
3 changed files with 20 additions and 44 deletions

View file

@ -258,13 +258,6 @@ mod bindings {
.collect()
}
fn get_boxed_types() -> Vec<String> {
get_types("ServoBoxedTypeList.h", "SERVO_BOXED_TYPE")
.into_iter()
.map(|(_, type_name)| type_name)
.collect()
}
struct BuilderWithConfig<'a> {
builder: Builder,
config: &'a Table,
@ -453,22 +446,6 @@ mod bindings {
ty
));
}
for ty in get_boxed_types().iter() {
builder = builder
.blacklist_type(format!("{}Owned", ty))
.raw_line(format!(
"pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;",
ty
))
.blacklist_type(format!("{}OwnedOrNull", ty))
.raw_line(format!(
concat!(
"pub type {0}OwnedOrNull = ",
"::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"
),
ty
));
}
write_binding_file(builder, BINDINGS_FILE, &fixups);
}