|
7 | 7 | // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
8 | 8 | //
|
9 | 9 |
|
10 |
| - |
11 |
| -/// A single name-value pair, for use with `URLComponents`. |
12 |
| -public struct URLQueryItem: ReferenceConvertible, Hashable, Equatable { |
13 |
| - public typealias ReferenceType = NSURLQueryItem |
14 |
| - |
15 |
| - fileprivate var _queryItem: NSURLQueryItem |
16 |
| - |
17 |
| - public init(name: String, value: String?) { |
18 |
| - _queryItem = NSURLQueryItem(name: name, value: value) |
19 |
| - } |
20 |
| - |
21 |
| - fileprivate init(reference: NSURLQueryItem) { _queryItem = reference.copy() as! NSURLQueryItem } |
22 |
| - fileprivate var reference: NSURLQueryItem { return _queryItem } |
23 |
| - |
24 |
| - public var name: String { |
25 |
| - get { return _queryItem.name } |
26 |
| - set { _queryItem = NSURLQueryItem(name: newValue, value: value) } |
27 |
| - } |
28 |
| - |
29 |
| - public var value: String? { |
30 |
| - get { return _queryItem.value } |
31 |
| - set { _queryItem = NSURLQueryItem(name: name, value: newValue) } |
32 |
| - } |
33 |
| - |
34 |
| - public func hash(into hasher: inout Hasher) { |
35 |
| - hasher.combine(_queryItem) |
36 |
| - } |
37 |
| - |
38 |
| - public static func ==(lhs: URLQueryItem, rhs: URLQueryItem) -> Bool { |
39 |
| - return lhs._queryItem.isEqual(rhs._queryItem) |
40 |
| - } |
41 |
| -} |
42 |
| - |
43 |
| -extension URLQueryItem: CustomStringConvertible, CustomDebugStringConvertible, CustomReflectable { |
44 |
| - public var description: String { |
45 |
| - if let v = value { |
46 |
| - return "\(name)=\(v)" |
47 |
| - } else { |
48 |
| - return name |
49 |
| - } |
50 |
| - } |
51 |
| - |
52 |
| - public var debugDescription: String { |
53 |
| - return self.description |
54 |
| - } |
55 |
| - |
56 |
| - public var customMirror: Mirror { |
57 |
| - var c: [(label: String?, value: Any)] = [] |
58 |
| - c.append((label: "name", value: name)) |
59 |
| - c.append((label: "value", value: value as Any)) |
60 |
| - return Mirror(self, children: c, displayStyle: .struct) |
61 |
| - } |
62 |
| -} |
| 10 | +// URLQueryItem is defined in FoundationEssentials |
| 11 | +@_exported import FoundationEssentials |
63 | 12 |
|
64 | 13 | extension URLQueryItem: _NSBridgeable {
|
65 | 14 | typealias NSType = NSURLQueryItem
|
66 |
| - internal var _nsObject: NSType { return _queryItem } |
67 |
| -} |
68 |
| - |
69 |
| -extension URLQueryItem: _ObjectiveCBridgeable { |
70 |
| - public typealias _ObjectType = NSURLQueryItem |
71 |
| - |
72 |
| - public static func _getObjectiveCType() -> Any.Type { |
73 |
| - return NSURLQueryItem.self |
74 |
| - } |
75 |
| - |
76 |
| - @_semantics("convertToObjectiveC") |
77 |
| - public func _bridgeToObjectiveC() -> NSURLQueryItem { |
78 |
| - return _queryItem |
79 |
| - } |
80 |
| - |
81 |
| - public static func _forceBridgeFromObjectiveC(_ x: NSURLQueryItem, result: inout URLQueryItem?) { |
82 |
| - if !_conditionallyBridgeFromObjectiveC(x, result: &result) { |
83 |
| - fatalError("Unable to bridge \(_ObjectType.self) to \(self)") |
84 |
| - } |
85 |
| - } |
86 |
| - |
87 |
| - public static func _conditionallyBridgeFromObjectiveC(_ x: NSURLQueryItem, result: inout URLQueryItem?) -> Bool { |
88 |
| - result = URLQueryItem(reference: x) |
89 |
| - return true |
90 |
| - } |
91 |
| - |
92 |
| - public static func _unconditionallyBridgeFromObjectiveC(_ source: NSURLQueryItem?) -> URLQueryItem { |
93 |
| - var result: URLQueryItem? = nil |
94 |
| - _forceBridgeFromObjectiveC(source!, result: &result) |
95 |
| - return result! |
96 |
| - } |
| 15 | + internal var _nsObject: NSType { return NSURLQueryItem(name: self.name, value: self.value) } |
97 | 16 | }
|
98 | 17 |
|
99 | 18 | extension NSURLQueryItem: _SwiftBridgeable {
|
100 | 19 | typealias SwiftType = URLQueryItem
|
101 |
| - internal var _swiftObject: SwiftType { return URLQueryItem(reference: self) } |
| 20 | + internal var _swiftObject: SwiftType { return URLQueryItem(name: self.name, value: self.value) } |
102 | 21 | }
|
0 commit comments