Skip to content

Commit 4d70a94

Browse files
authored
Merge pull request #18 from stackotter/master
Support macOS 10.15, iOS 13, tvOS 13, and watchOS 6
2 parents 7a3fbb7 + d589995 commit 4d70a94

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PackageDescription
33

44
let package:Package = .init(
55
name: "swift-hash",
6-
platforms: [.macOS("13.3"), .iOS("16.4"), .tvOS("16.4"), .watchOS("9.4")],
6+
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)],
77
products: [
88
.library(name: "Base16", targets: ["Base16"]),
99
.library(name: "Base64", targets: ["Base64"]),

Sources/InlineBuffer/InlineBuffer.swift

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ extension InlineBuffer:RandomAccessCollection, MutableCollection
100100
}
101101
}
102102
}
103+
@available(macOS 13.3, iOS 16.4, macCatalyst 16.4, tvOS 16.4, visionOS 1, watchOS 9.4, *)
103104
extension InlineBuffer:ExpressibleByIntegerLiteral
104105
{
105106
@inlinable public
@@ -153,18 +154,32 @@ extension InlineBuffer:CustomStringConvertible
153154
@inlinable public
154155
var description:String
155156
{
156-
.init(unsafeUninitializedCapacity: 2 * self.count)
157+
func hex(remainder:UInt8) -> UInt8
157158
{
158-
func hex(remainder:UInt8) -> UInt8
159+
(remainder < 10 ? 0x30 : 0x61 - 10) &+ remainder
160+
}
161+
if #available(macOS 11, iOS 14, macCatalyst 14, tvOS 14, visionOS 1, watchOS 7, *)
162+
{
163+
return .init(unsafeUninitializedCapacity: 2 * self.count)
159164
{
160-
(remainder < 10 ? 0x30 : 0x61 - 10) &+ remainder
165+
for (i, byte):(Int, UInt8) in self.enumerated()
166+
{
167+
$0[2 * i ] = hex(remainder: byte >> 4)
168+
$0[2 * i + 1] = hex(remainder: byte & 0x0f)
169+
}
170+
return 2 * self.count
161171
}
162-
for (i, byte):(Int, UInt8) in self.enumerated()
172+
}
173+
else
174+
{
175+
var description:String = ""
176+
description.reserveCapacity(2 * self.count)
177+
for byte:UInt8 in self
163178
{
164-
$0[2 * i ] = hex(remainder: byte >> 4)
165-
$0[2 * i + 1] = hex(remainder: byte & 0x0f)
179+
description.append(Character.init(.init(hex(remainder: byte >> 4))))
180+
description.append(Character.init(.init(hex(remainder: byte & 0x0f))))
166181
}
167-
return 2 * self.count
182+
return description
168183
}
169184
}
170185
}

Sources/MD5/MD5.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ extension MD5:LosslessStringConvertible
100100
}
101101
}
102102
}
103+
@available(macOS 13.3, iOS 16.4, macCatalyst 16.4, tvOS 16.4, visionOS 1, watchOS 9.4, *)
103104
extension MD5:ExpressibleByIntegerLiteral
104105
{
105106
@inlinable public

Sources/MD5Tests/Main.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ enum Main:TestMain, TestBattery
77
static
88
func run(tests:TestGroup)
99
{
10+
guard #available(
11+
macOS 13.3,
12+
iOS 16.4,
13+
macCatalyst 16.4,
14+
tvOS 16.4,
15+
visionOS 1.0,
16+
watchOS 9.4,
17+
*
18+
)
19+
else
20+
{
21+
fatalError("MD5Tests requires macOS 13.3+, iOS 16.4+, tvOS 16.4+, visionOS 1.0+, or watchOS 9.4+")
22+
}
23+
1024
if let tests:TestGroup = tests / "Strings"
1125
{
1226
let string:String = "d41d8cd98f00b204e9800998ecf8427e"

Sources/SHA1/SHA1.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ extension SHA1:LosslessStringConvertible
8383
}
8484
}
8585
}
86+
@available(macOS 13.3, iOS 16.4, macCatalyst 16.4, tvOS 16.4, visionOS 1, watchOS 9.4, *)
8687
extension SHA1:ExpressibleByIntegerLiteral
8788
{
8889
@inlinable public

0 commit comments

Comments
 (0)