diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index e8974ae..0000000 --- a/Package.resolved +++ /dev/null @@ -1,16 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "icu4c-swift", - "repositoryURL": "https://github.com/allevato/icu4c-swift", - "state": { - "branch": null, - "revision": "eb1ea105e25d17ce6481b5a3338711530b7bd13d", - "version": "1.0.1" - } - } - ] - }, - "version": 1 -} diff --git a/Package.swift b/Package.swift index b56296e..9218588 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.0 +// swift-tools-version:5.0 // Copyright 2017 Tony Allevato. // @@ -19,13 +19,24 @@ import PackageDescription let package = Package( name: "icu-swift", products: [ - .library(name: "swiftICU", type: .static, targets: ["ICU"]), - ], - dependencies: [ - .package(url: "https://github.com/allevato/icu4c-swift", from: "1.0.1"), + .library( + name: "swiftICU", + type: .static, + targets: ["ICU"]), ], targets: [ - .target(name: "ICU"), - .testTarget(name: "ICUTests", dependencies: ["ICU"]), + .target( + name: "ICU", + dependencies: ["ICU4C"]), + .systemLibrary( + name: "ICU4C", + pkgConfig: "icu-uc", + providers: [ + .brew(["icu4c"]), + .apt(["libicu-dev"]), + ]), + .testTarget( + name: "ICUTests", + dependencies: ["ICU"]), ] ) diff --git a/Sources/ICU/GeneralCategory.swift b/Sources/ICU/GeneralCategory.swift index 92ccedb..ee2eb0f 100644 --- a/Sources/ICU/GeneralCategory.swift +++ b/Sources/ICU/GeneralCategory.swift @@ -14,260 +14,156 @@ import ICU4C -extension Unicode { - - /// The general category types of Unicode scalars. - public enum GeneralCategory: ConvertibleFromUnicodeIntProperty { - - /// An uppercase letter (abbreviated Lu). - case uppercaseLetter - - /// A lowercase letter (abbreviated Ll). - case lowercaseLetter - - /// A digraph character whose first part is uppercase (abbreviated Lt). - case titlecaseLetter - - /// A modifier letter (abbreviated Lm). - case modifierLetter - - /// Other letters, including syllables and ideographs (abbreviated Lo). - case otherLetter - - /// A non-spacing combining mark with zero advance width (abbreviated Mn). - case nonspacingMark - - /// A spacing combining mark with positive advance width (abbreviated Mc). - case spacingMark - - /// An enclosing combining mark (abbreviated Me). - case enclosingMark - - /// A decimal digit (abbreviated Nd). - case decimalNumber - - /// A letter-like numeric character (abbreviated Nl). - case letterNumber - - /// A numeric character of another type (abbreviated No). - case otherNumber - - /// A connecting punctuation mark like a tie (abbreviated Pc). - case connectorPunctuation - - /// A dash or hyphen punctuation mark (abbreviated Pd). - case dashPunctuation - - /// An opening punctuation mark of a pair (abbreviated Ps). - case openPunctuation - - /// A closing punctuation mark of a pair (abbreviated Pe). - case closePunctuation - - /// An initial quotation mark (abbreviated Pi). - case initialPunctuation - - /// A final quotation mark (abbreviated Pf). - case finalPunctuation - - /// A punctuation mark of another type (abbreviated Po). - case otherPunctuation - - /// A symbol of mathematical use (abbreviated Sm). - case mathSymbol - - /// A currency sign (abbreviated Sc). - case currencySymbol - - /// A non-letterlike modifier symbol (abbreviated Sk). - case modifierSymbol - - /// A symbol of another type (abbreviated So). - case otherSymbol - - /// A space character of non-zero width (abbreviated Zs). - case spaceSeparator - - /// A line separator, which is specifically (and only) U+2028 LINE SEPARATOR - /// (abbreviated Zl). - case lineSeparator - - /// A paragraph separator, which is specifically (and only) U+2029 PARAGRAPH - /// SEPARATOR (abbreviated Zp). - case paragraphSeparator - - /// A C0 or C1 control code (abbreviated Cc). - case control - - /// A format control character (abbreviated Cf). - case format - - /// A surrogate code point (abbreviated Cs). - case surrogate - - /// A private-use character (abbreviated Co). - case privateUse - - /// A reserved unassigned code point or a non-character (abbreviated Cn). - case unassigned - - /// Indicates whether the general category is in the grouping that - /// represents a cased letter: Lu, Ll, and Lt. - /// - /// This grouping is abbreviated LC in the Unicode standard. - var isCasedLetter: Bool { - switch self { - case .uppercaseLetter, .lowercaseLetter, .titlecaseLetter: return true - default: return false - } - } - - /// Indicates whether the general category is in the grouping that - /// represents a letter: Lu, Ll, Lt, Lm, and Lo. - /// - /// This grouping is abbreviated L in the Unicode standard. - var isLetter: Bool { - switch self { - case .uppercaseLetter, - .lowercaseLetter, - .titlecaseLetter, - .modifierLetter, - .otherLetter: - return true - default: return false - } +extension Unicode.GeneralCategory: ConvertibleFromUnicodeIntProperty { + + /// Indicates whether the general category is in the grouping that + /// represents a cased letter: Lu, Ll, and Lt. + /// + /// This grouping is abbreviated LC in the Unicode standard. + var isCasedLetter: Bool { + switch self { + case .uppercaseLetter, .lowercaseLetter, .titlecaseLetter: return true + default: return false } + } - /// Indicates whether the general category is in the grouping that - /// represents a mark: Mn, Mc, and Me. - /// - /// This grouping is abbreviated M in the Unicode standard. - var isMark: Bool { - switch self { - case .nonspacingMark, .spacingMark, .enclosingMark: return true - default: return false - } + /// Indicates whether the general category is in the grouping that + /// represents a letter: Lu, Ll, Lt, Lm, and Lo. + /// + /// This grouping is abbreviated L in the Unicode standard. + var isLetter: Bool { + switch self { + case .uppercaseLetter, + .lowercaseLetter, + .titlecaseLetter, + .modifierLetter, + .otherLetter: + return true + default: return false } + } - /// Indicates whether the general category is in the grouping that - /// represents a number: Nd, Nl, and No. - /// - /// This grouping is abbreviated N in the Unicode standard. - var isNumber: Bool { - switch self { - case .decimalNumber, .letterNumber, .otherNumber: return true - default: return false - } + /// Indicates whether the general category is in the grouping that + /// represents a mark: Mn, Mc, and Me. + /// + /// This grouping is abbreviated M in the Unicode standard. + var isMark: Bool { + switch self { + case .nonspacingMark, .spacingMark, .enclosingMark: return true + default: return false } + } - /// Indicates whether the general category is in the grouping that - /// represents punctuation: Pc, Pd, Ps, Pe, Pi, Pf, and Po. - /// - /// This grouping is abbreviated P in the Unicode standard. - var isPunctuation: Bool { - switch self { - case .connectorPunctuation, - .dashPunctuation, - .openPunctuation, - .closePunctuation, - .initialPunctuation, - .finalPunctuation, - .otherPunctuation: - return true - default: return false - } + /// Indicates whether the general category is in the grouping that + /// represents a number: Nd, Nl, and No. + /// + /// This grouping is abbreviated N in the Unicode standard. + var isNumber: Bool { + switch self { + case .decimalNumber, .letterNumber, .otherNumber: return true + default: return false } + } - /// Indicates whether the general category is in the grouping that - /// represents symbols: Sm, Sc, Sk, and So. - /// - /// This grouping is abbreviated S in the Unicode standard. - var isSymbol: Bool { - switch self { - case .mathSymbol, - .currencySymbol, - .modifierSymbol, - .otherSymbol: - return true - default: return false - } + /// Indicates whether the general category is in the grouping that + /// represents punctuation: Pc, Pd, Ps, Pe, Pi, Pf, and Po. + /// + /// This grouping is abbreviated P in the Unicode standard. + var isPunctuation: Bool { + switch self { + case .connectorPunctuation, + .dashPunctuation, + .openPunctuation, + .closePunctuation, + .initialPunctuation, + .finalPunctuation, + .otherPunctuation: + return true + default: return false } + } - /// Indicates whether the general category is in the grouping that - /// represents separators: Zs, Zl, and Zp. - /// - /// This grouping is abbreviated Z in the Unicode standard. - var isSeparator: Bool { - switch self { - case .spaceSeparator, .lineSeparator, .paragraphSeparator: return true - default: return false - } + /// Indicates whether the general category is in the grouping that + /// represents symbols: Sm, Sc, Sk, and So. + /// + /// This grouping is abbreviated S in the Unicode standard. + var isSymbol: Bool { + switch self { + case .mathSymbol, + .currencySymbol, + .modifierSymbol, + .otherSymbol: + return true + default: return false } + } - /// Indicates whether the general category is in the grouping that - /// represents control characters: Cc, Cf, Cs, Co, and Cn. - /// - /// This grouping is abbreviated C in the Unicode standard. - var isControl: Bool { - switch self { - case .control, - .format, - .surrogate, - .privateUse, - .unassigned: - return true - default: return false - } + /// Indicates whether the general category is in the grouping that + /// represents separators: Zs, Zl, and Zp. + /// + /// This grouping is abbreviated Z in the Unicode standard. + var isSeparator: Bool { + switch self { + case .spaceSeparator, .lineSeparator, .paragraphSeparator: return true + default: return false } + } - /// Creates a new general category value from the given ICU C API value. - /// - /// - Parameter cValue: The ICU C API value. - init?(cValue: UCharCategory) { - switch cValue { - // UNASSIGNED and GENERAL_OTHER_TYPES have the same numeric value (zero) - // so we can't actually distinguish them even though Swift imports them as - // distinct values. - case U_UNASSIGNED, U_GENERAL_OTHER_TYPES: return nil - case U_UPPERCASE_LETTER: self = .uppercaseLetter - case U_LOWERCASE_LETTER: self = .lowercaseLetter - case U_TITLECASE_LETTER: self = .titlecaseLetter - case U_MODIFIER_LETTER: self = .modifierLetter - case U_OTHER_LETTER: self = .otherLetter - case U_NON_SPACING_MARK: self = .nonspacingMark - case U_ENCLOSING_MARK: self = .enclosingMark - case U_COMBINING_SPACING_MARK: self = .spacingMark - case U_DECIMAL_DIGIT_NUMBER: self = .decimalNumber - case U_LETTER_NUMBER: self = .letterNumber - case U_OTHER_NUMBER: self = .otherNumber - case U_SPACE_SEPARATOR: self = .spaceSeparator - case U_LINE_SEPARATOR: self = .lineSeparator - case U_PARAGRAPH_SEPARATOR: self = .paragraphSeparator - case U_CONTROL_CHAR: self = .control - case U_FORMAT_CHAR: self = .format - case U_PRIVATE_USE_CHAR: self = .privateUse - case U_SURROGATE: self = .surrogate - case U_DASH_PUNCTUATION: self = .dashPunctuation - case U_START_PUNCTUATION: self = .openPunctuation - case U_END_PUNCTUATION: self = .closePunctuation - case U_CONNECTOR_PUNCTUATION: self = .connectorPunctuation - case U_OTHER_PUNCTUATION: self = .otherPunctuation - case U_MATH_SYMBOL: self = .mathSymbol - case U_CURRENCY_SYMBOL: self = .currencySymbol - case U_MODIFIER_SYMBOL: self = .modifierSymbol - case U_OTHER_SYMBOL: self = .otherSymbol - case U_INITIAL_PUNCTUATION: self = .initialPunctuation - case U_FINAL_PUNCTUATION: self = .finalPunctuation - default: fatalError("Invalid UCharCategory value: \(cValue)") - } + /// Indicates whether the general category is in the grouping that + /// represents control characters: Cc, Cf, Cs, Co, and Cn. + /// + /// This grouping is abbreviated C in the Unicode standard. + var isControl: Bool { + switch self { + case .control, + .format, + .surrogate, + .privateUse, + .unassigned: + return true + default: return false } } -} -extension UnicodeScalar { - - /// The Unicode general category of the receiving scalar. - public var generalCategory: Unicode.GeneralCategory? { - return value(of: UCHAR_GENERAL_CATEGORY) + /// Creates a new general category value from the given ICU C API value. + /// + /// - Parameter cValue: The ICU C API value. + init?(cValue: UCharCategory) { + switch cValue { + // UNASSIGNED and GENERAL_OTHER_TYPES have the same numeric value (zero) + // so we can't actually distinguish them even though Swift imports them as + // distinct values. + case U_UNASSIGNED, U_GENERAL_OTHER_TYPES: return nil + case U_UPPERCASE_LETTER: self = .uppercaseLetter + case U_LOWERCASE_LETTER: self = .lowercaseLetter + case U_TITLECASE_LETTER: self = .titlecaseLetter + case U_MODIFIER_LETTER: self = .modifierLetter + case U_OTHER_LETTER: self = .otherLetter + case U_NON_SPACING_MARK: self = .nonspacingMark + case U_ENCLOSING_MARK: self = .enclosingMark + case U_COMBINING_SPACING_MARK: self = .spacingMark + case U_DECIMAL_DIGIT_NUMBER: self = .decimalNumber + case U_LETTER_NUMBER: self = .letterNumber + case U_OTHER_NUMBER: self = .otherNumber + case U_SPACE_SEPARATOR: self = .spaceSeparator + case U_LINE_SEPARATOR: self = .lineSeparator + case U_PARAGRAPH_SEPARATOR: self = .paragraphSeparator + case U_CONTROL_CHAR: self = .control + case U_FORMAT_CHAR: self = .format + case U_PRIVATE_USE_CHAR: self = .privateUse + case U_SURROGATE: self = .surrogate + case U_DASH_PUNCTUATION: self = .dashPunctuation + case U_START_PUNCTUATION: self = .openPunctuation + case U_END_PUNCTUATION: self = .closePunctuation + case U_CONNECTOR_PUNCTUATION: self = .connectorPunctuation + case U_OTHER_PUNCTUATION: self = .otherPunctuation + case U_MATH_SYMBOL: self = .mathSymbol + case U_CURRENCY_SYMBOL: self = .currencySymbol + case U_MODIFIER_SYMBOL: self = .modifierSymbol + case U_OTHER_SYMBOL: self = .otherSymbol + case U_INITIAL_PUNCTUATION: self = .initialPunctuation + case U_FINAL_PUNCTUATION: self = .finalPunctuation + default: fatalError("Invalid UCharCategory value: \(cValue)") + } } } diff --git a/Sources/ICU/ScriptCode.swift b/Sources/ICU/ScriptCode.swift index 7a3b1b6..5e1233f 100644 --- a/Sources/ICU/ScriptCode.swift +++ b/Sources/ICU/ScriptCode.swift @@ -792,7 +792,7 @@ extension Unicode { var error = UErrorCode() var buffer = UnsafeMutablePointer.allocate( capacity: sampleStringBufferLength) - defer { buffer.deallocate(capacity: sampleStringBufferLength) } + defer { buffer.deallocate() } let length = uscript_getSampleString( cValue, @@ -1069,7 +1069,7 @@ extension UnicodeScalar { var error = UErrorCode() var buffer = UnsafeMutablePointer.allocate( capacity: scriptExtensionsBufferLength) - defer { buffer.deallocate(capacity: scriptExtensionsBufferLength) } + defer { buffer.deallocate() } let length = uscript_getScriptExtensions( uchar32Value, diff --git a/Sources/ICU/UnicodeScalar+Casing.swift b/Sources/ICU/UnicodeScalar+Casing.swift index 279b587..96c85d8 100644 --- a/Sources/ICU/UnicodeScalar+Casing.swift +++ b/Sources/ICU/UnicodeScalar+Casing.swift @@ -14,7 +14,7 @@ import ICU4C -public extension UnicodeScalar { +extension UnicodeScalar { /// Returns the lowercase equivalent of the receiving scalar, or the scalar /// itself if it has no lowercase equivalent. diff --git a/Sources/ICU/UnicodeScalar+Miscellaneous.swift b/Sources/ICU/UnicodeScalar+Miscellaneous.swift index c9caecf..3e84cc1 100644 --- a/Sources/ICU/UnicodeScalar+Miscellaneous.swift +++ b/Sources/ICU/UnicodeScalar+Miscellaneous.swift @@ -14,7 +14,7 @@ import ICU4C -public extension UnicodeScalar { +extension UnicodeScalar { /// The canonical combining class of the receiving scalar. public var canonicalCombiningClass: Int { diff --git a/Sources/ICU/UnicodeScalar+Naming.swift b/Sources/ICU/UnicodeScalar+Naming.swift index 4dbdf31..913f882 100644 --- a/Sources/ICU/UnicodeScalar+Naming.swift +++ b/Sources/ICU/UnicodeScalar+Naming.swift @@ -42,7 +42,7 @@ extension Unicode { } } -public extension UnicodeScalar { +extension UnicodeScalar { /// Creates a new Unicode scalar with the given name. /// @@ -76,7 +76,7 @@ public extension UnicodeScalar { var error = UErrorCode() var buffer = UnsafeMutablePointer.allocate( capacity: charNameBufferLength) - defer { buffer.deallocate(capacity: charNameBufferLength) } + defer { buffer.deallocate() } let length = u_charName( uchar32Value, diff --git a/Sources/ICU/UnicodeScalar+Numeric.swift b/Sources/ICU/UnicodeScalar+Numeric.swift index 3df3932..902b953 100644 --- a/Sources/ICU/UnicodeScalar+Numeric.swift +++ b/Sources/ICU/UnicodeScalar+Numeric.swift @@ -14,7 +14,7 @@ import ICU4C -public extension UnicodeScalar { +extension UnicodeScalar { /// Returns the decimal digit value of the receiving scalar in the given /// radix. diff --git a/Sources/ICU/UnicodeVersion.swift b/Sources/ICU/UnicodeVersion.swift deleted file mode 100644 index 349057d..0000000 --- a/Sources/ICU/UnicodeVersion.swift +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2017 Tony Allevato. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import ICU4C - -extension Unicode { - - /// A four-component version value. These values are used to represent, for - /// example, the Unicode version at which a code point was introduced. - /// - /// Values of this type support comparison (equality and ordering) and can be - /// converted to/from human-readable strings. - /// - /// See also `UnicodeScalar.unicodeAge`. - public struct Version { - - /// The underlying C value representing the version. - private(set) var cValue: UVersionInfo - - /// The major component of the version. - public var major: Int { - return Int(cValue.0) - } - - /// The minor component of the version. - public var minor: Int { - return Int(cValue.1) - } - - /// The patch level component of the version. - public var patchLevel: Int { - return Int(cValue.2) - } - - /// The build level component of the version. - public var buildLevel: Int { - return Int(cValue.3) - } - - /// Creates a new Unicode version value with the given components. - /// - /// - Precondition: All components must be in the range `0...255`. - /// - /// - Parameters: - /// - major: The major component. - /// - minor: The minor component. - /// - patchLevel: The patch level component. - /// - buildLevel: The build level component. - public init( - major: Int, - minor: Int = 0, - patchLevel: Int = 0, - buildLevel: Int = 0 - ) { - precondition((0...255).contains(major) && - (0...255).contains(minor) && - (0...255).contains(patchLevel) && - (0...255).contains(buildLevel), - "Version components must be in the range 0...255.") - self.cValue.0 = UInt8(truncatingIfNeeded: major) - self.cValue.1 = UInt8(truncatingIfNeeded: minor) - self.cValue.2 = UInt8(truncatingIfNeeded: patchLevel) - self.cValue.3 = UInt8(truncatingIfNeeded: buildLevel) - } - - /// Creates a new Unicode version value equivalent to the given C value. - /// - /// - Parameter cValue: The C value to be wrapped. - init(cValue: UVersionInfo) { - self.cValue = cValue - } - - /// Invokes the given closure with an immutable `UInt8` pointer to the - /// underlying C value. - /// - /// - Parameter body: A closure that takes an immutable pointer to the - /// underlying C value as its sole argument, represented as a pointer to - /// `UInt8`. - /// - Returns: The return value of the `body` closure, if any. - /// - Throws: The error thrown by the `body` closure, if any. - func withUnsafeUInt8Pointer( - _ body: (UnsafePointer) throws -> Result - ) rethrows -> Result { - var valueCopy = cValue - return try withUnsafePointer(to: &valueCopy) { pointer in - return try pointer.withMemoryRebound( - to: UInt8.self, - capacity: MemoryLayout.size - ) { pointer in - return try body(pointer) - } - } - } - - /// Invokes the given closure with a mutable `UInt8` pointer to the - /// underlying C value. - /// - /// - Parameter body: A closure that takes a mutable pointer to the - /// underlying C value its sole argument, represented as a pointer to - /// `UInt8`. - /// - Returns: The return value of the `body` closure, if any. - /// - Throws: The error thrown by the `body` closure, if any. - mutating func withUnsafeMutableUInt8Pointer( - _ body: (UnsafeMutablePointer) throws -> Result - ) rethrows -> Result { - return try withUnsafeMutablePointer(to: &cValue) { pointer in - return try pointer.withMemoryRebound( - to: UInt8.self, - capacity: MemoryLayout.size - ) { pointer in - return try body(pointer) - } - } - } - - /// Performs a three-way comparison of the receiver with another version. - /// - /// - Parameter other: Another version. - /// - Returns: Zero if the receiver is equal to `other`, a negative number - /// if the receiver is ordered before `other`, or a positive number if the - /// receiver is ordered after `other`. - fileprivate func threeWayCompare(to other: Unicode.Version) -> Int { - var lhsValue = cValue - var rhsValue = other.cValue - - let result = withUnsafeBytes(of: &lhsValue) { lhsBuffer in - return withUnsafeBytes(of: &rhsValue) { rhsBuffer in - return memcmp(lhsBuffer.baseAddress!, - rhsBuffer.baseAddress!, - MemoryLayout.size) - } - } - return Int(result) - } - } -} - -extension Unicode.Version: Comparable { - - /// Returns a value indicating whether the first version is less than the - /// second version. - /// - /// - Parameters: - /// - lhs: A version. - /// - rhs: A version. - /// - Returns: True if the first version is less than the second version, or - /// false otherwise. - public static func < (lhs: Unicode.Version, rhs: Unicode.Version) -> Bool { - return lhs.threeWayCompare(to: rhs) < 0 - } -} - -extension Unicode.Version: Equatable { - - /// Returns a value indicating whether two versions are equal. - /// - /// - Parameters: - /// - lhs: A version. - /// - rhs: A version. - /// - Returns: True if the versions are equal, or false otherwise. - public static func == (lhs: Unicode.Version, rhs: Unicode.Version) -> Bool { - return lhs.threeWayCompare(to: rhs) == 0 - } -} - -extension Unicode.Version: LosslessStringConvertible { - - /// A string representation of the version, in the form - /// `major.minor.patch.buildLevel` (trailing zero components are omitted). - public var description: String { - let capacity = Int(U_MAX_VERSION_STRING_LENGTH) - let stringPointer = UnsafeMutablePointer.allocate(capacity: capacity) - defer { stringPointer.deallocate(capacity: capacity) } - - withUnsafeUInt8Pointer { versionPointer in - u_versionToString(versionPointer, stringPointer) - } - - return String(cString: stringPointer) - } - - /// Creates a new `UnicodeVersion` by parsing the given string. - /// - /// Since the underlying ICU API does not provide error reporting, this - /// initializer never fails. Instead, for values of `description` that do not - /// meet the standard version string format, the created value is undefined. - /// - /// - Parameter description: A string representation of a version containing - /// between 1 and 4 components separated by dots, where each component is an - /// integer in the range `0...255`. - public init(_ description: String) { - var cValue: UVersionInfo = (0, 0, 0, 0) - description.withCString { stringPointer in - withUnsafeMutablePointer(to: &cValue) { pointer in - pointer.withMemoryRebound( - to: UInt8.self, - capacity: MemoryLayout.size - ) { pointer in - u_versionFromString(pointer, stringPointer) - } - } - } - self.init(cValue: cValue) - } -} - -extension UnicodeScalar { - - /// The Unicode version in which the receiving scalar was first defined. - public var unicodeAge: Unicode.Version { - var version = Unicode.Version(major: 0) - version.withUnsafeMutableUInt8Pointer { pointer in - u_charAge(uchar32Value, pointer) - } - return version - } -} diff --git a/Sources/ICU/UnsafeMutableBufferPointer+Deallocate.swift b/Sources/ICU/UnsafeMutableBufferPointer+Deallocate.swift deleted file mode 100644 index cd83056..0000000 --- a/Sources/ICU/UnsafeMutableBufferPointer+Deallocate.swift +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 Tony Allevato. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import ICU4C - -extension UnsafeMutableBufferPointer { - - /// Deallocates the member underlying this buffer pointer. - internal func deallocate() { - baseAddress!.deallocate(capacity: count) - } -} diff --git a/Sources/ICU4C/module.modulemap b/Sources/ICU4C/module.modulemap new file mode 100644 index 0000000..dc3cb22 --- /dev/null +++ b/Sources/ICU4C/module.modulemap @@ -0,0 +1,5 @@ +module ICU4C { + header "umbrella.h" + link "icucore" + export * +} diff --git a/Sources/ICU4C/umbrella.h b/Sources/ICU4C/umbrella.h new file mode 100644 index 0000000..17d9f4f --- /dev/null +++ b/Sources/ICU4C/umbrella.h @@ -0,0 +1,69 @@ +// Copyright 2017 Tony Allevato. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Ensure that the imported symbols don't have version number suffixes. +#define U_DISABLE_RENAMING 1 + +// Only the files defining (non-deprecated) C APIs are included below. C++ APIs +// are excluded, as they would not be imported into Swift. +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import diff --git a/Tests/ICUTests/TestSupport.swift b/Tests/ICUTests/TestSupport.swift index 30ae1e1..f4d9004 100644 --- a/Tests/ICUTests/TestSupport.swift +++ b/Tests/ICUTests/TestSupport.swift @@ -25,7 +25,7 @@ import XCTest /// `index`. func assertIndex( _ index: C.Index?, - isDistance distance: C.IndexDistance, + isDistance distance: Int, fromStartOf collection: C, file: StaticString = #file, line: UInt = #line