Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of explicit internal #29

Merged
merged 1 commit into from Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Auxiliaries/ISO8601DateFormatter.swift
Expand Up @@ -14,7 +14,7 @@ import Foundation
/// whichever Foundation the user has. ISO8601DateFormatter might not exist, so
/// we better not hit this code path on an older OS.
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
internal var _iso8601Formatter: ISO8601DateFormatter = {
var _iso8601Formatter: ISO8601DateFormatter = {
let formatter = ISO8601DateFormatter()
formatter.formatOptions = .withInternetDateTime
return formatter
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Auxiliaries/String+Extensions.swift
Expand Up @@ -8,7 +8,7 @@
import Foundation

extension String {
internal func escape(_ characterSet: [(character: String, escapedCharacter: String)]) -> String {
func escape(_ characterSet: [(character: String, escapedCharacter: String)]) -> String {
var string = self

for set in characterSet {
Expand Down
6 changes: 3 additions & 3 deletions Sources/XMLCoder/Auxiliaries/XMLElement.swift
Expand Up @@ -7,7 +7,7 @@

import Foundation

internal class _XMLElement {
class _XMLElement {
static let attributesKey = "___ATTRIBUTES"
static let escapedCharacterSet = [("&", "&amp"), ("<", "&lt;"), (">", "&gt;"), ("'", "&apos;"), ("\"", "&quot;")]

Expand All @@ -16,7 +16,7 @@ internal class _XMLElement {
var attributes: [String: String] = [:]
var children: [String: [_XMLElement]] = [:]

internal init(key: String, value: String? = nil, attributes: [String: String] = [:], children: [String: [_XMLElement]] = [:]) {
init(key: String, value: String? = nil, attributes: [String: String] = [:], children: [String: [_XMLElement]] = [:]) {
self.key = key
self.value = value
self.attributes = attributes
Expand Down Expand Up @@ -78,7 +78,7 @@ internal class _XMLElement {
self.value = value
}

internal func flatten() -> [String: Box] {
func flatten() -> [String: Box] {
var node: [String: Box] = attributes.mapValues { StringBox($0) }

for childElement in children {
Expand Down
4 changes: 2 additions & 2 deletions Sources/XMLCoder/Auxiliaries/XMLHeader.swift
Expand Up @@ -21,11 +21,11 @@ public struct XMLHeader {
self.standalone = standalone
}

internal func isEmpty() -> Bool {
func isEmpty() -> Bool {
return version == nil && encoding == nil && standalone == nil
}

internal func toXML() -> String? {
func toXML() -> String? {
guard !isEmpty() else { return nil }

var string = "<?xml "
Expand Down
6 changes: 3 additions & 3 deletions Sources/XMLCoder/Auxiliaries/XMLKey.swift
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// Shared Key Types
internal struct _XMLKey: CodingKey {
struct _XMLKey: CodingKey {
public let stringValue: String
public let intValue: Int?

Expand All @@ -28,10 +28,10 @@ internal struct _XMLKey: CodingKey {
self.intValue = intValue
}

internal init(index: Int) {
init(index: Int) {
stringValue = "Index \(index)"
intValue = index
}

internal static let `super` = _XMLKey(stringValue: "super")!
static let `super` = _XMLKey(stringValue: "super")!
}
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Auxiliaries/XMLStackParser.swift
Expand Up @@ -8,7 +8,7 @@

import Foundation

internal class _XMLStackParser: NSObject {
class _XMLStackParser: NSObject {
var root: _XMLElement? = nil
var stack: [_XMLElement] = []
var currentNode: _XMLElement? = nil
Expand Down
6 changes: 3 additions & 3 deletions Sources/XMLCoder/Decoder/DecodingErrorExtension.swift
Expand Up @@ -12,14 +12,14 @@ import Foundation
// Error Utilities
//===----------------------------------------------------------------------===//

internal extension DecodingError {
extension DecodingError {
/// Returns a `.typeMismatch` error describing the expected type.
///
/// - parameter path: The path of `CodingKey`s taken to decode a value of this type.
/// - parameter expectation: The type expected to be encountered.
/// - parameter reality: The value that was encountered instead of the expected type.
/// - returns: A `DecodingError` with the appropriate path and debug description.
internal static func _typeMismatch(at path: [CodingKey], expectation: Any.Type, reality: Box) -> DecodingError {
static func _typeMismatch(at path: [CodingKey], expectation: Any.Type, reality: Box) -> DecodingError {
let description = "Expected to decode \(expectation) but found \(_typeDescription(of: reality)) instead."
return .typeMismatch(expectation, Context(codingPath: path, debugDescription: description))
}
Expand All @@ -29,7 +29,7 @@ internal extension DecodingError {
/// - parameter value: The value whose type to describe.
/// - returns: A string describing `value`.
/// - precondition: `value` is one of the types below.
internal static func _typeDescription(of box: Box) -> String {
static func _typeDescription(of box: Box) -> String {
switch box {
case is NullBox:
return "a null value"
Expand Down
30 changes: 15 additions & 15 deletions Sources/XMLCoder/Decoder/XMLDecoder.swift
Expand Up @@ -211,7 +211,7 @@ open class XMLDecoder {
open var userInfo: [CodingUserInfoKey: Any] = [:]

/// Options set on the top-level encoder to pass down the decoding hierarchy.
internal struct _Options {
struct _Options {
let dateDecodingStrategy: DateDecodingStrategy
let dataDecodingStrategy: DataDecodingStrategy
let nonConformingFloatDecodingStrategy: NonConformingFloatDecodingStrategy
Expand All @@ -220,7 +220,7 @@ open class XMLDecoder {
}

/// The options set on the top-level decoder.
internal var options: _Options {
var options: _Options {
return _Options(dateDecodingStrategy: dateDecodingStrategy,
dataDecodingStrategy: dataDecodingStrategy,
nonConformingFloatDecodingStrategy: nonConformingFloatDecodingStrategy,
Expand Down Expand Up @@ -268,14 +268,14 @@ open class XMLDecoder {

// MARK: - _XMLDecoder

internal class _XMLDecoder: Decoder {
class _XMLDecoder: Decoder {
// MARK: Properties

/// The decoder's storage.
internal var storage: _XMLDecodingStorage
var storage: _XMLDecodingStorage

/// Options set on the top-level decoder.
internal let options: XMLDecoder._Options
let options: XMLDecoder._Options

/// The path to the current point in encoding.
public internal(set) var codingPath: [CodingKey]
Expand All @@ -288,7 +288,7 @@ internal class _XMLDecoder: Decoder {
// MARK: - Initialization

/// Initializes `self` with the given top-level container and options.
internal init(referencing container: Box, at codingPath: [CodingKey] = [], options: XMLDecoder._Options) {
init(referencing container: Box, at codingPath: [CodingKey] = [], options: XMLDecoder._Options) {
storage = _XMLDecodingStorage()
storage.push(container: container)
self.codingPath = codingPath
Expand Down Expand Up @@ -398,7 +398,7 @@ extension _XMLDecoder: SingleValueDecodingContainer {
extension _XMLDecoder {
/// Returns the given box unboxed from a container.

internal func unbox(_ box: Box) throws -> Bool? {
func unbox(_ box: Box) throws -> Bool? {
guard !box.isNull else { return nil }

guard let string = (box as? StringBox)?.unbox() else { return nil }
Expand All @@ -410,7 +410,7 @@ extension _XMLDecoder {
return boolBox.unbox()
}

internal func unbox(_ box: Box) throws -> Decimal? {
func unbox(_ box: Box) throws -> Decimal? {
guard !box.isNull else { return nil }

guard let string = (box as? StringBox)?.unbox() else { return nil }
Expand All @@ -422,7 +422,7 @@ extension _XMLDecoder {
return decimalBox.unbox()
}

internal func unbox<T: BinaryInteger & SignedInteger & Decodable>(_ box: Box) throws -> T? {
func unbox<T: BinaryInteger & SignedInteger & Decodable>(_ box: Box) throws -> T? {
guard !box.isNull else { return nil }

guard let string = (box as? StringBox)?.unbox() else { return nil }
Expand All @@ -441,7 +441,7 @@ extension _XMLDecoder {
return int
}

internal func unbox<T: BinaryInteger & UnsignedInteger & Decodable>(_ box: Box) throws -> T? {
func unbox<T: BinaryInteger & UnsignedInteger & Decodable>(_ box: Box) throws -> T? {
guard !box.isNull else { return nil }

guard let string = (box as? StringBox)?.unbox() else { return nil }
Expand All @@ -460,7 +460,7 @@ extension _XMLDecoder {
return uint
}

internal func unbox<T: BinaryFloatingPoint & Decodable>(_ box: Box) throws -> T? {
func unbox<T: BinaryFloatingPoint & Decodable>(_ box: Box) throws -> T? {
guard !box.isNull else { return nil }

guard let string = (box as? StringBox)?.unbox() else { return nil }
Expand All @@ -479,7 +479,7 @@ extension _XMLDecoder {
return float
}

internal func unbox(_ box: Box) throws -> String? {
func unbox(_ box: Box) throws -> String? {
guard !box.isNull else { return nil }

guard let string = (box as? StringBox)?.unbox() else {
Expand All @@ -489,7 +489,7 @@ extension _XMLDecoder {
return string
}

internal func unbox(_ box: Box) throws -> Date? {
func unbox(_ box: Box) throws -> Date? {
guard !box.isNull else { return nil }

switch options.dateDecodingStrategy {
Expand Down Expand Up @@ -549,7 +549,7 @@ extension _XMLDecoder {
}
}

internal func unbox(_ box: Box) throws -> Data? {
func unbox(_ box: Box) throws -> Data? {
guard !box.isNull else { return nil }

switch options.dataDecodingStrategy {
Expand All @@ -576,7 +576,7 @@ extension _XMLDecoder {
}
}

internal func unbox<T: Decodable>(_ box: Box) throws -> T? {
func unbox<T: Decodable>(_ box: Box) throws -> T? {
let decoded: T
let type = T.self
if type == Date.self || type == NSDate.self {
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Decoder/XMLDecodingStorage.swift
Expand Up @@ -10,7 +10,7 @@ import Foundation

// MARK: - Decoding Storage

internal struct _XMLDecodingStorage {
struct _XMLDecodingStorage {
// MARK: Properties

/// The container stack.
Expand Down
4 changes: 2 additions & 2 deletions Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
Expand Up @@ -19,7 +19,7 @@ extension Dictionary: AnyEmptySequence {}

// MARK: Decoding Containers

internal struct _XMLKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContainerProtocol {
struct _XMLKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContainerProtocol {
typealias Key = K

// MARK: Properties
Expand All @@ -36,7 +36,7 @@ internal struct _XMLKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContainer
// MARK: - Initialization

/// Initializes `self` by referencing the given decoder and container.
internal init(referencing decoder: _XMLDecoder, wrapping container: KeyedBox) {
init(referencing decoder: _XMLDecoder, wrapping container: KeyedBox) {
self.decoder = decoder
switch decoder.options.keyDecodingStrategy {
case .useDefaultKeys:
Expand Down
4 changes: 2 additions & 2 deletions Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift
Expand Up @@ -8,7 +8,7 @@

import Foundation

internal struct _XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
struct _XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
// MARK: Properties

/// A reference to the decoder we're reading from.
Expand All @@ -26,7 +26,7 @@ internal struct _XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
// MARK: - Initialization

/// Initializes `self` by referencing the given decoder and container.
internal init(referencing decoder: _XMLDecoder, wrapping container: UnkeyedBox) {
init(referencing decoder: _XMLDecoder, wrapping container: UnkeyedBox) {
self.decoder = decoder
self.container = container
codingPath = decoder.codingPath
Expand Down
4 changes: 2 additions & 2 deletions Sources/XMLCoder/Encoder/EncodingErrorExtension.swift
Expand Up @@ -9,14 +9,14 @@
import Foundation

/// Error Utilities
internal extension EncodingError {
extension EncodingError {
/// Returns a `.invalidValue` error describing the given invalid floating-point value.
///
///
/// - parameter value: The value that was invalid to encode.
/// - parameter path: The path of `CodingKey`s taken to encode this value.
/// - returns: An `EncodingError` with the appropriate path and debug description.
internal static func _invalidFloatingPointValue<T: FloatingPoint>(_ value: T, at codingPath: [CodingKey]) -> EncodingError {
static func _invalidFloatingPointValue<T: FloatingPoint>(_ value: T, at codingPath: [CodingKey]) -> EncodingError {
let valueDescription: String
if value == T.infinity {
valueDescription = "\(T.self).infinity"
Expand Down