Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)

* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
This commit is contained in:
Andrew Trick
2016-07-26 02:18:21 -07:00
committed by GitHub
parent 3b03d45277
commit ece0951924
74 changed files with 339 additions and 307 deletions

View File

@@ -28,7 +28,7 @@ autoreleasepool {
repeat {
let data = NSData(bytes: [2, 3, 5, 7] as [UInt8], length: 4)
hangCanary(data)
bytes = UnsafeMutablePointer<UInt8>(data.bytes)
bytes = UnsafeMutablePointer<UInt8>(data.bytes.assumingMemoryBound(to: UInt8.self))
} while false // CHECK-NOT: died
print(bytes[0]) // CHECK: 2
print(bytes[1]) // CHECK-NEXT: 3
@@ -44,7 +44,7 @@ autoreleasepool {
let data = NSData(bytes: [11, 13, 17, 19] as [UInt8], length: 4)
hangCanary(data)
let dataAsAny: AnyObject = data
bytes = UnsafeMutablePointer<UInt8>(dataAsAny.bytes!)
bytes = UnsafeMutablePointer<UInt8>(dataAsAny.bytes!.assumingMemoryBound(to: UInt8.self))
} while false // CHECK-NOT: died
print(bytes[0]) // CHECK: 11
print(bytes[1]) // CHECK-NEXT: 13