Auto merge of #548 - burtonageo:update_foreign_types, r=jdm
Update `foreign-types` crate to v0.5 Splits out the `foreign-types` part of https://github.com/servo/core-foundation-rs/pull/545
This commit is contained in:
@@ -16,7 +16,7 @@ highsierra = []
|
||||
bitflags = "1.0"
|
||||
core-foundation = { path = "../core-foundation", version = "0.9" }
|
||||
core-graphics-types = { path = "../core-graphics-types", version = "0.1" }
|
||||
foreign-types = "0.3.0"
|
||||
foreign-types = "0.5.0"
|
||||
libc = "0.2"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
||||
@@ -13,11 +13,11 @@ use foreign_types::ForeignType;
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGColorSpace;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGColorSpace;
|
||||
pub struct CGColorSpaceRef;
|
||||
pub unsafe type CGColorSpace {
|
||||
type CType = ::sys::CGColorSpace;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGColorSpace {
|
||||
|
||||
@@ -109,11 +109,11 @@ pub enum CGInterpolationQuality {
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGContext;
|
||||
fn drop = |cs| CGContextRelease(cs);
|
||||
fn clone = |p| CGContextRetain(p);
|
||||
pub struct CGContext;
|
||||
pub struct CGContextRef;
|
||||
pub unsafe type CGContext {
|
||||
type CType = ::sys::CGContext;
|
||||
fn drop = |cs| CGContextRelease(cs);
|
||||
fn clone = |p| CGContextRetain(p);
|
||||
}
|
||||
}
|
||||
|
||||
impl CGContext {
|
||||
|
||||
@@ -32,11 +32,11 @@ pub type CGDataProviderGetBytesAtPositionCallback = Option<unsafe extern fn (*mu
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGDataProvider;
|
||||
fn drop = |cs| CFRelease(cs as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGDataProvider;
|
||||
pub struct CGDataProviderRef;
|
||||
pub unsafe type CGDataProvider {
|
||||
type CType = ::sys::CGDataProvider;
|
||||
fn drop = |cs| CFRelease(cs as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGDataProvider {
|
||||
|
||||
@@ -116,11 +116,11 @@ pub struct CGDisplay {
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGDisplayMode;
|
||||
fn drop = CGDisplayModeRelease;
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGDisplayMode;
|
||||
pub struct CGDisplayModeRef;
|
||||
pub unsafe type CGDisplayMode {
|
||||
type CType = ::sys::CGDisplayMode;
|
||||
fn drop = CGDisplayModeRelease;
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGDisplay {
|
||||
|
||||
@@ -518,11 +518,11 @@ impl<'tap_life> CGEventTap<'tap_life> {
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGEvent;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGEvent;
|
||||
pub struct CGEventRef;
|
||||
pub unsafe type CGEvent {
|
||||
type CType = ::sys::CGEvent;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGEvent {
|
||||
|
||||
@@ -12,11 +12,11 @@ pub enum CGEventSourceStateID {
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGEventSource;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGEventSource;
|
||||
pub struct CGEventSourceRef;
|
||||
pub unsafe type CGEventSource {
|
||||
type CType = ::sys::CGEventSource;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGEventSource {
|
||||
|
||||
+15
-20
@@ -15,6 +15,7 @@ use core_foundation::string::{CFString, CFStringRef};
|
||||
use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
|
||||
use data_provider::CGDataProvider;
|
||||
use geometry::CGRect;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use foreign_types::ForeignType;
|
||||
|
||||
@@ -24,16 +25,13 @@ pub use core_graphics_types::base::CGGlyph;
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGFont;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGFont;
|
||||
pub struct CGFontRef;
|
||||
pub unsafe type CGFont: Send + Sync {
|
||||
type CType = ::sys::CGFont;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for CGFont {}
|
||||
unsafe impl Sync for CGFont {}
|
||||
|
||||
impl CGFont {
|
||||
pub fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
@@ -44,10 +42,9 @@ impl CGFont {
|
||||
pub fn from_data_provider(provider: CGDataProvider) -> Result<CGFont, ()> {
|
||||
unsafe {
|
||||
let font_ref = CGFontCreateWithDataProvider(provider.as_ptr());
|
||||
if !font_ref.is_null() {
|
||||
Ok(CGFont::from_ptr(font_ref))
|
||||
} else {
|
||||
Err(())
|
||||
match NonNull::new(font_ref) {
|
||||
Some(font_ref) => Ok(CGFont(font_ref)),
|
||||
None => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,10 +52,9 @@ impl CGFont {
|
||||
pub fn from_name(name: &CFString) -> Result<CGFont, ()> {
|
||||
unsafe {
|
||||
let font_ref = CGFontCreateWithFontName(name.as_concrete_TypeRef());
|
||||
if !font_ref.is_null() {
|
||||
Ok(CGFont::from_ptr(font_ref))
|
||||
} else {
|
||||
Err(())
|
||||
match NonNull::new(font_ref) {
|
||||
Some(font_ref) => Ok(CGFont(font_ref)),
|
||||
None => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,10 +63,9 @@ impl CGFont {
|
||||
unsafe {
|
||||
let font_ref = CGFontCreateCopyWithVariations(self.as_ptr(),
|
||||
vars.as_concrete_TypeRef());
|
||||
if !font_ref.is_null() {
|
||||
Ok(CGFont::from_ptr(font_ref))
|
||||
} else {
|
||||
Err(())
|
||||
match NonNull::new(font_ref) {
|
||||
Some(font_ref) => Ok(CGFont(font_ref)),
|
||||
None => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ bitflags! {
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGGradient;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGGradient;
|
||||
pub struct CGGradientRef;
|
||||
pub unsafe type CGGradient {
|
||||
type CType = ::sys::CGGradient;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGGradient {
|
||||
|
||||
@@ -32,11 +32,11 @@ pub enum CGImageByteOrderInfo {
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGImage;
|
||||
fn drop = CGImageRelease;
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGImage;
|
||||
pub struct CGImageRef;
|
||||
pub unsafe type CGImage {
|
||||
type CType = ::sys::CGImage;
|
||||
fn drop = CGImageRelease;
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGImage {
|
||||
|
||||
@@ -21,11 +21,11 @@ use std::slice;
|
||||
|
||||
foreign_type! {
|
||||
#[doc(hidden)]
|
||||
type CType = ::sys::CGPath;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
pub struct CGPath;
|
||||
pub struct CGPathRef;
|
||||
pub unsafe type CGPath {
|
||||
type CType = ::sys::CGPath;
|
||||
fn drop = |p| CFRelease(p as *mut _);
|
||||
fn clone = |p| CFRetain(p as *const _) as *mut _;
|
||||
}
|
||||
}
|
||||
|
||||
impl CGPath {
|
||||
@@ -35,7 +35,7 @@ impl CGPath {
|
||||
None => ptr::null(),
|
||||
Some(transform) => transform as *const CGAffineTransform,
|
||||
};
|
||||
CGPath(CGPathCreateWithRect(rect, transform))
|
||||
CGPath::from_ptr(CGPathCreateWithRect(rect, transform))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user