Skip to content

Commit fd9e5d9

Browse files
authored
Merge pull request #14 from iCharlesHu/charles/misc
Miscellaneous fixes
2 parents 421eff1 + 9990c28 commit fd9e5d9

19 files changed

+909
-568
lines changed

Sources/FoundationEssentials/Data/Collections+DataProtocol.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212

1313
//===--- DataProtocol -----------------------------------------------------===//
1414

15-
@available(macOS 10.10, iOS 8.0, *)
15+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
1616
extension Array: DataProtocol where Element == UInt8 {
1717
public var regions: CollectionOfOne<Array<UInt8>> {
1818
return CollectionOfOne(self)
1919
}
2020
}
2121

22-
@available(macOS 10.10, iOS 8.0, *)
22+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
2323
extension ArraySlice: DataProtocol where Element == UInt8 {
2424
public var regions: CollectionOfOne<ArraySlice<UInt8>> {
2525
return CollectionOfOne(self)
2626
}
2727
}
2828

29-
@available(macOS 10.10, iOS 8.0, *)
29+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
3030
extension ContiguousArray: DataProtocol where Element == UInt8 {
3131
public var regions: CollectionOfOne<ContiguousArray<UInt8>> {
3232
return CollectionOfOne(self)
@@ -42,14 +42,14 @@ extension ContiguousArray: DataProtocol where Element == UInt8 {
4242
// }
4343
// }
4444

45-
@available(macOS 10.10, iOS 8.0, *)
45+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
4646
extension EmptyCollection : DataProtocol where Element == UInt8 {
4747
public var regions: EmptyCollection<Data> {
4848
return EmptyCollection<Data>()
4949
}
5050
}
5151

52-
@available(macOS 10.10, iOS 8.0, *)
52+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
5353
extension Repeated: DataProtocol where Element == UInt8 {
5454
public typealias Regions = Repeated<Data>
5555

@@ -61,8 +61,8 @@ extension Repeated: DataProtocol where Element == UInt8 {
6161

6262
//===--- MutableDataProtocol ----------------------------------------------===//
6363

64-
@available(macOS 10.10, iOS 8.0, *)
64+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
6565
extension Array: MutableDataProtocol where Element == UInt8 { }
6666

67-
@available(macOS 10.10, iOS 8.0, *)
67+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
6868
extension ContiguousArray: MutableDataProtocol where Element == UInt8 { }

Sources/FoundationEssentials/Data/ContiguousBytes.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/// Indicates that the conforming type is a contiguous collection of raw bytes
1616
/// whose underlying storage is directly accessible by withUnsafeBytes.
17-
@available(macOS 10.10, iOS 8.0, *)
17+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
1818
public protocol ContiguousBytes {
1919
/// Calls the given closure with the contents of underlying storage.
2020
///
@@ -28,28 +28,28 @@ public protocol ContiguousBytes {
2828
//===--- Collection Conformances ------------------------------------------===//
2929

3030
// FIXME: When possible, expand conformance to `where Element : Trivial`.
31-
@available(macOS 10.10, iOS 8.0, *)
31+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
3232
extension Array : ContiguousBytes where Element == UInt8 { }
3333

3434
// FIXME: When possible, expand conformance to `where Element : Trivial`.
35-
@available(macOS 10.10, iOS 8.0, *)
35+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
3636
extension ArraySlice : ContiguousBytes where Element == UInt8 { }
3737

3838
// FIXME: When possible, expand conformance to `where Element : Trivial`.
39-
@available(macOS 10.10, iOS 8.0, *)
39+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
4040
extension ContiguousArray : ContiguousBytes where Element == UInt8 { }
4141

4242
//===--- Pointer Conformances ---------------------------------------------===//
4343

44-
@available(macOS 10.10, iOS 8.0, *)
44+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
4545
extension UnsafeRawBufferPointer : ContiguousBytes {
4646
@inlinable
4747
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
4848
return try body(self)
4949
}
5050
}
5151

52-
@available(macOS 10.10, iOS 8.0, *)
52+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
5353
extension UnsafeMutableRawBufferPointer : ContiguousBytes {
5454
@inlinable
5555
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
@@ -58,7 +58,7 @@ extension UnsafeMutableRawBufferPointer : ContiguousBytes {
5858
}
5959

6060
// FIXME: When possible, expand conformance to `where Element : Trivial`.
61-
@available(macOS 10.10, iOS 8.0, *)
61+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
6262
extension UnsafeBufferPointer : ContiguousBytes where Element == UInt8 {
6363
@inlinable
6464
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
@@ -67,7 +67,7 @@ extension UnsafeBufferPointer : ContiguousBytes where Element == UInt8 {
6767
}
6868

6969
// FIXME: When possible, expand conformance to `where Element : Trivial`.
70-
@available(macOS 10.10, iOS 8.0, *)
70+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
7171
extension UnsafeMutableBufferPointer : ContiguousBytes where Element == UInt8 {
7272
@inlinable
7373
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
@@ -76,7 +76,7 @@ extension UnsafeMutableBufferPointer : ContiguousBytes where Element == UInt8 {
7676
}
7777

7878
// FIXME: When possible, expand conformance to `where Element : Trivial`.
79-
@available(macOS 10.10, iOS 8.0, *)
79+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
8080
extension EmptyCollection : ContiguousBytes where Element == UInt8 {
8181
@inlinable
8282
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
@@ -85,7 +85,7 @@ extension EmptyCollection : ContiguousBytes where Element == UInt8 {
8585
}
8686

8787
// FIXME: When possible, expand conformance to `where Element : Trivial`.
88-
@available(macOS 10.10, iOS 8.0, *)
88+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
8989
extension CollectionOfOne : ContiguousBytes where Element == UInt8 {
9090
@inlinable
9191
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
@@ -98,7 +98,7 @@ extension CollectionOfOne : ContiguousBytes where Element == UInt8 {
9898

9999
//===--- Conditional Conformances -----------------------------------------===//
100100

101-
@available(macOS 10.10, iOS 8.0, *)
101+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
102102
extension Slice : ContiguousBytes where Base : ContiguousBytes {
103103
public func withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
104104
let offset = base.distance(from: base.startIndex, to: self.startIndex)

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Darwin
1717
internal func __DataInvokeDeallocatorVirtualMemory(_ mem: UnsafeMutableRawPointer, _ length: Int) {
1818
guard vm_deallocate(
1919
mach_task_self_,
20-
unsafeBitCast(mem, to: vm_address_t.self),
20+
vm_address_t(UInt(bitPattern: mem)),
2121
vm_size_t(length)) == ERR_SUCCESS else {
2222
fatalError("*** __DataInvokeDeallocatorVirtualMemory(\(mem), \(length)) failed")
2323
}
@@ -80,7 +80,7 @@ internal func _withStackOrHeapBuffer(capacity: Int, _ body: (UnsafeMutableBuffer
8080
// coexist without a conflicting ObjC class name, so it was renamed.
8181
// The old name must not be used in the new runtime.
8282
@usableFromInline
83-
@available(macOS 10.10, iOS 8.0, *)
83+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
8484
internal final class __DataStorage : @unchecked Sendable {
8585
@usableFromInline static let maxSize = Int.max >> 1
8686
@usableFromInline static let vmOpsThreshold = Platform.pageSize * 4
@@ -506,7 +506,7 @@ internal final class __DataStorage : @unchecked Sendable {
506506
}
507507

508508
@frozen
509-
@available(macOS 10.10, iOS 8.0, *)
509+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
510510
public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollection, RangeReplaceableCollection, MutableDataProtocol, ContiguousBytes, Sendable {
511511

512512
public typealias Index = Int
@@ -2541,7 +2541,7 @@ extension Data {
25412541
#endif //!FOUNDATION_FRAMEWORK
25422542

25432543

2544-
@available(macOS 10.10, iOS 8.0, *)
2544+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
25452545
extension Data : CustomStringConvertible, CustomDebugStringConvertible, CustomReflectable {
25462546
/// A human-readable description for the data.
25472547
public var description: String {
@@ -2572,7 +2572,7 @@ extension Data : CustomStringConvertible, CustomDebugStringConvertible, CustomRe
25722572
}
25732573
}
25742574

2575-
@available(macOS 10.10, iOS 8.0, *)
2575+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
25762576
extension Data : Codable {
25772577
public init(from decoder: Decoder) throws {
25782578
var container = try decoder.unkeyedContainer()

Sources/FoundationEssentials/Data/DataProtocol.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Glibc
1818

1919
//===--- DataProtocol -----------------------------------------------------===//
2020

21-
@available(macOS 10.10, iOS 8.0, *)
21+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
2222
public protocol DataProtocol : RandomAccessCollection where Element == UInt8, SubSequence : DataProtocol {
2323
// FIXME: Remove in favor of opaque type on `regions`.
2424
associatedtype Regions: BidirectionalCollection where Regions.Element : DataProtocol & ContiguousBytes, Regions.Element.SubSequence : ContiguousBytes
@@ -71,7 +71,7 @@ public protocol DataProtocol : RandomAccessCollection where Element == UInt8, Su
7171

7272
//===--- MutableDataProtocol ----------------------------------------------===//
7373

74-
@available(macOS 10.10, iOS 8.0, *)
74+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
7575
public protocol MutableDataProtocol : DataProtocol, MutableCollection, RangeReplaceableCollection {
7676
/// Replaces the contents of the buffer at the given range with zeroes.
7777
///
@@ -82,7 +82,7 @@ public protocol MutableDataProtocol : DataProtocol, MutableCollection, RangeRepl
8282

8383
//===--- DataProtocol Extensions ------------------------------------------===//
8484

85-
@available(macOS 10.10, iOS 8.0, *)
85+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
8686
extension DataProtocol {
8787
public func firstRange<D: DataProtocol>(of data: D) -> Range<Index>? {
8888
return self.firstRange(of: data, in: self.startIndex ..< self.endIndex)
@@ -200,7 +200,7 @@ extension DataProtocol {
200200
}
201201
}
202202

203-
@available(macOS 10.10, iOS 8.0, *)
203+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
204204
extension DataProtocol where Self : ContiguousBytes {
205205
public func copyBytes<DestinationType, R: RangeExpression>(to ptr: UnsafeMutableBufferPointer<DestinationType>, from range: R) where R.Bound == Index {
206206
precondition(ptr.baseAddress != nil)
@@ -216,7 +216,7 @@ extension DataProtocol where Self : ContiguousBytes {
216216

217217
//===--- MutableDataProtocol Extensions -----------------------------------===//
218218

219-
@available(macOS 10.10, iOS 8.0, *)
219+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
220220
extension MutableDataProtocol {
221221
public mutating func resetBytes<R: RangeExpression>(in range: R) where R.Bound == Index {
222222
let r = range.relative(to: self)
@@ -227,7 +227,7 @@ extension MutableDataProtocol {
227227

228228
//===--- DataProtocol Conditional Conformances ----------------------------===//
229229

230-
@available(macOS 10.10, iOS 8.0, *)
230+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
231231
extension Slice : DataProtocol where Base : DataProtocol {
232232
public typealias Regions = [Base.Regions.Element.SubSequence]
233233

Sources/FoundationEssentials/Data/Pointers+DataProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
//===----------------------------------------------------------------------===//
1212

1313

14-
@available(macOS 10.10, iOS 8.0, *)
14+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
1515
extension UnsafeRawBufferPointer : DataProtocol {
1616
public var regions: CollectionOfOne<UnsafeRawBufferPointer> {
1717
return CollectionOfOne(self)
1818
}
1919
}
2020

21-
@available(macOS 10.10, iOS 8.0, *)
21+
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
2222
extension UnsafeBufferPointer : DataProtocol where Element == UInt8 {
2323
public var regions: CollectionOfOne<UnsafeBufferPointer<Element>> {
2424
return CollectionOfOne(self)

Sources/FoundationEssentials/Platform.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ internal struct Platform {
4343
#if canImport(Darwin)
4444
if vm_copy(
4545
mach_task_self_,
46-
unsafeBitCast(source, to: vm_address_t.self),
46+
vm_address_t(UInt(bitPattern: source)),
4747
vm_size_t(length),
48-
unsafeBitCast(dest, to: vm_address_t.self)) != KERN_SUCCESS {
48+
vm_address_t(UInt(bitPattern: dest))) != KERN_SUCCESS {
4949
memmove(dest, source, length)
5050
}
5151
#else

Sources/FoundationEssentials/UUID.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3-
// This source file is part of the Swift Collections open source project
3+
// This source file is part of the Swift open source project
44
//
55
// Copyright (c) 2022 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
@@ -9,7 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
@_implementationOnly import _CShims
12+
@_implementationOnly import _CShims // uuid.h
1313

1414
public typealias uuid_t = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8)
1515
public typealias uuid_string_t = (Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8)

0 commit comments

Comments
 (0)