Skip to content

Change some global constants to type properties to match the Darwin version #771

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
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
5 changes: 3 additions & 2 deletions Foundation/NSLocale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ public func <(_ lhs: NSLocale.Key, _ rhs: NSLocale.Key) -> Bool {
}



public let NSCurrentLocaleDidChangeNotification: String = "kCFLocaleCurrentLocaleDidChangeNotification"
public extension NSLocale {
public static let currentLocaleDidChangeNotification = NSNotification.Name(rawValue: "kCFLocaleCurrentLocaleDidChangeNotification")
}


extension CFLocale : _NSBridgeable, _SwiftBridgeable {
Expand Down
10 changes: 6 additions & 4 deletions Foundation/NSOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ open class BlockOperation: Operation {
}
}

public let NSOperationQueueDefaultMaxConcurrentOperationCount: Int = Int.max
public extension OperationQueue {
public static let defaultMaxConcurrentOperationCount: Int = Int.max
}

internal struct _OperationList {
var veryLow = [Operation]()
Expand Down Expand Up @@ -332,7 +334,7 @@ open class OperationQueue: NSObject {
__concurrencyGate = DispatchSemaphore(value: 1)
} else {
attr = .concurrent
if maxConcurrentOperationCount != NSOperationQueueDefaultMaxConcurrentOperationCount {
if maxConcurrentOperationCount != OperationQueue.defaultMaxConcurrentOperationCount {
__concurrencyGate = DispatchSemaphore(value:maxConcurrentOperationCount)
}
}
Expand All @@ -352,7 +354,7 @@ open class OperationQueue: NSObject {
}

#if DEPLOYMENT_ENABLE_LIBDISPATCH
internal init(_queue queue: DispatchQueue, maxConcurrentOperations: Int = NSOperationQueueDefaultMaxConcurrentOperationCount) {
internal init(_queue queue: DispatchQueue, maxConcurrentOperations: Int = OperationQueue.defaultMaxConcurrentOperationCount) {
__underlyingQueue = queue
maxConcurrentOperationCount = maxConcurrentOperations
super.init()
Expand Down Expand Up @@ -462,7 +464,7 @@ open class OperationQueue: NSObject {
return count
}

open var maxConcurrentOperationCount: Int = NSOperationQueueDefaultMaxConcurrentOperationCount
open var maxConcurrentOperationCount: Int = OperationQueue.defaultMaxConcurrentOperationCount

internal var _suspended = false
open var isSuspended: Bool {
Expand Down
14 changes: 8 additions & 6 deletions Foundation/NSURLCredentialStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ extension URLCredentialStorage {
public func setDefaultCredential(_ credential: URLCredential, for protectionSpace: URLProtectionSpace, task: URLSessionTask) { NSUnimplemented() }
}

/*!
@const NSURLCredentialStorageChangedNotification
@abstract This notification is sent on the main thread whenever
the set of stored credentials changes.
*/
public let NSURLCredentialStorageChangedNotification: String = "" // NSUnimplemented
public extension Notification.Name {
/*!
@const NSURLCredentialStorageChangedNotification
@abstract This notification is sent on the main thread whenever
the set of stored credentials changes.
*/
public static let NSURLCredentialStorageChanged = NSNotification.Name(rawValue: "") // NSUnimplemented
}

/*
* NSURLCredentialStorageRemoveSynchronizableCredentials - (NSNumber value)
Expand Down
4 changes: 2 additions & 2 deletions TestFoundation/TestNSLocale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class TestNSLocale : XCTestCase {
}

func test_constants() {
XCTAssertEqual(NSCurrentLocaleDidChangeNotification, "kCFLocaleCurrentLocaleDidChangeNotification",
"\(NSCurrentLocaleDidChangeNotification) is not equal to kCFLocaleCurrentLocaleDidChangeNotification")
XCTAssertEqual(NSLocale.currentLocaleDidChangeNotification.rawValue, "kCFLocaleCurrentLocaleDidChangeNotification",
"\(NSLocale.currentLocaleDidChangeNotification.rawValue) is not equal to kCFLocaleCurrentLocaleDidChangeNotification")

XCTAssertEqual(NSLocale.Key.identifier.rawValue, "kCFLocaleIdentifierKey",
"\(NSLocale.Key.identifier.rawValue) is not equal to kCFLocaleIdentifierKey")
Expand Down