Skip to content

Commit 1d5e35a

Browse files
authored
Merge pull request #75 from lorentey/introduce-availability-macros
Unify availability annotations & introduce a script to manage them
2 parents 836bc45 + fd82b5a commit 1d5e35a

23 files changed

+163
-75
lines changed

Sources/System/Errno.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// An error number used by system calls to communicate what kind of error
1111
/// occurred.
1212
@frozen
13-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
13+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
1414
public struct Errno: RawRepresentable, Error, Hashable, Codable {
1515
/// The raw C error number.
1616
@_alwaysEmitIntoClient
@@ -1376,7 +1376,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
13761376
}
13771377

13781378
// Constants defined in header but not man page
1379-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1379+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
13801380
extension Errno {
13811381

13821382
/// Operation would block.
@@ -1470,7 +1470,7 @@ extension Errno {
14701470
#endif
14711471
}
14721472

1473-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1473+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
14741474
extension Errno {
14751475
// TODO: We want to provide safe access to `errno`, but we need a
14761476
// release-barrier to do so.
@@ -1485,14 +1485,14 @@ extension Errno {
14851485
}
14861486

14871487
// Use "hidden" entry points for `NSError` bridging
1488-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1488+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
14891489
extension Errno {
14901490
public var _code: Int { Int(rawValue) }
14911491

14921492
public var _domain: String { "NSPOSIXErrorDomain" }
14931493
}
14941494

1495-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1495+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
14961496
extension Errno: CustomStringConvertible, CustomDebugStringConvertible {
14971497
/// A textual representation of the most recent error
14981498
/// returned by a system call.
@@ -1512,7 +1512,7 @@ extension Errno: CustomStringConvertible, CustomDebugStringConvertible {
15121512
public var debugDescription: String { self.description }
15131513
}
15141514

1515-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1515+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
15161516
extension Errno {
15171517
@_alwaysEmitIntoClient
15181518
public static func ~=(_ lhs: Errno, _ rhs: Error) -> Bool {

Sources/System/FileDescriptor.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// of `FileDescriptor` values,
1515
/// in the same way as you manage a raw C file handle.
1616
@frozen
17-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
17+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
1818
public struct FileDescriptor: RawRepresentable, Hashable, Codable {
1919
/// The raw C file handle.
2020
@_alwaysEmitIntoClient
@@ -40,7 +40,7 @@ extension FileDescriptor {
4040
public static var standardError: FileDescriptor { .init(rawValue: 2) }
4141
}
4242

43-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
43+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
4444
extension FileDescriptor {
4545
/// The desired read and write access for a newly opened file.
4646
@frozen
@@ -385,7 +385,7 @@ extension FileDescriptor {
385385
}
386386
}
387387

388-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
388+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
389389
extension FileDescriptor.AccessMode
390390
: CustomStringConvertible, CustomDebugStringConvertible
391391
{
@@ -404,7 +404,7 @@ extension FileDescriptor.AccessMode
404404
public var debugDescription: String { self.description }
405405
}
406406

407-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
407+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
408408
extension FileDescriptor.SeekOrigin
409409
: CustomStringConvertible, CustomDebugStringConvertible
410410
{
@@ -427,7 +427,7 @@ extension FileDescriptor.SeekOrigin
427427
public var debugDescription: String { self.description }
428428
}
429429

430-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
430+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
431431
extension FileDescriptor.OpenOptions
432432
: CustomStringConvertible, CustomDebugStringConvertible
433433
{

Sources/System/FileHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
10+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
1111
extension FileDescriptor {
1212
/// Runs a closure and then closes the file descriptor, even if an error occurs.
1313
///

Sources/System/FileOperations.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
10+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
1111
extension FileDescriptor {
1212
/// Opens or creates a file for reading or writing.
1313
///
@@ -337,15 +337,15 @@ extension FileDescriptor {
337337
///
338338
/// The corresponding C functions are `dup` and `dup2`.
339339
@_alwaysEmitIntoClient
340-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
340+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
341341
public func duplicate(
342342
as target: FileDescriptor? = nil,
343343
retryOnInterrupt: Bool = true
344344
) throws -> FileDescriptor {
345345
try _duplicate(as: target, retryOnInterrupt: retryOnInterrupt).get()
346346
}
347347

348-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
348+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
349349
@usableFromInline
350350
internal func _duplicate(
351351
as target: FileDescriptor?,
@@ -370,19 +370,23 @@ extension FileDescriptor {
370370
public func dup2() throws -> FileDescriptor {
371371
fatalError("Not implemented")
372372
}
373-
373+
}
374+
375+
/*System 1.1.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
376+
extension FileDescriptor {
374377
#if !os(Windows)
375378
/// Create a pipe, a unidirectional data channel which can be used for interprocess communication.
376379
///
377380
/// - Returns: The pair of file descriptors.
378381
///
379382
/// The corresponding C function is `pipe`.
380383
@_alwaysEmitIntoClient
381-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
384+
/*System 1.1.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
382385
public static func pipe() throws -> (readEnd: FileDescriptor, writeEnd: FileDescriptor) {
383386
try _pipe().get()
384387
}
385388

389+
/*System 1.1.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
386390
@usableFromInline
387391
internal static func _pipe() -> Result<(readEnd: FileDescriptor, writeEnd: FileDescriptor), Errno> {
388392
var fds: (Int32, Int32) = (-1, -1)

Sources/System/FilePath/FilePath.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
///
4141
// TODO(docs): Section on all the new syntactic operations, lexical normalization, decomposition,
4242
// components, etc.
43-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
43+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
4444
public struct FilePath {
4545
internal var _storage: SystemString
4646

@@ -60,12 +60,12 @@ public struct FilePath {
6060
}
6161
}
6262

63-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
63+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
6464
extension FilePath {
6565
/// The length of the file path, excluding the null terminator.
6666
public var length: Int { _storage.length }
6767
}
6868

69-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
69+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
7070
extension FilePath: Hashable, Codable {}
7171

Sources/System/FilePath/FilePathComponentView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// MARK: - API
1111

12-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
12+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
1313
extension FilePath {
1414
/// A bidirectional, range replaceable collection of the non-root components
1515
/// that make up a file path.
@@ -89,7 +89,7 @@ extension FilePath {
8989
#endif
9090
}
9191

92-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
92+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
9393
extension FilePath.ComponentView: BidirectionalCollection {
9494
public typealias Element = FilePath.Component
9595
public struct Index: Comparable, Hashable {
@@ -123,7 +123,7 @@ extension FilePath.ComponentView: BidirectionalCollection {
123123
}
124124
}
125125

126-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
126+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
127127
extension FilePath.ComponentView: RangeReplaceableCollection {
128128
public init() {
129129
self.init(FilePath())
@@ -173,7 +173,7 @@ extension FilePath.ComponentView: RangeReplaceableCollection {
173173
}
174174
}
175175

176-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
176+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
177177
extension FilePath {
178178
/// Create a file path from a root and a collection of components.
179179
public init<C: Collection>(

Sources/System/FilePath/FilePathComponents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// MARK: - API
1111

12-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
12+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
1313
extension FilePath {
1414
/// Represents a root of a file path.
1515
///
@@ -73,7 +73,7 @@ extension FilePath {
7373
}
7474
}
7575

76-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
76+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
7777
extension FilePath.Component {
7878

7979
/// Whether a component is a regular file or directory name, or a special

Sources/System/FilePath/FilePathString.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// MARK: - Platform string
1111

12-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
12+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
1313
extension FilePath {
1414
/// Creates a file path by copying bytes from a null-terminated platform
1515
/// string.
@@ -45,7 +45,7 @@ extension FilePath {
4545
}
4646
}
4747

48-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
48+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
4949
extension FilePath.Component {
5050
/// Creates a file path component by copying bytes from a null-terminated
5151
/// platform string.
@@ -82,7 +82,7 @@ extension FilePath.Component {
8282
}
8383
}
8484

85-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
85+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
8686
extension FilePath.Root {
8787
/// Creates a file path root by copying bytes from a null-terminated platform
8888
/// string.
@@ -120,7 +120,7 @@ extension FilePath.Root {
120120

121121
// MARK: - String literals
122122

123-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
123+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
124124
extension FilePath: ExpressibleByStringLiteral {
125125
/// Creates a file path from a string literal.
126126
///
@@ -139,7 +139,7 @@ extension FilePath: ExpressibleByStringLiteral {
139139
}
140140
}
141141

142-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
142+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
143143
extension FilePath.Component: ExpressibleByStringLiteral {
144144
/// Create a file path component from a string literal.
145145
///
@@ -164,7 +164,7 @@ extension FilePath.Component: ExpressibleByStringLiteral {
164164
}
165165
}
166166

167-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
167+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
168168
extension FilePath.Root: ExpressibleByStringLiteral {
169169
/// Create a file path root from a string literal.
170170
///
@@ -189,7 +189,7 @@ extension FilePath.Root: ExpressibleByStringLiteral {
189189

190190
// MARK: - Printing and dumping
191191

192-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
192+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
193193
extension FilePath: CustomStringConvertible, CustomDebugStringConvertible {
194194
/// A textual representation of the file path.
195195
///
@@ -205,7 +205,7 @@ extension FilePath: CustomStringConvertible, CustomDebugStringConvertible {
205205
public var debugDescription: String { description.debugDescription }
206206
}
207207

208-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
208+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
209209
extension FilePath.Component: CustomStringConvertible, CustomDebugStringConvertible {
210210

211211
/// A textual representation of the path component.
@@ -222,7 +222,7 @@ extension FilePath.Component: CustomStringConvertible, CustomDebugStringConverti
222222
public var debugDescription: String { description.debugDescription }
223223
}
224224

225-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
225+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
226226
extension FilePath.Root: CustomStringConvertible, CustomDebugStringConvertible {
227227

228228
/// A textual representation of the path root.
@@ -242,7 +242,7 @@ extension FilePath.Root: CustomStringConvertible, CustomDebugStringConvertible {
242242
// MARK: - Convenience helpers
243243

244244
// Convenience helpers
245-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
245+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
246246
extension FilePath {
247247
/// Creates a string by interpreting the path’s content as UTF-8 on Unix
248248
/// and UTF-16 on Windows.
@@ -253,7 +253,7 @@ extension FilePath {
253253
}
254254
}
255255

256-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
256+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
257257
extension FilePath.Component {
258258
/// Creates a string by interpreting the component’s content as UTF-8 on Unix
259259
/// and UTF-16 on Windows.
@@ -264,7 +264,7 @@ extension FilePath.Component {
264264
}
265265
}
266266

267-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
267+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
268268
extension FilePath.Root {
269269
/// On Unix, this returns `"/"`.
270270
///
@@ -278,7 +278,7 @@ extension FilePath.Root {
278278

279279
// MARK: - Decoding and validating
280280

281-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
281+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
282282
extension String {
283283
/// Creates a string by interpreting the file path's content as UTF-8 on Unix
284284
/// and UTF-16 on Windows.
@@ -308,7 +308,7 @@ extension String {
308308
}
309309
}
310310

311-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
311+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
312312
extension String {
313313
/// Creates a string by interpreting the path component's content as UTF-8 on
314314
/// Unix and UTF-16 on Windows.
@@ -338,7 +338,7 @@ extension String {
338338
}
339339
}
340340

341-
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
341+
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
342342
extension String {
343343
/// On Unix, creates the string `"/"`
344344
///
@@ -391,7 +391,7 @@ extension String {
391391

392392
// MARK: - Deprecations
393393

394-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
394+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
395395
extension String {
396396
@available(*, deprecated, renamed: "init(decoding:)")
397397
public init(_ path: FilePath) { self.init(decoding: path) }
@@ -401,7 +401,7 @@ extension String {
401401
}
402402

403403
#if !os(Windows)
404-
// @available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
404+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
405405
extension FilePath {
406406
/// For backwards compatibility only. This initializer is equivalent to
407407
/// the preferred `FilePath(platformString:)`.

0 commit comments

Comments
 (0)