Swift 2 auto convert by Xcode.

This commit is contained in:
Helge Hess 2015-06-12 13:20:08 +02:00
parent 5abcc9836c
commit 4f0f0cbac3
6 changed files with 28 additions and 22 deletions

View File

@ -285,7 +285,8 @@
E8FB77351971609A00E0557D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Always Right Institute";
TargetAttributes = {
E8FB773D1971609A00E0557D = {
@ -401,6 +402,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@ -474,6 +476,7 @@
INFOPLIST_FILE = SwiftyExpat/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.alwaysrightinstitute.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
@ -491,6 +494,7 @@
INFOPLIST_FILE = SwiftyExpat/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.alwaysrightinstitute.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
@ -510,6 +514,7 @@
);
INFOPLIST_FILE = SwiftyExpatTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.alwaysrightinstitute.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@ -524,6 +529,7 @@
);
INFOPLIST_FILE = SwiftyExpatTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.alwaysrightinstitute.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;

View File

@ -192,8 +192,8 @@ public class Expat : OutputStreamType, BooleanType {
cb(s)
}
else {
println("ERROR: could not convert CString to String?! (len=\(cslen))")
dumpCharBuf(cs, Int(cslen))
print("ERROR: could not convert CString to String?! (len=\(cslen))")
dumpCharBuf(cs, len: Int(cslen))
}
}
}
@ -215,7 +215,7 @@ public extension Expat { // Namespaces
{
let sep = self.nsSeparator // so that we don't capture 'self' (necessary?)
return onStartElement {
let comps = split($0, maxSplit: 1, allowEmptySlices: false) { $0 == sep }
let comps = split($0.characters, maxSplit: 1, allowEmptySlices: false) { $0 == sep }.map { String($0) }
cb(comps[0], comps[1], $1)
}
}
@ -223,7 +223,7 @@ public extension Expat { // Namespaces
public func onEndElementNS(cb: ( String, String ) -> Void) -> Self {
let sep = self.nsSeparator // so that we don't capture 'self' (necessary?)
return onEndElement {
let comps = split($0, maxSplit: 1, allowEmptySlices: false) { $0 == sep }
let comps = split($0.characters, maxSplit: 1, allowEmptySlices: false) { $0 == sep }.map { String($0) }
cb(comps[0], comps[1])
}
}
@ -247,14 +247,14 @@ public func ==(lhs: XML_Error, rhs: XML_Error) -> Bool {
// this failes, maybe because it's not public?:
// return lhs.value == rhs.value
// Hard hack, does it actually work? :-)
return isByteEqual(lhs, rhs)
return isByteEqual(lhs, rhs: rhs)
}
public func ==(lhs: XML_Status, rhs: XML_Status) -> Bool {
return isByteEqual(lhs, rhs)
return isByteEqual(lhs, rhs: rhs)
}
extension XML_Error : Printable {
extension XML_Error : CustomStringConvertible {
public var description: String {
switch self {
@ -275,7 +275,7 @@ extension XML_Error : Printable {
}
}
public enum ExpatResult : Printable, BooleanType {
public enum ExpatResult : CustomStringConvertible, BooleanType {
case OK
case Suspended
@ -301,11 +301,11 @@ public enum ExpatResult : Printable, BooleanType {
/* debug */
func dumpCharBuf(buf: UnsafePointer<CChar>, len : Int) {
println("*-- buffer (len=\(len))")
print("*-- buffer (len=\(len))")
for var i = 0; i < len; i++ {
let cp = Int(buf[i])
let c = Character(UnicodeScalar(cp))
println(" [\(i)]: \(cp) \(c)")
print(" [\(i)]: \(cp) \(c)")
}
println("---")
print("---")
}

View File

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>de.alwaysrightinstitute.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -26,7 +26,7 @@ extension String {
}
let buflen = length + 1
var buf = UnsafeMutablePointer<CChar>.alloc(buflen)
let buf = UnsafeMutablePointer<CChar>.alloc(buflen)
memcpy(buf, cs, length)
buf[length] = 0 // zero terminate
let s = String.fromCString(buf)

View File

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>de.alwaysrightinstitute.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -18,12 +18,12 @@ class SwiftyExpatTests: XCTestCase {
super.setUp()
p = Expat()
.onStartElement { name, attrs in println("<\(name) \(attrs)") }
.onEndElement { name in println(">\(name)") }
.onStartNamespace { prefix, uri in println("+NS[\(prefix)] = \(uri)") }
.onEndNamespace { prefix in println("-NS[\(prefix)]") }
.onCharacterData { content in println("TEXT: \(content)") }
.onError { error in println("ERROR \(error)") }
.onStartElement { name, attrs in print("<\(name) \(attrs)") }
.onEndElement { name in print(">\(name)") }
.onStartNamespace { prefix, uri in print("+NS[\(prefix)] = \(uri)") }
.onEndNamespace { prefix in print("-NS[\(prefix)]") }
.onCharacterData { content in print("TEXT: \(content)") }
.onError { error in print("ERROR \(error)") }
}
override func tearDown() {
@ -51,7 +51,7 @@ class SwiftyExpatTests: XCTestCase {
let testXML = "<hello xmlns='YoYo' a='5'>x>world</x></hello>"
result = p.feed(testXML)
println("Feed result: \(result)")
print("Feed result: \(result)")
XCTAssert(!result)
result = p.close() // EOF