@@ -16,11 +16,11 @@ import Darwin
16
16
import Glibc
17
17
#endif
18
18
19
- internal func __NSDataInvokeDeallocatorUnmap( _ mem: UnsafeMutableRawPointer , _ length: Int ) -> Void {
19
+ internal func __NSDataInvokeDeallocatorUnmap( _ mem: UnsafeMutablePointer < Void > , _ length: Int ) -> Void {
20
20
munmap ( mem, length)
21
21
}
22
22
23
- internal func __NSDataInvokeDeallocatorFree( _ mem: UnsafeMutableRawPointer , _ length: Int ) -> Void {
23
+ internal func __NSDataInvokeDeallocatorFree( _ mem: UnsafeMutablePointer < Void > , _ length: Int ) -> Void {
24
24
free ( mem)
25
25
}
26
26
@@ -34,30 +34,30 @@ internal final class _SwiftNSData : NSData, _SwiftNativeFoundationType {
34
34
// Take ownership.
35
35
__wrapped = . Immutable( Unmanaged . passRetained ( _unsafeReferenceCast ( immutableObject, to: ImmutableType . self) ) )
36
36
37
- let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutableRawPointer . self)
37
+ let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutablePointer < Void > . self )
38
38
super. init ( bytes: dummyPointer, length: 0 , copy: false , deallocator: nil )
39
39
}
40
40
41
41
init ( mutableObject: AnyObject ) {
42
42
// Take ownership.
43
43
__wrapped = . Mutable( Unmanaged . passRetained ( _unsafeReferenceCast ( mutableObject, to: MutableType . self) ) )
44
- let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutableRawPointer . self)
44
+ let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutablePointer < Void > . self )
45
45
super. init ( bytes: dummyPointer, length: 0 , copy: false , deallocator: nil )
46
46
}
47
47
48
48
internal required init ( unmanagedImmutableObject: Unmanaged < ImmutableType > ) {
49
49
// Take ownership.
50
50
__wrapped = . Immutable( unmanagedImmutableObject)
51
51
52
- let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutableRawPointer . self)
52
+ let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutablePointer < Void > . self )
53
53
super. init ( bytes: dummyPointer, length: 0 , copy: false , deallocator: nil )
54
54
}
55
55
56
56
internal required init ( unmanagedMutableObject: Unmanaged < MutableType > ) {
57
57
// Take ownership.
58
58
__wrapped = . Mutable( unmanagedMutableObject)
59
59
60
- let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutableRawPointer . self)
60
+ let dummyPointer = unsafeBitCast ( NSData . self, to: UnsafeMutablePointer < Void > . self )
61
61
super. init ( bytes: dummyPointer, length: 0 , copy: false , deallocator: nil )
62
62
}
63
63
@@ -82,19 +82,19 @@ internal final class _SwiftNSData : NSData, _SwiftNativeFoundationType {
82
82
}
83
83
}
84
84
85
- override var bytes : UnsafeRawPointer {
85
+ override var bytes : UnsafePointer < Void > {
86
86
return _mapUnmanaged { $0. bytes }
87
87
}
88
88
89
89
// override func subdata(with range: NSRange) -> Data {
90
90
// return _mapUnmanaged { $0.subdata(with: range) }
91
91
// }
92
92
//
93
- // override func getBytes(_ buffer: UnsafeMutableRawPointer , length: Int) {
93
+ // override func getBytes(_ buffer: UnsafeMutablePointer<Void> , length: Int) {
94
94
// return _mapUnmanaged { $0.getBytes(buffer, length: length) }
95
95
// }
96
96
//
97
- // override func getBytes(_ buffer: UnsafeMutableRawPointer , range: NSRange) {
97
+ // override func getBytes(_ buffer: UnsafeMutablePointer<Void> , range: NSRange) {
98
98
// return _mapUnmanaged { $0.getBytes(buffer, range: range) }
99
99
// }
100
100
//
@@ -112,7 +112,7 @@ internal final class _SwiftNSData : NSData, _SwiftNativeFoundationType {
112
112
// }
113
113
// }
114
114
//
115
- // override func enumerateByteRanges(using block: @noescape (UnsafeRawPointer , NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
115
+ // override func enumerateByteRanges(using block: @noescape (UnsafePointer<Void> , NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
116
116
// return _mapUnmanaged { $0.enumerateBytes(block) }
117
117
// }
118
118
//
@@ -163,7 +163,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
163
163
/// A custom deallocator.
164
164
case custom( ( UnsafeMutablePointer < UInt8 > , Int ) -> Void )
165
165
166
- fileprivate var _deallocator : ( ( UnsafeMutableRawPointer , Int ) -> Void ) ? {
166
+ fileprivate var _deallocator : ( ( UnsafeMutablePointer < Void > , Int ) -> Void ) ? {
167
167
switch self {
168
168
case . unmap:
169
169
return { __NSDataInvokeDeallocatorUnmap ( $0, $1) }
@@ -186,7 +186,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
186
186
///
187
187
/// - parameter bytes: A pointer to the memory. It will be copied.
188
188
/// - parameter count: The number of bytes to copy.
189
- public init ( bytes: UnsafeRawPointer , count: Int ) {
189
+ public init ( bytes: UnsafePointer < Void > , count: Int ) {
190
190
_wrapped = _SwiftNSData ( immutableObject: NSData ( bytes: bytes, length: count) )
191
191
}
192
192
@@ -279,8 +279,8 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
279
279
}
280
280
281
281
public init ? ( count: Int ) {
282
- if let memory = malloc ( count) ? . bindMemory ( to : UInt8 . self , capacity : count ) {
283
- self . init ( bytesNoCopy: memory, count: count, deallocator: . free)
282
+ if let memory = malloc ( count) {
283
+ self . init ( bytesNoCopy: UnsafeMutablePointer < UInt8 > ( memory) , count: count, deallocator: . free)
284
284
} else {
285
285
return nil
286
286
}
@@ -304,7 +304,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
304
304
}
305
305
}
306
306
307
- private func _getUnsafeBytesPointer( ) -> UnsafeRawPointer {
307
+ private func _getUnsafeBytesPointer( ) -> UnsafePointer < Void > {
308
308
return _mapUnmanaged { return $0. bytes }
309
309
}
310
310
@@ -314,11 +314,10 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
314
314
public func withUnsafeBytes< ResultType, ContentType> ( _ body: @noescape ( UnsafePointer < ContentType > ) throws -> ResultType ) rethrows -> ResultType {
315
315
let bytes = _getUnsafeBytesPointer ( )
316
316
defer { _fixLifetime ( self ) }
317
- let contentPtr = bytes. bindMemory ( to: ContentType . self, capacity: count / strideof( ContentType . self) )
318
- return try body ( contentPtr)
317
+ return try body ( UnsafePointer ( bytes) )
319
318
}
320
319
321
- private mutating func _getUnsafeMutableBytesPointer( ) -> UnsafeMutableRawPointer {
320
+ private mutating func _getUnsafeMutableBytesPointer( ) -> UnsafeMutablePointer < Void > {
322
321
return _applyUnmanagedMutation {
323
322
return $0. mutableBytes
324
323
}
@@ -331,8 +330,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
331
330
public mutating func withUnsafeMutableBytes< ResultType, ContentType> ( _ body: @noescape ( UnsafeMutablePointer < ContentType > ) throws -> ResultType ) rethrows -> ResultType {
332
331
let mutableBytes = _getUnsafeMutableBytesPointer ( )
333
332
defer { _fixLifetime ( self ) }
334
- let contentPtr = mutableBytes. bindMemory ( to: ContentType . self, capacity: count / strideof( ContentType . self) )
335
- return try body ( contentPtr)
333
+ return try body ( UnsafeMutablePointer ( mutableBytes) )
336
334
}
337
335
338
336
// MARK: -
0 commit comments