Merge pull request #18 from SimonSapin/rust-upgrade
Upgrade to rustc 0.8-pre (0ac3e02 2013-08-30 05:45:45 -0700)
This commit is contained in:
@@ -40,7 +40,7 @@ pub type CFArrayRef = *__CFArray;
|
||||
impl AbstractCFTypeRef for CFArrayRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID { unsafe { CFArrayGetTypeID() } }
|
||||
fn type_id(_dummy: Option<CFArrayRef>) -> CFTypeID { unsafe { CFArrayGetTypeID() } }
|
||||
}
|
||||
|
||||
// FIXME: Should be a newtype struct, but that fails due to a Rust compiler bug.
|
||||
|
||||
@@ -16,7 +16,9 @@ use std::libc::c_long;
|
||||
// borrow semantics.
|
||||
pub trait AbstractCFTypeRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef;
|
||||
fn type_id() -> CFTypeID;
|
||||
|
||||
// FIXME https://github.com/mozilla-servo/rust-core-foundation/issues/17
|
||||
fn type_id(_dummy: Option<Self>) -> CFTypeID;
|
||||
}
|
||||
|
||||
pub type Boolean = u8;
|
||||
@@ -48,13 +50,14 @@ pub type CFTypeRef = *__CFType;
|
||||
impl AbstractCFTypeRef for CFTypeRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self }
|
||||
// this can't be used, because CFType is the supertype and has no type id.
|
||||
fn type_id() -> CFTypeID { fail!(); }
|
||||
fn type_id(_dummy: Option<CFTypeRef>) -> CFTypeID { fail!(); }
|
||||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub fn downcast<T:AbstractCFTypeRef>(r: CFTypeRef) -> T {
|
||||
unsafe {
|
||||
assert!(CFGetTypeID(r) == AbstractCFTypeRef::type_id::<T>());
|
||||
let dummy: Option<T> = None;
|
||||
assert!(CFGetTypeID(r) == AbstractCFTypeRef::type_id(dummy));
|
||||
cast::transmute::<CFTypeRef, T>(r)
|
||||
}
|
||||
}
|
||||
@@ -125,7 +128,8 @@ impl<'self, T:Clone + AbstractCFTypeRef, E1, E2> CFWrapper<T,E1,E2> {
|
||||
|
||||
pub fn from_CFType(wrapper: CFType) -> CFWrapper<T,E1,E2> {
|
||||
unsafe {
|
||||
assert!(wrapper.type_id() == AbstractCFTypeRef::type_id::<T>());
|
||||
let dummy: Option<T> = None;
|
||||
assert!(wrapper.type_id() == AbstractCFTypeRef::type_id(dummy));
|
||||
cast::transmute::<CFType,CFWrapper<T,E1,E2>>(wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ impl AbstractCFTypeRef for CFBooleanRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID {
|
||||
fn type_id(_dummy: Option<CFBooleanRef>) -> CFTypeID {
|
||||
unsafe { CFBooleanGetTypeID() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl AbstractCFTypeRef for CFDataRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID {
|
||||
fn type_id(_dummy: Option<CFDataRef>) -> CFTypeID {
|
||||
unsafe {
|
||||
CFDataGetTypeID()
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ impl AbstractCFTypeRef for CFDictionaryRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID {
|
||||
fn type_id(_dummy: Option<CFDictionaryRef>) -> CFTypeID {
|
||||
unsafe {
|
||||
CFDictionaryGetTypeID()
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ impl AbstractCFTypeRef for CFNumberRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID {
|
||||
fn type_id(_dummy: Option<CFNumberRef>) -> CFTypeID {
|
||||
unsafe {
|
||||
CFNumberGetTypeID()
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ impl AbstractCFTypeRef for CFSetRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID {
|
||||
fn type_id(_dummy: Option<CFSetRef>) -> CFTypeID {
|
||||
unsafe {
|
||||
CFSetGetTypeID()
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ impl AbstractCFTypeRef for CFStringRef {
|
||||
fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef }
|
||||
|
||||
#[fixed_stack_segment]
|
||||
fn type_id() -> CFTypeID {
|
||||
fn type_id(_dummy: Option<CFStringRef>) -> CFTypeID {
|
||||
unsafe {
|
||||
CFStringGetTypeID()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user