Skip to content

Commit f178e9c

Browse files
committed
Swift 4 support
1 parent b4005b4 commit f178e9c

File tree

7 files changed

+19
-8
lines changed

7 files changed

+19
-8
lines changed

Package.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
// swift-tools-version:4.0
2+
13
import PackageDescription
24

35
let package = Package(
4-
name: "SGLImage"
6+
name: "SGLImage",
7+
products: [
8+
.library(name: "SGLImage", targets: ["SGLImage"]),
9+
],
10+
dependencies: [
11+
],
12+
targets: [
13+
.target(name: "SGLImage", dependencies: []),
14+
.testTarget(name: "SGLImageTests", dependencies: ["SGLImage"]),
15+
]
516
)
File renamed without changes.
File renamed without changes.

Sources/ImageGIF.swift renamed to Sources/SGLImage/ImageGIF.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ final public class SGLImageDecoderGIF : SGLImageDecoder {
171171
for init_code in 0 ..< clear {
172172
codes[init_code] = (
173173
prefix: -1,
174-
first: UInt8(truncatingBitPattern:init_code),
175-
suffix: UInt8(truncatingBitPattern:init_code)
174+
first: UInt8(truncatingIfNeeded:init_code),
175+
suffix: UInt8(truncatingIfNeeded:init_code)
176176
)
177177
}
178178

File renamed without changes.
File renamed without changes.

Sources/Inflate.swift renamed to Sources/SGLImage/Inflate.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
// These interfaces will change in the future.
2525

2626

27-
public func inflate(_ reader: @escaping (Void) throws -> UInt8, _ writer: @escaping (UInt8) throws -> Void) throws
27+
public func inflate(_ reader: @escaping () throws -> UInt8, _ writer: @escaping (UInt8) throws -> Void) throws
2828
{
2929
let _ = try Inflate(reader, writer)
3030
}
3131

3232

33-
public func inflate(_ reader: @escaping (Void) throws -> UInt8) throws -> Int
33+
public func inflate(_ reader: @escaping () throws -> UInt8) throws -> Int
3434
{
3535
var size = 0
3636
let _ = try Inflate(reader) { _ in size += 1 }
@@ -76,7 +76,7 @@ private let CodeOrder = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
7676

7777
// http://graphics.stanford.edu/~seander/bithacks.html
7878
private func bitReverse16(_ value:Int) -> Int {
79-
var v = UInt16(truncatingBitPattern: value)
79+
var v = UInt16(truncatingIfNeeded: value)
8080
v = ((v & 0xAAAA) >> 1) | ((v & 0x5555) << 1)
8181
v = ((v & 0xCCCC) >> 2) | ((v & 0x3333) << 2)
8282
v = ((v & 0xF0F0) >> 4) | ((v & 0x0F0F) << 4)
@@ -87,7 +87,7 @@ private func bitReverse16(_ value:Int) -> Int {
8787

8888
private final class Inflate
8989
{
90-
let readUInt8:(Void) throws -> UInt8
90+
let readUInt8:() throws -> UInt8
9191
let writeUInt8:(UInt8) throws -> Void
9292

9393
var bitsBuffer = 0
@@ -103,7 +103,7 @@ private final class Inflate
103103
var dynamicLen = Huffman()
104104
var dynamicDist = Huffman()
105105

106-
init(_ reader: @escaping (Void) throws -> UInt8, _ writer: @escaping (UInt8) throws -> Void) throws
106+
init(_ reader: @escaping () throws -> UInt8, _ writer: @escaping (UInt8) throws -> Void) throws
107107
{
108108
self.readUInt8 = reader
109109
self.writeUInt8 = writer

0 commit comments

Comments
 (0)