diff --git a/array.rs b/array.rs index 48116b6..17be32c 100644 --- a/array.rs +++ b/array.rs @@ -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) -> CFTypeID { unsafe { CFArrayGetTypeID() } } } // FIXME: Should be a newtype struct, but that fails due to a Rust compiler bug. diff --git a/base.rs b/base.rs index fe451cf..096e56e 100644 --- a/base.rs +++ b/base.rs @@ -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) -> 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) -> CFTypeID { fail!(); } } #[fixed_stack_segment] pub fn downcast(r: CFTypeRef) -> T { unsafe { - assert!(CFGetTypeID(r) == AbstractCFTypeRef::type_id::()); + let dummy: Option = None; + assert!(CFGetTypeID(r) == AbstractCFTypeRef::type_id(dummy)); cast::transmute::(r) } } @@ -125,7 +128,8 @@ impl<'self, T:Clone + AbstractCFTypeRef, E1, E2> CFWrapper { pub fn from_CFType(wrapper: CFType) -> CFWrapper { unsafe { - assert!(wrapper.type_id() == AbstractCFTypeRef::type_id::()); + let dummy: Option = None; + assert!(wrapper.type_id() == AbstractCFTypeRef::type_id(dummy)); cast::transmute::>(wrapper) } } diff --git a/boolean.rs b/boolean.rs index bdd8a8e..c1b8e59 100644 --- a/boolean.rs +++ b/boolean.rs @@ -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) -> CFTypeID { unsafe { CFBooleanGetTypeID() } } } diff --git a/data.rs b/data.rs index 7ae3a07..bf23bab 100644 --- a/data.rs +++ b/data.rs @@ -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) -> CFTypeID { unsafe { CFDataGetTypeID() } diff --git a/dictionary.rs b/dictionary.rs index c1d4746..a0b98af 100644 --- a/dictionary.rs +++ b/dictionary.rs @@ -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) -> CFTypeID { unsafe { CFDictionaryGetTypeID() } diff --git a/number.rs b/number.rs index 258f11c..1d2ad67 100644 --- a/number.rs +++ b/number.rs @@ -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) -> CFTypeID { unsafe { CFNumberGetTypeID() } diff --git a/set.rs b/set.rs index aac9696..efc6fa7 100644 --- a/set.rs +++ b/set.rs @@ -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) -> CFTypeID { unsafe { CFSetGetTypeID() } diff --git a/string.rs b/string.rs index 4702f45..3c4d0a0 100644 --- a/string.rs +++ b/string.rs @@ -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) -> CFTypeID { unsafe { CFStringGetTypeID() } diff --git a/url.rs b/url.rs index b22a8ee..53b5b54 100644 --- a/url.rs +++ b/url.rs @@ -20,7 +20,7 @@ impl AbstractCFTypeRef for CFURLRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } #[fixed_stack_segment] - fn type_id() -> CFTypeID { + fn type_id(_dummy: Option) -> CFTypeID { unsafe { CFURLGetTypeID() }