From 95f2f30981e12128e1dab0956f11c70386d85bfc Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 2 Sep 2013 17:08:05 +0100 Subject: [PATCH 1/2] Upgrade to rustc 0.8-pre (0ac3e02 2013-08-30 05:45:45 -0700) --- array.rs | 2 +- base.rs | 10 ++++++---- boolean.rs | 2 +- data.rs | 2 +- dictionary.rs | 2 +- number.rs | 2 +- set.rs | 2 +- string.rs | 2 +- url.rs | 2 +- 9 files changed, 14 insertions(+), 12 deletions(-) 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..f44ef8e 100644 --- a/base.rs +++ b/base.rs @@ -16,7 +16,7 @@ use std::libc::c_long; // borrow semantics. pub trait AbstractCFTypeRef { fn as_type_ref(&self) -> CFTypeRef; - fn type_id() -> CFTypeID; + fn type_id(_dummy: Option) -> CFTypeID; } pub type Boolean = u8; @@ -48,13 +48,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 +126,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() } From e0efe40213acc7e2f4cf9758cf91993b2c67c538 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Sep 2013 19:32:32 +0100 Subject: [PATCH 2/2] Add a FIXME comment for the dummy parameter work around. See #17 --- base.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base.rs b/base.rs index f44ef8e..096e56e 100644 --- a/base.rs +++ b/base.rs @@ -16,6 +16,8 @@ use std::libc::c_long; // borrow semantics. pub trait AbstractCFTypeRef { fn as_type_ref(&self) -> CFTypeRef; + + // FIXME https://github.com/mozilla-servo/rust-core-foundation/issues/17 fn type_id(_dummy: Option) -> CFTypeID; }