Skip to content

Commit

Permalink
Merge pull request #86 from thomas-em/tm/swift-3
Browse files Browse the repository at this point in the history
Fixes to make SWXMLHash work with Swift 3 of current Xcode 8 beta 2 (8S162m)
  • Loading branch information
drmohundro authored Jul 15, 2016
2 parents e56067f + d1a6bcf commit 89fafda
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion SWXMLHashPlayground.playground/section-1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct Book: XMLIndexerDeserializable {
let year: Int
let amount: Int?

static func deserialize(node: XMLIndexer) throws -> Book {
static func deserialize(_ node: XMLIndexer) throws -> Book {
return try Book(
title: node["title"].value(),
price: node["price"].value(),
Expand Down
18 changes: 9 additions & 9 deletions Source/SWXMLHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class LazyXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
parser.parse()
}

private func parser(_ parser: XMLParser,
func parser(_ parser: Foundation.XMLParser,
didStartElement elementName: String,
namespaceURI: String?,
qualifiedName qName: String?,
Expand All @@ -202,7 +202,7 @@ class LazyXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
parentStack.push(currentNode)
}

private func parser(_ parser: XMLParser, foundCharacters string: String) {
func parser(_ parser: Foundation.XMLParser, foundCharacters string: String) {
if !onMatch() {
return
}
Expand All @@ -212,17 +212,17 @@ class LazyXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
current.addText(string)
}

private func parser(_ parser: XMLParser,
func parser(_ parser: Foundation.XMLParser,
didEndElement elementName: String,
namespaceURI: String?,
qualifiedName qName: String?) {

let match = onMatch()

elementStack.pop()
let _ = elementStack.pop()

if match {
parentStack.pop()
let _ = parentStack.pop()
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ class XMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
return XMLIndexer(root)
}

private func parser(_ parser: XMLParser,
func parser(_ parser: Foundation.XMLParser,
didStartElement elementName: String,
namespaceURI: String?,
qualifiedName qName: String?,
Expand All @@ -273,18 +273,18 @@ class XMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
parentStack.push(currentNode)
}

private func parser(_ parser: XMLParser, foundCharacters string: String) {
func parser(_ parser: Foundation.XMLParser, foundCharacters string: String) {
let current = parentStack.top()

current.addText(string)
}

private func parser(_ parser: XMLParser,
func parser(_ parser: Foundation.XMLParser,
didEndElement elementName: String,
namespaceURI: String?,
qualifiedName qName: String?) {

parentStack.pop()
let _ = parentStack.pop()
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/TypeConversionBasicTypesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ struct BasicItem: XMLIndexerDeserializable {
let name: String
let price: Double

static func deserialize(node: XMLIndexer) throws -> BasicItem {
static func deserialize(_ node: XMLIndexer) throws -> BasicItem {
return try BasicItem(
name: node["name"].value(),
price: node["price"].value()
Expand Down
2 changes: 1 addition & 1 deletion Tests/TypeConversionComplexTypesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct ComplexItem: XMLIndexerDeserializable {
let priceOptional: Double?
let basics: [BasicItem]

static func deserialize(node: XMLIndexer) throws -> ComplexItem {
static func deserialize(_ node: XMLIndexer) throws -> ComplexItem {
return try ComplexItem(
name: node["name"].value(),
priceOptional: node["price"].value(),
Expand Down
4 changes: 2 additions & 2 deletions Tests/XMLParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class XMLParsingTests: XCTestCase {
XCTAssertNotNil(err)
}
do {
try xml!.byKey("root").byKey("what").byKey("header").byKey("foo")
let _ = try xml!.byKey("root").byKey("what").byKey("header").byKey("foo")
} catch let error as XMLIndexer.Error {
err = error
} catch { err = nil }
Expand All @@ -144,7 +144,7 @@ class XMLParsingTests: XCTestCase {
XCTAssertNotNil(err)
}
do {
try xml!.byKey("what").byKey("subelement").byIndex(5).byKey("nomatch")
let _ = try xml!.byKey("what").byKey("subelement").byIndex(5).byKey("nomatch")
} catch let error as XMLIndexer.Error {
err = error
} catch { err = nil }
Expand Down

0 comments on commit 89fafda

Please sign in to comment.