mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[stdlib] Unicode[Encoding|Parser] => Unicode.[Encoding|Parser]
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
public protocol _UnicodeEncoding {
|
||||
public protocol _UnicodeEncoding_ {
|
||||
/// The basic unit of encoding
|
||||
associatedtype CodeUnit : UnsignedInteger, FixedWidthInteger
|
||||
|
||||
@@ -37,18 +37,18 @@ public protocol _UnicodeEncoding {
|
||||
///
|
||||
/// A default implementation of this method will be provided
|
||||
/// automatically for any conforming type that does not implement one.
|
||||
static func transcode<FromEncoding : UnicodeEncoding>(
|
||||
static func transcode<FromEncoding : Unicode.Encoding>(
|
||||
_ content: FromEncoding.EncodedScalar, from _: FromEncoding.Type
|
||||
) -> EncodedScalar?
|
||||
|
||||
/// A type that can be used to parse `CodeUnits` into
|
||||
/// `EncodedScalar`s.
|
||||
associatedtype ForwardParser : UnicodeParser
|
||||
associatedtype ForwardParser : Unicode.Parser
|
||||
// where ForwardParser.Encoding == Self
|
||||
|
||||
/// A type that can be used to parse a reversed sequence of
|
||||
/// `CodeUnits` into `EncodedScalar`s.
|
||||
associatedtype ReverseParser : UnicodeParser
|
||||
associatedtype ReverseParser : Unicode.Parser
|
||||
// where ReverseParser.Encoding == Self
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
@@ -60,16 +60,16 @@ public protocol _UnicodeEncoding {
|
||||
static func _isScalar(_ x: CodeUnit) -> Bool
|
||||
}
|
||||
|
||||
extension _UnicodeEncoding {
|
||||
extension _UnicodeEncoding_ {
|
||||
// See note on declaration of requirement, above
|
||||
public static func _isScalar(_ x: CodeUnit) -> Bool { return false }
|
||||
}
|
||||
|
||||
public protocol UnicodeEncoding : _UnicodeEncoding
|
||||
public protocol _UnicodeEncoding : _UnicodeEncoding_
|
||||
where ForwardParser.Encoding == Self, ReverseParser.Encoding == Self {}
|
||||
|
||||
extension _UnicodeEncoding {
|
||||
public static func transcode<FromEncoding : UnicodeEncoding>(
|
||||
extension _UnicodeEncoding_ {
|
||||
public static func transcode<FromEncoding : Unicode.Encoding>(
|
||||
_ content: FromEncoding.EncodedScalar, from _: FromEncoding.Type
|
||||
) -> EncodedScalar? {
|
||||
return encode(FromEncoding.decode(content))
|
||||
@@ -85,9 +85,14 @@ extension _UnicodeEncoding {
|
||||
/// Converts a scalar from another encoding's representation, returning
|
||||
/// `encodedReplacementCharacter` if the scalar can't be represented in this
|
||||
/// encoding.
|
||||
internal static func _transcode<FromEncoding : UnicodeEncoding>(
|
||||
internal static func _transcode<FromEncoding : Unicode.Encoding>(
|
||||
_ content: FromEncoding.EncodedScalar, from _: FromEncoding.Type
|
||||
) -> EncodedScalar {
|
||||
return _encode(FromEncoding.decode(content))
|
||||
}
|
||||
}
|
||||
|
||||
extension Unicode {
|
||||
public typealias Encoding = _UnicodeEncoding
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user