Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #79 from ken-broadsheet/master
Browse files Browse the repository at this point in the history
Update for Swift 5.
  • Loading branch information
0xTim authored May 18, 2020
2 parents 1d23662 + 18755af commit acde20d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// swift-tools-version:5.2
import PackageDescription

let package = Package(
name: "PostgreSQL",
products: [
.library(name: "PostgreSQL", targets: ["PostgreSQL"]),
],
dependencies: [
// Module map for `libpq`
.package(name: "CPostgreSQL", url: "https://github.com/vapor-community/cpostgresql.git", from: "2.1.0"),

// Data structure for converting between multiple representations
.package(name: "Node", url: "https://github.com/vapor/node.git", from: "2.1.0"),

// Core extensions, type-aliases, and functions that facilitate common tasks
.package(name: "Core", url: "https://github.com/vapor/core.git", from: "2.1.2"),
],
targets: [
.target(name: "PostgreSQL", dependencies: ["CPostgreSQL", "Node", "Core"]),
.testTarget(name: "PostgreSQLTests", dependencies: ["PostgreSQL"]),
]
)
12 changes: 12 additions & 0 deletions Sources/PostgreSQL/Bind/BinaryUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import Core
extension UInt8 {
var lowercaseHexPair: String {
let hexString = String(self, radix: 16, uppercase: false)
#if swift(>=5.0)
return String(repeating: "0", count: 2 - hexString.count) + hexString
#else
return String(repeating: "0", count: 2 - hexString.characters.count) + hexString
#endif
}

var lowercaseBinaryString: String {
let bitString = String(self, radix: 2, uppercase: false)
#if swift(>=5.0)
return String(repeating: "0", count: 8 - bitString.count) + bitString
#else
return String(repeating: "0", count: 8 - bitString.characters.count) + bitString
#endif
}
}

Expand Down Expand Up @@ -190,7 +198,11 @@ struct BinaryUtils {

// The number of digits should be 4 (DEC_DIGITS),
// so pad if necessary.
#if swift(>=5.0)
return String(repeating: "0", count: Numeric.decDigits - stringDigits.count) + stringDigits
#else
return String(repeating: "0", count: Numeric.decDigits - stringDigits.characters.count) + stringDigits
#endif
}

/// Function for rounding numeric values.
Expand Down
4 changes: 4 additions & 0 deletions Sources/PostgreSQL/Bind/Bind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public final class Bind {

deinit {
if ownsMemory {
#if swift(>=5.0)
bytes.deallocate()
#else
bytes.deallocate(capacity: length)
#endif
}
}
}
Expand Down

0 comments on commit acde20d

Please sign in to comment.