Skip to content

Commit

Permalink
Update Tools to Swift 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jkolb committed Aug 4, 2017
1 parent 557e4d8 commit 0a006ef
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Tools/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

import Foundation

extension NSOutputStream
extension OutputStream
{
func write(string:String) {
func write(_ string:String) {
if string.isEmpty {return}
let encodedDataArray = [UInt8](string.utf8)
write(encodedDataArray, maxLength: encodedDataArray.count)
}
}


func writeLicense(outstream:NSOutputStream)
func writeLicense(_ outstream:OutputStream)
{
var s = "// WARNING: This file is generated. Modifications will be lost.\n\n"
s += "// Copyright (c) 2015-2016 David Turnbull\n"
Expand Down Expand Up @@ -62,7 +62,7 @@ func writeLicense(outstream:NSOutputStream)
}


func writeSwizzle(out:NSOutputStream)
func writeSwizzle(_ out:OutputStream)
{
writeLicense(out)

Expand Down Expand Up @@ -117,22 +117,22 @@ func writeSwizzle(out:NSOutputStream)
}


func writer(filename:String, _ generator:(outstream:NSOutputStream) -> Void)
func writer(_ filename:String, _ generator:(OutputStream) -> Void)
{
let outstream:NSOutputStream! = NSOutputStream(toFileAtPath: filename, append: false)
let outstream:OutputStream! = OutputStream(toFileAtPath: filename, append: false)
outstream.open()
assert(outstream.streamStatus == .Open, "Unable to write \(filename)")
generator(outstream: outstream)
assert(outstream.streamStatus == .open, "Unable to write \(filename)")
generator(outstream)
outstream.close()
}

// Got error from Xcode? Add $(SRCROOT)/Math to arguments in scheme.

if (Process.argc != 2) {
if (CommandLine.arguments.count != 2) {
print("\nusage: main.swift path_to_root\n")
exit(1)
}
let pathPrefix = Process.arguments[1]
let pathPrefix = CommandLine.arguments[1]
print("Working...")
writer(pathPrefix + "/Sources/Swizzle.swift", writeSwizzle)
print("Success")

0 comments on commit 0a006ef

Please sign in to comment.