From 713b3ce28e29f3c6d799214060659216b1f957ae Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sun, 3 Jul 2016 04:52:57 -0500 Subject: [PATCH 01/19] Added default initialization values for base64 --- Sources/SwiftFoundation/Base64.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftFoundation/Base64.swift b/Sources/SwiftFoundation/Base64.swift index b4adbaa..10a0081 100644 --- a/Sources/SwiftFoundation/Base64.swift +++ b/Sources/SwiftFoundation/Base64.swift @@ -29,7 +29,7 @@ /* Create an NSData from a Base-64 encoded NSString using the given options. By default, returns nil when the input is not recognized as valid Base-64. */ - public init?(base64Encoded base64String: String, options: Base64DecodingOptions) { + public init?(base64Encoded base64String: String, options: Base64DecodingOptions = []) { let encodedBytes = Array(base64String.utf8) guard let decodedBytes = Data.base64DecodeBytes(encodedBytes, options: options) else { return nil @@ -47,7 +47,7 @@ /* Create an NSData from a Base-64, UTF-8 encoded NSData. By default, returns nil when the input is not recognized as valid Base-64. */ - public init?(base64Encoded base64Data: Data, options: Base64DecodingOptions) { + public init?(base64Encoded base64Data: Data, options: Base64DecodingOptions = []) { guard let decodedBytes = Data.base64DecodeBytes(base64Data.bytes, options: options) else { return nil } From 5672f340b876433587fa9499bf48ea987663b2e1 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Fri, 15 Jul 2016 00:01:34 -0500 Subject: [PATCH 02/19] Updated for Xcode 8 Beta 2 --- Sources/SwiftFoundation/Thread.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Sources/SwiftFoundation/Thread.swift b/Sources/SwiftFoundation/Thread.swift index 86d2085..06176db 100644 --- a/Sources/SwiftFoundation/Thread.swift +++ b/Sources/SwiftFoundation/Thread.swift @@ -25,10 +25,10 @@ public final class Thread { let holder = Unmanaged.passRetained(Closure(closure: closure)) + let pointer = UnsafeMutablePointer(holder.toOpaque()) + #if os(Linux) - let pointer = UnsafeMutablePointer(holder.toOpaque()) - var internalThread: pthread_t = 0 guard pthread_create(&internalThread, nil, ThreadPrivateMainLinux, pointer) == 0 @@ -40,8 +40,6 @@ public final class Thread { #elseif os(OSX) || os(iOS) || os(watchOS) || os(tvOS) - let pointer = UnsafeMutablePointer(OpaquePointer(bitPattern: holder)) - var internalThread: pthread_t? = nil guard pthread_create(&internalThread, nil, ThreadPrivateMainDarwin, pointer) == 0 @@ -101,7 +99,7 @@ public final class Thread { private func ThreadPrivateMainDarwin(arg: UnsafeMutablePointer) -> UnsafeMutablePointer? { - let unmanaged = Unmanaged.fromOpaque(OpaquePointer(arg)) + let unmanaged = Unmanaged.fromOpaque(arg) unmanaged.takeUnretainedValue().closure() From 18e504ff75d463d7c486555ef702aa89261c59bc Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Fri, 15 Jul 2016 03:03:48 -0500 Subject: [PATCH 03/19] Updated for Xcode 8 beta 2 Fixed code signing for Carthage --- Cartfile.resolved | 2 +- .../SwiftFoundation.xcodeproj/project.pbxproj | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 0619d85..9ed696b 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "PureSwift/JSON-C" "098c5ad91d262de5ad695a6162b6d0d4b384741d" +github "PureSwift/JSON-C" "0b49467d3f881523c9a74994f6e460a757bdb84f" diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 902ef19..9a1bfc7 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -135,12 +135,6 @@ 6E957C2B1C43AA55003F3C51 /* JSONSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C291C43AA55003F3C51 /* JSONSerialization.swift */; }; 6E957C2C1C43AA55003F3C51 /* JSONSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C291C43AA55003F3C51 /* JSONSerialization.swift */; }; 6E957C2D1C43AA55003F3C51 /* JSONSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C291C43AA55003F3C51 /* JSONSerialization.swift */; }; - 6E957C481C43B397003F3C51 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C451C43B397003F3C51 /* JSON.framework */; }; - 6E957C491C43B397003F3C51 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C451C43B397003F3C51 /* JSON.framework */; }; - 6E957C4A1C43B397003F3C51 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C451C43B397003F3C51 /* JSON.framework */; }; - 6E957C4B1C43B397003F3C51 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C471C43B397003F3C51 /* JSON.framework */; }; - 6E957C4C1C43B397003F3C51 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C471C43B397003F3C51 /* JSON.framework */; }; - 6E957C4D1C43B397003F3C51 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C471C43B397003F3C51 /* JSON.framework */; }; 6E957C4E1C43B3A1003F3C51 /* JSON.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C471C43B397003F3C51 /* JSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 6E957C4F1C43B3A5003F3C51 /* JSON.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C451C43B397003F3C51 /* JSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 6E957C571C442E3E003F3C51 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C561C442E3E003F3C51 /* JSONTests.swift */; }; @@ -267,8 +261,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6E957C4C1C43B397003F3C51 /* JSON.framework in Frameworks */, - 6E957C491C43B397003F3C51 /* JSON.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -276,8 +268,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6E957C4D1C43B397003F3C51 /* JSON.framework in Frameworks */, - 6E957C4A1C43B397003F3C51 /* JSON.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -293,8 +283,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6E957C4B1C43B397003F3C51 /* JSON.framework in Frameworks */, - 6E957C481C43B397003F3C51 /* JSON.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -866,12 +854,13 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_BITCODE = YES; FRAMEWORK_SEARCH_PATHS = $SRCROOT/../Carthage/Build/iOS; FRAMEWORK_VERSION = A; INFOPLIST_FILE = "$(SRCROOT)/SwiftFoundation/Info.plist"; @@ -889,12 +878,13 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_BITCODE = YES; FRAMEWORK_SEARCH_PATHS = $SRCROOT/../Carthage/Build/iOS; FRAMEWORK_VERSION = A; INFOPLIST_FILE = "$(SRCROOT)/SwiftFoundation/Info.plist"; @@ -991,6 +981,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; @@ -1041,6 +1032,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; From c5de493c848c01fb6978e29caf59ab6227d84d9f Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 16 Jul 2016 00:58:28 -0500 Subject: [PATCH 04/19] Disabled code signing for WatchOS target --- Xcode/SwiftFoundation.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 9a1bfc7..7efb0c9 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -901,6 +901,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -922,6 +923,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; From 6e145f4cb7e920ed907df4ce8658495fcf6c7c1f Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Wed, 20 Jul 2016 23:45:04 -0500 Subject: [PATCH 05/19] Fixed #32 --- Sources/SwiftFoundation/POSIXError.swift | 250 +++++++++++++++++++++-- 1 file changed, 235 insertions(+), 15 deletions(-) diff --git a/Sources/SwiftFoundation/POSIXError.swift b/Sources/SwiftFoundation/POSIXError.swift index adaf7aa..747c525 100644 --- a/Sources/SwiftFoundation/POSIXError.swift +++ b/Sources/SwiftFoundation/POSIXError.swift @@ -8,38 +8,258 @@ #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) import Darwin.C + import Foundation #elseif os(Linux) import Glibc #endif +#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) + +#endif + public extension POSIXError { /// Creates error from C ```errno```. - static var fromErrno: POSIXError? { return self.init(rawValue: errno) } + static var fromErrno: POSIXError? { + + guard let code = POSIXErrorCode(rawValue: errno) + else { return nil } + + return self.init(code: code) + } + + /// Creates `POSIXError` from error code. + @inline(__always) + init(code: POSIXErrorCode) { + + let nsError = NSError(domain: NSPOSIXErrorDomain, code: Int(code.rawValue), userInfo: nil) + + self.init(_nsError: nsError) + } } #if os(Linux) /// Enumeration describing POSIX error codes. - public enum POSIXError: ErrorProtocol, RawRepresentable { + public struct POSIXError: Error { - case Value(CInt) + let code: POSIXErrorCode - public init?(rawValue: CInt) { - - guard rawValue != 0 - else { return nil } + public init(code: POSIXErrorCode) { - self = .Value(rawValue) + self.code = code } + } + + /// Enumeration describing POSIX error codes. + public enum POSIXErrorCode : Int32 { - public var rawValue: CInt { - - switch self { - - case let .Value(rawValue): return rawValue - } - } + /// Operation not permitted. + case EPERM = 1 + /// No such file or directory. + case ENOENT = 2 + /// No such process. + case ESRCH = 3 + /// Interrupted system call. + case EINTR = 4 + /// Input/output error. + case EIO = 5 + /// Device not configured. + case ENXIO = 6 + /// Argument list too long. + case E2BIG = 7 + /// Exec format error. + case ENOEXEC = 8 + /// Bad file descriptor. + case EBADF = 9 + /// No child processes. + case ECHILD = 10 + /// Try again. + case EAGAIN = 11 + /// Cannot allocate memory. + case ENOMEM = 12 + /// Permission denied. + case EACCES = 13 + /// Bad address. + case EFAULT = 14 + /// Block device required. + case ENOTBLK = 15 + /// Device / Resource busy. + case EBUSY = 16 + /// File exists. + case EEXIST = 17 + /// Cross-device link. + case EXDEV = 18 + /// Operation not supported by device. + case ENODEV = 19 + /// Not a directory. + case ENOTDIR = 20 + /// Is a directory. + case EISDIR = 21 + /// Invalid argument. + case EINVAL = 22 + /// Too many open files in system. + case ENFILE = 23 + /// Too many open files. + case EMFILE = 24 + /// Inappropriate ioctl for device. + case ENOTTY = 25 + /// Text file busy. + case ETXTBSY = 26 + /// File too large. + case EFBIG = 27 + /// No space left on device. + case ENOSPC = 28 + /// Illegal seek. + case ESPIPE = 29 + /// Read-only file system. + case EROFS = 30 + /// Too many links. + case EMLINK = 31 + /// Broken pipe. + case EPIPE = 32 + + /// math software. + /// Numerical argument out of domain. + case EDOM = 33 + /// Result too large. + case ERANGE = 34 + + /// Resource deadlock would occur. + case EDEADLK = 35 + + /// File name too long. + case ENAMETOOLONG = 36 + + /// No record locks available + case ENOLCK = 37 + + /// Function not implemented. + case ENOSYS = 38 + + /// Directory not empty. + case ENOTEMPTY = 39 + + /// Too many symbolic links encountered + case ELOOP = 40 + + /// Operation would block. + public static var EWOULDBLOCK: POSIXErrorCode { return .EAGAIN } + + /// No message of desired type. + case ENOMSG = 42 + + /// Identifier removed. + case EIDRM = 43 + + /// Channel number out of range. + case ECHRNG = 44 + + /// Level 2 not synchronized. + case EL2NSYNC = 45 + + /// Level 3 halted + case EL3HLT = 46 + + /// Level 3 reset. + case EL3RST = 47 + + /// Link number out of range. + case ELNRNG = 48 + + /// Protocol driver not attached. + case EUNATCH = 49 + + /// No CSI structure available. + case ENOCSI = 50 + + /// Level 2 halted. + case EL2HLT = 51 + case EBADE = 52 /* Invalid exchange */ + case EBADR = 53 /* Invalid request descriptor */ + case EXFULL = 54 /* Exchange full */ + case ENOANO = 55 /* No anode */ + case EBADRQC = 56 /* Invalid request code */ + case EBADSLT = 57 /* Invalid slot */ + + public static var EDEADLOCK: POSIXErrorCode { return .EDEADLK } + + case EBFONT = 59 /* Bad font file format */ + case ENOSTR = 60 /* Device not a stream */ + case ENODATA = 61 /* No data available */ + case ETIME = 62 /* Timer expired */ + case ENOSR = 63 /* Out of streams resources */ + case ENONET = 64 /* Machine is not on the network */ + case ENOPKG = 65 /* Package not installed */ + case EREMOTE = 66 /* Object is remote */ + case ENOLINK = 67 /* Link has been severed */ + case EADV = 68 /* Advertise error */ + case ESRMNT = 69 /* Srmount error */ + case ECOMM = 70 /* Communication error on send */ + case EPROTO = 71 /* Protocol error */ + case EMULTIHOP = 72 /* Multihop attempted */ + case EDOTDOT = 73 /* RFS specific error */ + case EBADMSG = 74 /* Not a data message */ + case EOVERFLOW = 75 /* Value too large for defined data type */ + case ENOTUNIQ = 76 /* Name not unique on network */ + case EBADFD = 77 /* File descriptor in bad state */ + case EREMCHG = 78 /* Remote address changed */ + case ELIBACC = 79 /* Can not access a needed shared library */ + case ELIBBAD = 80 /* Accessing a corrupted shared library */ + case ELIBSCN = 81 /* .lib section in a.out corrupted */ + case ELIBMAX = 82 /* Attempting to link in too many shared libraries */ + case ELIBEXEC = 83 /* Cannot exec a shared library directly */ + case EILSEQ = 84 /* Illegal byte sequence */ + case ERESTART = 85 /* Interrupted system call should be restarted */ + case ESTRPIPE = 86 /* Streams pipe error */ + case EUSERS = 87 /* Too many users */ + case ENOTSOCK = 88 /* Socket operation on non-socket */ + case EDESTADDRREQ = 89 /* Destination address required */ + case EMSGSIZE = 90 /* Message too long */ + case EPROTOTYPE = 91 /* Protocol wrong type for socket */ + case ENOPROTOOPT = 92 /* Protocol not available */ + case EPROTONOSUPPORT = 93 /* Protocol not supported */ + case ESOCKTNOSUPPORT = 94 /* Socket type not supported */ + case EOPNOTSUPP = 95 /* Operation not supported on transport endpoint */ + case EPFNOSUPPORT = 96 /* Protocol family not supported */ + case EAFNOSUPPORT = 97 /* Address family not supported by protocol */ + case EADDRINUSE = 98 /* Address already in use */ + case EADDRNOTAVAIL = 99 /* Cannot assign requested address */ + case ENETDOWN = 100 /* Network is down */ + case ENETUNREACH = 101 /* Network is unreachable */ + case ENETRESET = 102 /* Network dropped connection because of reset */ + case ECONNABORTED = 103 /* Software caused connection abort */ + case ECONNRESET = 104 /* Connection reset by peer */ + case ENOBUFS = 105 /* No buffer space available */ + case EISCONN = 106 /* Transport endpoint is already connected */ + case ENOTCONN = 107 /* Transport endpoint is not connected */ + case ESHUTDOWN = 108 /* Cannot send after transport endpoint shutdown */ + case ETOOMANYREFS = 109 /* Too many references: cannot splice */ + case ETIMEDOUT = 110 /* Connection timed out */ + case ECONNREFUSED = 111 /* Connection refused */ + case EHOSTDOWN = 112 /* Host is down */ + case EHOSTUNREACH = 113 /* No route to host */ + case EALREADY = 114 /* Operation already in progress */ + case EINPROGRESS = 115 /* Operation now in progress */ + case ESTALE = 116 /* Stale NFS file handle */ + case EUCLEAN = 117 /* Structure needs cleaning */ + case ENOTNAM = 118 /* Not a XENIX named type file */ + case ENAVAIL = 119 /* No XENIX semaphores available */ + case EISNAM = 120 /* Is a named type file */ + case EREMOTEIO = 121 /* Remote I/O error */ + case EDQUOT = 122 /* Quota exceeded */ + + case ENOMEDIUM = 123 /* No medium found */ + case EMEDIUMTYPE = 124 /* Wrong medium type */ + case ECANCELED = 125 /* Operation Canceled */ + case ENOKEY = 126 /* Required key not available */ + case EKEYEXPIRED = 127 /* Key has expired */ + case EKEYREVOKED = 128 /* Key has been revoked */ + case EKEYREJECTED = 129 /* Key was rejected by service */ + + /* for robust mutexes */ + case EOWNERDEAD = 130 /* Owner died */ + case ENOTRECOVERABLE = 131 /* State not recoverable */ } #endif From d06e4ac56a978d16757a0f4139792872dcaf2c97 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 21 Jul 2016 00:34:53 -0500 Subject: [PATCH 06/19] Updated for Swift 3.0 Swift 3.0 Development 2016-07-16 --- Sources/SwiftFoundation/Base64.swift | 2 +- Sources/SwiftFoundation/Data.swift | 2 +- Sources/SwiftFoundation/JSONExtensions.swift | 2 +- .../SwiftFoundation/JSONSerialization.swift | 18 +++---- Sources/SwiftFoundation/POSIXError.swift | 10 ++-- .../RegularExpressionCompileError.swift | 50 +++++++++---------- .../RegularExpressionCompileOption.swift | 8 +-- .../RegularExpressionMatchOption.swift | 6 +-- Sources/SwiftFoundation/Thread.swift | 4 +- .../SwiftFoundation.xcodeproj/project.pbxproj | 2 + 10 files changed, 53 insertions(+), 51 deletions(-) diff --git a/Sources/SwiftFoundation/Base64.swift b/Sources/SwiftFoundation/Base64.swift index 10a0081..9b837fb 100644 --- a/Sources/SwiftFoundation/Base64.swift +++ b/Sources/SwiftFoundation/Base64.swift @@ -232,7 +232,7 @@ let appendByteToResult : (UInt8) -> () = { result.append($0) currentLineCount += 1 - if let options = lineOptions where currentLineCount == options.lineLength { + if let options = lineOptions, currentLineCount == options.lineLength { result.append(contentsOf: options.separator) currentLineCount = 0 } diff --git a/Sources/SwiftFoundation/Data.swift b/Sources/SwiftFoundation/Data.swift index 5cc931c..f3827d6 100644 --- a/Sources/SwiftFoundation/Data.swift +++ b/Sources/SwiftFoundation/Data.swift @@ -85,7 +85,7 @@ guard let pointer = buffer.baseAddress else { self.init(); return } - self.init(bytes: pointer, count: sizeof(SourceType) * buffer.count) + self.init(bytes: pointer, count: sizeof(SourceType.self) * buffer.count) } // MARK: - Accessors diff --git a/Sources/SwiftFoundation/JSONExtensions.swift b/Sources/SwiftFoundation/JSONExtensions.swift index 80e9708..7e1330c 100644 --- a/Sources/SwiftFoundation/JSONExtensions.swift +++ b/Sources/SwiftFoundation/JSONExtensions.swift @@ -100,7 +100,7 @@ public extension Collection where Iterator.Element: JSONEncodable { } } -public extension Dictionary where Value: JSONEncodable, Key: StringLiteralConvertible { +public extension Dictionary where Value: JSONEncodable, Key: ExpressibleByStringLiteral { /// Encodes the reciever into JSON. func toJSON() -> JSON.Value { diff --git a/Sources/SwiftFoundation/JSONSerialization.swift b/Sources/SwiftFoundation/JSONSerialization.swift index 24e86c1..3c50589 100755 --- a/Sources/SwiftFoundation/JSONSerialization.swift +++ b/Sources/SwiftFoundation/JSONSerialization.swift @@ -103,22 +103,22 @@ public extension JSON { public enum WritingOption: BitMaskOption { /// Causes the output to have minimal whitespace inserted to make things slightly more readable. - case Spaced + case spaced /// Causes the output to be formatted. See the [Two Space Tab](http://jsonformatter.curiousconcept.com/) option /// for an example of the format. - case Pretty + case pretty /// Drop trailing zero for float values - case NoZero + case noZero public init?(rawValue: Int32) { switch rawValue { - case JSON_C_TO_STRING_SPACED: self = .Spaced - case JSON_C_TO_STRING_PRETTY: self = .Pretty - case JSON_C_TO_STRING_NOZERO: self = .NoZero + case JSON_C_TO_STRING_SPACED: self = .spaced + case JSON_C_TO_STRING_PRETTY: self = .pretty + case JSON_C_TO_STRING_NOZERO: self = .noZero default: return nil } @@ -128,9 +128,9 @@ public extension JSON { switch self { - case Spaced: return JSON_C_TO_STRING_SPACED - case Pretty: return JSON_C_TO_STRING_PRETTY - case NoZero: return JSON_C_TO_STRING_NOZERO + case .spaced: return JSON_C_TO_STRING_SPACED + case .pretty: return JSON_C_TO_STRING_PRETTY + case .noZero: return JSON_C_TO_STRING_NOZERO } } } diff --git a/Sources/SwiftFoundation/POSIXError.swift b/Sources/SwiftFoundation/POSIXError.swift index 747c525..f389c39 100644 --- a/Sources/SwiftFoundation/POSIXError.swift +++ b/Sources/SwiftFoundation/POSIXError.swift @@ -13,10 +13,6 @@ import Glibc #endif -#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) - -#endif - public extension POSIXError { /// Creates error from C ```errno```. @@ -28,14 +24,18 @@ public extension POSIXError { return self.init(code: code) } +#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) + /// Creates `POSIXError` from error code. - @inline(__always) init(code: POSIXErrorCode) { let nsError = NSError(domain: NSPOSIXErrorDomain, code: Int(code.rawValue), userInfo: nil) self.init(_nsError: nsError) } + +#endif + } #if os(Linux) diff --git a/Sources/SwiftFoundation/RegularExpressionCompileError.swift b/Sources/SwiftFoundation/RegularExpressionCompileError.swift index c6dfac2..08aa54c 100644 --- a/Sources/SwiftFoundation/RegularExpressionCompileError.swift +++ b/Sources/SwiftFoundation/RegularExpressionCompileError.swift @@ -15,7 +15,7 @@ public extension RegularExpression { // POSIX Regular Expression compilation error - public enum CompileError: RawRepresentable, ErrorProtocol { + public enum CompileError: Error, RawRepresentable { /// Invalid use of repetition operators such as using '*' as the first character. /// @@ -71,18 +71,18 @@ public extension RegularExpression { switch rawValue { - case REG_BADRPT: self = InvalidRepetition - case REG_BADBR: self = InvalidBackReference - case REG_ESPACE: self = OutOfMemory - case REG_BADPAT: self = InvalidPatternOperator - case REG_EBRACE: self = UnMatchedBraceInterval - case REG_EBRACK: self = UnMatchedBracketList - case REG_ECOLLATE: self = InvalidCollating - case REG_ECTYPE: self = UnknownCharacterClassName - case REG_EESCAPE: self = TrailingBackslash - case REG_EPAREN: self = UnMatchedParenthesis - case REG_ERANGE: self = InvalidRange - case REG_ESUBREG: self = InvalidBackReferenceToSubExpression + case REG_BADRPT: self = .InvalidRepetition + case REG_BADBR: self = .InvalidBackReference + case REG_ESPACE: self = .OutOfMemory + case REG_BADPAT: self = .InvalidPatternOperator + case REG_EBRACE: self = .UnMatchedBraceInterval + case REG_EBRACK: self = .UnMatchedBracketList + case REG_ECOLLATE: self = .InvalidCollating + case REG_ECTYPE: self = .UnknownCharacterClassName + case REG_EESCAPE: self = .TrailingBackslash + case REG_EPAREN: self = .UnMatchedParenthesis + case REG_ERANGE: self = .InvalidRange + case REG_ESUBREG: self = .InvalidBackReferenceToSubExpression /* #if os(linux) @@ -101,18 +101,18 @@ public extension RegularExpression { switch self { - case InvalidRepetition: return REG_BADRPT - case InvalidBackReference: return REG_BADBR - case OutOfMemory: return REG_ESPACE - case InvalidPatternOperator: return REG_BADPAT - case UnMatchedBraceInterval: return REG_EBRACE - case UnMatchedBracketList: return REG_EBRACK - case InvalidCollating: return REG_ECOLLATE - case UnknownCharacterClassName: return REG_ECTYPE - case TrailingBackslash: return REG_EESCAPE - case UnMatchedParenthesis: return REG_EPAREN - case InvalidRange: return REG_ERANGE - case InvalidBackReferenceToSubExpression: return REG_ESUBREG + case .InvalidRepetition: return REG_BADRPT + case .InvalidBackReference: return REG_BADBR + case .OutOfMemory: return REG_ESPACE + case .InvalidPatternOperator: return REG_BADPAT + case .UnMatchedBraceInterval: return REG_EBRACE + case .UnMatchedBracketList: return REG_EBRACK + case .InvalidCollating: return REG_ECOLLATE + case .UnknownCharacterClassName: return REG_ECTYPE + case .TrailingBackslash: return REG_EESCAPE + case .UnMatchedParenthesis: return REG_EPAREN + case .InvalidRange: return REG_ERANGE + case .InvalidBackReferenceToSubExpression: return REG_ESUBREG } } } diff --git a/Sources/SwiftFoundation/RegularExpressionCompileOption.swift b/Sources/SwiftFoundation/RegularExpressionCompileOption.swift index 9ad9cc9..ac105b6 100644 --- a/Sources/SwiftFoundation/RegularExpressionCompileOption.swift +++ b/Sources/SwiftFoundation/RegularExpressionCompileOption.swift @@ -36,10 +36,10 @@ public extension RegularExpression { switch rawValue { - case REG_ICASE: self = CaseInsensitive - case REG_EXTENDED: self = ExtendedSyntax - case REG_NOSUB: self = NoSub - case REG_NEWLINE: self = NewLine + case REG_ICASE: self = .CaseInsensitive + case REG_EXTENDED: self = .ExtendedSyntax + case REG_NOSUB: self = .NoSub + case REG_NEWLINE: self = .NewLine default: return nil } diff --git a/Sources/SwiftFoundation/RegularExpressionMatchOption.swift b/Sources/SwiftFoundation/RegularExpressionMatchOption.swift index bab9d6c..ba11d4a 100644 --- a/Sources/SwiftFoundation/RegularExpressionMatchOption.swift +++ b/Sources/SwiftFoundation/RegularExpressionMatchOption.swift @@ -29,8 +29,8 @@ public extension RegularExpression { switch rawValue { - case REG_NOTBOL: self = NotBeginningOfLine - case REG_NOTEOL: self = NotEndOfLine + case REG_NOTBOL: self = .NotBeginningOfLine + case REG_NOTEOL: self = .NotEndOfLine default: return nil } @@ -45,4 +45,4 @@ public extension RegularExpression { } } } -} \ No newline at end of file +} diff --git a/Sources/SwiftFoundation/Thread.swift b/Sources/SwiftFoundation/Thread.swift index 06176db..9d26d28 100644 --- a/Sources/SwiftFoundation/Thread.swift +++ b/Sources/SwiftFoundation/Thread.swift @@ -66,7 +66,7 @@ public final class Thread { let errorCode = pthread_join(internalThread, nil) guard errorCode == 0 - else { throw POSIXError(rawValue: errorCode)! } + else { throw POSIXError(code: POSIXErrorCode(rawValue: errorCode)!) } } public func cancel() throws { @@ -74,7 +74,7 @@ public final class Thread { let errorCode = pthread_cancel(internalThread) guard errorCode == 0 - else { throw POSIXError(rawValue: errorCode)! } + else { throw POSIXError(code: POSIXErrorCode(rawValue: errorCode)!) } } } diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 7efb0c9..639551b 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -1011,6 +1011,7 @@ PRODUCT_NAME = SwiftFoundation; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; WATCHOS_DEPLOYMENT_TARGET = 2.0; @@ -1056,6 +1057,7 @@ PRODUCT_NAME = SwiftFoundation; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; WATCHOS_DEPLOYMENT_TARGET = 2.0; From 6e29f531be8dabec911692ed7a2447ccdd9f2613 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sun, 24 Jul 2016 00:04:08 -0500 Subject: [PATCH 07/19] Updated for Swift 3.0 2016-07-23 --- Sources/SwiftFoundation/Data.swift | 2 +- Sources/SwiftFoundation/FileManager.swift | 8 ++++---- Sources/SwiftFoundation/Hash.swift | 2 +- Sources/SwiftFoundation/JSONParse.swift | 4 ++-- Sources/SwiftFoundation/Lock.swift | 16 ++++++++-------- .../SwiftFoundation/POSIXRegularExpression.swift | 2 +- Sources/SwiftFoundation/UUID.swift | 4 ++-- Sources/UnitTests/DataTests.swift | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Sources/SwiftFoundation/Data.swift b/Sources/SwiftFoundation/Data.swift index f3827d6..458875f 100644 --- a/Sources/SwiftFoundation/Data.swift +++ b/Sources/SwiftFoundation/Data.swift @@ -100,7 +100,7 @@ public var description: String { - let hexString = bytes.map({ $0.toHexadecimal() }).reduce("", combine: { $0.0 + $0.1 }) + let hexString = bytes.map({ $0.toHexadecimal() }).reduce("", { $0.0 + $0.1 }) return "<" + hexString + ">" } diff --git a/Sources/SwiftFoundation/FileManager.swift b/Sources/SwiftFoundation/FileManager.swift index 3b07060..acb7bb2 100644 --- a/Sources/SwiftFoundation/FileManager.swift +++ b/Sources/SwiftFoundation/FileManager.swift @@ -75,9 +75,9 @@ public struct FileManager { let stringBufferSize = Int(PATH_MAX) - let path = UnsafeMutablePointer(allocatingCapacity: stringBufferSize) + let path = UnsafeMutablePointer.allocate(capacity: stringBufferSize) - defer { path.deallocateCapacity(stringBufferSize) } + defer { path.deallocate(capacity: stringBufferSize) } getcwd(path, stringBufferSize - 1) @@ -193,9 +193,9 @@ public struct FileManager { #endif - let memoryPointer = UnsafeMutablePointer(allocatingCapacity: fileSize) + let memoryPointer = UnsafeMutablePointer.allocate(capacity: fileSize) - defer { memoryPointer.deallocateCapacity(fileSize) } + defer { memoryPointer.deallocate(capacity: fileSize) } let readBytes = read(file, memoryPointer, fileSize) diff --git a/Sources/SwiftFoundation/Hash.swift b/Sources/SwiftFoundation/Hash.swift index 83d5796..2076caf 100644 --- a/Sources/SwiftFoundation/Hash.swift +++ b/Sources/SwiftFoundation/Hash.swift @@ -10,5 +10,5 @@ public func Hash(_ data: Data) -> Int { // more expensive than casting but that's not safe for large values. - return data.bytes.map({ Int($0) }).reduce(0, combine: { $0.0 ^ $0.1 }) + return data.bytes.map({ Int($0) }).reduce(0, { $0.0 ^ $0.1 }) } diff --git a/Sources/SwiftFoundation/JSONParse.swift b/Sources/SwiftFoundation/JSONParse.swift index 1b3ed56..8babb38 100755 --- a/Sources/SwiftFoundation/JSONParse.swift +++ b/Sources/SwiftFoundation/JSONParse.swift @@ -16,9 +16,9 @@ public extension JSON.Value { public init?(string: Swift.String) { - let tokenerError: UnsafeMutablePointer! = UnsafeMutablePointer(allocatingCapacity: 1) + let tokenerError: UnsafeMutablePointer! = UnsafeMutablePointer.allocate(capacity: 1) - defer { tokenerError.deallocateCapacity(1) } + defer { tokenerError.deallocate(capacity: 1) } let jsonObject = json_tokener_parse_verbose(string, tokenerError) diff --git a/Sources/SwiftFoundation/Lock.swift b/Sources/SwiftFoundation/Lock.swift index 9c553dd..a2d7065 100644 --- a/Sources/SwiftFoundation/Lock.swift +++ b/Sources/SwiftFoundation/Lock.swift @@ -22,7 +22,7 @@ public final class Lock: Locking { - private var mutex = UnsafeMutablePointer(allocatingCapacity: 1) + private var mutex = UnsafeMutablePointer.allocate(capacity: 1) public init() { pthread_mutex_init(mutex, nil) @@ -31,7 +31,7 @@ deinit { pthread_mutex_destroy(mutex) mutex.deinitialize() - mutex.deallocateCapacity(1) + mutex.deallocate(capacity: 1) } public func lock() { @@ -131,7 +131,7 @@ } public final class RecursiveLock: Locking { - private var mutex = UnsafeMutablePointer(allocatingCapacity: 1) + private var mutex = UnsafeMutablePointer.allocate(capacity: 1) public init() { @@ -145,7 +145,7 @@ deinit { pthread_mutex_destroy(mutex) mutex.deinitialize() - mutex.deallocateCapacity(1) + mutex.deallocate(capacity: 1) } public func lock() { @@ -164,8 +164,8 @@ } public final class Condition: Locking { - private var mutex = UnsafeMutablePointer(allocatingCapacity: 1) - private var cond = UnsafeMutablePointer(allocatingCapacity: 1) + private var mutex = UnsafeMutablePointer.allocate(capacity: 1) + private var cond = UnsafeMutablePointer.allocate(capacity: 1) public init() { pthread_mutex_init(mutex, nil) @@ -177,8 +177,8 @@ pthread_cond_destroy(cond) mutex.deinitialize() cond.deinitialize() - mutex.deallocateCapacity(1) - cond.deallocateCapacity(1) + mutex.deallocate(capacity: 1) + cond.deallocate(capacity: 1) } public func lock() { diff --git a/Sources/SwiftFoundation/POSIXRegularExpression.swift b/Sources/SwiftFoundation/POSIXRegularExpression.swift index fb2c70d..b8e070c 100644 --- a/Sources/SwiftFoundation/POSIXRegularExpression.swift +++ b/Sources/SwiftFoundation/POSIXRegularExpression.swift @@ -39,7 +39,7 @@ public extension POSIXRegularExpression { let numberOfMatches = re_nsub + 1 // first match is the expression itself, later matches are subexpressions - let matchesPointer = UnsafeMutablePointer.init(allocatingCapacity: numberOfMatches) + let matchesPointer = UnsafeMutablePointer.allocate(capacity: numberOfMatches) defer { matchesPointer.deinitialize(count: numberOfMatches) } let flags = options.optionsBitmask() diff --git a/Sources/SwiftFoundation/UUID.swift b/Sources/SwiftFoundation/UUID.swift index 33106f1..4d16db7 100644 --- a/Sources/SwiftFoundation/UUID.swift +++ b/Sources/SwiftFoundation/UUID.swift @@ -59,9 +59,9 @@ init?(rawValue: String) { - let uuidPointer = UnsafeMutablePointer(allocatingCapacity: 1) + let uuidPointer = UnsafeMutablePointer.allocate(capacity: 1) - defer { uuidPointer.deallocateCapacity(1) } + defer { uuidPointer.deallocate(capacity: 1) } guard uuid_parse(rawValue, unsafeBitCast(uuidPointer, to: UnsafeMutablePointer.self)) != -1 else { return nil } diff --git a/Sources/UnitTests/DataTests.swift b/Sources/UnitTests/DataTests.swift index eb87be3..6094aad 100644 --- a/Sources/UnitTests/DataTests.swift +++ b/Sources/UnitTests/DataTests.swift @@ -25,9 +25,9 @@ final class DataTests: XCTestCase { XCTAssert(testData.isEmpty == false, "Could not create test data") - let dataPointer = UnsafeMutablePointer(allocatingCapacity: testData.count) + let dataPointer = UnsafeMutablePointer.allocate(capacity: testData.count) - defer { dataPointer.deallocateCapacity(testData.count) } + defer { dataPointer.deallocate(capacity: testData.count) } memcpy(dataPointer, testData.bytes, testData.count) From 9415e238f02ff78bb1f1c61f31bd1120959ddf4c Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 30 Jul 2016 20:06:40 -0500 Subject: [PATCH 08/19] Updated for Swift 3.0 29-07-2016 --- Sources/SwiftFoundation/BitMaskOption.swift | 2 +- Sources/SwiftFoundation/ByteValue.swift | 2 +- Sources/SwiftFoundation/Data.swift | 2 +- Sources/SwiftFoundation/JSONExtensions.swift | 6 ++--- Sources/SwiftFoundation/Lock.swift | 6 ++--- .../SwiftFoundation/RawRepresentable.swift | 8 +++---- Sources/SwiftFoundation/String.swift | 4 +++- Sources/SwiftFoundation/Thread.swift | 10 ++++---- Sources/SwiftFoundation/UUID.swift | 23 +++++++++++-------- .../SwiftFoundation.xcodeproj/project.pbxproj | 4 ++-- 10 files changed, 37 insertions(+), 30 deletions(-) diff --git a/Sources/SwiftFoundation/BitMaskOption.swift b/Sources/SwiftFoundation/BitMaskOption.swift index 2a24953..6bb3674 100644 --- a/Sources/SwiftFoundation/BitMaskOption.swift +++ b/Sources/SwiftFoundation/BitMaskOption.swift @@ -14,7 +14,7 @@ public protocol BitMaskOption: RawRepresentable { public extension BitMaskOption where Self.RawValue: Integer { - static func bitmask(options: S) -> Self.RawValue { + static func bitmask(options: S) -> Self.RawValue where S.Iterator.Element == Self { return options.reduce(0) { mask, option in mask | option.rawValue } diff --git a/Sources/SwiftFoundation/ByteValue.swift b/Sources/SwiftFoundation/ByteValue.swift index 4e9e275..1fa4fd4 100644 --- a/Sources/SwiftFoundation/ByteValue.swift +++ b/Sources/SwiftFoundation/ByteValue.swift @@ -22,7 +22,7 @@ public protocol ByteValue: Equatable { // MARK: - Equatable -public func == (lhs: T, rhs: T) -> Bool { +public func == (lhs: T, rhs: T) -> Bool where T.ByteValue: Equatable { return lhs.bytes == rhs.bytes } diff --git a/Sources/SwiftFoundation/Data.swift b/Sources/SwiftFoundation/Data.swift index 458875f..6577aa7 100644 --- a/Sources/SwiftFoundation/Data.swift +++ b/Sources/SwiftFoundation/Data.swift @@ -24,7 +24,7 @@ // MARK: - Properties - private var _bytes: ContiguousArray + fileprivate var _bytes: ContiguousArray public var bytes: [Byte] { diff --git a/Sources/SwiftFoundation/JSONExtensions.swift b/Sources/SwiftFoundation/JSONExtensions.swift index 7e1330c..8723a9f 100644 --- a/Sources/SwiftFoundation/JSONExtensions.swift +++ b/Sources/SwiftFoundation/JSONExtensions.swift @@ -100,18 +100,18 @@ public extension Collection where Iterator.Element: JSONEncodable { } } -public extension Dictionary where Value: JSONEncodable, Key: ExpressibleByStringLiteral { +public extension Collection where Index == DictionaryIndex, Iterator.Element == (key: String, value: JSONEncodable) { /// Encodes the reciever into JSON. func toJSON() -> JSON.Value { - var jsonObject = JSON.Object(minimumCapacity: self.count) + var jsonObject = JSON.Object(minimumCapacity: numericCast(self.count)) for (key, value) in self { let jsonValue = value.toJSON() - let keyString = String(key) + let keyString: String = key jsonObject[keyString] = jsonValue } diff --git a/Sources/SwiftFoundation/Lock.swift b/Sources/SwiftFoundation/Lock.swift index a2d7065..aad5d3c 100644 --- a/Sources/SwiftFoundation/Lock.swift +++ b/Sources/SwiftFoundation/Lock.swift @@ -136,7 +136,7 @@ public init() { var attrib = pthread_mutexattr_t() - withUnsafeMutablePointer(&attrib) { attrs in + withUnsafeMutablePointer(to: &attrib) { attrs in pthread_mutexattr_settype(attrs, Int32(PTHREAD_MUTEX_RECURSIVE)) pthread_mutex_init(mutex, attrs) } @@ -203,12 +203,12 @@ ts.tv_sec = Int(floor(ti)) ts.tv_nsec = Int((ti - Double(ts.tv_sec)) * 1000000000.0) var tv = timeval() - withUnsafeMutablePointer(&tv) { t in + withUnsafeMutablePointer(to: &tv) { t in gettimeofday(t, nil) ts.tv_sec += t.pointee.tv_sec ts.tv_nsec += Int((t.pointee.tv_usec * 1000000) / 1000000000) } - let retVal: Int32 = withUnsafePointer(&ts) { t in + let retVal: Int32 = withUnsafePointer(to: &ts) { t in return pthread_cond_timedwait(cond, mutex, t) } diff --git a/Sources/SwiftFoundation/RawRepresentable.swift b/Sources/SwiftFoundation/RawRepresentable.swift index a532011..35bb618 100644 --- a/Sources/SwiftFoundation/RawRepresentable.swift +++ b/Sources/SwiftFoundation/RawRepresentable.swift @@ -51,22 +51,22 @@ public extension RawRepresentable { // MARK: Comparable -public func < (lhs: T, rhs: T) -> Bool { +public func < (lhs: T, rhs: T) -> Bool where T: RawRepresentable, T.RawValue: Comparable { return lhs.rawValue < rhs.rawValue } -public func <= (lhs: T, rhs: T) -> Bool { +public func <= (lhs: T, rhs: T) -> Bool where T: RawRepresentable, T.RawValue: Comparable { return lhs.rawValue <= rhs.rawValue } -public func >= (lhs: T, rhs: T) -> Bool { +public func >= (lhs: T, rhs: T) -> Bool where T: RawRepresentable, T.RawValue: Comparable { return lhs.rawValue >= rhs.rawValue } -public func > (lhs: T, rhs: T) -> Bool { +public func > (lhs: T, rhs: T) -> Bool where T: RawRepresentable, T.RawValue: Comparable { return lhs.rawValue > rhs.rawValue } diff --git a/Sources/SwiftFoundation/String.swift b/Sources/SwiftFoundation/String.swift index 0207893..0baf034 100644 --- a/Sources/SwiftFoundation/String.swift +++ b/Sources/SwiftFoundation/String.swift @@ -24,7 +24,9 @@ public extension String { case let .scalarValue(scalar): - string.append(scalar) + let scalarString = String(scalar) + + string.append(scalarString) case .emptyInput: diff --git a/Sources/SwiftFoundation/Thread.swift b/Sources/SwiftFoundation/Thread.swift index 9d26d28..01893ad 100644 --- a/Sources/SwiftFoundation/Thread.swift +++ b/Sources/SwiftFoundation/Thread.swift @@ -25,7 +25,7 @@ public final class Thread { let holder = Unmanaged.passRetained(Closure(closure: closure)) - let pointer = UnsafeMutablePointer(holder.toOpaque()) + let pointer = holder.toOpaque() #if os(Linux) @@ -82,7 +82,7 @@ public final class Thread { #if os(Linux) - private func ThreadPrivateMainLinux(arg: UnsafeMutablePointer?) -> UnsafeMutablePointer? { + private func ThreadPrivateMainLinux(arg: UnsafeMutableRawPointer?) -> UnsafeMutableRawPointer? { let unmanaged = Unmanaged.fromOpaque(arg!) @@ -97,7 +97,7 @@ public final class Thread { #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) - private func ThreadPrivateMainDarwin(arg: UnsafeMutablePointer) -> UnsafeMutablePointer? { + private func ThreadPrivateMainDarwin(arg: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { let unmanaged = Unmanaged.fromOpaque(arg) @@ -110,9 +110,9 @@ public final class Thread { #endif -private extension Thread { +fileprivate extension Thread { - private final class Closure { + final class Closure { let closure: () -> () diff --git a/Sources/SwiftFoundation/UUID.swift b/Sources/SwiftFoundation/UUID.swift index 4d16db7..0bd6ebd 100644 --- a/Sources/SwiftFoundation/UUID.swift +++ b/Sources/SwiftFoundation/UUID.swift @@ -38,7 +38,7 @@ var uuid = uuid_t(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) - withUnsafeMutablePointer(&uuid, { (valuePointer: UnsafeMutablePointer) in + withUnsafeMutablePointer(to: &uuid, { (valuePointer: UnsafeMutablePointer) in uuid_generate(unsafeBitCast(valuePointer, to: UnsafeMutablePointer.self)) }) @@ -74,17 +74,22 @@ var uuidCopy = bytes var uuidString = POSIXUUIDStringType(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + // withUnsafeMutablePointer(&uuidCopy, &uuidString) { (uuidPointer: UnsafeMutablePointer, uuidStringPointer: UnsafeMutablePointer) -> Void in - withUnsafeMutablePointers(&uuidCopy, &uuidString) { (uuidPointer: UnsafeMutablePointer, uuidStringPointer: UnsafeMutablePointer) -> Void in - - let stringBuffer = unsafeBitCast(uuidStringPointer, to: UnsafeMutablePointer.self) - - let uuidBuffer = unsafeBitCast(uuidPointer, to: UnsafeMutablePointer.self) - - uuid_unparse(unsafeBitCast(uuidBuffer, to: UnsafePointer.self), stringBuffer) + withUnsafeMutablePointer(to: &uuidCopy) { (uuidPointer: UnsafeMutablePointer) in + + withUnsafeMutablePointer(to: &uuidString) { (uuidStringPointer: UnsafeMutablePointer) in + + let stringBuffer = unsafeBitCast(uuidStringPointer, to: UnsafeMutablePointer.self) + + let uuidBuffer = unsafeBitCast(uuidPointer, to: UnsafeMutablePointer.self) + + uuid_unparse(unsafeBitCast(uuidBuffer, to: UnsafePointer.self), stringBuffer) + } } - return withUnsafeMutablePointer(&uuidString, { (valuePointer: UnsafeMutablePointer) -> String in + return withUnsafeMutablePointer(to: &uuidString, { (valuePointer: UnsafeMutablePointer) -> String in let buffer = unsafeBitCast(valuePointer, to: UnsafeMutablePointer.self) diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 639551b..0c9cbb7 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -9,11 +9,11 @@ /* Begin PBXBuildFile section */ 1AE78F671B96774100CDEF17 /* SwiftFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E30BA101B40F543009B1B49 /* SwiftFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1AE78FBF1B96774300CDEF17 /* SwiftFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E30BA101B40F543009B1B49 /* SwiftFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6E04074E1CB3E07500BE3A79 /* Thread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E04074D1CB3E07500BE3A79 /* Thread.swift */; }; 6E04074F1CB3E2E400BE3A79 /* Thread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E04074D1CB3E07500BE3A79 /* Thread.swift */; }; 6E0407501CB3E2E500BE3A79 /* Thread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E04074D1CB3E07500BE3A79 /* Thread.swift */; }; 6E041D3D1CB404CD004E080B /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B461C20F6EB00B2C995 /* String.swift */; }; 6E08F85D1BBE7DE900548B1E /* SwiftFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AE78F6C1B96774100CDEF17 /* SwiftFoundation.framework */; }; + 6E102F3B1D4D504C0046128B /* Thread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E04074D1CB3E07500BE3A79 /* Thread.swift */; }; 6E1ACD4B1C435822005775FD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E1ACD4A1C435822005775FD /* DataTests.swift */; }; 6E1ACD4C1C435822005775FD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E1ACD4A1C435822005775FD /* DataTests.swift */; }; 6E2C2B7B1C20F76600B2C995 /* Base64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B1C1C20F6EB00B2C995 /* Base64.swift */; }; @@ -793,7 +793,6 @@ 6E8474CD1D24FCFE009CA7DB /* ComparisonResult.swift in Sources */, 6EFF9A1B1CAD0C6B00917CB3 /* Range.swift in Sources */, 6E2C2BFD1C20F76700B2C995 /* Null.swift in Sources */, - 6E04074E1CB3E07500BE3A79 /* Thread.swift in Sources */, 6E2C2BE41C20F76700B2C995 /* BitMaskOption.swift in Sources */, 6E82FD721CBA06C10049CD1B /* Lock.swift in Sources */, 6E2C2C091C20F76700B2C995 /* RegularExpressionCompileOption.swift in Sources */, @@ -807,6 +806,7 @@ 6E2C2C0F1C20F76700B2C995 /* Transformer.swift in Sources */, 6E2C2C081C20F76700B2C995 /* RegularExpressionCompileError.swift in Sources */, 6E2C2C0B1C20F76700B2C995 /* SemanticVersion.swift in Sources */, + 6E102F3B1D4D504C0046128B /* Thread.swift in Sources */, 6E2C2BF11C20F76700B2C995 /* FilePermission.swift in Sources */, 6E2C2C071C20F76700B2C995 /* RegularExpression.swift in Sources */, 6E957C2B1C43AA55003F3C51 /* JSONSerialization.swift in Sources */, From 3b754756a2d65b42df542977aef2f63e509a924b Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sun, 31 Jul 2016 17:00:24 -0500 Subject: [PATCH 09/19] Moved test source files to "Tests" folder --- Package.swift | 7 ------- {Sources/UnitTests => Tests}/DataTests.swift | 0 {Sources/UnitTests => Tests}/DateComponentsTest.swift | 0 {Sources/UnitTests => Tests}/JSONTests.swift | 0 {Sources/UnitTests => Tests}/POSIXTimeTests.swift | 0 {Sources/UnitTests => Tests}/RangeTests.swift | 0 {Sources/UnitTests => Tests}/RegularExpressionTests.swift | 0 {Sources/UnitTests => Tests}/StringTests.swift | 0 {Sources/UnitTests => Tests}/UUIDTests.swift | 0 {Sources/UnitTests => Tests}/main.swift | 0 Xcode/SwiftFoundation.xcodeproj/project.pbxproj | 3 ++- 11 files changed, 2 insertions(+), 8 deletions(-) rename {Sources/UnitTests => Tests}/DataTests.swift (100%) rename {Sources/UnitTests => Tests}/DateComponentsTest.swift (100%) rename {Sources/UnitTests => Tests}/JSONTests.swift (100%) rename {Sources/UnitTests => Tests}/POSIXTimeTests.swift (100%) rename {Sources/UnitTests => Tests}/RangeTests.swift (100%) rename {Sources/UnitTests => Tests}/RegularExpressionTests.swift (100%) rename {Sources/UnitTests => Tests}/StringTests.swift (100%) rename {Sources/UnitTests => Tests}/UUIDTests.swift (100%) rename {Sources/UnitTests => Tests}/main.swift (100%) diff --git a/Package.swift b/Package.swift index 10f4c85..4194a4e 100644 --- a/Package.swift +++ b/Package.swift @@ -2,13 +2,6 @@ import PackageDescription let package = Package( name: "SwiftFoundation", - targets: [ - Target( - name: "UnitTests", - dependencies: [.Target(name: "SwiftFoundation")]), - Target( - name: "SwiftFoundation") - ], dependencies: [ .Package(url: "https://github.com/PureSwift/CStatfs.git", majorVersion: 1), .Package(url: "https://github.com/PureSwift/CJSONC.git", majorVersion: 1) diff --git a/Sources/UnitTests/DataTests.swift b/Tests/DataTests.swift similarity index 100% rename from Sources/UnitTests/DataTests.swift rename to Tests/DataTests.swift diff --git a/Sources/UnitTests/DateComponentsTest.swift b/Tests/DateComponentsTest.swift similarity index 100% rename from Sources/UnitTests/DateComponentsTest.swift rename to Tests/DateComponentsTest.swift diff --git a/Sources/UnitTests/JSONTests.swift b/Tests/JSONTests.swift similarity index 100% rename from Sources/UnitTests/JSONTests.swift rename to Tests/JSONTests.swift diff --git a/Sources/UnitTests/POSIXTimeTests.swift b/Tests/POSIXTimeTests.swift similarity index 100% rename from Sources/UnitTests/POSIXTimeTests.swift rename to Tests/POSIXTimeTests.swift diff --git a/Sources/UnitTests/RangeTests.swift b/Tests/RangeTests.swift similarity index 100% rename from Sources/UnitTests/RangeTests.swift rename to Tests/RangeTests.swift diff --git a/Sources/UnitTests/RegularExpressionTests.swift b/Tests/RegularExpressionTests.swift similarity index 100% rename from Sources/UnitTests/RegularExpressionTests.swift rename to Tests/RegularExpressionTests.swift diff --git a/Sources/UnitTests/StringTests.swift b/Tests/StringTests.swift similarity index 100% rename from Sources/UnitTests/StringTests.swift rename to Tests/StringTests.swift diff --git a/Sources/UnitTests/UUIDTests.swift b/Tests/UUIDTests.swift similarity index 100% rename from Sources/UnitTests/UUIDTests.swift rename to Tests/UUIDTests.swift diff --git a/Sources/UnitTests/main.swift b/Tests/main.swift similarity index 100% rename from Sources/UnitTests/main.swift rename to Tests/main.swift diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 0c9cbb7..83a0df9 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -368,7 +368,8 @@ 6E957C561C442E3E003F3C51 /* JSONTests.swift */, 6EFF9A1C1CAD108400917CB3 /* RangeTests.swift */, ); - path = UnitTests; + name = UnitTests; + path = ../Tests; sourceTree = ""; }; 6E2C2C251C20FAED00B2C995 /* Standard Library Extensions */ = { From e7e03829d5dc13ca12e38809bfc5411beb0ea9fb Mon Sep 17 00:00:00 2001 From: "lvs(zikuan.ly)" Date: Thu, 4 Aug 2016 18:27:07 +0800 Subject: [PATCH 10/19] make file manager set function truncated old file at first --- Sources/SwiftFoundation/FileManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftFoundation/FileManager.swift b/Sources/SwiftFoundation/FileManager.swift index acb7bb2..eedae62 100644 --- a/Sources/SwiftFoundation/FileManager.swift +++ b/Sources/SwiftFoundation/FileManager.swift @@ -212,7 +212,7 @@ public struct FileManager { public static func set(contents data: Data, at path: String) throws { // get file descriptor for path (open file) - let file = open(path, O_WRONLY) + let file = open(path, O_TRUNC | O_WRONLY) guard file != -1 else { throw POSIXError.fromErrno! } From 8048cd25a9d38d5cc5917a783434da41e027aec3 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 6 Aug 2016 00:58:55 -0500 Subject: [PATCH 11/19] Updated for Swift 3.0 Swift 3.0 Development 04-08-2016 --- Sources/SwiftFoundation/Data.swift | 2 +- Sources/SwiftFoundation/Hash.swift | 2 +- Sources/SwiftFoundation/JSONParse.swift | 2 +- Sources/SwiftFoundation/Thread.swift | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/SwiftFoundation/Data.swift b/Sources/SwiftFoundation/Data.swift index 6577aa7..6dc25e1 100644 --- a/Sources/SwiftFoundation/Data.swift +++ b/Sources/SwiftFoundation/Data.swift @@ -85,7 +85,7 @@ guard let pointer = buffer.baseAddress else { self.init(); return } - self.init(bytes: pointer, count: sizeof(SourceType.self) * buffer.count) + self.init(bytes: pointer, count: MemoryLayout.size * buffer.count) } // MARK: - Accessors diff --git a/Sources/SwiftFoundation/Hash.swift b/Sources/SwiftFoundation/Hash.swift index 2076caf..9a103a0 100644 --- a/Sources/SwiftFoundation/Hash.swift +++ b/Sources/SwiftFoundation/Hash.swift @@ -10,5 +10,5 @@ public func Hash(_ data: Data) -> Int { // more expensive than casting but that's not safe for large values. - return data.bytes.map({ Int($0) }).reduce(0, { $0.0 ^ $0.1 }) + return data.bytes.map({ Int($0) }).reduce(0) { $0.0 ^ $0.1 } } diff --git a/Sources/SwiftFoundation/JSONParse.swift b/Sources/SwiftFoundation/JSONParse.swift index 8babb38..08f11b2 100755 --- a/Sources/SwiftFoundation/JSONParse.swift +++ b/Sources/SwiftFoundation/JSONParse.swift @@ -27,7 +27,7 @@ public extension JSON.Value { // could not parse guard tokenerError != nil else { return nil } - self = self.dynamicType.init(jsonObject: jsonObject) + self.init(jsonObject: jsonObject) } } diff --git a/Sources/SwiftFoundation/Thread.swift b/Sources/SwiftFoundation/Thread.swift index 01893ad..1ba7049 100644 --- a/Sources/SwiftFoundation/Thread.swift +++ b/Sources/SwiftFoundation/Thread.swift @@ -21,7 +21,7 @@ public final class Thread { // MARK: - Intialization - public init(_ closure: () -> ()) throws { + public init(_ closure: @escaping () -> ()) throws { let holder = Unmanaged.passRetained(Closure(closure: closure)) @@ -116,7 +116,7 @@ fileprivate extension Thread { let closure: () -> () - init(closure: () -> ()) { + init(closure: @escaping () -> ()) { self.closure = closure } From 66126f58ae4254d7196763c5e0182a8cc32a2411 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 6 Aug 2016 10:18:50 -0500 Subject: [PATCH 12/19] Updated Travis CI --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9785fbd..a6bd3fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: generic osx_image: xcode8 os: - linux - - osx sudo: required dist: trusty before_install: @@ -13,9 +12,9 @@ install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install clang uuid-dev libjson-c-dev ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir $SWIFT_DIR ; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://swift.org/builds/swift-3.0-preview-1/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz -s | tar xz -C $SWIFT_DIR &> /dev/null ; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://swift.org/builds/development/ubuntu1404/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu14.04.tar.gz -s | tar xz -C $SWIFT_DIR &> /dev/null ; fi env: - - SWIFT_VERSION=swift-3.0-PREVIEW-1 + - SWIFT_VERSION=swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a script: - uname - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then xctool test -project Xcode/SwiftFoundation.xcodeproj -scheme "SwiftFoundation OS X" -sdk macosx ONLY_ACTIVE_ARCH=NO ; fi From 9d716b5cc9b43e548c14aa3a54a3dd75a73dbb53 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 6 Aug 2016 10:20:03 -0500 Subject: [PATCH 13/19] Fixed POSIXError for Linux --- Sources/SwiftFoundation/POSIXError.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftFoundation/POSIXError.swift b/Sources/SwiftFoundation/POSIXError.swift index f389c39..f7c2fbb 100644 --- a/Sources/SwiftFoundation/POSIXError.swift +++ b/Sources/SwiftFoundation/POSIXError.swift @@ -43,7 +43,7 @@ public extension POSIXError { /// Enumeration describing POSIX error codes. public struct POSIXError: Error { - let code: POSIXErrorCode + public let code: POSIXErrorCode public init(code: POSIXErrorCode) { From 642fc06cf6fb76226e42cbfb2f660c95a97a456f Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Fri, 16 Sep 2016 18:05:26 -0500 Subject: [PATCH 14/19] Updated for Xcode 8 --- Sources/SwiftFoundation/Data.swift | 2 +- Sources/SwiftFoundation/Lock.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftFoundation/Data.swift b/Sources/SwiftFoundation/Data.swift index 6dc25e1..43a7285 100644 --- a/Sources/SwiftFoundation/Data.swift +++ b/Sources/SwiftFoundation/Data.swift @@ -70,7 +70,7 @@ /// - parameter bytes: A pointer to the memory. It will be copied. /// - parameter count: The number of bytes to copy. @inline(__always) - public init(bytes pointer: UnsafePointer, count: Int) { + public init(bytes pointer: UnsafeRawPointer, count: Int) { _bytes = ContiguousArray(repeating: 0, count: count) diff --git a/Sources/SwiftFoundation/Lock.swift b/Sources/SwiftFoundation/Lock.swift index aad5d3c..b6b04ba 100644 --- a/Sources/SwiftFoundation/Lock.swift +++ b/Sources/SwiftFoundation/Lock.swift @@ -50,7 +50,7 @@ } extension Lock { - private func synchronized(_ closure: @noescape () -> T) -> T { + private func synchronized(_ closure: () -> T) -> T { self.lock() defer { self.unlock() } return closure() From b8722ea4ec63af69b4d6af5062df001e2c79cec3 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Fri, 16 Sep 2016 18:05:35 -0500 Subject: [PATCH 15/19] ignore .DS_Store --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 73636c7..8a0fe86 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ SwiftFoundation/build Xcode/SwiftFoundation.xcodeproj/xcuserdata Xcode/SwiftFoundation.xcodeproj/project.xcworkspace/xcuserdata + +.DS_Store From e60b8fd0a06ec3d7d03e30ebc5faa92f586215c7 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 22 Sep 2016 20:35:50 -0500 Subject: [PATCH 16/19] removed Transformer --- Sources/SwiftFoundation/Transformer.swift | 23 ------------------- .../SwiftFoundation.xcodeproj/project.pbxproj | 8 ------- 2 files changed, 31 deletions(-) delete mode 100644 Sources/SwiftFoundation/Transformer.swift diff --git a/Sources/SwiftFoundation/Transformer.swift b/Sources/SwiftFoundation/Transformer.swift deleted file mode 100644 index 827767e..0000000 --- a/Sources/SwiftFoundation/Transformer.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// Transformer.swift -// SwiftFoundation -// -// Created by Alsey Coleman Miller on 6/29/15. -// Copyright © 2015 PureSwift. All rights reserved. -// - -/// Used to convert values from one representation to another. Doesn't fail. -public protocol TransformerType { - - associatedtype OriginalValue - - associatedtype TransformedValue - - func transformedValue(value: OriginalValue) -> TransformedValue -} - -/// Transformer that allows reverse transformation. -public protocol ReverseTransformerType: TransformerType { - - func reverseTransformedValue(value: TransformedValue) -> OriginalValue -} \ No newline at end of file diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 83a0df9..80fa36a 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -44,7 +44,6 @@ 6E2C2BA21C20F76600B2C995 /* RegularExpressionMatchOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B431C20F6EB00B2C995 /* RegularExpressionMatchOption.swift */; }; 6E2C2BA31C20F76600B2C995 /* SemanticVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B441C20F6EB00B2C995 /* SemanticVersion.swift */; }; 6E2C2BA51C20F76600B2C995 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B461C20F6EB00B2C995 /* String.swift */; }; - 6E2C2BA71C20F76600B2C995 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B481C20F6EB00B2C995 /* Transformer.swift */; }; 6E2C2BAD1C20F76600B2C995 /* UUID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B4E1C20F6EB00B2C995 /* UUID.swift */; }; 6E2C2BAE1C20F76600B2C995 /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */; }; 6E2C2BAF1C20F76600B2C995 /* Base64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B1C1C20F6EB00B2C995 /* Base64.swift */; }; @@ -75,7 +74,6 @@ 6E2C2BD61C20F76600B2C995 /* RegularExpressionMatchOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B431C20F6EB00B2C995 /* RegularExpressionMatchOption.swift */; }; 6E2C2BD71C20F76600B2C995 /* SemanticVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B441C20F6EB00B2C995 /* SemanticVersion.swift */; }; 6E2C2BD91C20F76600B2C995 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B461C20F6EB00B2C995 /* String.swift */; }; - 6E2C2BDB1C20F76600B2C995 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B481C20F6EB00B2C995 /* Transformer.swift */; }; 6E2C2BE11C20F76600B2C995 /* UUID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B4E1C20F6EB00B2C995 /* UUID.swift */; }; 6E2C2BE21C20F76600B2C995 /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */; }; 6E2C2BE31C20F76700B2C995 /* Base64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B1C1C20F6EB00B2C995 /* Base64.swift */; }; @@ -105,7 +103,6 @@ 6E2C2C091C20F76700B2C995 /* RegularExpressionCompileOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B421C20F6EB00B2C995 /* RegularExpressionCompileOption.swift */; }; 6E2C2C0A1C20F76700B2C995 /* RegularExpressionMatchOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B431C20F6EB00B2C995 /* RegularExpressionMatchOption.swift */; }; 6E2C2C0B1C20F76700B2C995 /* SemanticVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B441C20F6EB00B2C995 /* SemanticVersion.swift */; }; - 6E2C2C0F1C20F76700B2C995 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B481C20F6EB00B2C995 /* Transformer.swift */; }; 6E2C2C161C20F76700B2C995 /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */; }; 6E2C2C171C20F76B00B2C995 /* DateComponentsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B511C20F6EB00B2C995 /* DateComponentsTest.swift */; }; 6E2C2C191C20F76B00B2C995 /* POSIXTimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B531C20F6EB00B2C995 /* POSIXTimeTests.swift */; }; @@ -227,7 +224,6 @@ 6E2C2B431C20F6EB00B2C995 /* RegularExpressionMatchOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegularExpressionMatchOption.swift; sourceTree = ""; }; 6E2C2B441C20F6EB00B2C995 /* SemanticVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticVersion.swift; sourceTree = ""; }; 6E2C2B461C20F6EB00B2C995 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; - 6E2C2B481C20F6EB00B2C995 /* Transformer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Transformer.swift; sourceTree = ""; }; 6E2C2B4E1C20F6EB00B2C995 /* UUID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UUID.swift; sourceTree = ""; }; 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = ""; }; 6E2C2B511C20F6EB00B2C995 /* DateComponentsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateComponentsTest.swift; sourceTree = ""; }; @@ -348,7 +344,6 @@ 6E2C2B431C20F6EB00B2C995 /* RegularExpressionMatchOption.swift */, 6E2C2B441C20F6EB00B2C995 /* SemanticVersion.swift */, 6E04074D1CB3E07500BE3A79 /* Thread.swift */, - 6E2C2B481C20F6EB00B2C995 /* Transformer.swift */, 6E2C2B4E1C20F6EB00B2C995 /* UUID.swift */, 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */, ); @@ -696,7 +691,6 @@ 6E2C2BE11C20F76600B2C995 /* UUID.swift in Sources */, 6E2C2BBB1C20F76600B2C995 /* FileDescriptor.swift in Sources */, 6E8474CE1D24FCFE009CA7DB /* ComparisonResult.swift in Sources */, - 6E2C2BDB1C20F76600B2C995 /* Transformer.swift in Sources */, 6E2C2BD41C20F76600B2C995 /* RegularExpressionCompileError.swift in Sources */, 6E2C2BD71C20F76600B2C995 /* SemanticVersion.swift in Sources */, 6E2C2BBD1C20F76600B2C995 /* FilePermission.swift in Sources */, @@ -741,7 +735,6 @@ 6E2C2BAD1C20F76600B2C995 /* UUID.swift in Sources */, 6E2C2B871C20F76600B2C995 /* FileDescriptor.swift in Sources */, 6E8474CF1D24FCFE009CA7DB /* ComparisonResult.swift in Sources */, - 6E2C2BA71C20F76600B2C995 /* Transformer.swift in Sources */, 6E2C2BA01C20F76600B2C995 /* RegularExpressionCompileError.swift in Sources */, 6E2C2BA31C20F76600B2C995 /* SemanticVersion.swift in Sources */, 6E2C2B891C20F76600B2C995 /* FilePermission.swift in Sources */, @@ -804,7 +797,6 @@ 6E2C2BF31C20F76700B2C995 /* Formatter.swift in Sources */, 6E2C2BFC1C20F76700B2C995 /* JSONExtensions.swift in Sources */, 6E2C2BEF1C20F76700B2C995 /* FileDescriptor.swift in Sources */, - 6E2C2C0F1C20F76700B2C995 /* Transformer.swift in Sources */, 6E2C2C081C20F76700B2C995 /* RegularExpressionCompileError.swift in Sources */, 6E2C2C0B1C20F76700B2C995 /* SemanticVersion.swift in Sources */, 6E102F3B1D4D504C0046128B /* Thread.swift in Sources */, From 96ba487709fbc444261599ffca4a2c5386884fcc Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 24 Sep 2016 16:23:47 -0500 Subject: [PATCH 17/19] Fixed Unit Tests file layout --- Tests/{main.swift => LinuxMain.swift} | 7 +- Tests/{ => UnitTests}/DataTests.swift | 0 .../{ => UnitTests}/DateComponentsTest.swift | 0 Tests/{ => UnitTests}/JSONTests.swift | 0 Tests/{ => UnitTests}/POSIXTimeTests.swift | 0 Tests/{ => UnitTests}/RangeTests.swift | 0 .../RegularExpressionTests.swift | 0 Tests/{ => UnitTests}/StringTests.swift | 0 Tests/{ => UnitTests}/UUIDTests.swift | 0 .../SwiftFoundation.xcodeproj/project.pbxproj | 104 +++++++++--------- 10 files changed, 55 insertions(+), 56 deletions(-) rename Tests/{main.swift => LinuxMain.swift} (92%) rename Tests/{ => UnitTests}/DataTests.swift (100%) rename Tests/{ => UnitTests}/DateComponentsTest.swift (100%) rename Tests/{ => UnitTests}/JSONTests.swift (100%) rename Tests/{ => UnitTests}/POSIXTimeTests.swift (100%) rename Tests/{ => UnitTests}/RangeTests.swift (100%) rename Tests/{ => UnitTests}/RegularExpressionTests.swift (100%) rename Tests/{ => UnitTests}/StringTests.swift (100%) rename Tests/{ => UnitTests}/UUIDTests.swift (100%) diff --git a/Tests/main.swift b/Tests/LinuxMain.swift similarity index 92% rename from Tests/main.swift rename to Tests/LinuxMain.swift index 195a913..32a7286 100644 --- a/Tests/main.swift +++ b/Tests/LinuxMain.swift @@ -8,13 +8,14 @@ import XCTest -#if os(OSX) || os(iOS) || os(watchOS) +#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) func XCTMain(_ testCases: [XCTestCaseEntry]) { fatalError("Not Implemented. Linux only") } func testCase(_ allTests: [(String, (T) -> () throws -> Void)]) -> XCTestCaseEntry { fatalError("Not Implemented. Linux only") } struct XCTestCaseEntry { } -#endif + +#else XCTMain([testCase(DateComponentsTest.allTests), testCase(POSIXTimeTests.allTests), @@ -25,3 +26,5 @@ XCTMain([testCase(DateComponentsTest.allTests), testCase(JSONTests.allTests), testCase(RangeTests.allTests) ]) + +#endif diff --git a/Tests/DataTests.swift b/Tests/UnitTests/DataTests.swift similarity index 100% rename from Tests/DataTests.swift rename to Tests/UnitTests/DataTests.swift diff --git a/Tests/DateComponentsTest.swift b/Tests/UnitTests/DateComponentsTest.swift similarity index 100% rename from Tests/DateComponentsTest.swift rename to Tests/UnitTests/DateComponentsTest.swift diff --git a/Tests/JSONTests.swift b/Tests/UnitTests/JSONTests.swift similarity index 100% rename from Tests/JSONTests.swift rename to Tests/UnitTests/JSONTests.swift diff --git a/Tests/POSIXTimeTests.swift b/Tests/UnitTests/POSIXTimeTests.swift similarity index 100% rename from Tests/POSIXTimeTests.swift rename to Tests/UnitTests/POSIXTimeTests.swift diff --git a/Tests/RangeTests.swift b/Tests/UnitTests/RangeTests.swift similarity index 100% rename from Tests/RangeTests.swift rename to Tests/UnitTests/RangeTests.swift diff --git a/Tests/RegularExpressionTests.swift b/Tests/UnitTests/RegularExpressionTests.swift similarity index 100% rename from Tests/RegularExpressionTests.swift rename to Tests/UnitTests/RegularExpressionTests.swift diff --git a/Tests/StringTests.swift b/Tests/UnitTests/StringTests.swift similarity index 100% rename from Tests/StringTests.swift rename to Tests/UnitTests/StringTests.swift diff --git a/Tests/UUIDTests.swift b/Tests/UnitTests/UUIDTests.swift similarity index 100% rename from Tests/UUIDTests.swift rename to Tests/UnitTests/UUIDTests.swift diff --git a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj index 80fa36a..b0da794 100644 --- a/Xcode/SwiftFoundation.xcodeproj/project.pbxproj +++ b/Xcode/SwiftFoundation.xcodeproj/project.pbxproj @@ -14,8 +14,6 @@ 6E041D3D1CB404CD004E080B /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B461C20F6EB00B2C995 /* String.swift */; }; 6E08F85D1BBE7DE900548B1E /* SwiftFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AE78F6C1B96774100CDEF17 /* SwiftFoundation.framework */; }; 6E102F3B1D4D504C0046128B /* Thread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E04074D1CB3E07500BE3A79 /* Thread.swift */; }; - 6E1ACD4B1C435822005775FD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E1ACD4A1C435822005775FD /* DataTests.swift */; }; - 6E1ACD4C1C435822005775FD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E1ACD4A1C435822005775FD /* DataTests.swift */; }; 6E2C2B7B1C20F76600B2C995 /* Base64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B1C1C20F6EB00B2C995 /* Base64.swift */; }; 6E2C2B7C1C20F76600B2C995 /* BitMaskOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B1D1C20F6EB00B2C995 /* BitMaskOption.swift */; }; 6E2C2B7E1C20F76600B2C995 /* ByteValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B1F1C20F6EB00B2C995 /* ByteValue.swift */; }; @@ -104,20 +102,24 @@ 6E2C2C0A1C20F76700B2C995 /* RegularExpressionMatchOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B431C20F6EB00B2C995 /* RegularExpressionMatchOption.swift */; }; 6E2C2C0B1C20F76700B2C995 /* SemanticVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B441C20F6EB00B2C995 /* SemanticVersion.swift */; }; 6E2C2C161C20F76700B2C995 /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */; }; - 6E2C2C171C20F76B00B2C995 /* DateComponentsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B511C20F6EB00B2C995 /* DateComponentsTest.swift */; }; - 6E2C2C191C20F76B00B2C995 /* POSIXTimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B531C20F6EB00B2C995 /* POSIXTimeTests.swift */; }; - 6E2C2C1A1C20F76B00B2C995 /* RegularExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B541C20F6EB00B2C995 /* RegularExpressionTests.swift */; }; - 6E2C2C1C1C20F76B00B2C995 /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B561C20F6EB00B2C995 /* StringTests.swift */; }; - 6E2C2C1D1C20F76B00B2C995 /* UUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B571C20F6EB00B2C995 /* UUIDTests.swift */; }; - 6E2C2C1E1C20F76D00B2C995 /* DateComponentsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B511C20F6EB00B2C995 /* DateComponentsTest.swift */; }; - 6E2C2C201C20F76D00B2C995 /* POSIXTimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B531C20F6EB00B2C995 /* POSIXTimeTests.swift */; }; - 6E2C2C211C20F76D00B2C995 /* RegularExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B541C20F6EB00B2C995 /* RegularExpressionTests.swift */; }; - 6E2C2C231C20F76D00B2C995 /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B561C20F6EB00B2C995 /* StringTests.swift */; }; - 6E2C2C241C20F76D00B2C995 /* UUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2B571C20F6EB00B2C995 /* UUIDTests.swift */; }; - 6E2C2C2F1C2128C600B2C995 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2C2E1C2128C600B2C995 /* main.swift */; }; - 6E2C2C301C2128C600B2C995 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E2C2C2E1C2128C600B2C995 /* main.swift */; }; 6E30BA111B40F543009B1B49 /* SwiftFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E30BA101B40F543009B1B49 /* SwiftFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E30BA181B40F543009B1B49 /* SwiftFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E30BA0D1B40F543009B1B49 /* SwiftFoundation.framework */; }; + 6E59F2301D97259A002EEF94 /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F2281D97259A002EEF94 /* DataTests.swift */; }; + 6E59F2311D97259A002EEF94 /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F2281D97259A002EEF94 /* DataTests.swift */; }; + 6E59F2321D97259A002EEF94 /* DateComponentsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F2291D97259A002EEF94 /* DateComponentsTest.swift */; }; + 6E59F2331D97259A002EEF94 /* DateComponentsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F2291D97259A002EEF94 /* DateComponentsTest.swift */; }; + 6E59F2341D97259A002EEF94 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22A1D97259A002EEF94 /* JSONTests.swift */; }; + 6E59F2351D97259A002EEF94 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22A1D97259A002EEF94 /* JSONTests.swift */; }; + 6E59F2361D97259A002EEF94 /* POSIXTimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22B1D97259A002EEF94 /* POSIXTimeTests.swift */; }; + 6E59F2371D97259A002EEF94 /* POSIXTimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22B1D97259A002EEF94 /* POSIXTimeTests.swift */; }; + 6E59F2381D97259A002EEF94 /* RangeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22C1D97259A002EEF94 /* RangeTests.swift */; }; + 6E59F2391D97259A002EEF94 /* RangeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22C1D97259A002EEF94 /* RangeTests.swift */; }; + 6E59F23A1D97259A002EEF94 /* RegularExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22D1D97259A002EEF94 /* RegularExpressionTests.swift */; }; + 6E59F23B1D97259A002EEF94 /* RegularExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22D1D97259A002EEF94 /* RegularExpressionTests.swift */; }; + 6E59F23C1D97259A002EEF94 /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22E1D97259A002EEF94 /* StringTests.swift */; }; + 6E59F23D1D97259A002EEF94 /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22E1D97259A002EEF94 /* StringTests.swift */; }; + 6E59F23E1D97259A002EEF94 /* UUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22F1D97259A002EEF94 /* UUIDTests.swift */; }; + 6E59F23F1D97259A002EEF94 /* UUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E59F22F1D97259A002EEF94 /* UUIDTests.swift */; }; 6E82FD721CBA06C10049CD1B /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E82FD711CBA06C10049CD1B /* Lock.swift */; }; 6E82FD731CBA06C10049CD1B /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E82FD711CBA06C10049CD1B /* Lock.swift */; }; 6E82FD741CBA06C10049CD1B /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E82FD711CBA06C10049CD1B /* Lock.swift */; }; @@ -134,8 +136,6 @@ 6E957C2D1C43AA55003F3C51 /* JSONSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C291C43AA55003F3C51 /* JSONSerialization.swift */; }; 6E957C4E1C43B3A1003F3C51 /* JSON.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C471C43B397003F3C51 /* JSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 6E957C4F1C43B3A5003F3C51 /* JSON.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 6E957C451C43B397003F3C51 /* JSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 6E957C571C442E3E003F3C51 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C561C442E3E003F3C51 /* JSONTests.swift */; }; - 6E957C581C442E3E003F3C51 /* JSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E957C561C442E3E003F3C51 /* JSONTests.swift */; }; 6EE84DD91CAF659800A40C4D /* Endianness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE84DD81CAF659800A40C4D /* Endianness.swift */; }; 6EE84DDA1CAF659800A40C4D /* Endianness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE84DD81CAF659800A40C4D /* Endianness.swift */; }; 6EE84DDB1CAF659800A40C4D /* Endianness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE84DD81CAF659800A40C4D /* Endianness.swift */; }; @@ -143,8 +143,6 @@ 6EE84DDE1CAF667E00A40C4D /* Hexadecimal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE84DDC1CAF667E00A40C4D /* Hexadecimal.swift */; }; 6EE84DDF1CAF667E00A40C4D /* Hexadecimal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE84DDC1CAF667E00A40C4D /* Hexadecimal.swift */; }; 6EFF9A1B1CAD0C6B00917CB3 /* Range.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EFF9A1A1CAD0C6B00917CB3 /* Range.swift */; }; - 6EFF9A1D1CAD108400917CB3 /* RangeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EFF9A1C1CAD108400917CB3 /* RangeTests.swift */; }; - 6EFF9A1E1CAD108400917CB3 /* RangeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EFF9A1C1CAD108400917CB3 /* RangeTests.swift */; }; 6EFF9A1F1CAD11F600917CB3 /* Range.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EFF9A1A1CAD0C6B00917CB3 /* Range.swift */; }; /* End PBXBuildFile section */ @@ -195,7 +193,6 @@ 1AE78FC41B96774300CDEF17 /* SwiftFoundation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftFoundation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6E04074D1CB3E07500BE3A79 /* Thread.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Thread.swift; sourceTree = ""; }; 6E08F8571BBE7B8800548B1E /* SwiftFoundationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftFoundationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 6E1ACD4A1C435822005775FD /* DataTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataTests.swift; sourceTree = ""; }; 6E2C2B1C1C20F6EB00B2C995 /* Base64.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base64.swift; sourceTree = ""; }; 6E2C2B1D1C20F6EB00B2C995 /* BitMaskOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BitMaskOption.swift; sourceTree = ""; }; 6E2C2B1F1C20F6EB00B2C995 /* ByteValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ByteValue.swift; sourceTree = ""; }; @@ -226,18 +223,21 @@ 6E2C2B461C20F6EB00B2C995 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; 6E2C2B4E1C20F6EB00B2C995 /* UUID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UUID.swift; sourceTree = ""; }; 6E2C2B4F1C20F6EB00B2C995 /* Version.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = ""; }; - 6E2C2B511C20F6EB00B2C995 /* DateComponentsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateComponentsTest.swift; sourceTree = ""; }; - 6E2C2B531C20F6EB00B2C995 /* POSIXTimeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = POSIXTimeTests.swift; sourceTree = ""; }; - 6E2C2B541C20F6EB00B2C995 /* RegularExpressionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegularExpressionTests.swift; sourceTree = ""; }; - 6E2C2B561C20F6EB00B2C995 /* StringTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringTests.swift; sourceTree = ""; }; - 6E2C2B571C20F6EB00B2C995 /* UUIDTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UUIDTests.swift; sourceTree = ""; }; 6E2C2C2A1C21105000B2C995 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Package.swift; sourceTree = ""; }; - 6E2C2C2E1C2128C600B2C995 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 6E30BA0D1B40F543009B1B49 /* SwiftFoundation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftFoundation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6E30BA101B40F543009B1B49 /* SwiftFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftFoundation.h; sourceTree = ""; }; 6E30BA121B40F543009B1B49 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 6E30BA171B40F543009B1B49 /* SwiftFoundationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftFoundationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 6E30BA1E1B40F543009B1B49 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6E59F2251D972579002EEF94 /* LinuxMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinuxMain.swift; sourceTree = ""; }; + 6E59F2281D97259A002EEF94 /* DataTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DataTests.swift; path = UnitTests/DataTests.swift; sourceTree = ""; }; + 6E59F2291D97259A002EEF94 /* DateComponentsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DateComponentsTest.swift; path = UnitTests/DateComponentsTest.swift; sourceTree = ""; }; + 6E59F22A1D97259A002EEF94 /* JSONTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = JSONTests.swift; path = UnitTests/JSONTests.swift; sourceTree = ""; }; + 6E59F22B1D97259A002EEF94 /* POSIXTimeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = POSIXTimeTests.swift; path = UnitTests/POSIXTimeTests.swift; sourceTree = ""; }; + 6E59F22C1D97259A002EEF94 /* RangeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RangeTests.swift; path = UnitTests/RangeTests.swift; sourceTree = ""; }; + 6E59F22D1D97259A002EEF94 /* RegularExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RegularExpressionTests.swift; path = UnitTests/RegularExpressionTests.swift; sourceTree = ""; }; + 6E59F22E1D97259A002EEF94 /* StringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StringTests.swift; path = UnitTests/StringTests.swift; sourceTree = ""; }; + 6E59F22F1D97259A002EEF94 /* UUIDTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UUIDTests.swift; path = UnitTests/UUIDTests.swift; sourceTree = ""; }; 6E82FD711CBA06C10049CD1B /* Lock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Lock.swift; sourceTree = ""; }; 6E8474C91D24EC3A009CA7DB /* Hash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Hash.swift; sourceTree = ""; }; 6E8474CC1D24FCFE009CA7DB /* ComparisonResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComparisonResult.swift; sourceTree = ""; }; @@ -245,11 +245,9 @@ 6E957C291C43AA55003F3C51 /* JSONSerialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONSerialization.swift; sourceTree = ""; }; 6E957C451C43B397003F3C51 /* JSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JSON.framework; sourceTree = ""; }; 6E957C471C43B397003F3C51 /* JSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JSON.framework; sourceTree = ""; }; - 6E957C561C442E3E003F3C51 /* JSONTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONTests.swift; sourceTree = ""; }; 6EE84DD81CAF659800A40C4D /* Endianness.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Endianness.swift; sourceTree = ""; }; 6EE84DDC1CAF667E00A40C4D /* Hexadecimal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Hexadecimal.swift; sourceTree = ""; }; 6EFF9A1A1CAD0C6B00917CB3 /* Range.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Range.swift; sourceTree = ""; }; - 6EFF9A1C1CAD108400917CB3 /* RangeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RangeTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -353,15 +351,15 @@ 6E2C2B501C20F6EB00B2C995 /* UnitTests */ = { isa = PBXGroup; children = ( - 6E2C2C2E1C2128C600B2C995 /* main.swift */, - 6E2C2B511C20F6EB00B2C995 /* DateComponentsTest.swift */, - 6E2C2B531C20F6EB00B2C995 /* POSIXTimeTests.swift */, - 6E2C2B541C20F6EB00B2C995 /* RegularExpressionTests.swift */, - 6E2C2B561C20F6EB00B2C995 /* StringTests.swift */, - 6E2C2B571C20F6EB00B2C995 /* UUIDTests.swift */, - 6E1ACD4A1C435822005775FD /* DataTests.swift */, - 6E957C561C442E3E003F3C51 /* JSONTests.swift */, - 6EFF9A1C1CAD108400917CB3 /* RangeTests.swift */, + 6E59F2251D972579002EEF94 /* LinuxMain.swift */, + 6E59F2281D97259A002EEF94 /* DataTests.swift */, + 6E59F2291D97259A002EEF94 /* DateComponentsTest.swift */, + 6E59F22A1D97259A002EEF94 /* JSONTests.swift */, + 6E59F22B1D97259A002EEF94 /* POSIXTimeTests.swift */, + 6E59F22C1D97259A002EEF94 /* RangeTests.swift */, + 6E59F22D1D97259A002EEF94 /* RegularExpressionTests.swift */, + 6E59F22E1D97259A002EEF94 /* StringTests.swift */, + 6E59F22F1D97259A002EEF94 /* UUIDTests.swift */, ); name = UnitTests; path = ../Tests; @@ -752,16 +750,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 6E2C2C301C2128C600B2C995 /* main.swift in Sources */, + 6E59F2371D97259A002EEF94 /* POSIXTimeTests.swift in Sources */, 6EFF9A1F1CAD11F600917CB3 /* Range.swift in Sources */, - 6E2C2C1D1C20F76B00B2C995 /* UUIDTests.swift in Sources */, - 6E957C581C442E3E003F3C51 /* JSONTests.swift in Sources */, - 6E2C2C171C20F76B00B2C995 /* DateComponentsTest.swift in Sources */, - 6E2C2C191C20F76B00B2C995 /* POSIXTimeTests.swift in Sources */, - 6E2C2C1A1C20F76B00B2C995 /* RegularExpressionTests.swift in Sources */, - 6E1ACD4C1C435822005775FD /* DataTests.swift in Sources */, - 6EFF9A1E1CAD108400917CB3 /* RangeTests.swift in Sources */, - 6E2C2C1C1C20F76B00B2C995 /* StringTests.swift in Sources */, + 6E59F23F1D97259A002EEF94 /* UUIDTests.swift in Sources */, + 6E59F2391D97259A002EEF94 /* RangeTests.swift in Sources */, + 6E59F2311D97259A002EEF94 /* DataTests.swift in Sources */, + 6E59F23B1D97259A002EEF94 /* RegularExpressionTests.swift in Sources */, + 6E59F2331D97259A002EEF94 /* DateComponentsTest.swift in Sources */, + 6E59F23D1D97259A002EEF94 /* StringTests.swift in Sources */, + 6E59F2351D97259A002EEF94 /* JSONTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -815,15 +812,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 6E2C2C2F1C2128C600B2C995 /* main.swift in Sources */, - 6E2C2C241C20F76D00B2C995 /* UUIDTests.swift in Sources */, - 6E957C571C442E3E003F3C51 /* JSONTests.swift in Sources */, - 6E2C2C1E1C20F76D00B2C995 /* DateComponentsTest.swift in Sources */, - 6E2C2C201C20F76D00B2C995 /* POSIXTimeTests.swift in Sources */, - 6E2C2C211C20F76D00B2C995 /* RegularExpressionTests.swift in Sources */, - 6E1ACD4B1C435822005775FD /* DataTests.swift in Sources */, - 6EFF9A1D1CAD108400917CB3 /* RangeTests.swift in Sources */, - 6E2C2C231C20F76D00B2C995 /* StringTests.swift in Sources */, + 6E59F2361D97259A002EEF94 /* POSIXTimeTests.swift in Sources */, + 6E59F23E1D97259A002EEF94 /* UUIDTests.swift in Sources */, + 6E59F2301D97259A002EEF94 /* DataTests.swift in Sources */, + 6E59F23A1D97259A002EEF94 /* RegularExpressionTests.swift in Sources */, + 6E59F2381D97259A002EEF94 /* RangeTests.swift in Sources */, + 6E59F2321D97259A002EEF94 /* DateComponentsTest.swift in Sources */, + 6E59F23C1D97259A002EEF94 /* StringTests.swift in Sources */, + 6E59F2341D97259A002EEF94 /* JSONTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From cf25a8e06cbdc585435dfbeb8cab84a7114049ec Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 24 Sep 2016 16:41:52 -0500 Subject: [PATCH 18/19] Fixing unit tests for Linux WIP --- Tests/LinuxMain.swift | 1 + Tests/UnitTests/DataTests.swift | 2 +- Tests/UnitTests/DateComponentsTest.swift | 6 +++++- Tests/UnitTests/JSONTests.swift | 6 +++++- Tests/UnitTests/POSIXTimeTests.swift | 2 +- Tests/UnitTests/RangeTests.swift | 8 ++++++-- Tests/UnitTests/RegularExpressionTests.swift | 18 +++++------------- Tests/UnitTests/StringTests.swift | 5 +++++ Tests/UnitTests/UUIDTests.swift | 7 +++++-- 9 files changed, 34 insertions(+), 21 deletions(-) mode change 100644 => 100755 Tests/LinuxMain.swift mode change 100644 => 100755 Tests/UnitTests/DataTests.swift mode change 100644 => 100755 Tests/UnitTests/DateComponentsTest.swift mode change 100644 => 100755 Tests/UnitTests/POSIXTimeTests.swift mode change 100644 => 100755 Tests/UnitTests/RangeTests.swift mode change 100644 => 100755 Tests/UnitTests/RegularExpressionTests.swift mode change 100644 => 100755 Tests/UnitTests/StringTests.swift mode change 100644 => 100755 Tests/UnitTests/UUIDTests.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift old mode 100644 new mode 100755 index 32a7286..4cd8dd2 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -7,6 +7,7 @@ // import XCTest +@testable import UnitTests #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) func XCTMain(_ testCases: [XCTestCaseEntry]) { fatalError("Not Implemented. Linux only") } diff --git a/Tests/UnitTests/DataTests.swift b/Tests/UnitTests/DataTests.swift old mode 100644 new mode 100755 index 6094aad..db1a9a9 --- a/Tests/UnitTests/DataTests.swift +++ b/Tests/UnitTests/DataTests.swift @@ -11,7 +11,7 @@ #endif import XCTest -import SwiftFoundation +@testable import SwiftFoundation final class DataTests: XCTestCase { diff --git a/Tests/UnitTests/DateComponentsTest.swift b/Tests/UnitTests/DateComponentsTest.swift old mode 100644 new mode 100755 index cec3c78..6f07350 --- a/Tests/UnitTests/DateComponentsTest.swift +++ b/Tests/UnitTests/DateComponentsTest.swift @@ -6,8 +6,12 @@ // Copyright © 2015 PureSwift. All rights reserved. // +#if os(Linux) + import Glibc +#endif + import XCTest -import SwiftFoundation +@testable import SwiftFoundation final class DateComponentsTest: XCTestCase { diff --git a/Tests/UnitTests/JSONTests.swift b/Tests/UnitTests/JSONTests.swift index 6907f08..90029f1 100755 --- a/Tests/UnitTests/JSONTests.swift +++ b/Tests/UnitTests/JSONTests.swift @@ -6,8 +6,12 @@ // Copyright © 2015 PureSwift. All rights reserved. // +#if os(Linux) + import Glibc +#endif + import XCTest -import SwiftFoundation +@testable import SwiftFoundation final class JSONTests: XCTestCase { diff --git a/Tests/UnitTests/POSIXTimeTests.swift b/Tests/UnitTests/POSIXTimeTests.swift old mode 100644 new mode 100755 index 1856ce2..382ca6f --- a/Tests/UnitTests/POSIXTimeTests.swift +++ b/Tests/UnitTests/POSIXTimeTests.swift @@ -13,7 +13,7 @@ #endif import XCTest -import SwiftFoundation +@testable import SwiftFoundation final class POSIXTimeTests: XCTestCase { diff --git a/Tests/UnitTests/RangeTests.swift b/Tests/UnitTests/RangeTests.swift old mode 100644 new mode 100755 index 41ce877..03da56d --- a/Tests/UnitTests/RangeTests.swift +++ b/Tests/UnitTests/RangeTests.swift @@ -6,8 +6,12 @@ // Copyright © 2016 PureSwift. All rights reserved. // +#if os(Linux) + import Glibc +#endif + import XCTest -import SwiftFoundation +@testable import SwiftFoundation final class RangeTests: XCTestCase { @@ -57,4 +61,4 @@ private extension Range where Bound: Integer { return true } -} \ No newline at end of file +} diff --git a/Tests/UnitTests/RegularExpressionTests.swift b/Tests/UnitTests/RegularExpressionTests.swift old mode 100644 new mode 100755 index 46c810e..c53b9f3 --- a/Tests/UnitTests/RegularExpressionTests.swift +++ b/Tests/UnitTests/RegularExpressionTests.swift @@ -6,9 +6,13 @@ // Copyright © 2015 PureSwift. All rights reserved. // +#if os(Linux) + import Glibc +#endif + import XCTest -import SwiftFoundation import Foundation +@testable import SwiftFoundation final class RegularExpressionTests: XCTestCase { @@ -124,15 +128,3 @@ final class RegularExpressionTests: XCTestCase { } } } - -#if os(Linux) - -extension NSRange { - - init(_ range: Range) { - - self = NSRange(CountableRange(range)) - } -} - -#endif diff --git a/Tests/UnitTests/StringTests.swift b/Tests/UnitTests/StringTests.swift old mode 100644 new mode 100755 index bcef604..f5a2d15 --- a/Tests/UnitTests/StringTests.swift +++ b/Tests/UnitTests/StringTests.swift @@ -6,7 +6,12 @@ // Copyright © 2015 PureSwift. All rights reserved. // +#if os(Linux) + import Glibc +#endif + import XCTest +@testable import SwiftFoundation final class StringTests: XCTestCase { diff --git a/Tests/UnitTests/UUIDTests.swift b/Tests/UnitTests/UUIDTests.swift old mode 100644 new mode 100755 index d11e778..5f0961c --- a/Tests/UnitTests/UUIDTests.swift +++ b/Tests/UnitTests/UUIDTests.swift @@ -6,9 +6,12 @@ // Copyright © 2015 PureSwift. All rights reserved. // +#if os(Linux) + import Glibc +#endif + import XCTest -import SwiftFoundation -import SwiftFoundation +@testable import SwiftFoundation final class UUIDTests: XCTestCase { From 2a5af94132f7af271f5c5978304ed6f95b8c68c7 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 24 Sep 2016 16:42:57 -0500 Subject: [PATCH 19/19] version bump --- Xcode/SwiftFoundation/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/SwiftFoundation/Info.plist b/Xcode/SwiftFoundation/Info.plist index 83f51e7..60ac016 100644 --- a/Xcode/SwiftFoundation/Info.plist +++ b/Xcode/SwiftFoundation/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.2.2 CFBundleSignature ???? CFBundleVersion