Skip to content

Commit 546dc8e

Browse files
committedFeb 9, 2016
Using CF*Ref emits warnings
1 parent bfa81ef commit 546dc8e

24 files changed

+67
-67
lines changed
 

‎Foundation/NSArray.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
565565
}
566566

567567
extension NSArray : _CFBridgable, _SwiftBridgable {
568-
internal var _cfObject: CFArrayRef { return unsafeBitCast(self, CFArrayRef.self) }
568+
internal var _cfObject: CFArray { return unsafeBitCast(self, CFArray.self) }
569569
internal var _swiftObject: [AnyObject] {
570570
var array: [AnyObject]?
571571
Array._forceBridgeFromObject(self, result: &array)
@@ -574,15 +574,15 @@ extension NSArray : _CFBridgable, _SwiftBridgable {
574574
}
575575

576576
extension NSMutableArray {
577-
internal var _cfMutableObject: CFMutableArrayRef { return unsafeBitCast(self, CFMutableArrayRef.self) }
577+
internal var _cfMutableObject: CFMutableArray { return unsafeBitCast(self, CFMutableArray.self) }
578578
}
579579

580-
extension CFArrayRef : _NSBridgable, _SwiftBridgable {
580+
extension CFArray : _NSBridgable, _SwiftBridgable {
581581
internal var _nsObject: NSArray { return unsafeBitCast(self, NSArray.self) }
582582
internal var _swiftObject: Array<AnyObject> { return _nsObject._swiftObject }
583583
}
584584

585-
extension CFArrayRef {
585+
extension CFArray {
586586
/// Bridge something returned from CF to an Array<T>. Useful when we already know that a CFArray contains objects that are toll-free bridged with Swift objects, e.g. CFArray<CFURLRef>.
587587
/// - Note: This bridging operation is unfortunately still O(n), but it only traverses the NSArray once, creating the Swift array and casting at the same time.
588588
func _unsafeTypedBridge<T : AnyObject>() -> Array<T> {
@@ -598,7 +598,7 @@ extension CFArrayRef {
598598

599599
extension Array : _NSBridgable, _CFBridgable {
600600
internal var _nsObject: NSArray { return _bridgeToObject() }
601-
internal var _cfObject: CFArrayRef { return _nsObject._cfObject }
601+
internal var _cfObject: CFArray { return _nsObject._cfObject }
602602
}
603603

604604
public struct NSBinarySearchingOptions : OptionSetType {

‎Foundation/NSBundle.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import CoreFoundation
1111

1212
public class NSBundle : NSObject {
13-
private var _bundle : CFBundleRef!
13+
private var _bundle : CFBundle!
1414

1515
private static var _mainBundle : NSBundle = {
1616
return NSBundle(cfBundle: CFBundleGetMainBundle())
@@ -20,7 +20,7 @@ public class NSBundle : NSObject {
2020
return _mainBundle
2121
}
2222

23-
internal init(cfBundle: CFBundleRef) {
23+
internal init(cfBundle: CFBundle) {
2424
super.init()
2525
_bundle = cfBundle
2626
}
@@ -36,7 +36,7 @@ public class NSBundle : NSObject {
3636
}
3737

3838
let url = NSURL(fileURLWithPath: resolvedPath)
39-
_bundle = CFBundleCreate(kCFAllocatorSystemDefault, unsafeBitCast(url, CFURLRef.self))
39+
_bundle = CFBundleCreate(kCFAllocatorSystemDefault, unsafeBitCast(url, CFURL.self))
4040
}
4141

4242
public convenience init?(URL url: NSURL) {

‎Foundation/NSCFDictionary.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal final class _NSCFDictionary : NSMutableDictionary {
3333
}
3434

3535
override var count: Int {
36-
return CFDictionaryGetCount(unsafeBitCast(self, CFDictionaryRef.self))
36+
return CFDictionaryGetCount(unsafeBitCast(self, CFDictionary.self))
3737
}
3838

3939
override func objectForKey(aKey: AnyObject) -> AnyObject? {

‎Foundation/NSCFString.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ internal class _NSCFString : NSMutableString {
4141
}
4242

4343
override var length: Int {
44-
return CFStringGetLength(unsafeBitCast(self, CFStringRef.self))
44+
return CFStringGetLength(unsafeBitCast(self, CFString.self))
4545
}
4646

4747
override func characterAtIndex(index: Int) -> unichar {
48-
return CFStringGetCharacterAtIndex(unsafeBitCast(self, CFStringRef.self), index)
48+
return CFStringGetCharacterAtIndex(unsafeBitCast(self, CFString.self), index)
4949
}
5050

5151
override func replaceCharactersInRange(range: NSRange, withString aString: String) {
52-
CFStringReplace(unsafeBitCast(self, CFMutableStringRef.self), CFRangeMake(range.location, range.length), aString._cfObject)
52+
CFStringReplace(unsafeBitCast(self, CFMutableString.self), CFRangeMake(range.location, range.length), aString._cfObject)
5353
}
5454

5555
override var classForCoder: AnyClass {

‎Foundation/NSCalendar.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public struct NSCalendarOptions : OptionSetType {
9494
}
9595

9696
public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
97-
typealias CFType = CFCalendarRef
97+
typealias CFType = CFCalendar
9898
private var _base = _CFInfo(typeID: CFCalendarGetTypeID())
9999
private var _identifier = UnsafeMutablePointer<Void>()
100100
private var _locale = UnsafeMutablePointer<Void>()
@@ -103,7 +103,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
103103
private var _cal = UnsafeMutablePointer<Void>()
104104

105105
internal var _cfObject: CFType {
106-
return unsafeBitCast(self, CFCalendarRef.self)
106+
return unsafeBitCast(self, CFCalendar.self)
107107
}
108108

109109
public convenience required init?(coder aDecoder: NSCoder) {
@@ -1720,7 +1720,7 @@ public class NSDateComponents : NSObject, NSCopying, NSSecureCoding {
17201720

17211721
extension NSCalendar : _CFBridgable { }
17221722

1723-
extension CFCalendarRef : _NSBridgable {
1723+
extension CFCalendar : _NSBridgable {
17241724
typealias NSType = NSCalendar
17251725
internal var _nsObject: NSType { return unsafeBitCast(self, NSType.self) }
17261726
}

‎Foundation/NSCharacterSet.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let kCFCharacterSetIllegal = CFCharacterSetPredefinedSet.Illegal
3030

3131

3232
public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
33-
typealias CFType = CFCharacterSetRef
33+
typealias CFType = CFCharacterSet
3434
private var _base = _CFInfo(typeID: CFCharacterSetGetTypeID())
3535
private var _hashValue = CFHashCode(0)
3636
private var _buffer = UnsafeMutablePointer<Void>()
@@ -41,8 +41,8 @@ public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
4141
return unsafeBitCast(self, CFType.self)
4242
}
4343

44-
internal var _cfMutableObject: CFMutableCharacterSetRef {
45-
return unsafeBitCast(self, CFMutableCharacterSetRef.self)
44+
internal var _cfMutableObject: CFMutableCharacterSet {
45+
return unsafeBitCast(self, CFMutableCharacterSet.self)
4646
}
4747

4848
public override var hash: Int {
@@ -292,7 +292,7 @@ public class NSMutableCharacterSet : NSCharacterSet {
292292
}
293293
}
294294

295-
extension CFCharacterSetRef : _NSBridgable {
295+
extension CFCharacterSet : _NSBridgable {
296296
typealias NSType = NSCharacterSet
297297
internal var _nsObject: NSType {
298298
return unsafeBitCast(self, NSType.self)

‎Foundation/NSData.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private let __kCFDontDeallocate: CFOptionFlags = 0x10
7171
private let __kCFAllocatesCollectable: CFOptionFlags = 0x20
7272

7373
public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
74-
typealias CFType = CFDataRef
74+
typealias CFType = CFData
7575
private var _base = _CFInfo(typeID: CFDataGetTypeID())
7676
private var _length: CFIndex = 0
7777
private var _capacity: CFIndex = 0
@@ -116,7 +116,7 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
116116
super.init()
117117
let options : CFOptionFlags = (self.dynamicType == NSMutableData.self) ? __kCFMutable | __kCFGrowable : 0x0
118118
if copy {
119-
_CFDataInit(unsafeBitCast(self, CFMutableDataRef.self), options, length, UnsafeMutablePointer<UInt8>(bytes), length, false)
119+
_CFDataInit(unsafeBitCast(self, CFMutableData.self), options, length, UnsafeMutablePointer<UInt8>(bytes), length, false)
120120
if let handler = deallocator {
121121
handler(bytes, length)
122122
}
@@ -125,7 +125,7 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
125125
_deallocHandler!.handler = handler
126126
}
127127
// The data initialization should flag that CF should not deallocate which leaves the handler a chance to deallocate instead
128-
_CFDataInit(unsafeBitCast(self, CFMutableDataRef.self), options | __kCFDontDeallocate, length, UnsafeMutablePointer<UInt8>(bytes), length, true)
128+
_CFDataInit(unsafeBitCast(self, CFMutableData.self), options | __kCFDontDeallocate, length, UnsafeMutablePointer<UInt8>(bytes), length, true)
129129
}
130130
}
131131

@@ -568,13 +568,13 @@ extension NSData {
568568

569569
extension NSData : _CFBridgable { }
570570

571-
extension CFDataRef : _NSBridgable {
571+
extension CFData : _NSBridgable {
572572
typealias NSType = NSData
573573
internal var _nsObject: NSType { return unsafeBitCast(self, NSType.self) }
574574
}
575575

576576
extension NSMutableData {
577-
internal var _cfMutableObject: CFMutableDataRef { return unsafeBitCast(self, CFMutableDataRef.self) }
577+
internal var _cfMutableObject: CFMutableData { return unsafeBitCast(self, CFMutableData.self) }
578578
}
579579

580580
public class NSMutableData : NSData {

‎Foundation/NSDate.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public var NSTimeIntervalSince1970: Double {
2222
}
2323

2424
public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
25-
typealias CFType = CFDateRef
25+
typealias CFType = CFDate
2626

2727
public override var hash: Int {
2828
return Int(bitPattern: CFHash(_cfObject))
@@ -224,7 +224,7 @@ extension NSDate {
224224

225225
extension NSDate : _CFBridgable { }
226226

227-
extension CFDateRef : _NSBridgable {
227+
extension CFDate : _NSBridgable {
228228
typealias NSType = NSDate
229229
internal var _nsObject: NSType { return unsafeBitCast(self, NSType.self) }
230230
}

‎Foundation/NSDateFormatter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import CoreFoundation
1111

1212
public class NSDateFormatter : NSFormatter {
13-
typealias CFType = CFDateFormatterRef
13+
typealias CFType = CFDateFormatter
1414
private var __cfObject: CFType?
1515
private var _cfObject: CFType {
1616
guard let obj = __cfObject else {

‎Foundation/NSDictionary.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
554554
}
555555

556556
extension NSDictionary : _CFBridgable, _SwiftBridgable {
557-
internal var _cfObject: CFDictionaryRef { return unsafeBitCast(self, CFDictionaryRef.self) }
557+
internal var _cfObject: CFDictionary { return unsafeBitCast(self, CFDictionary.self) }
558558
internal var _swiftObject: Dictionary<NSObject, AnyObject> {
559559
var dictionary: [NSObject: AnyObject]?
560560
Dictionary._forceBridgeFromObject(self, result: &dictionary)
@@ -563,17 +563,17 @@ extension NSDictionary : _CFBridgable, _SwiftBridgable {
563563
}
564564

565565
extension NSMutableDictionary {
566-
internal var _cfMutableObject: CFMutableDictionaryRef { return unsafeBitCast(self, CFMutableDictionaryRef.self) }
566+
internal var _cfMutableObject: CFMutableDictionary { return unsafeBitCast(self, CFMutableDictionary.self) }
567567
}
568568

569-
extension CFDictionaryRef : _NSBridgable, _SwiftBridgable {
569+
extension CFDictionary : _NSBridgable, _SwiftBridgable {
570570
internal var _nsObject: NSDictionary { return unsafeBitCast(self, NSDictionary.self) }
571571
internal var _swiftObject: [NSObject: AnyObject] { return _nsObject._swiftObject }
572572
}
573573

574574
extension Dictionary : _NSBridgable, _CFBridgable {
575575
internal var _nsObject: NSDictionary { return _bridgeToObject() }
576-
internal var _cfObject: CFDictionaryRef { return _nsObject._cfObject }
576+
internal var _cfObject: CFDictionary { return _nsObject._cfObject }
577577
}
578578

579579
public class NSMutableDictionary : NSDictionary {

‎Foundation/NSError.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public let NSFilePathErrorKey: String = "NSFilePathErrorKey"
3131

3232

3333
public class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
34-
typealias CFType = CFErrorRef
34+
typealias CFType = CFError
3535

3636
internal var _cfObject: CFType {
3737
return CFErrorCreate(kCFAllocatorSystemDefault, domain._cfObject, code, nil)
@@ -168,7 +168,7 @@ public class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
168168
extension NSError : ErrorType { }
169169

170170
extension NSError : _CFBridgable { }
171-
extension CFErrorRef : _NSBridgable {
171+
extension CFError : _NSBridgable {
172172
typealias NSType = NSError
173173
internal var _nsObject: NSType {
174174
let userInfo = CFErrorCopyUserInfo(self)._swiftObject

‎Foundation/NSLocale.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import CoreFoundation
1212

1313
public class NSLocale : NSObject, NSCopying, NSSecureCoding {
14-
typealias CFType = CFLocaleRef
14+
typealias CFType = CFLocale
1515
private var _base = _CFInfo(typeID: CFLocaleGetTypeID())
1616
private var _identifier = UnsafeMutablePointer<Void>()
1717
private var _cache = UnsafeMutablePointer<Void>()
@@ -209,7 +209,7 @@ public let NSLocaleCalendarIdentifier: String = "kCFLocaleCalendarIdentifierKey"
209209
public let NSLocaleAlternateQuotationBeginDelimiterKey: String = "kCFLocaleAlternateQuotationBeginDelimiterKey"
210210
public let NSLocaleAlternateQuotationEndDelimiterKey: String = "kCFLocaleAlternateQuotationEndDelimiterKey"
211211

212-
extension CFLocaleRef : _NSBridgable {
212+
extension CFLocale : _NSBridgable {
213213
typealias NSType = NSLocale
214214
internal var _nsObject: NSLocale {
215215
return unsafeBitCast(self, NSType.self)

‎Foundation/NSNumber.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ extension Bool : _ObjectTypeBridgeable {
124124
}
125125

126126
extension Bool : _CFBridgable {
127-
typealias CFType = CFBooleanRef
127+
typealias CFType = CFBoolean
128128
var _cfObject: CFType {
129129
return self ? kCFBooleanTrue : kCFBooleanFalse
130130
}
@@ -135,7 +135,7 @@ extension NSNumber : FloatLiteralConvertible, IntegerLiteralConvertible, Boolean
135135
}
136136

137137
public class NSNumber : NSValue {
138-
typealias CFType = CFNumberRef
138+
typealias CFType = CFNumber
139139
// This layout MUST be the same as CFNumber so that they are bridgeable
140140
private var _base = _CFInfo(typeID: CFNumberGetTypeID())
141141
private var _pad: UInt64 = 0
@@ -465,7 +465,7 @@ public class NSNumber : NSValue {
465465
}
466466
}
467467

468-
extension CFNumberRef : _NSBridgable {
468+
extension CFNumber : _NSBridgable {
469469
typealias NSType = NSNumber
470470
internal var _nsObject: NSType { return unsafeBitCast(self, NSType.self) }
471471
}

‎Foundation/NSNumberFormatter.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal let kCFNumberFormatterCurrencyAccountingStyle = CFNumberFormatterStyle.
2424

2525
public class NSNumberFormatter : NSFormatter {
2626

27-
typealias CFType = CFNumberFormatterRef
27+
typealias CFType = CFNumberFormatter
2828
private var _currentCfFormatter: CFType?
2929
private var _cfFormatter: CFType {
3030
if let obj = _currentCfFormatter {
@@ -83,7 +83,7 @@ public class NSNumberFormatter : NSFormatter {
8383
_currentCfFormatter = nil
8484
}
8585

86-
internal func _setFormatterAttributes(formatter: CFNumberFormatterRef) {
86+
internal func _setFormatterAttributes(formatter: CFNumberFormatter) {
8787
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencyCode, value: _currencyCode?._cfObject)
8888
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterDecimalSeparator, value: _decimalSeparator?._cfObject)
8989
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencyDecimalSeparator, value: _currencyDecimalSeparator?._cfObject)
@@ -127,7 +127,7 @@ public class NSNumberFormatter : NSFormatter {
127127
}
128128
}
129129

130-
internal func _setFormatterAttribute(formatter: CFNumberFormatterRef, attributeName: CFString, value: AnyObject?) {
130+
internal func _setFormatterAttribute(formatter: CFNumberFormatter, attributeName: CFString, value: AnyObject?) {
131131
if let value = value {
132132
CFNumberFormatterSetProperty(formatter, attributeName, value)
133133
}

‎Foundation/NSPropertyList.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class NSPropertyListSerialization : NSObject {
6868
var fmt = kCFPropertyListBinaryFormat_v1_0
6969
var error: Unmanaged<CFError>? = nil
7070
let decoded = withUnsafeMutablePointers(&fmt, &error) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>, outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
71-
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, unsafeBitCast(data, CFDataRef.self), CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), NSObject.self)
71+
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, unsafeBitCast(data, CFData.self), CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), NSObject.self)
7272
}
7373
if format != nil {
7474
#if os(OSX) || os(iOS)

‎Foundation/NSRegularExpression.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct NSRegularExpressionOptions : OptionSetType {
2626
}
2727

2828
public class NSRegularExpression : NSObject, NSCopying, NSCoding {
29-
internal var _internal: _CFRegularExpressionRef
29+
internal var _internal: _CFRegularExpression
3030

3131
public override func copy() -> AnyObject {
3232
return copyWithZone(nil)

‎Foundation/NSRunLoop.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ import CoreFoundation
1212
public let NSDefaultRunLoopMode: String = "kCFRunLoopDefaultMode"
1313
public let NSRunLoopCommonModes: String = "kCFRunLoopCommonModes"
1414

15-
internal func _NSRunLoopNew(cf: CFRunLoopRef) -> Unmanaged<AnyObject> {
15+
internal func _NSRunLoopNew(cf: CFRunLoop) -> Unmanaged<AnyObject> {
1616
let rl = Unmanaged<NSRunLoop>.passRetained(NSRunLoop(cfObject: cf))
1717
return unsafeBitCast(rl, Unmanaged<AnyObject>.self) // this retain is balanced on the other side of the CF fence
1818
}
1919

2020
public class NSRunLoop : NSObject {
21-
internal var _cfRunLoop : CFRunLoopRef!
21+
internal var _cfRunLoop : CFRunLoop!
2222
internal static var _mainRunLoop : NSRunLoop = {
2323
return NSRunLoop(cfObject: CFRunLoopGetMain())
2424
}()
2525

26-
internal init(cfObject : CFRunLoopRef) {
26+
internal init(cfObject : CFRunLoop) {
2727
_cfRunLoop = cfObject
2828
}
2929

0 commit comments

Comments
 (0)
Please sign in to comment.