Skip to content

Commit 8994408

Browse files
mikeashairspeedswift
authored andcommitted
[swiftdt] Import Foundation again, and get rid of our horrible handcrafted NSString bridging.
rdar://problem/55481578
1 parent c0963cb commit 8994408

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

tools/swiftdt/Sources/swiftdt/Inspector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Darwin
1+
import Foundation
22
import SwiftRemoteMirror
33
import SymbolicationShims
44

tools/swiftdt/Sources/swiftdt/stdio.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Darwin
1+
import Foundation
22

33
enum Std {
44
struct File: TextOutputStream {

tools/swiftdt/Sources/swiftdt/symbolication.swift

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Darwin
1+
import Foundation
22
import SymbolicationShims
33

44
private let symbolicationPath =
@@ -51,25 +51,11 @@ enum Sym {
5151
symbol(symbolicationHandle, "task_stop_peeking")
5252
}
5353

54-
private enum CF {
55-
static let path = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"
56-
static let handle = dlopen(path, RTLD_LAZY)!
57-
static let stringCreateWithCString:
58-
@convention(c) (UnsafeRawPointer?, UnsafePointer<CChar>, UInt32) ->
59-
Unmanaged<AnyObject> = symbol(handle, "CFStringCreateWithCString")
60-
static let stringEncodingUTF8: UInt32 = 0x08000100
61-
}
62-
6354
typealias CSMachineTime = UInt64
6455
let kCSNow = CSMachineTime(Int64.max) + 1
6556

66-
private func withNSString<T>(_ str: String, call: (AnyObject) -> T) -> T {
67-
let cfstr = CF.stringCreateWithCString(nil, str, CF.stringEncodingUTF8)
68-
return call(cfstr.takeRetainedValue())
69-
}
70-
7157
func pidFromHint(_ hint: String) -> pid_t? {
72-
let result = withNSString(hint, call: Sym.pidFromHint)
58+
let result = Sym.pidFromHint(hint as NSString)
7359
return result == 0 ? nil : result
7460
}
7561

0 commit comments

Comments
 (0)