Skip to content

Commit 038d708

Browse files
swiftixparkera
authored andcommitted
Migrate from the removed unsafeAddress(of:) API. (swiftlang#475)
1 parent 43f39f9 commit 038d708

5 files changed

+6
-6
lines changed

Foundation/NSCFString.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ internal class _NSCFString : NSMutableString {
5959

6060
internal final class _NSCFConstantString : _NSCFString {
6161
internal var _ptr : UnsafePointer<UInt8> {
62-
let ptr = unsafeAddress(of: self) + sizeof(OpaquePointer.self) + sizeof(Int32.self) + sizeof(Int32.self) + sizeof(_CFInfo.self)
62+
let ptr = Unmanaged.passUnretained(self).toOpaque() + sizeof(OpaquePointer.self) + sizeof(Int32.self) + sizeof(Int32.self) + sizeof(_CFInfo.self)
6363
return UnsafePointer<UnsafePointer<UInt8>>(ptr).pointee
6464
}
6565
internal var _length : UInt32 {
6666
let offset = sizeof(OpaquePointer.self) + sizeof(Int32.self) + sizeof(Int32.self) + sizeof(_CFInfo.self) + sizeof(UnsafePointer<UInt8>.self)
67-
let ptr = unsafeAddress(of: self) + offset
67+
let ptr = Unmanaged.passUnretained(self).toOpaque() + offset
6868
return UnsafePointer<UInt32>(ptr).pointee
6969
}
7070

Foundation/NSNotification.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class NSNotification: NSObject, NSCopying, NSCoding {
8585
}
8686

8787
public override var description: String {
88-
var str = "\(self.dynamicType) \(unsafeAddress(of: self)) {"
88+
var str = "\(self.dynamicType) \(Unmanaged.passUnretained(self).toOpaque()) {"
8989

9090
str += "name = \(self.name.rawValue)"
9191
if let object = self.object {

Foundation/NSObject.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class NSObject : NSObjectProtocol, Equatable, Hashable {
100100
}
101101

102102
public var description: String {
103-
return "<\(self.dynamicType): \(unsafeAddress(of: self))>"
103+
return "<\(self.dynamicType): \(Unmanaged.passUnretained(self).toOpaque())>"
104104
}
105105

106106
public var debugDescription: String {

Foundation/NSOperation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public class OperationQueue: NSObject {
324324
if let requestedName = _name {
325325
effectiveName = requestedName
326326
} else {
327-
effectiveName = "NSOperationQueue::\(unsafeAddress(of: self))"
327+
effectiveName = "NSOperationQueue::\(Unmanaged.passUnretained(self).toOpaque())"
328328
}
329329
let attr: DispatchQueueAttributes
330330
if maxConcurrentOperationCount == 1 {

Foundation/NSURLResponse.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public class NSHTTPURLResponse : URLResponse {
232232
/// A string that represents the contents of the NSHTTPURLResponse Object.
233233
/// This property is intended to produce readable output.
234234
override public var description: String {
235-
var result = "<\(self.dynamicType) \(unsafeAddress(of: self))> { URL: \(url!.absoluteString) }{ status: \(statusCode), headers {\n"
235+
var result = "<\(self.dynamicType) \(Unmanaged.passUnretained(self).toOpaque())> { URL: \(url!.absoluteString) }{ status: \(statusCode), headers {\n"
236236
for(key, value) in allHeaderFields {
237237
if((key.lowercased() == "content-disposition" && suggestedFilename != "Unknown") || key.lowercased() == "content-type") {
238238
result += " \"\(key)\" = \"\(value)\";\n"

0 commit comments

Comments
 (0)