Skip to content

Commit 60ae6e8

Browse files
authored
Merge pull request #2491 from millenomi/nsunimplemented-remove-most
2 parents 7207b89 + 68d6912 commit 60ae6e8

8 files changed

+25
-70
lines changed

Foundation/MeasurementFormatter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ open class MeasurementFormatter : Formatter, NSSecureCoding {
6767
*/
6868
open func string(from unit: Unit) -> String { NSUnsupported() }
6969

70-
public override init() { NSUnimplemented() }
70+
public override init() { NSUnsupported() }
7171

7272
public required init?(coder aDecoder: NSCoder) { NSUnsupported() }
7373
open override func encode(with aCoder: NSCoder) { NSUnsupported() }

Foundation/NSSpecialValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ internal class NSSpecialValue : NSValue {
8383

8484
required init(bytes value: UnsafeRawPointer, objCType type: UnsafePointer<Int8>) {
8585
guard let specialType = NSSpecialValue._typeFromObjCType(type) else {
86-
NSUnimplemented()
86+
NSUnsupported()
8787
}
8888

8989
self._value = specialType.init(bytes: value)

Foundation/PersonNameComponentsFormatter.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ extension PersonNameComponentsFormatter {
3939
}
4040
}
4141

42+
@available(*, deprecated, message: "Person name components formatting isn't available in swift-corelibs-foundation")
4243
open class PersonNameComponentsFormatter : Formatter {
4344

45+
@available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
4446
public required init?(coder: NSCoder) {
45-
NSUnimplemented()
47+
NSUnsupported()
4648
}
4749

4850
/* Specify the formatting style for the formatted string on an instance. ShortStyle will fall back to user preferences and language-specific defaults
@@ -56,18 +58,22 @@ open class PersonNameComponentsFormatter : Formatter {
5658
/* Shortcut for converting an NSPersonNameComponents object into a string without explicitly creating an instance.
5759
Create an instance for greater customizability.
5860
*/
59-
open class func localizedString(from components: PersonNameComponents, style nameFormatStyle: Style, options nameOptions: Options = []) -> String { NSUnimplemented() }
61+
@available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
62+
open class func localizedString(from components: PersonNameComponents, style nameFormatStyle: Style, options nameOptions: Options = []) -> String { NSUnsupported() }
6063

6164
/* Convenience method on string(for:):. Returns a string containing the formatted value of the provided components object.
6265
*/
63-
open func string(from components: PersonNameComponents) -> String { NSUnimplemented() }
66+
@available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
67+
open func string(from components: PersonNameComponents) -> String { NSUnsupported() }
6468

6569
/* Returns attributed string with annotations for each component. For each range, attributes can be obtained by querying
6670
dictionary key NSPersonNameComponentKey , using NSPersonNameComponent constant values.
6771
*/
68-
open func annotatedString(from components: PersonNameComponents) -> NSAttributedString { NSUnimplemented() }
72+
@available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
73+
open func annotatedString(from components: PersonNameComponents) -> NSAttributedString { NSUnsupported() }
6974

70-
open func personNameComponents(from string: String) -> PersonNameComponents? { NSUnimplemented() }
75+
@available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
76+
open func personNameComponents(from string: String) -> PersonNameComponents? { NSUnsupported() }
7177
}
7278

7379
// Attributed String identifier key string

Foundation/URLCredential.swift

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -155,59 +155,3 @@ open class URLCredential : NSObject, NSSecureCoding, NSCopying {
155155
return true
156156
}
157157
}
158-
159-
// TODO: We have no implementation for Security.framework primitive types SecIdentity and SecTrust yet
160-
/*
161-
extension URLCredential {
162-
163-
/*!
164-
@method initWithIdentity:certificates:persistence:
165-
@abstract Initialize an URLCredential with an identity and array of at least 1 client certificates (SecCertificateRef)
166-
@param identity a SecIdentityRef object
167-
@param certArray an array containing at least one SecCertificateRef objects
168-
@param persistence enum that says to store per session, permanently or not at all
169-
@result the Initialized URLCredential
170-
*/
171-
public convenience init(identity: SecIdentity, certificates certArray: [AnyObject]?, persistence: URLCredential.Persistence)
172-
173-
/*!
174-
@method credentialWithIdentity:certificates:persistence:
175-
@abstract Create a new URLCredential with an identity and certificate array
176-
@param identity a SecIdentityRef object
177-
@param certArray an array containing at least one SecCertificateRef objects
178-
@param persistence enum that says to store per session, permanently or not at all
179-
@result The new autoreleased URLCredential
180-
*/
181-
182-
/*!
183-
@method identity
184-
@abstract Returns the SecIdentityRef of this credential, if it was created with a certificate and identity
185-
@result A SecIdentityRef or NULL if this is a username/password credential
186-
*/
187-
public var identity: SecIdentity? { NSUnimplemented() }
188-
189-
/*!
190-
@method certificates
191-
@abstract Returns an NSArray of SecCertificateRef objects representing the client certificate for this credential, if this credential was created with an identity and certificate.
192-
@result an NSArray of SecCertificateRef or NULL if this is a username/password credential
193-
*/
194-
public var certificates: [AnyObject] { NSUnimplemented() }
195-
}
196-
197-
extension URLCredential {
198-
199-
/*!
200-
@method initWithTrust:
201-
@abstract Initialize a new URLCredential which specifies that the specified trust has been accepted.
202-
@result the Initialized URLCredential
203-
*/
204-
public convenience init(trust: SecTrust) { NSUnimplemented() }
205-
206-
/*!
207-
@method credentialForTrust:
208-
@abstract Create a new URLCredential which specifies that a handshake has been trusted.
209-
@result The new autoreleased URLCredential
210-
*/
211-
public convenience init(forTrust trust: SecTrust) { NSUnimplemented() }
212-
}
213-
*/

