Commit Graph

59 Commits

Author SHA1 Message Date
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Ben Cohen
f9b3e14137 [stdlib] Use Swift-native Character iteration for hasPrefix/Suffix (#14390)
* Use Swift-native Character iteration for hasPrefix/Suffix

* Remove old tests for removed C shims
2018-03-12 17:41:55 -07:00
Connor Wakamo
37f7493c89 Merge pull request #14690 from cwakamo/introducing-CustomPlaygroundDisplayConvertible
This implements SE-0198 by introducing the `CustomPlaygroundDisplayConvertible` protocol and deprecating `PlaygroundQuickLook`/`CustomPlaygroundQuickLookable` in advance of removal from the standard library in the future.
2018-02-21 16:09:06 -08:00
Connor Wakamo
a2aacd73dd [stdlib] Deprecated PlaygroundQuickLook and CustomPlaygroundQuickLookable.
Deprecated the `PlaygroundQuickLook` enum and `CustomPlaygroundQuickLookable`
protocol. These are being targeted for removal in Swift 5, so we want to
unconditionally deprecate them now to encourage use of
`CustomPlaygroundDisplayConvertible` instead.

This commit includes deprecated the various `CustomPlaygroundQuickLookable`
conformances across the standard library and overlay libraries.
2018-02-21 13:38:31 -08:00
Ben Cohen
d8d7edf89d [stdlib][NFC] Warning cleanup (#14727)
* Remove Countable use from _ArrayBufferProtocol

* Mark _SwiftNativeNSArrayWithContiguousStorage's init @nonobjc

* Give {Closed}Range a _customIndexOfEquatableElement, supressing warning for _customContainsEquatableElement near-miss

* Eliminate CharacterView.init warning, since it's hard to supress and these things warn constantly.
2018-02-20 11:42:32 -08:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Lance Parker
bce84b8c49 fix mutations for substrings through views 2018-01-31 16:49:14 -08:00
Karoy Lorentey
e6afe829a1 [stdlib] Silence deprecation warnings about CharacterView in stdlib
- Rename `Substring.CharacterView` to `Substring._CharacterView`, adding a deprecated typealias for the original name, like we do for `String.CharacterView`.
- Add a non-deprecated `Substring._characters` property, emulating `String.characters`.
- Explicitly deprecate the following members:
    * String.withMutableCharacters<R>(_: (inout CharacterView) -> R) -> R
    * String.subscript(Range<Index>) -> String.CharacterView
    * Substring._CharacterView.subscript(Range<Index>) -> Substring.CharacterView
    * Substring.init(_: CharacterView)
    * String.init(_: Substring.CharacterView)
2018-01-24 21:16:48 +00:00
Karoy Lorentey
b8d8949166 String & String views: Add bounds checking to range subscripts. 2018-01-21 12:40:21 -08:00
Michael Ilseman
3be2faf5d3 [String] Initial implementation of 64-bit StringGuts.
Include the initial implementation of _StringGuts, a 2-word
replacement for _LegacyStringCore. 64-bit Darwin supported, 32-bit and
Linux support in subsequent commits.
2018-01-21 12:32:26 -08:00
Michael Ilseman
75463e30f3 [stdlib] Rename _StringCore to _LegacyStringCore. NFC.
In grand LLVM tradition, the first step to redesigning _StringCore is
to first rename it to _LegacyStringCore. Subsequent commits will
introduce the replacement, and eventually all uses of the old one will
be moved to the new one.

NFC.
2018-01-21 12:28:56 -08:00
Nate Cook
0782b482b3 [stdlib] Documentation improvements
- Revise Equatable and Hashable for synthesized requirements
- Complete Strideable and stride(from:...:by:) documentation
- Revise DoubleWidth type docs
- Add complexity notes for Set.index(of:) and .contains(_:)
- Fix typos in Set.formUnion docs
- Add missing axioms for SetAlgebra (SR-6319)
- Improve guidance for description and debugDescription
- Add note about the result of passing duplicate keys to
  Dictionary(uniqueKeysWithValues:)
- Fix typo in BinaryInteger docs
- Update Substring docs with better conversion example
- Improve docs for withMemoryRebound and isKnownUniquelyReferenced
- Add missing docs not propagated from protocols
2018-01-05 17:06:44 -06:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Ben Cohen
dcab9493ae Removed some warnings (#12753) 2017-11-30 15:12:56 -08:00
Ben Cohen
c4f0b5fe94 [stdlib] Adopt conditional conformance for Indices, Slice, ReversedCollection (#12913)
* Refactor Indices and Slice to use conditional conformance

* Replace ReversedRandomAccessCollection with a conditional extension

* Refactor some types into struct+extensions

* Revise Slice documentation

* Fix test cases for adoption of conditional conformances.

* [RangeReplaceableCollection] Eliminate unnecessary slicing subscript operator.

* Add -enable-experimental-conditional-conformances to test.

* Gruesome workaround for crasher in MutableSlice tests
2017-11-30 09:10:22 -08:00
Nate Cook
0b62b0608d [stdlib] Doc revisions
- Add missing docs & parameter lists
- Remove deprecated `characters` usage in examples
- Revise documentation for Mirror and CVarArg
- Revise documentation for swap(_:_:)
- Various typo and grammar fixes
2017-11-07 11:11:23 -06:00
Max Moiseev
a24998a5b1 [stdlib] Add missing @_fixed_layout attributes to fix resilience build 2017-10-02 15:19:06 -07:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Michael Ilseman
7c705c3a75 [stdlib] Deprecate String/Substring.CharacterView
CharacterView is now entirely redundant in Swift 4. Deprecate its
use. This also allows us to schedule the unbreaking of
String.CharacterView leakiness without a hard source break.
2017-08-10 17:24:06 -07:00
Michael Ilseman
64e0e1859e [stdlib] Deprecate popFirst in Swift 3.2
Add a deprecation warning for use of popFirst even with -swift-version
3, as it's prone to leaks under the old model. Test cases added.
2017-08-10 15:27:05 -07:00
Michael Ilseman
3243b8a59f [stdlib] Availability checking for String.*View.popFirst
Collection's popFirst is only present when the Collection is its own
SubSequence type. String and String's views are no longer their own
SubSequenes, so popFirst is no longer present. Unfortunately, this
breaks code in swift-version 3 and it also gives a terrible diagnostic
to users. This change introduces an implementation for swift-version 3
mode and better diagnostics for Swift 4 code. Tests included.
2017-08-09 19:41:52 -07:00
Dave Abrahams
3c6f0c3c67 [stdlib] Repair Substring -> String conversion 2017-07-26 16:02:18 -07:00
Dave Abrahams
41c53ae729 [stdlib] Give Substring its own views
This necessary for ensuring the property that String doesn't keep
inaccessible memory alive.  For example, before this change,

    String(s.dropFirst().unicodeScalars)

would compile and produce a String that owned inaccessible memory.
Now it no longer compiles.

String's view's SubSequences are the same as the Substring's
view. E.g. String.UnicodeScalarView.SubSequence is
Substring.UnicodeScalarView.

New compatibility inits added, to work around the fact that many
previously failable initializers are now non-failable.
2017-07-26 15:59:51 -07:00
Michael Ilseman
10e9e336fe [stdlib] Fix bug in Substring's _persistentContent
Substring's _persistentContent has a fast path that avoids a copy when
the Substring represents the entire outer String. It correctly
detected situations where the wrapped _StringCore was not itself a
slice, but was omitting the extra checks to make sure the Substring's
own range covered the entire String.

Test added.
2017-07-25 14:28:57 -07:00
Ben Cohen
ddea636951 [stdlib] Have Substring.filter return a String (#10871)
* Have Substring.filter return a String

* fix spacing nits

new machine so editor misconfigured excuses excuses

* fix spacing nits
2017-07-24 15:23:30 -07:00
Dave Abrahams
9159239995 Un-revert "[stdlib] String index interchange, etc." (#10812)
I failed to merge the upstream changes to swift-corelibs-foundation at the same
time as I merged that #9806, and it broke on linux. Going to get it right this
time.
2017-07-07 12:13:25 -07:00
Xi Ge
d9fb110674 Revert "[stdlib] String index interchange, etc." (#10812)
rdar://33186295
2017-07-07 12:03:16 -07:00
Dave Abrahams
e523c80339 [stdlib] Index interchange, part I 2017-07-07 00:59:04 -07:00
Michael Ilseman
a3e892fca5 [stdlib] Relax ephemeralString sanity check
Creating an ephemeral string from a non-contiguous substring does not
reuse the same storage. Relax a sanity check assuming that it did.
2017-06-28 15:48:17 -07:00
Nate Cook
825e9d077d [stdlib] More documentation revisions / consistency fixes. 2017-06-13 14:08:00 -05:00
Ben Cohen
d0c0043f93 [stdlib] Use ephemeral string for substring comparison (#10009)
* Use _ephemeralString for substring comparison

Add back != for String/Substring comparison

* OK fine, Linux, if you're going to be difficult

* Different forms of comparison, tests
2017-06-03 11:20:01 -07:00
Dave Abrahams
b2e4bd5d09 [stdlib] Replace _HeapBuffer with a thin wrapper
...over ManagedBufferPointer
2017-06-01 04:40:52 -07:00
Dave Abrahams
807410b99e [stdlib] Make String("...") non-failable in Swift 4 2017-05-24 16:11:34 -07:00
Dave Abrahams
d6fee05375 [stdlib] Enable interchange among StringProtocol models 2017-05-17 17:21:43 -07:00
Maxim Moiseev
8876655f6b [stdlib] Reverting the String.init?(_: String) behavior (#9659) 2017-05-17 13:56:15 -07:00
Nate Cook
817a1efa3b [stdlib] Documentation revisions
- remove additional 'characters' references from String docs
- improved language around escaping pointer arguments
- key path type abstracts
- codable type abstract revisions
- a few more NSString API fixes
2017-05-17 11:58:08 -05:00
practicalswift
aae419ad30 [gardening] Fix word processing artefacts 2017-05-15 11:30:25 +02:00
Nate Cook
f650e0a7da [stdlib] String and range expressions
* finish string documentation revisions
* revise examples throughout to use range expressions instead of e.g.
  prefix(upTo: _)
2017-05-13 10:06:12 -05:00
Dave Abrahams
41c244a065 [stdlib] Unicode[Encoding|Parser] => Unicode.[Encoding|Parser] 2017-05-11 17:21:39 -07:00
Dave Abrahams
c64534a873 [stdlib] API adjustments in preparation for proposal update 2017-05-09 11:19:24 -07:00
Dave Abrahams
fd8cfea3ac [stdlib] String initialization with encoding and CString interop 2017-05-08 19:50:38 -07:00
swift-ci
4b69240301 Merge pull request #9372 from airspeedswift/drop-nuffing 2017-05-06 14:11:13 -07:00
ben-cohen
02562c3eb0 Substring.index(_:offsetBy:) is allowed offset of 0 2017-05-06 13:34:27 -07:00
Max Moiseev
bfb1824f44 [stdlib] Adding the StringProtocol 2017-05-01 16:41:26 -07:00
Ben Cohen
38903764df Revert "Revert "[stdlib] One-sided ranges and RangeExpression (#8710)"" 2017-04-30 16:47:23 -07:00
Arnold Schwaighofer
7d5d63eaf8 Revert "[stdlib] One-sided ranges and RangeExpression (#8710)"
This reverts commit 946b776e37.
2017-04-30 15:51:16 -07:00
Mark Lacey
bcdf09d166 [stdlib] Disambiguate a subscript operation.
This is only flagged by some type checker changes that I have, but it
appears to be a legitimate ambiguity.
2017-04-29 17:15:02 -07:00
Ben Cohen
946b776e37 [stdlib] One-sided ranges and RangeExpression (#8710)
* One-sided ranges and RangeExpression

* Remove redundant ClosedRange methods from String

* Fix up brittle tests

* Account for Substring update

* XFAIL range diagnostics on Linux
2017-04-28 12:59:04 -07:00