|
24 | 24 |
|
25 | 25 | import Foundation |
26 | 26 |
|
27 | | -extension NSOutputStream |
| 27 | +extension OutputStream |
28 | 28 | { |
29 | | - func write(string:String) { |
| 29 | + func write(_ string:String) { |
30 | 30 | if string.isEmpty {return} |
31 | 31 | let encodedDataArray = [UInt8](string.utf8) |
32 | 32 | write(encodedDataArray, maxLength: encodedDataArray.count) |
33 | 33 | } |
34 | 34 | } |
35 | 35 |
|
36 | 36 |
|
37 | | -func writeLicense(outstream:NSOutputStream) |
| 37 | +func writeLicense(_ outstream:OutputStream) |
38 | 38 | { |
39 | 39 | var s = "// WARNING: This file is generated. Modifications will be lost.\n\n" |
40 | 40 | s += "// Copyright (c) 2015-2016 David Turnbull\n" |
@@ -62,7 +62,7 @@ func writeLicense(outstream:NSOutputStream) |
62 | 62 | } |
63 | 63 |
|
64 | 64 |
|
65 | | -func writeSwizzle(out:NSOutputStream) |
| 65 | +func writeSwizzle(_ out:OutputStream) |
66 | 66 | { |
67 | 67 | writeLicense(out) |
68 | 68 |
|
@@ -117,22 +117,22 @@ func writeSwizzle(out:NSOutputStream) |
117 | 117 | } |
118 | 118 |
|
119 | 119 |
|
120 | | -func writer(filename:String, _ generator:(outstream:NSOutputStream) -> Void) |
| 120 | +func writer(_ filename:String, _ generator:(OutputStream) -> Void) |
121 | 121 | { |
122 | | - let outstream:NSOutputStream! = NSOutputStream(toFileAtPath: filename, append: false) |
| 122 | + let outstream:OutputStream! = OutputStream(toFileAtPath: filename, append: false) |
123 | 123 | outstream.open() |
124 | | - assert(outstream.streamStatus == .Open, "Unable to write \(filename)") |
125 | | - generator(outstream: outstream) |
| 124 | + assert(outstream.streamStatus == .open, "Unable to write \(filename)") |
| 125 | + generator(outstream) |
126 | 126 | outstream.close() |
127 | 127 | } |
128 | 128 |
|
129 | 129 | // Got error from Xcode? Add $(SRCROOT)/Math to arguments in scheme. |
130 | 130 |
|
131 | | -if (Process.argc != 2) { |
| 131 | +if (CommandLine.arguments.count != 2) { |
132 | 132 | print("\nusage: main.swift path_to_root\n") |
133 | 133 | exit(1) |
134 | 134 | } |
135 | | -let pathPrefix = Process.arguments[1] |
| 135 | +let pathPrefix = CommandLine.arguments[1] |
136 | 136 | print("Working...") |
137 | 137 | writer(pathPrefix + "/Sources/Swizzle.swift", writeSwizzle) |
138 | 138 | print("Success") |
0 commit comments