Skip to content

Finish String and Unicode ABI audit #20605

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

Merged
merged 4 commits into from
Nov 15, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdlib/public/core/ASCII.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension Unicode.ASCII : Unicode.Encoding {
public typealias CodeUnit = UInt8
public typealias EncodedScalar = CollectionOfOne<CodeUnit>

@inlinable // FIXME(sil-serialize-all)
@inlinable
public static var encodedReplacementCharacter : EncodedScalar {
return EncodedScalar(0x1a) // U+001A SUBSTITUTE; best we can do for ASCII
}
Expand Down Expand Up @@ -46,7 +46,7 @@ extension Unicode.ASCII : Unicode.Encoding {
}

@inline(__always)
@inlinable // FIXME(sil-serialize-all)
@inlinable
public static func transcode<FromEncoding : Unicode.Encoding>(
_ content: FromEncoding.EncodedScalar, from _: FromEncoding.Type
) -> EncodedScalar? {
Expand All @@ -64,9 +64,9 @@ extension Unicode.ASCII : Unicode.Encoding {
return encode(FromEncoding.decode(content))
}

@_fixed_layout // FIXME(sil-serialize-all)
@_fixed_layout
public struct Parser {
@inlinable // FIXME(sil-serialize-all)
@inlinable
public init() { }
}

Expand All @@ -78,7 +78,7 @@ extension Unicode.ASCII.Parser : Unicode.Parser {
public typealias Encoding = Unicode.ASCII

/// Parses a single Unicode scalar value from `input`.
@inlinable // FIXME(sil-serialize-all)
@inlinable
public mutating func parseScalar<I : IteratorProtocol>(
from input: inout I
) -> Unicode.ParseResult<Encoding.EncodedScalar>
Expand Down
3 changes: 0 additions & 3 deletions stdlib/public/core/ICU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
import SwiftShims

extension __swift_stdlib_UErrorCode {
@inlinable // FIXME(sil-serialize-all)
internal var isFailure: Bool {
return rawValue > __swift_stdlib_U_ZERO_ERROR.rawValue
}
@inlinable // FIXME(sil-serialize-all)
internal var isWarning: Bool {
return rawValue < __swift_stdlib_U_ZERO_ERROR.rawValue
}
@inlinable // FIXME(sil-serialize-all)
internal var isSuccess: Bool {
return rawValue <= __swift_stdlib_U_ZERO_ERROR.rawValue
}
Expand Down
7 changes: 7 additions & 0 deletions stdlib/public/core/IntegerParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
//
//===----------------------------------------------------------------------===//

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

@inlinable
@inline(__always)
internal func _asciiDigit<CodeUnit : UnsignedInteger, Result : BinaryInteger>(
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/StringIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ the default value being `0`.
*/
extension String {
/// A position of a character or code unit in a string.
@_fixed_layout // FIXME(sil-serialize-all)
@_fixed_layout
public struct Index {
@usableFromInline
internal var _rawBits: UInt64
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/StringIndexConversions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ extension String.Index {
/// If this index does not have an exact corresponding position in `utf8`,
/// this method returns `nil`. For example, an attempt to convert the
/// position of a UTF-16 trailing surrogate returns `nil`.
@inlinable // FIXME(sil-serialize-all)
public func samePosition(
in utf8: String.UTF8View
) -> String.UTF8View.Index? {
Expand Down Expand Up @@ -108,7 +107,6 @@ extension String.Index {
/// index. If this index does not have an exact corresponding position in
/// `utf16`, this method returns `nil`. For example, an attempt to convert
/// the position of a UTF-8 continuation byte returns `nil`.
@inlinable // FIXME(sil-serialize-all)
public func samePosition(
in utf16: String.UTF16View
) -> String.UTF16View.Index? {
Expand Down
11 changes: 5 additions & 6 deletions stdlib/public/core/StringUTF16View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ extension String {
/// print(snowy[range])
/// }
/// // Prints "Let it snow!"
@_fixed_layout // FIXME(sil-serialize-all)
@_fixed_layout
public struct UTF16View {
@usableFromInline
internal var _guts: _StringGuts

@inlinable // FIXME(sil-serialize-all)
@inlinable
internal init(_ guts: _StringGuts) {
self._guts = guts
_invariantCheck()
Expand All @@ -127,7 +127,7 @@ extension String.UTF16View: BidirectionalCollection {

/// The position of the first code unit if the `String` is
/// nonempty; identical to `endIndex` otherwise.
@inlinable // FIXME(sil-serialize-all)
@inlinable
public var startIndex: Index {
@inline(__always) get { return _guts.startIndex }
}
Expand All @@ -136,7 +136,7 @@ extension String.UTF16View: BidirectionalCollection {
/// the last valid subscript argument.
///
/// In an empty UTF-16 view, `endIndex` is equal to `startIndex`.
@inlinable // FIXME(sil-serialize-all)
@inlinable
public var endIndex: Index {
@inline(__always) get { return _guts.endIndex }
}
Expand Down Expand Up @@ -280,7 +280,7 @@ extension String.UTF16View: CustomDebugStringConvertible {

extension String {
/// A UTF-16 encoding of `self`.
@inlinable // FIXME(sil-serialize-all)
@inlinable
public var utf16: UTF16View {
@inline(__always) get { return UTF16View(_guts) }
@inline(__always) set { self = String(newValue._guts) }
Expand Down Expand Up @@ -356,7 +356,6 @@ extension String.UTF16View.Index {
/// position in `unicodeScalars`, this method returns `nil`. For example,
/// an attempt to convert the position of a UTF-16 trailing surrogate
/// returns `nil`.
@inlinable // FIXME(sil-serialize-all)
public func samePosition(
in unicodeScalars: String.UnicodeScalarView
) -> String.UnicodeScalarIndex? {
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/Substring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ extension Substring : LosslessStringConvertible {
}

extension Substring {
@_fixed_layout // FIXME(sil-serialize-all)
@_fixed_layout
public struct UTF8View {
@usableFromInline // FIXME(sil-serialize-all)
@usableFromInline
internal var _slice: Slice<String.UTF8View>
}
}
Expand Down Expand Up @@ -390,12 +390,12 @@ extension Substring.UTF8View : BidirectionalCollection {
return _slice.distance(from: start, to: end)
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
public func _failEarlyRangeCheck(_ index: Index, bounds: Range<Index>) {
_slice._failEarlyRangeCheck(index, bounds: bounds)
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
public func _failEarlyRangeCheck(
_ range: Range<Index>, bounds: Range<Index>
) {
Expand Down
58 changes: 28 additions & 30 deletions stdlib/public/core/UIntBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@
//
//===----------------------------------------------------------------------===//
@_fixed_layout
public struct _UIntBuffer<
Storage: UnsignedInteger & FixedWidthInteger,
Element: UnsignedInteger & FixedWidthInteger
> {
public struct _UIntBuffer<Element: UnsignedInteger & FixedWidthInteger> {
public typealias Storage = UInt32
public var _storage: Storage
public var _bitCount: UInt8

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public init(_storage: Storage, _bitCount: UInt8) {
self._storage = _storage
self._bitCount = _bitCount
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public init(containing e: Element) {
_storage = Storage(truncatingIfNeeded: e)
Expand All @@ -42,11 +40,11 @@ extension _UIntBuffer : Sequence {

@_fixed_layout
public struct Iterator : IteratorProtocol, Sequence {
@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public init(_ x: _UIntBuffer) { _impl = x }

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public mutating func next() -> Element? {
if _impl._bitCount == 0 { return nil }
Expand All @@ -60,56 +58,56 @@ extension _UIntBuffer : Sequence {
var _impl: _UIntBuffer
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public func makeIterator() -> Iterator {
return Iterator(self)
}
}

extension _UIntBuffer : Collection {
@_fixed_layout // FIXME(sil-serialize-all)
@_fixed_layout
public struct Index : Comparable {
@usableFromInline
internal var bitOffset: UInt8

@inlinable // FIXME(sil-serialize-all)
@inlinable
internal init(bitOffset: UInt8) { self.bitOffset = bitOffset }

@inlinable // FIXME(sil-serialize-all)
@inlinable
public static func == (lhs: Index, rhs: Index) -> Bool {
return lhs.bitOffset == rhs.bitOffset
}
@inlinable // FIXME(sil-serialize-all)
@inlinable
public static func < (lhs: Index, rhs: Index) -> Bool {
return lhs.bitOffset < rhs.bitOffset
}
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
public var startIndex : Index {
@inline(__always)
get { return Index(bitOffset: 0) }
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
public var endIndex : Index {
@inline(__always)
get { return Index(bitOffset: _bitCount) }
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public func index(after i: Index) -> Index {
return Index(bitOffset: i.bitOffset &+ _elementWidth)
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
internal var _elementWidth : UInt8 {
return UInt8(truncatingIfNeeded: Element.bitWidth)
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
public subscript(i: Index) -> Element {
@inline(__always)
get {
Expand All @@ -119,7 +117,7 @@ extension _UIntBuffer : Collection {
}

extension _UIntBuffer : BidirectionalCollection {
@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public func index(before i: Index) -> Index {
return Index(bitOffset: i.bitOffset &- _elementWidth)
Expand All @@ -129,14 +127,14 @@ extension _UIntBuffer : BidirectionalCollection {
extension _UIntBuffer : RandomAccessCollection {
public typealias Indices = DefaultIndices<_UIntBuffer>

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public func index(_ i: Index, offsetBy n: Int) -> Index {
let x = Int(i.bitOffset) &+ n &* Element.bitWidth
return Index(bitOffset: UInt8(truncatingIfNeeded: x))
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public func distance(from i: Index, to j: Index) -> Int {
return (Int(j.bitOffset) &- Int(i.bitOffset)) / Element.bitWidth
Expand All @@ -145,44 +143,44 @@ extension _UIntBuffer : RandomAccessCollection {

extension FixedWidthInteger {
@inline(__always)
@inlinable // FIXME(sil-serialize-all)
@inlinable
internal func _fullShiftLeft<N: FixedWidthInteger>(_ n: N) -> Self {
return (self &<< ((n &+ 1) &>> 1)) &<< (n &>> 1)
}
@inline(__always)
@inlinable // FIXME(sil-serialize-all)
@inlinable
internal func _fullShiftRight<N: FixedWidthInteger>(_ n: N) -> Self {
return (self &>> ((n &+ 1) &>> 1)) &>> (n &>> 1)
}
@inline(__always)
@inlinable // FIXME(sil-serialize-all)
@inlinable
internal static func _lowBits<N: FixedWidthInteger>(_ n: N) -> Self {
return ~((~0 as Self)._fullShiftLeft(n))
}
}

extension Range {
@inline(__always)
@inlinable // FIXME(sil-serialize-all)
@inlinable
internal func _contains_(_ other: Range) -> Bool {
return other.clamped(to: self) == other
}
}

extension _UIntBuffer : RangeReplaceableCollection {
@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public init() {
_storage = 0
_bitCount = 0
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
public var capacity: Int {
return Storage.bitWidth / Element.bitWidth
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public mutating func append(_ newElement: Element) {
_debugPrecondition(count + 1 <= capacity)
Expand All @@ -191,7 +189,7 @@ extension _UIntBuffer : RangeReplaceableCollection {
_bitCount = _bitCount &+ _elementWidth
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
@discardableResult
public mutating func removeFirst() -> Element {
Expand All @@ -202,7 +200,7 @@ extension _UIntBuffer : RangeReplaceableCollection {
return result
}

@inlinable // FIXME(sil-serialize-all)
@inlinable
@inline(__always)
public mutating func replaceSubrange<C: Collection>(
_ target: Range<Index>, with replacement: C
Expand Down
Loading