Skip to content

Commit

Permalink
Migration to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Rien committed Apr 5, 2018
1 parent 82a4a13 commit 5cd3d15
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
build
/DerivedData
Package.pins
Package.resolved
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import PackageDescription
let package = Package(
name: "SwifterSockets",
dependencies: [
.Package(url: "https://github.com/Balancingrock/BRUtils", Version(0, 10, 0))
.Package(url: "https://github.com/Balancingrock/BRUtils", Version(0, 11, 0))
]
)
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ Note: Planned releases are for information only, they are subject to change with

- The current verion will be upgraded to 1.0.0 status when the full set necessary for Swiftfire 1.0.0 has been completed.

#### 0.10.10 (Current)
#### 0.10.11 (Current)

- Migration to Swift 4, minor adjustments.

#### 0.10.10

- Upgraded BRUtils to 0.10.0

Expand Down
5 changes: 3 additions & 2 deletions Sources/SwifterSockets.Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// File: SwifterSockets.Connection.swift
// Project: SwifterSockets
//
// Version: 0.10.8
// Version: 0.10.11
//
// Author: Marinus van der Lugt
// Company: http://balancingrock.nl
Expand Down Expand Up @@ -48,6 +48,7 @@
//
// History
//
// 0.10.11 - Migration to Swift 4, minor adjustments.
// 0.10.8 - Made incrementUsageCount and decrementUsageCount public.
// 0.10.7 - Bugfix: partial reimplementation to prevent crashes due to clashes of receiver events and close events.
// 0.10.6 - Renamed 'abortConnection' to 'connectionWasClosed'.
Expand Down Expand Up @@ -872,7 +873,7 @@ open class Connection: ReceiverProtocol, TransmitterProtocol {

if let queue = tqueue() {

let copy = UnsafeMutableRawBufferPointer.allocate(count: buffer.count)
let copy = UnsafeMutableRawBufferPointer.allocate(byteCount: buffer.count, alignment: 8)
memcpy(copy.baseAddress, buffer.baseAddress, buffer.count)

queue.async {
Expand Down
7 changes: 4 additions & 3 deletions Sources/SwifterSockets.Receive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// File: SwifterSockets.Receive.swift
// Project: SwifterSockets
//
// Version: 0.9.14
// Version: 0.10.11
//
// Author: Marinus van der Lugt
// Company: http://balancingrock.nl
Expand Down Expand Up @@ -48,6 +48,7 @@
//
// History
//
// 0.10.11 - Migration to Swift 4, minor adjustments.
// 0.9.14 - Moved receiver protocol to this file
// 0.9.13 - Comment section update
// 0.9.12 - Documentation updated to accomodate the documentation tool 'jazzy'
Expand Down Expand Up @@ -135,7 +136,7 @@ public func tipReceiverLoop(

// Allocate the data buffer

let buffer = UnsafeMutableRawPointer.allocate(bytes: bufferSize, alignedTo: 1)
let buffer = UnsafeMutableRawPointer.allocate(byteCount: bufferSize, alignment: 8)


// ===============================================================================
Expand Down Expand Up @@ -201,6 +202,6 @@ public func tipReceiverLoop(

// Deallocate the data buffer

buffer.deallocate(bytes: bufferSize, alignedTo: 1)
buffer.deallocate()
}

23 changes: 12 additions & 11 deletions Sources/SwifterSockets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// File: SwifterSockets.swift
// Project: SwifterSockets
//
// Version: 0.10.2
// Version: 0.10.11
//
// Author: Marinus van der Lugt
// Company: http://balancingrock.nl
Expand Down Expand Up @@ -48,6 +48,7 @@
//
// History
//
// 0.10.10 - Migration to Swift 4, minor adjustments.
// 0.10.2 - Added BRUtils for the Result type
// 0.10.1 - Analysed compilation time and speed up
// 0.10.0 - Added func result
Expand Down Expand Up @@ -81,7 +82,7 @@ import Foundation

/// A helper extensions to allow increment/decrement operations on counter values

extension Integer {
extension BinaryInteger {


/// Increases self by one
Expand Down Expand Up @@ -428,9 +429,9 @@ public func fdSet(_ fd: Int32?, set: inout fd_set) {

if let fd = fd {

let intOffset = Int(fd / 32)
let bitOffset = fd % 32
let mask = 1 << bitOffset
let intOffset: Int32 = fd / 32
let bitOffset: Int32 = fd % 32
let mask: Int32 = 1 << bitOffset

switch intOffset {
case 0: set.fds_bits.0 = set.fds_bits.0 | mask
Expand Down Expand Up @@ -482,9 +483,9 @@ public func fdClr(_ fd: Int32?, set: inout fd_set) {

if let fd = fd {

let intOffset = Int(fd / 32)
let bitOffset = fd % 32
let mask = ~(1 << bitOffset)
let intOffset: Int32 = fd / 32
let bitOffset: Int32 = fd % 32
let mask: Int32 = ~(1 << bitOffset)

switch intOffset {
case 0: set.fds_bits.0 = set.fds_bits.0 & mask
Expand Down Expand Up @@ -536,9 +537,9 @@ public func fdIsSet(_ fd: Int32?, set: inout fd_set) -> Bool {

if let fd = fd {

let intOffset = Int(fd / 32)
let bitOffset = fd % 32
let mask = 1 << bitOffset
let intOffset: Int32 = fd / 32
let bitOffset: Int32 = fd % 32
let mask: Int32 = 1 << bitOffset

switch intOffset {
case 0: return set.fds_bits.0 & mask != 0
Expand Down
17 changes: 0 additions & 17 deletions Tests/SwifterSocketsTests/SwifterSocketsTests.swift

This file was deleted.

0 comments on commit 5cd3d15

Please sign in to comment.