Skip to content

Commit

Permalink
[gardening] Prefer macOS over OSX (swiftlang#1500)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo authored and parkera committed Apr 2, 2018
1 parent d1272be commit 590c3be
Show file tree
Hide file tree
Showing 53 changed files with 115 additions and 118 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Please remember to include platform information with your report. If the bug is

Before embarking on a large amount of work to implement missing functionality, please double-check with the community on the [swift-corelibs-dev](https://lists.swift.org/mailman/listinfo/swift-corelibs-dev) mailing list. Someone may already be working in this area, and we want to avoid duplication of work.

If your request includes functionality changes, please be sure to test your code on Linux as well as OS X. Differences in the compiler and runtime on each platform means that code that compiles and runs correctly on Darwin (where the Objective-C runtime is present) may not compile at all on Linux.
If your request includes functionality changes, please be sure to test your code on Linux as well as macOS. Differences in the compiler and runtime on each platform means that code that compiles and runs correctly on Darwin (where the Objective-C runtime is present) may not compile at all on Linux.

##### Review

Expand Down
4 changes: 2 additions & 2 deletions Docs/Archiving.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Archiving Notes

There is a preliminary implementation of NSKeyedArchiver and NSKeyedUnarchiver which should be compatible with the OS X version.
There is a preliminary implementation of NSKeyedArchiver and NSKeyedUnarchiver which should be compatible with the macOS version.

* NSKeyedUnarchiver reads the entire plist into memory before constructing the object graph, it should construct it incrementally as does Foundation on OS X
* NSKeyedUnarchiver reads the entire plist into memory before constructing the object graph, it should construct it incrementally as does Foundation on macOS

* Paths that raise errors vs. calling _fatalError() need to be reviewed carefully

Expand Down
6 changes: 3 additions & 3 deletions Docs/Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Portability

This version of Foundation is designed to support the same API as the Foundation that ships with Apple operating systems. A key difference is that the distribution of Swift open source does not include the Objective-C runtime. This means that the source code of Foundation from OS X and iOS could not be simply reused on other platforms. However, we believe that the vast majority of the core API concepts presented in Foundation are themselves portable and are useful on all platforms.
This version of Foundation is designed to support the same API as the Foundation that ships with Apple operating systems. A key difference is that the distribution of Swift open source does not include the Objective-C runtime. This means that the source code of Foundation from macOS and iOS could not be simply reused on other platforms. However, we believe that the vast majority of the core API concepts presented in Foundation are themselves portable and are useful on all platforms.

It is not a goal of this project to create new API that extends beyond the API provided on Apple operating systems, as that would hamper the goal of portability.

Expand Down Expand Up @@ -85,7 +85,7 @@ When different logic is required for the Swift runtime in CF, use the following

In Swift, the OS-check macro is also available:
```swift
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux)
import Glibc
Expand Down Expand Up @@ -113,7 +113,7 @@ One of the main challenges of developing and maintaining a widely used library i

## Keeping Organized

Parts of the CoreFoundation and Foundation libraries are as old as OS X (or older). In order to support long-term maintainability, it is important to keep our source code organized.
Parts of the CoreFoundation and Foundation libraries are as old as macOS (or older). In order to support long-term maintainability, it is important to keep our source code organized.

* If it helps keep an effective separation of concerns, feel free to split up functionality of one class over several files.
* If appropriate, use `// MARK - Topic` to split up sections of a file.
Expand Down
7 changes: 3 additions & 4 deletions Docs/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Getting Started

## On OS X
## On macOS

Although OS X is not a deployment platform for Swift Foundation, it is useful for development and test purposes.
Although macOS is not a deployment platform for Swift Foundation, it is useful for development and test purposes.

In order to build on OS X, you will need:
In order to build on macOS, you will need:

* The latest version of Xcode
* The latest version of the macOS SDK (at this time: 10.13.2)
Expand Down Expand Up @@ -81,4 +81,3 @@ When new source files or flags are added to the `build.py` script, the project w
% ninja reconfigure
% ninja
```

2 changes: 1 addition & 1 deletion Foundation/AffineTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
4 changes: 2 additions & 2 deletions Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#if DEPLOYMENT_RUNTIME_SWIFT

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux)
import Glibc
Expand Down Expand Up @@ -1391,7 +1391,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl

// Avoid a crash that happens on OS X 10.11.x and iOS 9.x or before when writing a bridged Data non-atomically with Foundation's standard write() implementation.
if !options.contains(.atomic) {
#if os(OSX)
#if os(macOS)
return NSFoundationVersionNumber <= Double(NSFoundationVersionNumber10_11_Max)
#else
return NSFoundationVersionNumber <= Double(NSFoundationVersionNumber_iOS_9_x_Max)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/DateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open class DateFormatter : Formatter {
private var __cfObject: CFType?
private var _cfObject: CFType {
guard let obj = __cfObject else {
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let dateStyle = CFDateFormatterStyle(rawValue: CFIndex(self.dateStyle.rawValue))!
let timeStyle = CFDateFormatterStyle(rawValue: CFIndex(self.timeStyle.rawValue))!
#else
Expand Down
2 changes: 1 addition & 1 deletion Foundation/FileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
12 changes: 6 additions & 6 deletions Foundation/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down Expand Up @@ -127,7 +127,7 @@ open class FileManager : NSObject {
guard let number = attributes[attribute] as? NSNumber else {
fatalError("Can't set file permissions to \(attributes[attribute] as Any?)")
}
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let modeT = number.uint16Value
#elseif os(Linux) || os(Android) || CYGWIN
let modeT = number.uint32Value
Expand Down Expand Up @@ -261,7 +261,7 @@ open class FileManager : NSObject {
var result = [FileAttributeKey : Any]()
result[.size] = NSNumber(value: UInt64(s.st_size))

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let ti = (TimeInterval(s.st_mtimespec.tv_sec) - kCFAbsoluteTimeIntervalSince1970) + (1.0e-9 * TimeInterval(s.st_mtimespec.tv_nsec))
#elseif os(Android)
let ti = (TimeInterval(s.st_mtime) - kCFAbsoluteTimeIntervalSince1970) + (1.0e-9 * TimeInterval(s.st_mtime_nsec))
Expand Down Expand Up @@ -301,7 +301,7 @@ open class FileManager : NSObject {
result[.deviceIdentifier] = NSNumber(value: UInt64(s.st_rdev))
}

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
if (s.st_flags & UInt32(UF_IMMUTABLE | SF_IMMUTABLE)) != 0 {
result[.immutable] = NSNumber(value: true)
}
Expand All @@ -324,7 +324,7 @@ open class FileManager : NSObject {
NSUnimplemented()
#else
// statvfs(2) doesn't support 64bit inode on Darwin (apfs), fallback to statfs(2)
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
var s = statfs()
guard statfs(path, &s) == 0 else {
throw _NSErrorWithErrno(errno, reading: true, path: path)
Expand All @@ -338,7 +338,7 @@ open class FileManager : NSObject {


var result = [FileAttributeKey : Any]()
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let blockSize = UInt64(s.f_bsize)
result[.systemNumber] = NSNumber(value: UInt64(s.f_fsid.val.0))
#else
Expand Down
2 changes: 1 addition & 1 deletion Foundation/FoundationErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public var NSCoderReadCorruptError: Int { return CocoaError

public var NSCoderValueNotFoundError: Int { return CocoaError.Code.coderValueNotFound.rawValue }

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
4 changes: 2 additions & 2 deletions Foundation/Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//


#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down Expand Up @@ -117,7 +117,7 @@ open class Host: NSObject {
}
var hints = addrinfo()
hints.ai_family = PF_UNSPEC
#if os(OSX) || os(iOS) || os(Android)
#if os(macOS) || os(iOS) || os(Android)
hints.ai_socktype = SOCK_STREAM
#else
hints.ai_socktype = Int32(SOCK_STREAM.rawValue)
Expand Down
4 changes: 2 additions & 2 deletions Foundation/ISO8601DateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ open class ISO8601DateFormatter : Formatter, NSSecureCoding {
private var __cfObject: CFType?
private var _cfObject: CFType {
guard let obj = __cfObject else {
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let format = CFISO8601DateFormatOptions(rawValue: formatOptions.rawValue)
#else
let format = CFISO8601DateFormatOptions(self.formatOptions.rawValue)
Expand Down Expand Up @@ -100,7 +100,7 @@ open class ISO8601DateFormatter : Formatter, NSSecureCoding {

open class func string(from date: Date, timeZone: TimeZone, formatOptions: ISO8601DateFormatter.Options = []) -> String {

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let format = CFISO8601DateFormatOptions(rawValue: formatOptions.rawValue)
#else
let format = CFISO8601DateFormatOptions(formatOptions.rawValue)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/JSONSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
4 changes: 2 additions & 2 deletions Foundation/NSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
internal let kCFCalendarUnitEra = CFCalendarUnit.era.rawValue
internal let kCFCalendarUnitYear = CFCalendarUnit.year.rawValue
internal let kCFCalendarUnitMonth = CFCalendarUnit.month.rawValue
Expand Down Expand Up @@ -89,7 +89,7 @@ extension NSCalendar {
public static let timeZone = Unit(rawValue: UInt(1 << 21))

internal var _cfValue: CFCalendarUnit {
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
return CFCalendarUnit(rawValue: self.rawValue)
#else
return CFCalendarUnit(self.rawValue)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCharacterSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
let kCFCharacterSetControl = CFCharacterSetPredefinedSet.control
let kCFCharacterSetWhitespace = CFCharacterSetPredefinedSet.whitespace
let kCFCharacterSetWhitespaceAndNewline = CFCharacterSetPredefinedSet.whitespaceAndNewline
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSConcreteValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
4 changes: 2 additions & 2 deletions Foundation/NSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down Expand Up @@ -507,7 +507,7 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
while bytesRemaining > 0 {
var bytesWritten : Int
repeat {
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
bytesWritten = Darwin.write(fd, buf.advanced(by: length - bytesRemaining), bytesRemaining)
#elseif os(Linux) || os(Android) || CYGWIN
bytesWritten = Glibc.write(fd, buf.advanced(by: length - bytesRemaining), bytesRemaining)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import CoreFoundation

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSGeometry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
import Darwin
#elseif os(Linux) || CYGWIN
import Glibc
Expand Down
6 changes: 3 additions & 3 deletions Foundation/NSLocale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open class NSLocale: NSObject, NSCopying, NSSecureCoding {
private var _identifier: UnsafeMutableRawPointer? = nil
private var _cache: UnsafeMutableRawPointer? = nil
private var _prefs: UnsafeMutableRawPointer? = nil
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
private var _lock = pthread_mutex_t()
#elseif os(Linux) || os(Android) || CYGWIN
private var _lock = Int32(0)
Expand Down Expand Up @@ -179,7 +179,7 @@ extension NSLocale {

open class func characterDirection(forLanguage isoLangCode: String) -> NSLocale.LanguageDirection {
let dir = CFLocaleGetLanguageCharacterDirection(isoLangCode._cfObject)
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
return NSLocale.LanguageDirection(rawValue: UInt(dir.rawValue))!
#else
return NSLocale.LanguageDirection(rawValue: UInt(dir))!
Expand All @@ -188,7 +188,7 @@ extension NSLocale {

open class func lineDirection(forLanguage isoLangCode: String) -> NSLocale.LanguageDirection {
let dir = CFLocaleGetLanguageLineDirection(isoLangCode._cfObject)
#if os(OSX) || os(iOS)
#if os(macOS) || os(iOS)
return NSLocale.LanguageDirection(rawValue: UInt(dir.rawValue))!
#else
return NSLocale.LanguageDirection(rawValue: UInt(dir))!
Expand Down
Loading

0 comments on commit 590c3be

Please sign in to comment.