diff --git a/array.rs b/array.rs index 44cd443..48116b6 100644 --- a/array.rs +++ b/array.rs @@ -39,6 +39,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() } } } @@ -77,6 +78,7 @@ impl CFArray { } } + #[fixed_stack_segment] pub fn new(elems: &[ElemRefType]) -> CFArray { let array_ref: CFArrayRef; let elems_refs = do elems.map |e: &ElemRefType| { e.as_type_ref() }; @@ -103,6 +105,7 @@ impl CFArray { } } + #[fixed_stack_segment] pub fn len(&self) -> uint { unsafe { return CFArrayGetCount(*self.contents.borrow_ref()) as uint; @@ -114,6 +117,7 @@ impl Index for CFArray ElemRefType { assert!(*idx < self.len()); unsafe { diff --git a/base.rs b/base.rs index 914bee3..fe451cf 100644 --- a/base.rs +++ b/base.rs @@ -51,6 +51,7 @@ impl AbstractCFTypeRef for CFTypeRef { fn type_id() -> CFTypeID { fail!(); } } +#[fixed_stack_segment] pub fn downcast(r: CFTypeRef) -> T { unsafe { assert!(CFGetTypeID(r) == AbstractCFTypeRef::type_id::()); @@ -68,6 +69,7 @@ pub struct CFWrapper { #[unsafe_destructor] impl Drop for CFWrapper { + #[fixed_stack_segment] fn drop(&self) { unsafe { // sadly, cannot use obj.as_type_ref() here, because drop @@ -104,6 +106,7 @@ impl<'self, T:Clone + AbstractCFTypeRef, E1, E2> CFWrapper { // Use this when following Core Foundation's "Get" rule. The wrapper does not have ownership. // Twe need to increment object's the retain count so it isn't freed out from under our noses. + #[fixed_stack_segment] pub fn wrap_shared(some_ref: T) -> CFWrapper { unsafe { CFRetain(some_ref.as_type_ref()); } CFWrapper { obj: some_ref } @@ -131,18 +134,21 @@ impl<'self, T:Clone + AbstractCFTypeRef, E1, E2> CFWrapper { CFWrapper::wrap_shared((*wrapper.borrow_ref()).clone()) } + #[fixed_stack_segment] pub fn retain_count(&self) -> CFIndex { unsafe { CFGetRetainCount(*self.borrow_type_ref()) } } + #[fixed_stack_segment] pub fn type_id(&self) -> CFTypeID { unsafe { CFGetTypeID(*self.borrow_type_ref()) } } + #[fixed_stack_segment] pub fn show(&self) { unsafe { CFShow(*self.borrow_type_ref()); diff --git a/boolean.rs b/boolean.rs index dbfc089..bdd8a8e 100644 --- a/boolean.rs +++ b/boolean.rs @@ -22,6 +22,7 @@ pub type CFBooleanRef = *__CFBoolean; impl AbstractCFTypeRef for CFBooleanRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFBooleanGetTypeID() } } diff --git a/data.rs b/data.rs index 3c906aa..7ae3a07 100644 --- a/data.rs +++ b/data.rs @@ -26,6 +26,7 @@ pub type CFDataRef = *__CFData; impl AbstractCFTypeRef for CFDataRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFDataGetTypeID() @@ -46,6 +47,7 @@ impl CFData { } } + #[fixed_stack_segment] pub fn new_from_buf(buf: &[u8]) -> CFData { let result; unsafe { @@ -60,12 +62,14 @@ impl CFData { } // tread with caution; read-only + #[fixed_stack_segment] pub fn bytes(&self) -> *u8 { unsafe { CFDataGetBytePtr(self.contents.obj) } } + #[fixed_stack_segment] pub fn len(&self) -> uint { unsafe { CFDataGetLength(self.contents.obj) as uint diff --git a/dictionary.rs b/dictionary.rs index 5a54ef8..c1d4746 100644 --- a/dictionary.rs +++ b/dictionary.rs @@ -54,6 +54,7 @@ pub type CFDictionaryRef = *__CFDictionary; impl AbstractCFTypeRef for CFDictionaryRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFDictionaryGetTypeID() @@ -77,6 +78,7 @@ impl CFDictionary { let mut keys : ~[CFTypeRef] = ~[]; let mut values : ~[CFTypeRef] = ~[]; @@ -109,6 +111,7 @@ impl uint { unsafe { CFDictionaryGetCount(self.contents.obj) as uint @@ -119,6 +122,7 @@ impl bool { unsafe { CFDictionaryContainsKey(self.contents.obj, @@ -127,6 +131,7 @@ impl Option { unsafe { let value : *c_void = ptr::null(); diff --git a/number.rs b/number.rs index 50c359c..258f11c 100644 --- a/number.rs +++ b/number.rs @@ -43,6 +43,7 @@ pub type CFNumberRef = *__CFNumber; impl AbstractCFTypeRef for CFNumberRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFNumberGetTypeID() @@ -67,6 +68,7 @@ impl CFNumber { } } + #[fixed_stack_segment] pub fn new(n: T) -> CFNumber { unsafe { let objref = CFNumberCreate(kCFAllocatorDefault, @@ -78,6 +80,7 @@ impl CFNumber { } } + #[fixed_stack_segment] pub fn to_i8(&self) -> i8 { let ty = kCFNumberSInt8Type; assert!(self.has_number_type(ty)); @@ -90,6 +93,7 @@ impl CFNumber { } } + #[fixed_stack_segment] pub fn to_i16(&self) -> i16 { let ty = kCFNumberSInt16Type; assert!(self.has_number_type(ty)); @@ -102,6 +106,7 @@ impl CFNumber { } } + #[fixed_stack_segment] pub fn to_i32(&self) -> i32 { let ty = kCFNumberSInt32Type; assert!(self.has_number_type(ty)); @@ -114,6 +119,7 @@ impl CFNumber { } } + #[fixed_stack_segment] pub fn to_float(&self) -> float { unsafe { assert!(self.has_float_type()); @@ -141,12 +147,14 @@ impl CFNumber { } } + #[fixed_stack_segment] fn has_float_type(&self) -> bool { unsafe { CFNumberIsFloatType(self.contents.obj) as bool } } + #[fixed_stack_segment] fn has_number_type(&self, ty: CFNumberType) -> bool { unsafe { CFNumberGetType(self.contents.obj) == ty diff --git a/set.rs b/set.rs index 2e00f80..aac9696 100644 --- a/set.rs +++ b/set.rs @@ -42,6 +42,7 @@ pub type CFSetRef = *__CFSet; impl AbstractCFTypeRef for CFSetRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFSetGetTypeID() @@ -56,6 +57,7 @@ pub struct CFSet { } impl CFSet { + #[fixed_stack_segment] pub fn new(elems: &[ElemRefType]) -> CFSet { let result: CFSetRef; let elems_refs = do elems.map |e: &ElemRefType| { diff --git a/string.rs b/string.rs index 276f722..4702f45 100644 --- a/string.rs +++ b/string.rs @@ -202,6 +202,7 @@ pub type CFStringRef = *__CFString; impl AbstractCFTypeRef for CFStringRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFStringGetTypeID() @@ -233,6 +234,7 @@ impl CFString { // like CFString::new, but references a string that can be used as // a backing store by virtue of being statically allocated. + #[fixed_stack_segment] pub fn new_static(string: &'static str) -> CFString { let string_ref = do string.as_imm_buf |bytes, len| { unsafe { @@ -250,6 +252,7 @@ impl CFString { } } + #[fixed_stack_segment] pub fn new(string: &str) -> CFString { let string_ref = do string.as_imm_buf |bytes, len| { unsafe { @@ -267,6 +270,7 @@ impl CFString { } } + #[fixed_stack_segment] pub fn char_len(&self) -> uint { unsafe { CFStringGetLength(self.contents.obj) as uint @@ -275,6 +279,7 @@ impl CFString { } impl ToStr for CFString { + #[fixed_stack_segment] fn to_str(&self) -> ~str { unsafe { let char_len = self.char_len(); diff --git a/url.rs b/url.rs index f03f943..b22a8ee 100644 --- a/url.rs +++ b/url.rs @@ -19,6 +19,7 @@ pub type CFURLRef = *__CFURL; impl AbstractCFTypeRef for CFURLRef { fn as_type_ref(&self) -> CFTypeRef { *self as CFTypeRef } + #[fixed_stack_segment] fn type_id() -> CFTypeID { unsafe { CFURLGetTypeID() @@ -29,6 +30,7 @@ impl AbstractCFTypeRef for CFURLRef { pub type CFURL = CFWrapper; impl ToStr for CFURL { + #[fixed_stack_segment] fn to_str(&self) -> ~str { unsafe { let cfstr: CFString = CFString {