mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Autogenerate Servo_ binding functions with cbindgen.
This depends on https://github.com/eqrion/cbindgen/pull/308. Other than that, this should be ready to go. There's still a bit more magic than what I'd like to eventually. I should be able to make cbindgen not rename types if it doesn't know about them, or something. But this removes most of the manual binding function implementations (all but the ones that are declared via macros, which cbindgen doesn't see across). I need to give up on the _Drop functions taking an Owned<T> because of instantiation order fiasco. In order to define DefaultDelete I need Owned to be complete, but I cannot do it after including the generated file since some declarations already instantiate the specialization. Oh well. Differential Revision: https://phabricator.services.mozilla.com/D24798
This commit is contained in:
parent
debd837bf0
commit
2f8e05e9e0
2 changed files with 8 additions and 247 deletions
|
@ -65,6 +65,14 @@ pub unsafe trait HasBoxFFI: HasSimpleFFI {
|
|||
fn into_ffi(self: Box<Self>) -> Owned<Self::FFIType> {
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
||||
/// Drops an owned FFI pointer. This conceptually takes the
|
||||
/// Owned<Self::FFIType>, except it's a bit of a paint to do that without
|
||||
/// much benefit.
|
||||
#[inline]
|
||||
unsafe fn drop_ffi(ptr: *mut Self::FFIType) {
|
||||
let _ = Box::from_raw(ptr as *mut Self);
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper trait for conversions between FFI Strong/Borrowed types and Arcs
|
||||
|
@ -268,14 +276,6 @@ pub struct Owned<GeckoType> {
|
|||
}
|
||||
|
||||
impl<GeckoType> Owned<GeckoType> {
|
||||
/// Gets this `Owned` type as a `Box<ServoType>`.
|
||||
pub fn into_box<ServoType>(self) -> Box<ServoType>
|
||||
where
|
||||
ServoType: HasBoxFFI<FFIType = GeckoType>,
|
||||
{
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
||||
/// Converts this instance to a (non-null) instance of `OwnedOrNull`.
|
||||
pub fn maybe(self) -> OwnedOrNull<GeckoType> {
|
||||
unsafe { transmute(self) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue