From cb48972c1d7cef5076da2b8c4be3339f2dee31b0 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Thu, 15 Aug 2013 18:45:17 -0600 Subject: [PATCH] Upgrade to latest rust. --- array.rs | 13 ++++++------- base.rs | 6 +++--- dictionary.rs | 12 +++++++----- number.rs | 6 +++--- string.rs | 5 ++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/array.rs b/array.rs index 8d36136..de1bd43 100644 --- a/array.rs +++ b/array.rs @@ -19,7 +19,6 @@ use base::{ use std::cast; use std::libc::c_void; use std::ptr; -use std::uint; use std::vec; pub type CFArrayRetainCallBack = *u8; @@ -78,7 +77,7 @@ impl CFArray { } pub fn each_ref(&self, cb: &fn(ElemRefType) -> bool) -> bool { - for uint::range(0, self.len()) |i| { + for i in range(0, self.len()) { cb(self[i]); } @@ -86,7 +85,7 @@ impl CFArray { } pub fn eachi_ref(&self, cb: &fn(uint, ElemRefType) -> bool) -> bool { - for uint::range(0, self.len()) |i| { + for i in range(0, self.len()) { cb(i, self[i]); } @@ -97,7 +96,7 @@ impl CFArray { // Generally, when array elements are Core Foundation objects (not // always true), they need to be wrapped with CFWrapper::wrap_shared. pub fn each(&self, cb: &fn(&ElemRefType) -> bool) -> bool { - for uint::range(0, self.len()) |i| { + for i in range(0, self.len()) { cb(&self[i]); } @@ -108,7 +107,7 @@ impl CFArray { // Generally, when array elements are Core Foundation objects (not // always true), they need to be wrapped with CFWrapper::wrap_shared. pub fn eachi(&self, cb: &fn(uint, &ElemRefType) -> bool) -> bool{ - for uint::range(0, self.len()) |i| { + for i in range(0, self.len()) { cb(i, &self[i]); } @@ -180,13 +179,13 @@ fn should_box_and_unbox() { let mut sum = 0i32; - for arr.each |elem: &CFNumberRef| { + for elem in arr.iter() { sum += CFNumber::wrap_shared(*elem).to_i32(); } assert!(sum == 15); - for arr.each |elem: &CFNumberRef| { + for elem in arr.iter() { sum += CFNumber::wrap_shared(*elem).to_i32(); } diff --git a/base.rs b/base.rs index b2b7d59..914bee3 100644 --- a/base.rs +++ b/base.rs @@ -82,7 +82,7 @@ impl Drop for CFWrapper { pub type CFType = CFWrapper; -impl<'self, T:Copy + AbstractCFTypeRef, E1, E2> CFWrapper { +impl<'self, T:Clone + AbstractCFTypeRef, E1, E2> CFWrapper { pub fn borrow_ref(&'self self) -> &'self T { &self.obj } @@ -111,7 +111,7 @@ impl<'self, T:Copy + AbstractCFTypeRef, E1, E2> CFWrapper { // Unwraps the wrapper, returning the underlying AbstractCFType. pub fn unwrap(wrapper: CFWrapper) -> T { - copy wrapper.obj + wrapper.obj.clone() } pub fn to_CFType(wrapper: CFWrapper) -> CFType { @@ -128,7 +128,7 @@ impl<'self, T:Copy + AbstractCFTypeRef, E1, E2> CFWrapper { } pub fn clone(wrapper: &CFWrapper) -> CFWrapper { - CFWrapper::wrap_shared(copy *wrapper.borrow_ref()) + CFWrapper::wrap_shared((*wrapper.borrow_ref()).clone()) } pub fn retain_count(&self) -> CFIndex { diff --git a/dictionary.rs b/dictionary.rs index 29e5da5..5a54ef8 100644 --- a/dictionary.rs +++ b/dictionary.rs @@ -22,7 +22,6 @@ use string::CFStringRef; use std::cast; use std::libc::c_void; use std::ptr; -use std::uint; use std::vec; pub type CFDictionaryApplierFunction = *u8; @@ -70,7 +69,7 @@ pub struct CFDictionary { pub type UntypedCFDictionary = CFDictionary; -impl +impl CFDictionary { pub fn wrap_owned(dictionary: CFDictionaryRef) -> CFDictionary { CFDictionary { @@ -81,7 +80,7 @@ impl CFDictionary { let mut keys : ~[CFTypeRef] = ~[]; let mut values : ~[CFTypeRef] = ~[]; - for pairs.iter().advance |pair| { + for pair in pairs.iter() { // FIXME: "let" would be much nicer here, but that doesn't work yet. match *pair { (ref key, ref value) => { @@ -154,6 +153,7 @@ impl bool) -> bool { unsafe { let len = self.len(); @@ -162,9 +162,11 @@ impl(ptr::null()); let values: ~[ValueRefType] = vec::from_elem(len, null_vals); - do uint::range(0,len) |i| { - blk(&keys[i], &values[i]) + for i in range(0, len) { + if !blk(&keys[i], &values[i]) { return false; } } + + true } } } diff --git a/number.rs b/number.rs index 7dc6c22..50c359c 100644 --- a/number.rs +++ b/number.rs @@ -67,7 +67,7 @@ impl CFNumber { } } - pub fn new(n: T) -> CFNumber { + pub fn new(n: T) -> CFNumber { unsafe { let objref = CFNumberCreate(kCFAllocatorDefault, n.cf_number_type(), @@ -141,13 +141,13 @@ impl CFNumber { } } - priv fn has_float_type(&self) -> bool { + fn has_float_type(&self) -> bool { unsafe { CFNumberIsFloatType(self.contents.obj) as bool } } - priv fn has_number_type(&self, ty: CFNumberType) -> bool { + fn has_number_type(&self, ty: CFNumberType) -> bool { unsafe { CFNumberGetType(self.contents.obj) == ty } diff --git a/string.rs b/string.rs index 11d991f..efa3fed 100644 --- a/string.rs +++ b/string.rs @@ -15,7 +15,6 @@ use base::{CFRangeMake, CFTypeRef, CFTypeID, CFWrapper, kCFAllocatorDefault, kCF use std::cast; use std::libc; use std::ptr; -use std::str; use std::vec; pub type UniChar = libc::c_ushort; @@ -235,7 +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. pub fn new_static(string: &'static str) -> CFString { - let string_ref = do str::as_buf(string) |bytes, len| { + let string_ref = do string.as_imm_buf |bytes, len| { unsafe { CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, @@ -252,7 +251,7 @@ impl CFString { } pub fn new(string: &str) -> CFString { - let string_ref = do str::as_buf(string) |bytes, len| { + let string_ref = do string.as_imm_buf |bytes, len| { unsafe { CFStringCreateWithBytes(kCFAllocatorDefault, bytes,