From 4ef941f09e58c122c96f15cecc7bd97e145bed01 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 30 Jan 2013 14:33:39 -0800 Subject: [PATCH] Rust upgrade --- data_provider.rs | 6 ++++-- font.rs | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/data_provider.rs b/data_provider.rs index c7054db..d4268e9 100644 --- a/data_provider.rs +++ b/data_provider.rs @@ -19,12 +19,13 @@ pub type CGDataProviderRef = *__CGDataProvider; pub impl CGDataProviderRef : AbstractCFTypeRef { pure fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } - static pure fn type_id() -> CFTypeID unsafe { CGDataProviderGetTypeID() } + static pure fn type_id() -> CFTypeID { unsafe { CGDataProviderGetTypeID() } } } pub type CGDataProvider = CFWrapper; -pub fn new_from_buffer(buf: *u8, len: uint) -> CGDataProvider unsafe { +pub fn new_from_buffer(buf: *u8, len: uint) -> CGDataProvider { + unsafe { let result = CGDataProviderCreateWithData( ptr::null(), cast::transmute(buf), @@ -32,6 +33,7 @@ pub fn new_from_buffer(buf: *u8, len: uint) -> CGDataProvider unsafe { ptr::null()); CFWrapper::wrap_owned(result) + } } #[nolink] diff --git a/font.rs b/font.rs index 9fdd7a7..5f504d5 100644 --- a/font.rs +++ b/font.rs @@ -11,15 +11,17 @@ pub type CGFontRef = *__CGFont; pub impl CGFontRef : AbstractCFTypeRef { pure fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } - static pure fn type_id() -> CFTypeID unsafe { CGFontGetTypeID() } + static pure fn type_id() -> CFTypeID { unsafe { CGFontGetTypeID() } } } pub type CGFont = CFWrapper; pub fn create_with_data_provider(provider: &CGDataProvider) -> CGFont { - // TODO: error handling - let value = CGFontCreateWithDataProvider(*provider.borrow_ref()); - CFWrapper::wrap_owned(value) + unsafe { + // TODO: error handling + let value = CGFontCreateWithDataProvider(*provider.borrow_ref()); + CFWrapper::wrap_owned(value) + } } #[nolink]