Browse Source

Swift 4.2 is the current GM, so our min is 3.2.

- Update docs.
- Remove all `#if swift(>=3.2)` checks dropping the `else` clause.
Thomas Van Lenten 7 years ago
parent
commit
3088a284d3

+ 1 - 1
Documentation/CONFORMANCE_TESTS.md

@@ -16,7 +16,7 @@ these tests regularly.
 
 ## Preparation
 
-The conformance test suite requires Swift 3.1, standard command-line
+The conformance test suite requires Swift 3.2, standard command-line
 tools such as make and awk, and a full source checkout of
 [Google's protobuf project](https://github.com/protocolbuffers/protobuf).
 

+ 2 - 2
Documentation/INTERNALS.md

@@ -19,8 +19,8 @@ behavior are always appreciated.
 
 The goal is to always support "one full major version”, which basically
 means if the current official release of Swift is `X.Y`, the library will
-support back to `X-1.Y`.  That is, when Swift 4.1 gets released, the minimum
-for support gets moved up to 3.1.
+support back to `X-1.Y`.  That is, when Swift 4.2 was released, the minimum
+for support got moved up to 3.2.
 
 When the minimum Swift version gets updated, update:
 - The `README.md` in the root of the project

+ 1 - 1
Documentation/PLUGIN.md

@@ -19,7 +19,7 @@ Swift runtime library to your project.
 
 To use Swift with Protocol buffers, you'll need:
 
-* A recent Swift 3.1 compiler that includes the Swift Package Manager.
+* A recent Swift 3.2 compiler that includes the Swift Package Manager.
   We recommend using the latest release build from
   [Swift.org](https://swift.org) or the command-line tools included
   with the latest version of Xcode.

+ 1 - 1
README.md

@@ -90,7 +90,7 @@ your project as explained below.
 
 To use Swift with Protocol buffers, you'll need:
 
-* A Swift 3.1 or later compiler (Xcode 8.3.3 or later).  Support is included
+* A Swift 3.2 or later compiler (Xcode 9.0 or later).  Support is included
 for the Swift Package Manager; or using the included Xcode project. The Swift
 protobuf project is being developed and tested against the latest release
 version of Swift available from [Swift.org](https://swift.org)

+ 0 - 4
Sources/SwiftProtobuf/Google_Protobuf_Any+Registry.swift

@@ -21,11 +21,7 @@ import Dispatch
 
 internal func buildTypeURL(forMessage message: Message, typePrefix: String) -> String {
   var url = typePrefix
-#if swift(>=3.2)
   let needsSlash = typePrefix.isEmpty || typePrefix.last != "/"
-#else
-  let needsSlash = typePrefix.isEmpty || typePrefix.characters.last != "/"
-#endif
   if needsSlash {
     url += "/"
   }

+ 0 - 4
Sources/SwiftProtobuf/Google_Protobuf_Duration+Extensions.swift

@@ -23,11 +23,7 @@ private func parseDuration(text: String) throws -> (Int64, Int32) {
   var digits = [Character]()
   var digitCount = 0
   var total = 0
-#if swift(>=3.2)
   var chars = text.makeIterator()
-#else
-  var chars = text.characters.makeIterator()
-#endif
   var seconds: Int64?
   var nanos: Int32 = 0
   while let c = chars.next() {

+ 2 - 16
Sources/SwiftProtobuf/Google_Protobuf_FieldMask+Extensions.swift

@@ -18,11 +18,7 @@
 
 private func ProtoToJSON(name: String) -> String? {
   var jsonPath = String()
-#if swift(>=3.2)
   var chars = name.makeIterator()
-#else
-  var chars = name.characters.makeIterator()
-#endif
   while let c = chars.next() {
     switch c {
     case "_":
@@ -47,12 +43,7 @@ private func ProtoToJSON(name: String) -> String? {
 
 private func JSONToProto(name: String) -> String? {
   var path = String()
-#if swift(>=3.2)
-  let chars = name
-#else
-  let chars = name.characters
-#endif
-  for c in chars {
+  for c in name {
     switch c {
     case "_":
       return nil
@@ -70,12 +61,7 @@ private func parseJSONFieldNames(names: String) -> [String]? {
   var fieldNameCount = 0
   var fieldName = String()
   var split = [String]()
-#if swift(>=3.2)
-  let namesChars = names
-#else
-  let namesChars = names.characters
-#endif
-  for c: Character in namesChars {
+  for c in names {
     switch c {
     case ",":
       if fieldNameCount == 0 {

+ 1 - 6
Sources/SwiftProtobuf/NameMap.swift

@@ -23,12 +23,7 @@
 private func toJsonFieldName(_ s: String) -> String {
     var result = String()
     var capitalizeNext = false
-#if swift(>=3.2)
-    let chars = s
-#else
-    let chars = s.characters
-#endif
-    for c in chars {
+    for c in s {
         if c == "_" {
             capitalizeNext = true
         } else if capitalizeNext {

+ 3 - 13
Sources/SwiftProtobufPluginLibrary/NamingUtils.swift

@@ -190,13 +190,8 @@ fileprivate func sanitizeTypeName(_ s: String, disambiguator: String) -> String
     // conflict.  This can be resolved recursively by stripping
     // the disambiguator, sanitizing the root, then re-adding the
     // disambiguator:
-    #if swift(>=3.2)
-      let e = s.index(s.endIndex, offsetBy: -disambiguator.count)
-      let truncated = String(s[..<e])
-    #else
-      let e = s.index(s.endIndex, offsetBy: -disambiguator.characters.count)
-      let truncated = s.substring(to: e)
-    #endif
+    let e = s.index(s.endIndex, offsetBy: -disambiguator.count)
+    let truncated = String(s[..<e])
     return sanitizeTypeName(truncated, disambiguator: disambiguator) + disambiguator
   } else {
     return s
@@ -302,12 +297,7 @@ public enum NamingUtils {
     //  "pacakge.some_name" -> "Package_SomeName"
     var makeUpper = true
     var prefix = ""
-#if swift(>=3.2)
-    let protoPackageChars = protoPackage
-#else
-    let protoPackageChars = protoPackage.characters
-#endif
-    for c in protoPackageChars {
+    for c in protoPackage {
       if c == "_" {
         makeUpper = true
       } else if c == "." {

+ 1 - 10
Sources/protoc-gen-swift/StringUtils.swift

@@ -14,12 +14,7 @@ func splitPath(pathname: String) -> (dir:String, base:String, suffix:String) {
   var dir = ""
   var base = ""
   var suffix = ""
-#if swift(>=3.2)
-  let pathnameChars = pathname
-#else
-  let pathnameChars = pathname.characters
-#endif
-  for c in pathnameChars {
+  for c in pathname {
     if c == "/" {
       dir += base + suffix + String(c)
       base = ""
@@ -31,11 +26,7 @@ func splitPath(pathname: String) -> (dir:String, base:String, suffix:String) {
       suffix += String(c)
     }
   }
-#if swift(>=3.2)
   let validSuffix = suffix.isEmpty || suffix.first == "."
-#else
-  let validSuffix = suffix.isEmpty || suffix.characters.first == "."
-#endif
   if !validSuffix {
     base += suffix
     suffix = ""

+ 1 - 6
Tests/SwiftProtobufTests/Test_JSON.swift

@@ -137,13 +137,8 @@ class Test_JSON: XCTestCase, PBTestHelpers {
         var m = MessageTestType()
         configureLargeObject(&m)
         let s = try m.jsonString()
-#if swift(>=3.2)
-        let chars = s
-#else
-	let chars = s.characters
-#endif
         var truncated = ""
-        for c in chars {
+        for c in s {
             truncated.append(c)
             do {
                 _ = try MessageTestType(jsonString: truncated)