Foundation/URLSession/NativeProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ internal class _NativeProtocol: URLProtocol, _EasyHandleDelegate {
292292
let transferState = _TransferState(url: url, bodyDataDrain: drain, bodySource: source)
293293
self.internalState = .transferInProgress(transferState)
294294
default:
295-
NSUnimplemented()
295+
fatalError()
296296
}
297297
default:
298298
//TODO: it's possible?
@@ -507,7 +507,7 @@ extension _NativeProtocol {
507507
NSUnimplemented()
508508
case .becomeStream:
509509
/* Turn this task into a stream task */
510-
NSUnimplemented()
510+
NSUnsupported()
511511
}
512512
}
513513
}

Foundation/URLSession/URLSessionDelegate.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ extension URLSession {
3434
}
3535

3636
public enum ResponseDisposition : Int {
37-
3837
case cancel /* Cancel the load, this is the same as -[task cancel] */
3938
case allow /* Allow the load to continue */
39+
40+
@available(*, deprecated, message: "swift-corelibs-foundation doesn't currently support turning responses into downloads dynamically.")
4041
case becomeDownload /* Turn this request into a download */
42+
43+
@available(*, unavailable, message: "swift-corelibs-foundation doesn't support stream tasks.")
4144
case becomeStream /* Turn this task into a stream task */
4245
}
4346
}

Foundation/URLSession/URLSessionTask.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,9 @@ extension _ProtocolClient : URLProtocolClient {
892892
}
893893

894894
func urlProtocol(_ protocol: URLProtocol, didCancel challenge: URLAuthenticationChallenge) {
895-
NSUnimplemented()
895+
guard let task = `protocol`.task else { fatalError() }
896+
// Fail with a cancellation error, for now.
897+
urlProtocol(task: task, didFailWithError: NSError(domain: NSCocoaErrorDomain, code: CocoaError.userCancelled.rawValue))
896898
}
897899

898900
func urlProtocol(_ protocol: URLProtocol, didReceive challenge: URLAuthenticationChallenge) {
@@ -1033,7 +1035,7 @@ extension _ProtocolClient : URLProtocolClient {
10331035
func urlProtocol(_ protocol: URLProtocol, cachedResponseIsValid cachedResponse: CachedURLResponse) {}
10341036

10351037
func urlProtocol(_ protocol: URLProtocol, wasRedirectedTo request: URLRequest, redirectResponse: URLResponse) {
1036-
NSUnimplemented()
1038+
fatalError("The URLSession swift-corelibs-foundation implementation doesn't currently handle redirects directly.")
10371039
}
10381040
}
10391041
extension URLSessionTask {
@@ -1058,7 +1060,7 @@ extension URLSessionTask {
10581060
}
10591061

10601062
static func digestAuth(_ task: URLSessionTask, _ disposition: URLSession.AuthChallengeDisposition, _ credential: URLCredential?) {
1061-
NSUnimplemented()
1063+
fatalError("The URLSession swift-corelibs-foundation implementation doesn't currently handle digest authentication.")
10621064
}
10631065
}
10641066

Foundation/XMLElement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,5 +422,5 @@ extension XMLElement {
422422
@discussion This method is deprecated and does not function correctly. Use -setAttributesWith: instead.
423423
*/
424424
@available(*, unavailable, renamed:"setAttributesWith")
425-
public func setAttributesAs(_ attributes: [NSObject : AnyObject]) { NSUnimplemented() }
425+
public func setAttributesAs(_ attributes: [NSObject : AnyObject]) { NSUnsupported() }
426426
}

0 commit comments

Comments
 (0)