Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmark/single-source/CharacterProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -48,7 +48,7 @@ public let CharacterPropertiesPrecomputed = BenchmarkInfo(
legacyFactor: 10)

extension Character {
var firstScalar: UnicodeScalar { return unicodeScalars.first! }
var firstScalar: Unicode.Scalar { return unicodeScalars.first! }
}


Expand Down Expand Up @@ -263,7 +263,7 @@ func precompute(_ charSet: CharacterSet, capacity: Int) -> Set<UInt32> {
guard charSet.hasMember(inPlane: UInt8(plane)) else { continue }
let offset = plane &* 0x1_0000
for codePoint in 0...0xFFFF {
guard let scalar = UnicodeScalar(codePoint &+ offset) else { continue }
guard let scalar = Unicode.Scalar(codePoint &+ offset) else { continue }
if charSet.contains(scalar) {
result.insert(scalar.value)
}
Expand Down
6 changes: 3 additions & 3 deletions benchmark/single-source/CharacterProperties.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -49,7 +49,7 @@ public let CharacterPropertiesPrecomputed = BenchmarkInfo(
legacyFactor: 10)

extension Character {
var firstScalar: UnicodeScalar { return unicodeScalars.first! }
var firstScalar: Unicode.Scalar { return unicodeScalars.first! }
}

% Properties = { "Alphanumeric": "alphanumerics", \
Expand Down Expand Up @@ -114,7 +114,7 @@ func precompute(_ charSet: CharacterSet, capacity: Int) -> Set<UInt32> {
guard charSet.hasMember(inPlane: UInt8(plane)) else { continue }
let offset = plane &* 0x1_0000
for codePoint in 0...0xFFFF {
guard let scalar = UnicodeScalar(codePoint &+ offset) else { continue }
guard let scalar = Unicode.Scalar(codePoint &+ offset) else { continue }
if charSet.contains(scalar) {
result.insert(scalar.value)
}
Expand Down
4 changes: 2 additions & 2 deletions benchmark/single-source/DataBenchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -534,7 +534,7 @@ public func setCount(_ N: Int, data: Data, extra: Int) {
@inline(never)
public func string(_ N: Int, from data: Data) {
for _ in 1...N {
blackHole(String(decoding: data, as: UTF8.self))
blackHole(String(decoding: data, as: Unicode.UTF8.self))
}
}

Expand Down
16 changes: 8 additions & 8 deletions benchmark/single-source/UTF8Decode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -115,7 +115,7 @@ public func run_UTF8Decode(_ N: Int) {
for _ in 1...200*N {
for string in strings {
var it = string.makeIterator()
var utf8 = UTF8()
var utf8 = Unicode.UTF8()
while !isEmpty(utf8.decode(&it)) { }
}
}
Expand All @@ -132,7 +132,7 @@ public func run_UTF8Decode_InitFromData(_ N: Int) {
public func run_UTF8Decode_InitDecoding(_ N: Int) {
let input = allStringsBytes
for _ in 0..<200*N {
blackHole(String(decoding: input, as: UTF8.self))
blackHole(String(decoding: input, as: Unicode.UTF8.self))
}
}
@inline(never)
Expand All @@ -154,7 +154,7 @@ public func run_UTF8Decode_InitFromData_ascii(_ N: Int) {
public func run_UTF8Decode_InitDecoding_ascii(_ N: Int) {
let input = asciiBytes
for _ in 0..<1_000*N {
blackHole(String(decoding: input, as: UTF8.self))
blackHole(String(decoding: input, as: Unicode.UTF8.self))
}
}
@inline(never)
Expand Down Expand Up @@ -232,14 +232,14 @@ let asciiCustomNoncontiguous = CustomNoncontiguousCollection(Array(ascii.utf8))
public func run_UTF8Decode_InitFromCustom_contiguous(_ N: Int) {
let input = allStringsCustomContiguous
for _ in 0..<200*N {
blackHole(String(decoding: input, as: UTF8.self))
blackHole(String(decoding: input, as: Unicode.UTF8.self))
}
}
@inline(never)
public func run_UTF8Decode_InitFromCustom_contiguous_ascii(_ N: Int) {
let input = asciiCustomContiguous
for _ in 0..<1_000*N {
blackHole(String(decoding: input, as: UTF8.self))
blackHole(String(decoding: input, as: Unicode.UTF8.self))
}
}
@inline(never)
Expand All @@ -254,14 +254,14 @@ public func run_UTF8Decode_InitFromCustom_contiguous_ascii_as_ascii(_ N: Int) {
public func run_UTF8Decode_InitFromCustom_noncontiguous(_ N: Int) {
let input = allStringsCustomNoncontiguous
for _ in 0..<200*N {
blackHole(String(decoding: input, as: UTF8.self))
blackHole(String(decoding: input, as: Unicode.UTF8.self))
}
}
@inline(never)
public func run_UTF8Decode_InitFromCustom_noncontiguous_ascii(_ N: Int) {
let input = asciiCustomNoncontiguous
for _ in 0..<1_000*N {
blackHole(String(decoding: input, as: UTF8.self))
blackHole(String(decoding: input, as: Unicode.UTF8.self))
}
}
@inline(never)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/private/StdlibUnittest/StdlibUnittest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,10 @@ func _stdlib_getline() -> String? {
if result.isEmpty {
return nil
}
return String(decoding: result, as: UTF8.self)
return String(decoding: result, as: Unicode.UTF8.self)
}
if c == CInt(Unicode.Scalar("\n").value) {
return String(decoding: result, as: UTF8.self)
return String(decoding: result, as: Unicode.UTF8.self)
}
result.append(UInt8(c))
}
Expand Down
10 changes: 5 additions & 5 deletions stdlib/private/SwiftPrivate/IO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -37,13 +37,13 @@ public struct _FDInputStream {
// on that and remove the workaround in the test harness
if let index =
_buffer[0..<_offset].firstIndex(of: UInt8(Unicode.Scalar("\n").value)) {
let result = String(decoding: _buffer[0..<index], as: UTF8.self)
let result = String(decoding: _buffer[0..<index], as: Unicode.UTF8.self)
_buffer.removeSubrange(0...index)
_offset -= index + 1
return result
}
if isEOF && _offset > 0 {
let result = String(decoding: _buffer[0..<_offset], as: UTF8.self)
let result = String(decoding: _buffer[0..<_offset], as: Unicode.UTF8.self)
_buffer.removeAll()
_offset = 0
return result
Expand Down Expand Up @@ -94,13 +94,13 @@ public struct _FDInputStream {
public mutating func getline() -> String? {
if let newlineIndex =
_buffer[0..<_bufferUsed].firstIndex(of: UInt8(Unicode.Scalar("\n").value)) {
let result = String(decoding: _buffer[0..<newlineIndex], as: UTF8.self)
let result = String(decoding: _buffer[0..<newlineIndex], as: Unicode.UTF8.self)
_buffer.removeSubrange(0...newlineIndex)
_bufferUsed -= newlineIndex + 1
return result
}
if isEOF && _bufferUsed > 0 {
let result = String(decoding: _buffer[0..<_bufferUsed], as: UTF8.self)
let result = String(decoding: _buffer[0..<_bufferUsed], as: Unicode.UTF8.self)
_buffer.removeAll()
_bufferUsed = 0
return result
Expand Down
4 changes: 2 additions & 2 deletions stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -105,7 +105,7 @@ public func spawnChild(_ args: [String])
// for more details on how to properly quote the command line for Windows.
let command: String =
([CommandLine.arguments[0]] + args).joined(separator: " ")
command.withCString(encodedAs: UTF16.self) { cString in
command.withCString(encodedAs: Unicode.UTF16.self) { cString in
if !CreateProcessW(nil, UnsafeMutablePointer<WCHAR>(mutating: cString),
nil, nil, true, 0, nil, nil,
&siStartupInfo, &piProcessInfo) {
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/Darwin/Foundation/NSStringAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -73,7 +73,7 @@ internal func _persistCString(_ p: UnsafePointer<CChar>?) -> [CChar]? {
guard let cString = p else {
return nil
}
let bytesToCopy = UTF8._nullCodeUnitOffset(in: cString) + 1 // +1 for the terminating NUL
let bytesToCopy = Unicode.UTF8._nullCodeUnitOffset(in: cString) + 1 // +1 for the terminating NUL
let result = [CChar](unsafeUninitializedCapacity: bytesToCopy) { buffer, initializedCount in
buffer.baseAddress!.initialize(from: cString, count: bytesToCopy)
initializedCount = bytesToCopy
Expand Down
12 changes: 6 additions & 6 deletions stdlib/public/core/ASCII.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand All @@ -25,7 +25,7 @@ extension Unicode.ASCII: Unicode.Encoding {

/// Returns whether the given code unit represents an ASCII scalar
@_alwaysEmitIntoClient
public static func isASCII(_ x: CodeUnit) -> Bool { return UTF8.isASCII(x) }
public static func isASCII(_ x: CodeUnit) -> Bool { Unicode.UTF8.isASCII(x) }

@inline(__always)
@inlinable
Expand Down Expand Up @@ -54,13 +54,13 @@ extension Unicode.ASCII: Unicode.Encoding {
public static func transcode<FromEncoding: Unicode.Encoding>(
_ content: FromEncoding.EncodedScalar, from _: FromEncoding.Type
) -> EncodedScalar? {
if _fastPath(FromEncoding.self == UTF16.self) {
let c = _identityCast(content, to: UTF16.EncodedScalar.self)
if _fastPath(FromEncoding.self == Unicode.UTF16.self) {
let c = _identityCast(content, to: Unicode.UTF16.EncodedScalar.self)
guard (c._storage & 0xFF80 == 0) else { return nil }
return EncodedScalar(CodeUnit(c._storage & 0x7f))
}
else if _fastPath(FromEncoding.self == UTF8.self) {
let c = _identityCast(content, to: UTF8.EncodedScalar.self)
else if _fastPath(FromEncoding.self == Unicode.UTF8.self) {
let c = _identityCast(content, to: Unicode.UTF8.EncodedScalar.self)
let first = c.first.unsafelyUnwrapped
guard (first < 0x80) else { return nil }
return EncodedScalar(CodeUnit(first))
Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/core/CString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -44,7 +44,7 @@ extension String {
///
/// - Parameter cString: A pointer to a null-terminated UTF-8 code sequence.
public init(cString: UnsafePointer<CChar>) {
let len = UTF8._nullCodeUnitOffset(in: cString)
let len = Unicode.UTF8._nullCodeUnitOffset(in: cString)
self = String._fromUTF8Repairing(
UnsafeBufferPointer(start: cString._asUInt8, count: len)).0
}
Expand All @@ -55,7 +55,7 @@ extension String {
/// This is identical to `init(cString: UnsafePointer<CChar>)` but operates on
/// an unsigned sequence of bytes.
public init(cString: UnsafePointer<UInt8>) {
let len = UTF8._nullCodeUnitOffset(in: cString)
let len = Unicode.UTF8._nullCodeUnitOffset(in: cString)
self = String._fromUTF8Repairing(
UnsafeBufferPointer(start: cString, count: len)).0
}
Expand Down Expand Up @@ -87,7 +87,7 @@ extension String {
///
/// - Parameter cString: A pointer to a null-terminated UTF-8 code sequence.
public init?(validatingUTF8 cString: UnsafePointer<CChar>) {
let len = UTF8._nullCodeUnitOffset(in: cString)
let len = Unicode.UTF8._nullCodeUnitOffset(in: cString)
guard let str = String._tryFromUTF8(
UnsafeBufferPointer(start: cString._asUInt8, count: len))
else { return nil }
Expand All @@ -110,7 +110,7 @@ extension String {
/// let validUTF8: [UInt8] = [67, 97, 102, 195, 169, 0]
/// validUTF8.withUnsafeBufferPointer { ptr in
/// let s = String.decodeCString(ptr.baseAddress,
/// as: UTF8.self,
/// as: Unicode.UTF8.self,
/// repairingInvalidCodeUnits: true)
/// print(s)
/// }
Expand All @@ -119,7 +119,7 @@ extension String {
/// let invalidUTF8: [UInt8] = [67, 97, 102, 195, 0]
/// invalidUTF8.withUnsafeBufferPointer { ptr in
/// let s = String.decodeCString(ptr.baseAddress,
/// as: UTF8.self,
/// as: Unicode.UTF8.self,
/// repairingInvalidCodeUnits: true)
/// print(s)
/// }
Expand Down Expand Up @@ -149,7 +149,7 @@ extension String {

if _fastPath(encoding == Unicode.UTF8.self) {
let ptr = UnsafeRawPointer(cPtr).assumingMemoryBound(to: UInt8.self)
let len = UTF8._nullCodeUnitOffset(in: ptr)
let len = Unicode.UTF8._nullCodeUnitOffset(in: ptr)
let codeUnits = UnsafeBufferPointer(start: ptr, count: len)
if isRepairing {
return String._fromUTF8Repairing(codeUnits)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/FloatingPointParsing.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -33,7 +33,7 @@ cFuncSuffix2 = {16: 'f16', 32: 'f', 64: 'd', 80: 'ld'}
/// Returns `true` iff isspace(u) would return nonzero when the current
/// locale is the C locale.
@inlinable // FIXME(sil-serialize-all)
internal func _isspace_clocale(_ u: UTF16.CodeUnit) -> Bool {
internal func _isspace_clocale(_ u: Unicode.UTF16.CodeUnit) -> Bool {
return "\t\n\u{b}\u{c}\r ".utf16.contains(u)
}

Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/IntegerParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

/// Returns c as a UTF16.CodeUnit. Meant to be used as _ascii16("x").
/// Returns c as a Unicode.UTF16.CodeUnit. Meant to be used as _ascii16("x").
@inlinable
internal func _ascii16(_ c: Unicode.Scalar) -> UTF16.CodeUnit {
internal func _ascii16(_ c: Unicode.Scalar) -> Unicode.UTF16.CodeUnit {
_internalInvariant(c.value >= 0 && c.value <= 0x7F, "not ASCII")
return UTF16.CodeUnit(c.value)
return Unicode.UTF16.CodeUnit(c.value)
}

@inlinable
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/LegacyABI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -30,7 +30,7 @@ internal func _isASCII(_ x: UInt8) -> Bool {
@available(*, unavailable, renamed: "Unicode.UTF8.isContinuation")
@inlinable
internal func _isContinuation(_ x: UInt8) -> Bool {
return UTF8.isContinuation(x)
return Unicode.UTF8.isContinuation(x)
}

extension Substring {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/ReflectionMirror.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extension Mirror {
}

let rawDisplayStyle = _getDisplayStyle(subject)
switch UnicodeScalar(Int(rawDisplayStyle)) {
switch Unicode.Scalar(Int(rawDisplayStyle)) {
case "c": self.displayStyle = .class
case "e": self.displayStyle = .enum
case "s": self.displayStyle = .struct
Expand Down
Loading