Explorar el Código

Ready for XCode 8 Beta 2.

Damian Kołakowski hace 10 años
padre
commit
4ada33484b

+ 1 - 1
Sources/Swifter/App.swift

@@ -56,7 +56,7 @@ public class App {
         #if os(Linux)
     	    while true { }
         #else
-    	    RunLoop.current().run()
+    	    RunLoop.current.run()
         #endif
     }
 }

+ 2 - 2
Sources/Swifter/DemoServer.swift

@@ -72,7 +72,7 @@ public func demoServer(_ publicDir: String) -> HttpServer {
                     }
                 }
             }
-            }(r)
+        }(r)
     }
     
     server.GET["/upload"] = scopes {
@@ -180,7 +180,7 @@ public func demoServer(_ publicDir: String) -> HttpServer {
     }
     
     server["/websocket-echo"] = websocket({ (session, text) in
-        session.writeText(text)
+            session.writeText(text)
         }, { (session, binary) in
             session.writeBinary(binary)
     })

+ 1 - 1
Sources/Swifter/Files.swift

@@ -50,7 +50,7 @@ public func directoryBrowser(_ dir: String) -> ((HttpRequest) -> HttpResponse) {
                             }
                         }
                     }
-                    }(r)
+                }(r)
             } else {
                 guard let file = try? File.openForReading(filePath) else {
                     return .NotFound

+ 14 - 14
Sources/Swifter/Reflection.swift

@@ -91,19 +91,19 @@ public func memoryLayoutForStructure(object: Any) -> [String: Range<Int>] {
     for case let (label?, value) in Mirror(reflecting: object).children {
         var fieldLength = 0
         // TODO - Replace this with something smarter.
-        if value is Int    { fieldLength = sizeof(Int)   } else
-        if value is UInt   { fieldLength = sizeof(UInt)  } else
-        if value is Int8   { fieldLength = sizeof(Int8)  } else
-        if value is UInt8  { fieldLength = sizeof(UInt8) } else
-        if value is Int16  { fieldLength = sizeof(Int16) } else
-        if value is UInt16 { fieldLength = sizeof(UInt16)} else
-        if value is Int32  { fieldLength = sizeof(Int32) } else
-        if value is UInt32 { fieldLength = sizeof(UInt32)} else
-        if value is Int64  { fieldLength = sizeof(Int64) } else
-        if value is UInt64 { fieldLength = sizeof(UInt64)} else
-        if value is Float  { fieldLength = sizeof(Float) } else
-        if value is Double { fieldLength = sizeof(Double)} else
-        if value is String { fieldLength = sizeof(String)}
+        if value is Int    { fieldLength = sizeof(Int.self)   } else
+        if value is UInt   { fieldLength = sizeof(UInt.self)  } else
+        if value is Int8   { fieldLength = sizeof(Int8.self)  } else
+        if value is UInt8  { fieldLength = sizeof(UInt8.self) } else
+        if value is Int16  { fieldLength = sizeof(Int16.self) } else
+        if value is UInt16 { fieldLength = sizeof(UInt16.self)} else
+        if value is Int32  { fieldLength = sizeof(Int32.self) } else
+        if value is UInt32 { fieldLength = sizeof(UInt32.self)} else
+        if value is Int64  { fieldLength = sizeof(Int64.self) } else
+        if value is UInt64 { fieldLength = sizeof(UInt64.self)} else
+        if value is Float  { fieldLength = sizeof(Float.self) } else
+        if value is Double { fieldLength = sizeof(Double.self)} else
+        if value is String { fieldLength = sizeof(String.self)}
         if fieldLength <= alignment {
             layout[label] = size ..< size + fieldLength
             size = size + fieldLength
@@ -116,4 +116,4 @@ public func memoryLayoutForStructure(object: Any) -> [String: Range<Int>] {
         }
     }
     return layout
-}
+}

+ 7 - 7
Sources/Swifter/Socket.swift

@@ -41,7 +41,7 @@ public class Socket: Hashable, Equatable {
         }
         
         var value: Int32 = 1
-        if setsockopt(socketFileDescriptor, SOL_SOCKET, SO_REUSEADDR, &value, socklen_t(sizeof(Int32))) == -1 {
+        if setsockopt(socketFileDescriptor, SOL_SOCKET, SO_REUSEADDR, &value, socklen_t(sizeof(Int32.self))) == -1 {
             let details = Socket.descriptionOfLastError()
             Socket.release(socketFileDescriptor)
             throw SocketError.SocketSettingReUseAddrFailed(details)
@@ -69,24 +69,24 @@ public class Socket: Hashable, Equatable {
         #else
             var bindResult: Int32 = -1
             if forceIPv4 {
-                var addr = sockaddr_in(sin_len: UInt8(strideof(sockaddr_in)),
+                var addr = sockaddr_in(sin_len: UInt8(strideof(sockaddr_in.self)),
                     sin_family: UInt8(AF_INET),
                     sin_port: Socket.htonsPort(port),
                     sin_addr: in_addr(s_addr: in_addr_t(0)),
                     sin_zero:(0, 0, 0, 0, 0, 0, 0, 0))
              
-                bindResult = withUnsafePointer(&addr) { bind(socketFileDescriptor, UnsafePointer<sockaddr>($0), socklen_t(sizeof(sockaddr_in))) }
+                bindResult = withUnsafePointer(&addr) { bind(socketFileDescriptor, UnsafePointer<sockaddr>($0), socklen_t(sizeof(sockaddr_in.self))) }
             } else {
                 // “Apple recommends always making an IPv6 socket to listen on.  The OS will automatically
                 // “downgrade” it to an IPv4 socket if necessary, so there is no need to listen on two different sockets”.
-                var addr = sockaddr_in6(sin6_len: UInt8(strideof(sockaddr_in6)),
+                var addr = sockaddr_in6(sin6_len: UInt8(strideof(sockaddr_in6.self)),
                     sin6_family: UInt8(AF_INET6),
                     sin6_port: Socket.htonsPort(port),
                     sin6_flowinfo: 0,
                     sin6_addr: in6addr_any,
                     sin6_scope_id: 0)
                 
-                bindResult = withUnsafePointer(&addr) { bind(socketFileDescriptor, UnsafePointer<sockaddr>($0), socklen_t(sizeof(sockaddr_in6))) }
+                bindResult = withUnsafePointer(&addr) { bind(socketFileDescriptor, UnsafePointer<sockaddr>($0), socklen_t(sizeof(sockaddr_in6.self))) }
             }
         #endif
 
@@ -182,7 +182,7 @@ public class Socket: Hashable, Equatable {
     }
     
     public func peername() throws -> String {
-        var addr = sockaddr(), len: socklen_t = socklen_t(sizeof(sockaddr))
+        var addr = sockaddr(), len: socklen_t = socklen_t(sizeof(sockaddr.self))
         if getpeername(self.socketFileDescriptor, &addr, &len) != 0 {
             throw SocketError.GetPeerNameFailed(Socket.descriptionOfLastError())
         }
@@ -204,7 +204,7 @@ public class Socket: Hashable, Equatable {
         #else
             // Prevents crashes when blocking calls are pending and the app is paused ( via Home button ).
             var no_sig_pipe: Int32 = 1
-            setsockopt(socket, SOL_SOCKET, SO_NOSIGPIPE, &no_sig_pipe, socklen_t(sizeof(Int32)))
+            setsockopt(socket, SOL_SOCKET, SO_NOSIGPIPE, &no_sig_pipe, socklen_t(sizeof(Int32.self)))
         #endif
     }
     

+ 1 - 1
XCode/SwifterSampleOSX/main.swift

@@ -18,7 +18,7 @@ do {
         // Fallback on earlier versions
     }
     print("Server has started ( port = 9080 ). Try to connect now...")
-    RunLoop.main().run()
+    RunLoop.main.run()
 } catch {
     print("Server start error: \(error)")
 }