Skip to content

Remove miscellaneous NSUnimplemented() use #2491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foundation/MeasurementFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ open class MeasurementFormatter : Formatter, NSSecureCoding {
*/
open func string(from unit: Unit) -> String { NSUnsupported() }

public override init() { NSUnimplemented() }
public override init() { NSUnsupported() }

public required init?(coder aDecoder: NSCoder) { NSUnsupported() }
open override func encode(with aCoder: NSCoder) { NSUnsupported() }
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSSpecialValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal class NSSpecialValue : NSValue {

required init(bytes value: UnsafeRawPointer, objCType type: UnsafePointer<Int8>) {
guard let specialType = NSSpecialValue._typeFromObjCType(type) else {
NSUnimplemented()
NSUnsupported()
}

self._value = specialType.init(bytes: value)
Expand Down
16 changes: 11 additions & 5 deletions Foundation/PersonNameComponentsFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ extension PersonNameComponentsFormatter {
}
}

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

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

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

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

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

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

// Attributed String identifier key string
Expand Down
56 changes: 0 additions & 56 deletions Foundation/URLCredential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,59 +155,3 @@ open class URLCredential : NSObject, NSSecureCoding, NSCopying {
return true
}
}

// TODO: We have no implementation for Security.framework primitive types SecIdentity and SecTrust yet
/*
extension URLCredential {

/*!
@method initWithIdentity:certificates:persistence:
@abstract Initialize an URLCredential with an identity and array of at least 1 client certificates (SecCertificateRef)
@param identity a SecIdentityRef object
@param certArray an array containing at least one SecCertificateRef objects
@param persistence enum that says to store per session, permanently or not at all
@result the Initialized URLCredential
*/
public convenience init(identity: SecIdentity, certificates certArray: [AnyObject]?, persistence: URLCredential.Persistence)

/*!
@method credentialWithIdentity:certificates:persistence:
@abstract Create a new URLCredential with an identity and certificate array
@param identity a SecIdentityRef object
@param certArray an array containing at least one SecCertificateRef objects
@param persistence enum that says to store per session, permanently or not at all
@result The new autoreleased URLCredential
*/

/*!
@method identity
@abstract Returns the SecIdentityRef of this credential, if it was created with a certificate and identity
@result A SecIdentityRef or NULL if this is a username/password credential
*/
public var identity: SecIdentity? { NSUnimplemented() }

/*!
@method certificates
@abstract Returns an NSArray of SecCertificateRef objects representing the client certificate for this credential, if this credential was created with an identity and certificate.
@result an NSArray of SecCertificateRef or NULL if this is a username/password credential
*/
public var certificates: [AnyObject] { NSUnimplemented() }
}

extension URLCredential {

/*!
@method initWithTrust:
@abstract Initialize a new URLCredential which specifies that the specified trust has been accepted.
@result the Initialized URLCredential
*/
public convenience init(trust: SecTrust) { NSUnimplemented() }

/*!
@method credentialForTrust:
@abstract Create a new URLCredential which specifies that a handshake has been trusted.
@result The new autoreleased URLCredential
*/
public convenience init(forTrust trust: SecTrust) { NSUnimplemented() }
}
*/
4 changes: 2 additions & 2 deletions Foundation/URLSession/NativeProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ internal class _NativeProtocol: URLProtocol, _EasyHandleDelegate {
let transferState = _TransferState(url: url, bodyDataDrain: drain, bodySource: source)
self.internalState = .transferInProgress(transferState)
default:
NSUnimplemented()
fatalError()
}
default:
//TODO: it's possible?
Expand Down Expand Up @@ -507,7 +507,7 @@ extension _NativeProtocol {
NSUnimplemented()
case .becomeStream:
/* Turn this task into a stream task */
NSUnimplemented()
NSUnsupported()
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion Foundation/URLSession/URLSessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ extension URLSession {
}

public enum ResponseDisposition : Int {

case cancel /* Cancel the load, this is the same as -[task cancel] */
case allow /* Allow the load to continue */

@available(*, deprecated, message: "swift-corelibs-foundation doesn't currently support turning responses into downloads dynamically.")
case becomeDownload /* Turn this request into a download */

@available(*, unavailable, message: "swift-corelibs-foundation doesn't support stream tasks.")
case becomeStream /* Turn this task into a stream task */
}
}
Expand Down
8 changes: 5 additions & 3 deletions Foundation/URLSession/URLSessionTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,9 @@ extension _ProtocolClient : URLProtocolClient {
}

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion Foundation/XMLElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,5 @@ extension XMLElement {
@discussion This method is deprecated and does not function correctly. Use -setAttributesWith: instead.
*/
@available(*, unavailable, renamed:"setAttributesWith")
public func setAttributesAs(_ attributes: [NSObject : AnyObject]) { NSUnimplemented() }
public func setAttributesAs(_ attributes: [NSObject : AnyObject]) { NSUnsupported() }
}