Skip to content

Commit

Permalink
De-underscore _MachError, _POSIXError, _NSCocoaError, _NSURLError.
Browse files Browse the repository at this point in the history
Turns rdar://problem/20536610 into API, per scattered but positive API
review feedback.

Swift SVN r28756
  • Loading branch information
DougGregor committed May 19, 2015
1 parent bddf134 commit 94aafe1
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 116 deletions.
20 changes: 10 additions & 10 deletions stdlib/public/SDK/AppKit/NSError.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public extension _NSCocoaError {
static let TextReadInapplicableDocumentTypeError = _NSCocoaError(rawValue: 65806)
static let TextWriteInapplicableDocumentTypeError = _NSCocoaError(rawValue: 66062)
static let ServiceApplicationNotFoundError = _NSCocoaError(rawValue: 66560)
static let ServiceApplicationLaunchFailedError = _NSCocoaError(rawValue: 66561)
static let ServiceRequestTimedOutError = _NSCocoaError(rawValue: 66562)
static let ServiceInvalidPasteboardDataError = _NSCocoaError(rawValue: 66563)
static let ServiceMalformedServiceDictionaryError = _NSCocoaError(rawValue: 66564)
static let ServiceMiscellaneousError = _NSCocoaError(rawValue: 66800)
static let SharingServiceNotConfiguredError = _NSCocoaError(rawValue: 67072)
public extension NSCocoaError {
static let TextReadInapplicableDocumentTypeError = NSCocoaError(rawValue: 65806)
static let TextWriteInapplicableDocumentTypeError = NSCocoaError(rawValue: 66062)
static let ServiceApplicationNotFoundError = NSCocoaError(rawValue: 66560)
static let ServiceApplicationLaunchFailedError = NSCocoaError(rawValue: 66561)
static let ServiceRequestTimedOutError = NSCocoaError(rawValue: 66562)
static let ServiceInvalidPasteboardDataError = NSCocoaError(rawValue: 66563)
static let ServiceMalformedServiceDictionaryError = NSCocoaError(rawValue: 66564)
static let ServiceMiscellaneousError = NSCocoaError(rawValue: 66800)
static let SharingServiceNotConfiguredError = NSCocoaError(rawValue: 67072)

public var isServiceError: Bool {
return rawValue >= 66560 && rawValue <= 66817;
Expand Down
86 changes: 43 additions & 43 deletions stdlib/public/SDK/CoreData/CoreData.swift
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
@exported import CoreData
import Foundation

public extension _NSCocoaError {
static let ManagedObjectValidationError = _NSCocoaError(rawValue: 1550)
static let ValidationMultipleErrorsError = _NSCocoaError(rawValue: 1560)
static let ValidationMissingMandatoryPropertyError = _NSCocoaError(rawValue: 1570)
static let ValidationRelationshipLacksMinimumCountError = _NSCocoaError(rawValue: 1580)
static let ValidationRelationshipExceedsMaximumCountError = _NSCocoaError(rawValue: 1590)
static let ValidationRelationshipDeniedDeleteError = _NSCocoaError(rawValue: 1600)
static let ValidationNumberTooLargeError = _NSCocoaError(rawValue: 1610)
static let ValidationNumberTooSmallError = _NSCocoaError(rawValue: 1620)
static let ValidationDateTooLateError = _NSCocoaError(rawValue: 1630)
static let ValidationDateTooSoonError = _NSCocoaError(rawValue: 1640)
static let ValidationInvalidDateError = _NSCocoaError(rawValue: 1650)
static let ValidationStringTooLongError = _NSCocoaError(rawValue: 1660)
static let ValidationStringTooShortError = _NSCocoaError(rawValue: 1670)
static let ValidationStringPatternMatchingError = _NSCocoaError(rawValue: 1680)
static let ManagedObjectContextLockingError = _NSCocoaError(rawValue: 132000)
static let PersistentStoreCoordinatorLockingError = _NSCocoaError(rawValue: 132010)
static let ManagedObjectReferentialIntegrityError = _NSCocoaError(rawValue: 133000)
static let ManagedObjectExternalRelationshipError = _NSCocoaError(rawValue: 133010)
static let ManagedObjectMergeError = _NSCocoaError(rawValue: 133020)
static let ManagedObjectConstraintMergeError = _NSCocoaError(rawValue: 133021)
static let PersistentStoreInvalidTypeError = _NSCocoaError(rawValue: 134000)
static let PersistentStoreTypeMismatchError = _NSCocoaError(rawValue: 134010)
static let PersistentStoreIncompatibleSchemaError = _NSCocoaError(rawValue: 134020)
static let PersistentStoreSaveError = _NSCocoaError(rawValue: 134030)
static let PersistentStoreIncompleteSaveError = _NSCocoaError(rawValue: 134040)
static let PersistentStoreSaveConflictsError = _NSCocoaError(rawValue: 134050)
static let CoreDataError = _NSCocoaError(rawValue: 134060)
static let PersistentStoreOperationError = _NSCocoaError(rawValue: 134070)
static let PersistentStoreOpenError = _NSCocoaError(rawValue: 134080)
static let PersistentStoreTimeoutError = _NSCocoaError(rawValue: 134090)
static let PersistentStoreUnsupportedRequestTypeError = _NSCocoaError(rawValue: 134091)
static let PersistentStoreIncompatibleVersionHashError = _NSCocoaError(rawValue: 134100)
static let MigrationError = _NSCocoaError(rawValue: 134110)
static let MigrationCancelledError = _NSCocoaError(rawValue: 134120)
static let MigrationMissingSourceModelError = _NSCocoaError(rawValue: 134130)
static let MigrationMissingMappingModelError = _NSCocoaError(rawValue: 134140)
static let MigrationManagerSourceStoreError = _NSCocoaError(rawValue: 134150)
static let MigrationManagerDestinationStoreError = _NSCocoaError(rawValue: 134160)
static let EntityMigrationPolicyError = _NSCocoaError(rawValue: 134170)
static let SQLiteError = _NSCocoaError(rawValue: 134180)
static let InferredMappingModelError = _NSCocoaError(rawValue: 134190)
static let ExternalRecordImportError = _NSCocoaError(rawValue: 134200)
public extension NSCocoaError {
static let ManagedObjectValidationError = NSCocoaError(rawValue: 1550)
static let ValidationMultipleErrorsError = NSCocoaError(rawValue: 1560)
static let ValidationMissingMandatoryPropertyError = NSCocoaError(rawValue: 1570)
static let ValidationRelationshipLacksMinimumCountError = NSCocoaError(rawValue: 1580)
static let ValidationRelationshipExceedsMaximumCountError = NSCocoaError(rawValue: 1590)
static let ValidationRelationshipDeniedDeleteError = NSCocoaError(rawValue: 1600)
static let ValidationNumberTooLargeError = NSCocoaError(rawValue: 1610)
static let ValidationNumberTooSmallError = NSCocoaError(rawValue: 1620)
static let ValidationDateTooLateError = NSCocoaError(rawValue: 1630)
static let ValidationDateTooSoonError = NSCocoaError(rawValue: 1640)
static let ValidationInvalidDateError = NSCocoaError(rawValue: 1650)
static let ValidationStringTooLongError = NSCocoaError(rawValue: 1660)
static let ValidationStringTooShortError = NSCocoaError(rawValue: 1670)
static let ValidationStringPatternMatchingError = NSCocoaError(rawValue: 1680)
static let ManagedObjectContextLockingError = NSCocoaError(rawValue: 132000)
static let PersistentStoreCoordinatorLockingError = NSCocoaError(rawValue: 132010)
static let ManagedObjectReferentialIntegrityError = NSCocoaError(rawValue: 133000)
static let ManagedObjectExternalRelationshipError = NSCocoaError(rawValue: 133010)
static let ManagedObjectMergeError = NSCocoaError(rawValue: 133020)
static let ManagedObjectConstraintMergeError = NSCocoaError(rawValue: 133021)
static let PersistentStoreInvalidTypeError = NSCocoaError(rawValue: 134000)
static let PersistentStoreTypeMismatchError = NSCocoaError(rawValue: 134010)
static let PersistentStoreIncompatibleSchemaError = NSCocoaError(rawValue: 134020)
static let PersistentStoreSaveError = NSCocoaError(rawValue: 134030)
static let PersistentStoreIncompleteSaveError = NSCocoaError(rawValue: 134040)
static let PersistentStoreSaveConflictsError = NSCocoaError(rawValue: 134050)
static let CoreDataError = NSCocoaError(rawValue: 134060)
static let PersistentStoreOperationError = NSCocoaError(rawValue: 134070)
static let PersistentStoreOpenError = NSCocoaError(rawValue: 134080)
static let PersistentStoreTimeoutError = NSCocoaError(rawValue: 134090)
static let PersistentStoreUnsupportedRequestTypeError = NSCocoaError(rawValue: 134091)
static let PersistentStoreIncompatibleVersionHashError = NSCocoaError(rawValue: 134100)
static let MigrationError = NSCocoaError(rawValue: 134110)
static let MigrationCancelledError = NSCocoaError(rawValue: 134120)
static let MigrationMissingSourceModelError = NSCocoaError(rawValue: 134130)
static let MigrationMissingMappingModelError = NSCocoaError(rawValue: 134140)
static let MigrationManagerSourceStoreError = NSCocoaError(rawValue: 134150)
static let MigrationManagerDestinationStoreError = NSCocoaError(rawValue: 134160)
static let EntityMigrationPolicyError = NSCocoaError(rawValue: 134170)
static let SQLiteError = NSCocoaError(rawValue: 134180)
static let InferredMappingModelError = NSCocoaError(rawValue: 134190)
static let ExternalRecordImportError = NSCocoaError(rawValue: 134200)
}

2 changes: 1 addition & 1 deletion stdlib/public/SDK/Darwin/MachError.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if os(OSX) || os(iOS) || os(tvOS) || os(watchOS)
/// Enumeration describing Mach error codes.
@objc public enum _MachError : CInt {
@objc public enum MachError : CInt {
case KERN_SUCCESS = 0

/// Specified address is not currently valid.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Darwin/POSIXError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if os(OSX) || os(iOS) || os(tvOS) || os(watchOS)
/// Enumeration describing POSIX error codes.
@objc public enum _POSIXError : CInt {
@objc public enum POSIXError : CInt {
// FIXME: These are the values for Darwin. We need to get the Linux
// values as well.
case EPERM = 1 /* Operation not permitted */
Expand Down
108 changes: 54 additions & 54 deletions stdlib/public/SDK/Foundation/NSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public protocol _BridgedNSError : __BridgedNSError,

/// Enumeration that describes the error codes within the Cocoa error
/// domain.
public struct _NSCocoaError : RawRepresentable, _BridgedNSError {
public struct NSCocoaError : RawRepresentable, _BridgedNSError {
public let rawValue: Int

public init(rawValue: Int) {
Expand All @@ -121,120 +121,120 @@ public struct _NSCocoaError : RawRepresentable, _BridgedNSError {
public static var _NSErrorDomain: String { return NSCocoaErrorDomain }
}

public func ~=(match: _NSCocoaError, error: ErrorType) -> Bool {
guard let cocoaError = error as? _NSCocoaError else { return false }
public func ~=(match: NSCocoaError, error: ErrorType) -> Bool {
guard let cocoaError = error as? NSCocoaError else { return false }
return match.rawValue == cocoaError.rawValue
}

public extension _NSCocoaError {
static let FileNoSuchFileError = _NSCocoaError(rawValue: 4)
static let FileLockingError = _NSCocoaError(rawValue: 255)
static let FileReadUnknownError = _NSCocoaError(rawValue: 256)
static let FileReadNoPermissionError = _NSCocoaError(rawValue: 257)
static let FileReadInvalidFileNameError = _NSCocoaError(rawValue: 258)
static let FileReadCorruptFileError = _NSCocoaError(rawValue: 259)
static let FileReadNoSuchFileError = _NSCocoaError(rawValue: 260)
static let FileReadInapplicableStringEncodingError = _NSCocoaError(rawValue: 261)
static let FileReadUnsupportedSchemeError = _NSCocoaError(rawValue: 262)
public extension NSCocoaError {
static let FileNoSuchFileError = NSCocoaError(rawValue: 4)
static let FileLockingError = NSCocoaError(rawValue: 255)
static let FileReadUnknownError = NSCocoaError(rawValue: 256)
static let FileReadNoPermissionError = NSCocoaError(rawValue: 257)
static let FileReadInvalidFileNameError = NSCocoaError(rawValue: 258)
static let FileReadCorruptFileError = NSCocoaError(rawValue: 259)
static let FileReadNoSuchFileError = NSCocoaError(rawValue: 260)
static let FileReadInapplicableStringEncodingError = NSCocoaError(rawValue: 261)
static let FileReadUnsupportedSchemeError = NSCocoaError(rawValue: 262)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let FileReadTooLargeError = _NSCocoaError(rawValue: 263)
static let FileReadTooLargeError = NSCocoaError(rawValue: 263)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let FileReadUnknownStringEncodingError = _NSCocoaError(rawValue: 264)
static let FileReadUnknownStringEncodingError = NSCocoaError(rawValue: 264)

static let FileWriteUnknownError = _NSCocoaError(rawValue: 512)
static let FileWriteNoPermissionError = _NSCocoaError(rawValue: 513)
static let FileWriteInvalidFileNameError = _NSCocoaError(rawValue: 514)
static let FileWriteUnknownError = NSCocoaError(rawValue: 512)
static let FileWriteNoPermissionError = NSCocoaError(rawValue: 513)
static let FileWriteInvalidFileNameError = NSCocoaError(rawValue: 514)

@available(OSX, introduced=10.7) @available(iOS, introduced=5.0)
static let FileWriteFileExistsError = _NSCocoaError(rawValue: 516)
static let FileWriteFileExistsError = NSCocoaError(rawValue: 516)

static let FileWriteInapplicableStringEncodingError = _NSCocoaError(rawValue: 517)
static let FileWriteUnsupportedSchemeError = _NSCocoaError(rawValue: 518)
static let FileWriteOutOfSpaceError = _NSCocoaError(rawValue: 640)
static let FileWriteInapplicableStringEncodingError = NSCocoaError(rawValue: 517)
static let FileWriteUnsupportedSchemeError = NSCocoaError(rawValue: 518)
static let FileWriteOutOfSpaceError = NSCocoaError(rawValue: 640)

@available(OSX, introduced=10.6) @available(iOS, introduced=4.0)
static let FileWriteVolumeReadOnlyError = _NSCocoaError(rawValue: 642)
static let FileWriteVolumeReadOnlyError = NSCocoaError(rawValue: 642)

@available(OSX, introduced=10.11) @available(iOS, unavailable)
static let FileManagerUnmountUnknownError = _NSCocoaError(rawValue: 768)
static let FileManagerUnmountUnknownError = NSCocoaError(rawValue: 768)

@available(OSX, introduced=10.11) @available(iOS, unavailable)
static let FileManagerUnmountBusyError = _NSCocoaError(rawValue: 769)
static let FileManagerUnmountBusyError = NSCocoaError(rawValue: 769)

static let KeyValueValidationError = _NSCocoaError(rawValue: 1024)
static let FormattingError = _NSCocoaError(rawValue: 2048)
static let UserCancelledError = _NSCocoaError(rawValue: 3072)
static let KeyValueValidationError = NSCocoaError(rawValue: 1024)
static let FormattingError = NSCocoaError(rawValue: 2048)
static let UserCancelledError = NSCocoaError(rawValue: 3072)

@available(OSX, introduced=10.8) @available(iOS, introduced=6.0)
static let FeatureUnsupportedError = _NSCocoaError(rawValue: 3328)
static let FeatureUnsupportedError = NSCocoaError(rawValue: 3328)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let ExecutableNotLoadableError = _NSCocoaError(rawValue: 3584)
static let ExecutableNotLoadableError = NSCocoaError(rawValue: 3584)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let ExecutableArchitectureMismatchError = _NSCocoaError(rawValue: 3585)
static let ExecutableArchitectureMismatchError = NSCocoaError(rawValue: 3585)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let ExecutableRuntimeMismatchError = _NSCocoaError(rawValue: 3586)
static let ExecutableRuntimeMismatchError = NSCocoaError(rawValue: 3586)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let ExecutableLoadError = _NSCocoaError(rawValue: 3587)
static let ExecutableLoadError = NSCocoaError(rawValue: 3587)

@available(OSX, introduced=10.5) @available(iOS, introduced=2.0)
static let ExecutableLinkError = _NSCocoaError(rawValue: 3588)
static let ExecutableLinkError = NSCocoaError(rawValue: 3588)

@available(OSX, introduced=10.6) @available(iOS, introduced=4.0)
static let PropertyListReadCorruptError = _NSCocoaError(rawValue: 3840)
static let PropertyListReadCorruptError = NSCocoaError(rawValue: 3840)

@available(OSX, introduced=10.6) @available(iOS, introduced=4.0)
static let PropertyListReadUnknownVersionError = _NSCocoaError(rawValue: 3841)
static let PropertyListReadUnknownVersionError = NSCocoaError(rawValue: 3841)

@available(OSX, introduced=10.6) @available(iOS, introduced=4.0)
static let PropertyListReadStreamError = _NSCocoaError(rawValue: 3842)
static let PropertyListReadStreamError = NSCocoaError(rawValue: 3842)

@available(OSX, introduced=10.6) @available(iOS, introduced=4.0)
static let PropertyListWriteStreamError = _NSCocoaError(rawValue: 3851)
static let PropertyListWriteStreamError = NSCocoaError(rawValue: 3851)

@available(OSX, introduced=10.10) @available(iOS, introduced=8.0)
static let PropertyListWriteInvalidError = _NSCocoaError(rawValue: 3852)
static let PropertyListWriteInvalidError = NSCocoaError(rawValue: 3852)

@available(OSX, introduced=10.8) @available(iOS, introduced=6.0)
static let XPCConnectionInterrupted = _NSCocoaError(rawValue: 4097)
static let XPCConnectionInterrupted = NSCocoaError(rawValue: 4097)

@available(OSX, introduced=10.8) @available(iOS, introduced=6.0)
static let XPCConnectionInvalid = _NSCocoaError(rawValue: 4099)
static let XPCConnectionInvalid = NSCocoaError(rawValue: 4099)

@available(OSX, introduced=10.8) @available(iOS, introduced=6.0)
static let XPCConnectionReplyInvalid = _NSCocoaError(rawValue: 4101)
static let XPCConnectionReplyInvalid = NSCocoaError(rawValue: 4101)

@available(OSX, introduced=10.9) @available(iOS, introduced=7.0)
static let UbiquitousFileUnavailableError = _NSCocoaError(rawValue: 4353)
static let UbiquitousFileUnavailableError = NSCocoaError(rawValue: 4353)

@available(OSX, introduced=10.9) @available(iOS, introduced=7.0)
static let UbiquitousFileNotUploadedDueToQuotaError = _NSCocoaError(rawValue: 4354)
static let UbiquitousFileNotUploadedDueToQuotaError = NSCocoaError(rawValue: 4354)

@available(OSX, introduced=10.9) @available(iOS, introduced=7.0)
static let UbiquitousFileUbiquityServerNotAvailable = _NSCocoaError(rawValue: 4355)
static let UbiquitousFileUbiquityServerNotAvailable = NSCocoaError(rawValue: 4355)

@available(OSX, introduced=10.10) @available(iOS, introduced=8.0)
static let UserActivityHandoffFailedError = _NSCocoaError(rawValue: 4608)
static let UserActivityHandoffFailedError = NSCocoaError(rawValue: 4608)

@available(OSX, introduced=10.10) @available(iOS, introduced=8.0)
static let UserActivityConnectionUnavailableError = _NSCocoaError(rawValue: 4609)
static let UserActivityConnectionUnavailableError = NSCocoaError(rawValue: 4609)

@available(OSX, introduced=10.10) @available(iOS, introduced=8.0)
static let UserActivityRemoteApplicationTimedOutError = _NSCocoaError(rawValue: 4610)
static let UserActivityRemoteApplicationTimedOutError = NSCocoaError(rawValue: 4610)

@available(OSX, introduced=10.10) @available(iOS, introduced=8.0)
static let UserActivityHandoffUserInfoTooLargeError = _NSCocoaError(rawValue: 4611)
static let UserActivityHandoffUserInfoTooLargeError = NSCocoaError(rawValue: 4611)

@available(OSX, introduced=10.11) @available(iOS, introduced=9.0)
static let CoderReadCorruptError = _NSCocoaError(rawValue: 4864)
static let CoderReadCorruptError = NSCocoaError(rawValue: 4864)

@available(OSX, introduced=10.11) @available(iOS, introduced=9.0)
static let CoderValueNotFoundError = _NSCocoaError(rawValue: 4865)
static let CoderValueNotFoundError = NSCocoaError(rawValue: 4865)


@available(OSX, introduced=10.11) @available(iOS, introduced=9.0)
Expand Down Expand Up @@ -282,7 +282,7 @@ public extension _NSCocoaError {

/// Enumeration that describes the error codes within the NSURL error
/// domain.
@objc public enum _NSURLError : Int, _BridgedNSError {
@objc public enum NSURLError : Int, _BridgedNSError {
case Unknown = -1
case Cancelled = -999
case BadURL = -1000
Expand Down Expand Up @@ -400,10 +400,10 @@ public protocol _BridgedNSErrorCInt : __BridgedNSErrorCInt,
static var _NSErrorDomain: String { get }
}

extension _POSIXError : _BridgedNSErrorCInt {
extension POSIXError : _BridgedNSErrorCInt {
public static var _NSErrorDomain: String { return NSPOSIXErrorDomain }
}

extension _MachError : _BridgedNSErrorCInt {
extension MachError : _BridgedNSErrorCInt {
public static var _NSErrorDomain: String { return NSMachErrorDomain }
}
Loading

0 comments on commit 94aafe1

Please sign in to comment.