Declare nullable strong borrowed ref type for RawServoDeclarationBlock.

This commit is contained in:
Manish Goregaokar 2016-10-18 15:50:23 +11:00 committed by Xidorn Quan
parent edeeafe5a7
commit f967647226
3 changed files with 17 additions and 0 deletions

View file

@ -319,6 +319,7 @@ COMPILATION_TARGETS = {
"RawGeckoNode",
"RawGeckoElement",
"RawGeckoDocument",
"RawServoDeclarationBlockStrong",
],
"whitelist_functions": [
"Servo_.*",

View file

@ -21,6 +21,8 @@ pub type RawGeckoElementBorrowed<'a> = &'a RawGeckoElement;
pub type RawGeckoElementBorrowedOrNull<'a> = Option<&'a RawGeckoElement>;
pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument;
pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>;
pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong;
pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>;
pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet;
pub type RawServoStyleSetBorrowedMut<'a> = &'a mut RawServoStyleSet;
pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;

View file

@ -161,6 +161,20 @@ impl<T> Strong<T> {
}
}
#[inline]
/// Given a reference to a strong FFI reference,
/// converts it to a reference to a servo-side Arc
/// Returns None on null.
///
/// Strong<GeckoType> -> Arc<ServoType>
pub fn as_arc_opt<U>(&self) -> Option<&Arc<U>> where U: HasArcFFI<FFIType = T> {
if self.is_null() {
None
} else {
unsafe { Some(transmute(self)) }
}
}
#[inline]
/// Produces a null strong FFI reference
pub fn null() -> Self {