Changes for the latest toolchain.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
8CC36DF91C4EA1BE00BAA659 /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C0F4C031C4E8630008B2B0A /* Socket.swift */; };
|
||||
8CC36DFA1C4EA1BE00BAA659 /* SocketUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C0F4C041C4E8630008B2B0A /* SocketUtils.swift */; };
|
||||
8CC7217B1D4BCB1D00F5FD19 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 8CC7217A1D4BCB1D00F5FD19 /* LICENSE */; };
|
||||
8CF04E221D4BCBC700C27814 /* SocketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CC721761D4BCA9400F5FD19 /* SocketTests.swift */; };
|
||||
8CF04E291D4FCE4A00C27814 /* BasicSocketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CC721761D4BCA9400F5FD19 /* BasicSocketTests.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -30,6 +30,7 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
8C0039F11D4FE0F50064B65F /* XCTestManifests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = XCTestManifests.swift; path = Tests/SocketTests/XCTestManifests.swift; sourceTree = "<group>"; };
|
||||
8C0F4BF61C4E84CC008B2B0A /* Socket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Socket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8C0F4BF91C4E84CC008B2B0A /* Socket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Socket.h; sourceTree = "<group>"; };
|
||||
8C0F4BFB1C4E84CC008B2B0A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
@@ -40,10 +41,10 @@
|
||||
8CA9B1631C98A00400E607FB /* SocketTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SocketTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8CC36E021C4EA1BE00BAA659 /* Socket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Socket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8CC36E041C4EA34700BAA659 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
8CC721761D4BCA9400F5FD19 /* SocketTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTests.swift; path = Tests/Socket/SocketTests.swift; sourceTree = "<group>"; };
|
||||
8CC721761D4BCA9400F5FD19 /* BasicSocketTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BasicSocketTests.swift; path = Tests/SocketTests/BasicSocketTests.swift; sourceTree = "<group>"; };
|
||||
8CC721781D4BCAA600F5FD19 /* LinuxMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LinuxMain.swift; path = Tests/LinuxMain.swift; sourceTree = "<group>"; };
|
||||
8CC7217A1D4BCB1D00F5FD19 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
8CF04E231D4BD03D00C27814 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Tests/Socket/Info.plist; sourceTree = "<group>"; };
|
||||
8CF04E231D4BD03D00C27814 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Tests/SocketTests/Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -114,20 +115,21 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8CC721751D4BCA7D00F5FD19 /* Socket */ = {
|
||||
8CC721751D4BCA7D00F5FD19 /* SocketTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8CF04E231D4BD03D00C27814 /* Info.plist */,
|
||||
8CC721761D4BCA9400F5FD19 /* SocketTests.swift */,
|
||||
8CC721761D4BCA9400F5FD19 /* BasicSocketTests.swift */,
|
||||
8C0039F11D4FE0F50064B65F /* XCTestManifests.swift */,
|
||||
);
|
||||
name = Socket;
|
||||
name = SocketTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8CF2D7371C989EE0000A7D2B /* Tests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8CC721781D4BCAA600F5FD19 /* LinuxMain.swift */,
|
||||
8CC721751D4BCA7D00F5FD19 /* Socket */,
|
||||
8CC721751D4BCA7D00F5FD19 /* SocketTests */,
|
||||
);
|
||||
name = Tests;
|
||||
sourceTree = "<group>";
|
||||
@@ -287,7 +289,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8CF04E221D4BCBC700C27814 /* SocketTests.swift in Sources */,
|
||||
8CF04E291D4FCE4A00C27814 /* BasicSocketTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -447,7 +449,7 @@
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = Tests/Socket/Info.plist;
|
||||
INFOPLIST_FILE = Tests/SocketTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ibm.oss.SocketTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -459,7 +461,7 @@
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = Tests/Socket/Info.plist;
|
||||
INFOPLIST_FILE = Tests/SocketTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ibm.oss.SocketTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||

|
||||

|
||||

|
||||
|
||||
# BlueSocket
|
||||
|
||||
|
||||
+35
-35
@@ -316,37 +316,37 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
/// Protocol Family
|
||||
///
|
||||
public private(set) var protocolFamily: ProtocolFamily
|
||||
public internal(set) var protocolFamily: ProtocolFamily
|
||||
|
||||
///
|
||||
/// Socket Type
|
||||
///
|
||||
public private(set) var socketType: SocketType
|
||||
public internal(set) var socketType: SocketType
|
||||
|
||||
///
|
||||
/// Socket Protocol
|
||||
///
|
||||
public private(set) var proto: SocketProtocol
|
||||
public internal(set) var proto: SocketProtocol
|
||||
|
||||
///
|
||||
/// Host name for connection
|
||||
///
|
||||
public private(set) var hostname: String? = Socket.NO_HOSTNAME
|
||||
public internal(set) var hostname: String? = Socket.NO_HOSTNAME
|
||||
|
||||
///
|
||||
/// Port for connection
|
||||
///
|
||||
public private(set) var port: Int32 = Socket.SOCKET_INVALID_PORT
|
||||
public internal(set) var port: Int32 = Socket.SOCKET_INVALID_PORT
|
||||
|
||||
///
|
||||
/// Address info for socket.
|
||||
///
|
||||
public private(set) var address: Address? = nil
|
||||
public internal(set) var address: Address? = nil
|
||||
|
||||
///
|
||||
/// Flag to indicate whether `Socket` is secure or not.
|
||||
///
|
||||
public private(set) var isSecure: Bool = false
|
||||
public internal(set) var isSecure: Bool = false
|
||||
|
||||
///
|
||||
/// Returns a string description of the error.
|
||||
@@ -429,7 +429,7 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
/// - Returns: New Signature instance
|
||||
///
|
||||
private init?(protocolFamily: Int32, socketType: Int32, proto: Int32, address: Address?, hostname: String?, port: Int32?) throws {
|
||||
internal init?(protocolFamily: Int32, socketType: Int32, proto: Int32, address: Address?, hostname: String?, port: Int32?) throws {
|
||||
|
||||
// This constructor requires all items be present...
|
||||
guard let family = ProtocolFamily.getFamily(forValue: protocolFamily),
|
||||
@@ -466,12 +466,12 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
/// The error code: **see constants above for possible errors**
|
||||
///
|
||||
public private(set) var errorCode: Int32
|
||||
public internal(set) var errorCode: Int32
|
||||
|
||||
///
|
||||
/// The reason for the error **(if available)**
|
||||
///
|
||||
public private(set) var errorReason: String?
|
||||
public internal(set) var errorReason: String?
|
||||
|
||||
///
|
||||
/// Returns a string description of the error.
|
||||
@@ -485,7 +485,7 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
/// The buffer size needed to complete the read.
|
||||
///
|
||||
public private(set) var bufferSizeNeeded: Int32
|
||||
public internal(set) var bufferSizeNeeded: Int32
|
||||
|
||||
// MARK: -- Public Functions
|
||||
|
||||
@@ -593,17 +593,17 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
/// True if this socket is connected. False otherwise. (Readonly)
|
||||
///
|
||||
public private(set) var isConnected: Bool = false
|
||||
public internal(set) var isConnected: Bool = false
|
||||
|
||||
///
|
||||
/// True if this socket is blocking. False otherwise. (Readonly)
|
||||
///
|
||||
public private(set) var isBlocking: Bool = true
|
||||
public internal(set) var isBlocking: Bool = true
|
||||
|
||||
///
|
||||
/// True if this socket is listening. False otherwise. (Readonly)
|
||||
///
|
||||
public private(set) var isListening: Bool = false
|
||||
public internal(set) var isListening: Bool = false
|
||||
|
||||
///
|
||||
/// True if the socket is listening or connected.
|
||||
@@ -652,13 +652,13 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
/// The file descriptor representing this socket. (Readonly)
|
||||
///
|
||||
public private(set) var socketfd: Int32 = SOCKET_INVALID_DESCRIPTOR
|
||||
public internal(set) var socketfd: Int32 = SOCKET_INVALID_DESCRIPTOR
|
||||
|
||||
///
|
||||
/// The signature for the socket.
|
||||
/// **Note:** See Signature above.
|
||||
///
|
||||
public private(set) var signature: Signature? = nil
|
||||
public internal(set) var signature: Signature? = nil
|
||||
|
||||
///
|
||||
/// True if this a server, false otherwise.
|
||||
@@ -1029,12 +1029,12 @@ public class Socket: SocketReader, SocketWriter {
|
||||
var addrSize = socklen_t(sizeofValue(acceptAddr))
|
||||
|
||||
#if os(Linux)
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#else
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#endif
|
||||
if fd < 0 {
|
||||
@@ -1053,12 +1053,12 @@ public class Socket: SocketReader, SocketWriter {
|
||||
var addrSize = socklen_t(sizeofValue(acceptAddr))
|
||||
|
||||
#if os(Linux)
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#else
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#endif
|
||||
if fd < 0 {
|
||||
@@ -1139,12 +1139,12 @@ public class Socket: SocketReader, SocketWriter {
|
||||
var addrSize = socklen_t(sizeofValue(acceptAddr))
|
||||
|
||||
#if os(Linux)
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#else
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#endif
|
||||
if fd < 0 {
|
||||
@@ -1163,12 +1163,12 @@ public class Socket: SocketReader, SocketWriter {
|
||||
var addrSize = socklen_t(sizeofValue(acceptAddr))
|
||||
|
||||
#if os(Linux)
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Glibc.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#else
|
||||
let fd = withUnsafeMutablePointer(&acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutablePointer($0), &addrSize)
|
||||
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
|
||||
Darwin.accept(self.socketfd, UnsafeMutableRawPointer($0).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
#endif
|
||||
if fd < 0 {
|
||||
@@ -1500,11 +1500,11 @@ public class Socket: SocketReader, SocketWriter {
|
||||
var remoteAddr = signature.address!.addr
|
||||
|
||||
#if os(Linux)
|
||||
let rc = withUnsafeMutablePointer(&remoteAddr) {
|
||||
let rc = withUnsafeMutablePointer(to: &remoteAddr) {
|
||||
Glibc.connect(self.socketfd, UnsafeMutablePointer($0), socklen_t(signature.address!.size))
|
||||
}
|
||||
#else
|
||||
let rc = withUnsafeMutablePointer(&remoteAddr) {
|
||||
let rc = withUnsafeMutablePointer(to: &remoteAddr) {
|
||||
Darwin.connect(self.socketfd, UnsafeMutablePointer($0), socklen_t(signature.address!.size))
|
||||
}
|
||||
#endif
|
||||
@@ -2082,7 +2082,7 @@ public class Socket: SocketReader, SocketWriter {
|
||||
///
|
||||
public func write(from string: String) throws {
|
||||
|
||||
try string.nulTerminatedUTF8.withUnsafeBufferPointer() {
|
||||
try string.utf8CString.withUnsafeBufferPointer() {
|
||||
|
||||
// The count returned by nullTerminatedUTF8 includes the null terminator...
|
||||
try self.write(from: $0.baseAddress!, bufSize: $0.count-1)
|
||||
|
||||
@@ -113,7 +113,7 @@ public protocol SSLServiceDelegate {
|
||||
///
|
||||
/// - Returns the number of bytes written. Zero indicates SSL shutdown, less than zero indicates error.
|
||||
///
|
||||
func send(buffer: UnsafePointer<Void>!, bufSize: Int) throws -> Int
|
||||
func send(buffer: UnsafeRawPointer!, bufSize: Int) throws -> Int
|
||||
|
||||
///
|
||||
/// Low level reader
|
||||
|
||||
+16
-15
@@ -38,10 +38,11 @@ public extension sockaddr_storage {
|
||||
public func asAddr() -> sockaddr {
|
||||
|
||||
var temp = self
|
||||
let addr = withUnsafePointer(&temp) {
|
||||
return UnsafePointer<sockaddr>($0).pointee
|
||||
let addr = withUnsafePointer(to: &temp) {
|
||||
return UnsafeRawPointer($0)
|
||||
}
|
||||
return addr
|
||||
return addr.assumingMemoryBound(to: sockaddr.self).pointee
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
@@ -52,10 +53,10 @@ public extension sockaddr_storage {
|
||||
public func asIPV4() -> sockaddr_in {
|
||||
|
||||
var temp = self
|
||||
let addr = withUnsafePointer(&temp) {
|
||||
return UnsafePointer<sockaddr_in>($0).pointee
|
||||
let addr = withUnsafePointer(to: &temp) {
|
||||
return UnsafeRawPointer($0)
|
||||
}
|
||||
return addr
|
||||
return addr.assumingMemoryBound(to: sockaddr_in.self).pointee
|
||||
}
|
||||
|
||||
///
|
||||
@@ -66,10 +67,10 @@ public extension sockaddr_storage {
|
||||
public func asIPV6() -> sockaddr_in6 {
|
||||
|
||||
var temp = self
|
||||
let addr = withUnsafePointer(&temp) {
|
||||
return UnsafePointer<sockaddr_in6>($0).pointee
|
||||
let addr = withUnsafePointer(to: &temp) {
|
||||
return UnsafeRawPointer($0)
|
||||
}
|
||||
return addr
|
||||
return addr.assumingMemoryBound(to: sockaddr_in6.self).pointee
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,10 +86,10 @@ public extension sockaddr_in {
|
||||
public func asAddr() -> sockaddr {
|
||||
|
||||
var temp = self
|
||||
let addr = withUnsafePointer(&temp) {
|
||||
return UnsafePointer<sockaddr>($0).pointee
|
||||
let addr = withUnsafePointer(to: &temp) {
|
||||
return UnsafeRawPointer($0)
|
||||
}
|
||||
return addr
|
||||
return addr.assumingMemoryBound(to: sockaddr.self).pointee
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,10 +105,10 @@ public extension sockaddr_in6 {
|
||||
public func asAddr() -> sockaddr {
|
||||
|
||||
var temp = self
|
||||
let addr = withUnsafePointer(&temp) {
|
||||
return UnsafePointer<sockaddr>($0).pointee
|
||||
let addr = withUnsafePointer(to: &temp) {
|
||||
return UnsafeRawPointer($0)
|
||||
}
|
||||
return addr
|
||||
return addr.assumingMemoryBound(to: sockaddr.self).pointee
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import SocketTestSuite
|
||||
import SocketTests
|
||||
|
||||
XCTMain([
|
||||
testCase(SocketTests.allTests)
|
||||
])
|
||||
var tests = [XCTestCaseEntry]()
|
||||
|
||||
tests += BasicSocketTests.allTests()
|
||||
|
||||
XCTMain(tests)
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
import XCTest
|
||||
@testable import Socket
|
||||
|
||||
class SocketTests: XCTestCase {
|
||||
class BasicSocketTests: XCTestCase {
|
||||
|
||||
#if os(Linux)
|
||||
/* #if os(Linux)
|
||||
static var allTests : [(String, (SocketTests) -> () throws -> Void)] {
|
||||
|
||||
return [
|
||||
@@ -31,7 +31,7 @@ class SocketTests: XCTestCase {
|
||||
]
|
||||
}
|
||||
#endif
|
||||
|
||||
*/
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
@@ -70,4 +70,8 @@ class SocketTests: XCTestCase {
|
||||
print("Error reported: \(socketError.description)")
|
||||
}
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testSocket", testSocket)
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// XCTestManifests.swift
|
||||
// Socket
|
||||
//
|
||||
// Created by Bill Abt on 8/1/16.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
#if !os(macOS)
|
||||
public func allTests() -> [XCTestCaseEntry] {
|
||||
return [
|
||||
testCase(BasicSocketTests.allTests),
|
||||
]
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user