mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
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:
parent
64f19ae34d
commit
02bc29a11b
3 changed files with 20 additions and 44 deletions
|
@ -320,27 +320,6 @@ impl<GeckoType> OwnedOrNull<GeckoType> {
|
|||
self.ptr.is_null()
|
||||
}
|
||||
|
||||
/// Returns an owned pointer if this is non-null, and `None` otherwise.
|
||||
pub fn into_box_opt<ServoType>(self) -> Option<Box<ServoType>>
|
||||
where
|
||||
ServoType: HasBoxFFI<FFIType = GeckoType>,
|
||||
{
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { transmute(self) })
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an `Owned<GeckoType>` if non-null, `None` otherwise.
|
||||
pub fn into_owned_opt(self) -> Option<Owned<GeckoType>> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { transmute(self) })
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a immutable reference to the underlying Gecko type, or `None` if
|
||||
/// null.
|
||||
pub fn borrow(&self) -> Option<&GeckoType> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue