Commit Graph

46 Commits

Author SHA1 Message Date
Ben Cohen
ca6c6b1d36 [stdlib] Cleanup DefaultIndices, delete dead code (#13952)
* Remove a bunch of Default(Bidirectional|RandomAccess)Indices usage from stdlib and test

* Remove some DefaultRandomAccessIndices and IndexDistance usage from Foundation

* Remove no-longer-used internal type in Existentials.swift

* Get rid of indicesForTraversal
2018-01-15 13:48:08 -08:00
Sho Ikeda
dacd46c95e [overlay][gardening] Use NSRange.init over NSMakeRange 2017-12-07 22:03:14 +09:00
Ben Cohen
85d190cd7d [stdlib] Replace various uses of BlahSlice with Slice to reduce warnings (#13263)
* Kill the slice variants from the gybbed collection test types

* Handful more SDK instances

* Fix SequencesCollections.swift.gyb
2017-12-05 19:09:56 -08:00
Doug Gregor
42968b2069 Eliminate a number of uses of the *Indexable protocols. 2017-10-01 15:08:23 -07:00
Itai Ferber
b05866a92f Fix IndexSet.RangeView indexing with subranges
On initialization, IndexSet.RangeView made the erroneous assumption that given an intersection range, a nil _indexOfRange(containing: bound) indicated that the bound was beyond the beginning or end of the index set. Instead, the index could simply not exist.

We now calculate the actual intersection of the parent index set with the given intersection range and use that as the index set to view.

This also makes the unit tests for testing range views more comprehensive.
2017-07-24 15:32:03 -07:00
Kevin Ballard
7be57bbf95 [SDK] Fix broken rangeIndex test for IndexSet.Index comparisons
It was always testing `rhs` against `rhs`, so it could never fail. But
we don't actually need the test at all, because the `value` field is
sufficient to compare indices.
2017-05-19 15:18:04 -07:00
Kevin Ballard
76fe9ea214 [SDK] Fix IndexSet.startIndex for empty sets that used to have values
We can't rely on `_range(at:)` producing valid results for sets that
have no ranges.

Fixes SR-4947.
2017-05-19 15:18:04 -07:00
Itai Ferber
012ea9373b Add Codable conformance to common Foundation types
Add conformances + unit tests for

* CGFloat
* AffineTransform
* Calendar
* CharacterSet
* DateComponents
* DateInterval
* Decimal
* IndexPath
* IndexSet
* Locale
* Measurement
* NSRange
* PersonNameComponents
* TimeZone
* URL
* UUID

along with some unit tests for each.
2017-05-18 07:56:03 -07:00
Michael Ilseman
75c476b984 Revert "Add Codable conformance to common Foundation types"
This reverts commit dee889f4d0.
2017-05-17 11:56:31 -07:00
Itai Ferber
dee889f4d0 Add Codable conformance to common Foundation types
Add conformances + unit tests for
* CGFloat
* AffineTransform
* Calendar
* CharacterSet
* DateComponents
* DateInterval
* Decimal
* IndexPath
* IndexSet
* Locale
* Measurement
* NSRange
* PersonNameComponents
* TimeZone
* URL
* UUID

along with some unit tests for each.
2017-05-16 16:57:46 -07:00
Philippe Hausler
cb47ec96d5 [Foundation] Correct IndexSet._unconditionallyBridgeFromObjectiveC to allow unexpected nil sources 2017-04-17 09:48:26 -07:00
Philippe Hausler
6c26b80e6e [Foundation] Rework the backing storage for CharacterSet to be more performant and bridge correctly to objective-c and CF
Some cases of using isSuperset can cause crashes, this was caused by improper subclassing callouts; this pr resolves those failures (and provides unit tests for that case)
The cases where the bridge was traversed too much now only causes a single bridge out call (without needing to reallocate or thrash retain/release)
String.components(separatedBy: CharacterSet) should be considerably faster now not only for more apporpriate bridging calls but also no longer needing to bridge arrays back and forth.

Resolves the following issues:
rdar://problem/17281998
rdar://problem/26611771
rdar://problem/29738989
2017-03-31 11:06:38 -07:00
Philippe Hausler
ce3ccfbd9b Change shims to always be counted as system headers via -isystem instead of conditionally marking them in debug versus non debug builds. (#7979) 2017-03-09 16:09:16 -08:00
Philippe Hausler
dc783c064c [Foundation] Remove @_silgen thunks and replace them with shims instead
This avoids indirection by making calls directly to the C implementations which prevents potentials of mismatched intent or changes of calling convention of @_silgen. The added benefit is that all of the shims in this case are no longer visible symbols (anyone using them was not authorized out side of the Foundation overlay). Also the callout methods in the headers now all share similar naming shcemes for easier refactoring and searching in the style of __NS<class><action> style. The previous compiled C/Objective-C source files were built with MRR the new headers MUST be ARC by Swift import rules.

The one caveat is that certain functions MUST avoid the bridge case (since they are part of the bridging code-paths and that would incur a recursive potential) which have the types erased up to NSObject * via the macro NS_NON_BRIDGED.

The remaining @_silgen declarations are either swift functions exposed externally to the rest of Swift’s runtime or are included in NSNumber.gyb which the Foundation team has other plans for removing those @_silgen functions at a later date and Data.swift has one external function left with @_silgen which is blocked by a bug in the compiler which seems to improperly import that particular method as an inline c function.
2017-03-06 09:59:37 -08:00
Slava Pestov
8b01cb6e24 Merge pull request #7243 from ikesyo/gardening-seq-to-array-conversion
[gardening] Prefer `Array(seq)` over `seq.map { $0 }`
2017-02-11 19:42:23 -08:00
Maxim Moiseev
8b95cc48de [stdlib] Fixing compilation warnings (#7314)
<rdar://problem/30320630>
2017-02-08 10:07:49 -08:00
Syo Ikeda
e2b03a98dd [gardening] Prefer Array(seq) over seq.map { $0 } 2017-02-04 10:37:22 +09:00
Robert Widmann
7d427aa62e Merge pull request #6569 from mekjaer/mk-inconsistent-spacing-on-properties-and-arguments
[gardening] spacing on properties and arguments in IndexSet (stdlib)
2017-01-06 16:11:00 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
mekjaer
272dfb26df Gardening spacing on properties and arguments in IndexSet (stdlib) 2017-01-04 23:09:17 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Michael Ilseman
b7c9eddd11 [noescape by default] drop @noescape from stdlib 2016-08-04 16:09:01 -07:00
Jordan Rose
b5003f4c48 Private members may not satisfy protocol requirements, ever. (#3842)
* Private members may not satisfy protocol requirements, ever.

...because by construction they can be invoked from outside of the
type.

Finishing up SE-0025 ('private' and 'fileprivate').

* Update docs and mark SE-0025 ('private' and 'fileprivate') as done!

There's still improvements we can make (see 508e825f), but the feature
is in place and should be working correctly.
2016-07-29 11:24:05 -07:00
Tony Parker
57e184a072 IndexSet's find family of methods should have optional returns 2016-07-28 10:37:42 -07:00
Joe Groff
4b9e49827d Make all _toAnyHashable() implements @nonobjc. 2016-07-27 09:25:30 -07:00
David Farler
4a57e647e6 Merge pull request #3762 from bitjammer/se-0081-diagnostic-and-crashes
[SE-0081] Warn on deprecated where clause inside angle brackets
2016-07-26 09:09:30 -07:00
Arnold Schwaighofer
39389b9c09 [SE-0125] Remove isUniquelyReferenced and the NonObjectiveCBase class
We can express the same using the `isUniquelyReferencedNonObjC` API.

- Rename `isUniquelyReferencedNonObjC` to `isKnownUniquelyReferenced`.
- Cleanup `ManagedBufferPointer` by removing holdsUniqueOrPinnedReference` and
  renaming `holdsUniqueReference` to `isUniqueReference`.
- No longer promise to return false from `isKnownUniquelyReferenced` for @objc
  class instances.

SR-1962
rdar://21886410
2016-07-26 07:09:29 -07:00
Dmitri Gribenko
34f6eb1438 Foundation: add custom AnyHashable representations to new value types 2016-07-26 03:10:52 -07:00
David Farler
7bfaeb57f1 [SE-0081] Warn on deprecated where clause inside angle brackets
and provide a fix-it to move it to the new location as referenced
in SE-0081.

Fix up a few stray places in the standard library that is still using
the old syntax.

Update any ./test files that aren't expecting the new warning/fix-it
in -verify mode.

While investigating what I thought was a new crash due to this new
diagnostic, I discovered two sources of quite a few compiler crashers
related to unterminated generic parameter lists, where the right
angle bracket source location was getting unconditionally set to
the current token, even though it wasn't actually a '>'.
2016-07-26 01:41:10 -07:00
swift-ci
3cfcb55bfc Merge pull request #3752 from parkera/foundation_reflection 2016-07-25 22:29:48 -07:00
Jordan Rose
0712ffcb07 Convert the Dispatch and Foundation overlays to 'fileprivate'. (#3753)
Similar to the work in apple/swift-corelibs-foundation#445.

Groundwork for SE-0025 ('private' and 'fileprivate').
No intended functionality change.
2016-07-25 20:58:06 -07:00
Tony Parker
dab81e8674 Add CustomReflectable implementation to most Foundation value types.
Also improves the basic debugDescription and description methods.

rdar://26580762
2016-07-25 17:05:51 -07:00
Joe Groff
32b50c624d stdlib: Remove _isBridgedToObjectiveC from _ObjectiveCBridgeable.
All generic bridgeable types can bridge for all their instantiations now. Removing this ferrets out some now-unnecessary traps that check for unbridgeable parameter types.
2016-07-25 06:01:21 -07:00
Doug Gregor
ab3a15c87a [SE-0091 / Foundation overlay] Move operators into types.
Foundation provides a number of specific operators defined in the
global scope. Push all of these into their corresponding types. This
cleanup helps verify that the SE-0091 implementation is generally
functional.
2016-07-18 23:18:57 -07:00
Mark Lacey
599ab76fb8 Remove ordered compare of optional and non-optional.
Safely unwrap two optionals used in the compare that follows.

NFC, but this (or another work-around) will be required if either
SE-0121 or SE-0123 is approved.
2016-07-17 17:45:36 -07:00
Tony Parker
510e5e17a0 Merge pull request #3486 from xwu/SR-1818
Fix IndexSet intersection and symmetric difference [SR-1818]
2016-07-13 15:34:29 -06:00
Nate Cook
56040ef828 Merge pull request #3494 from natecook1000/nc-indexset-contains
Fix IndexSet.contains(integersIn:) documentation
2016-07-13 12:24:19 -05:00
Nate Cook
f54ad5a1f5 Fix IndexSet.contains(integersIn:) documentation 2016-07-13 11:05:31 -05:00
Xiaodi Wu
c0c704641a Remove unnecessary condition in IndexSetBoundaryIterator 2016-07-12 23:22:23 -05:00
Xiaodi Wu
39d7dd27a1 Fix IndexSet intersection and symmetricDifference [SR-1818] 2016-07-12 23:03:37 -05:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Tony Parker
f9c1dd4386 Adopt the new indexing model for better perf in IndexSet
Concurrently with the development of struct IndexSet, the stdlib team
was busy reworking the way that all indexes in collections worked
(https://github.com/apple/swift-evolution/blob/master/proposals/0065-collections-move-indices.md).
Both efforts landed at basically the same time. We did the minimum
possible to adopt the new indexing model when IndexSet landed. This
change more correctly adopts the new model.

In summary, the new model has the Collection change the value of the
Index, instead of the Index changing the value on its own. Previously,
the Index had methods like successor(), but now the Collection has
methods like index(after:). This means that the index no longer has to
store a reference to the collection in many cases, which means that CoW
semantics can kick in far more often as the index is a dead simple model
object that just stores a bunch of integers. So basically, this change
moves all the logic for moving indexes from Index into IndexSet.

<rdar://problem/26269319> More fully adopt new indexing model for better performance in IndexSet
2016-07-08 14:15:49 -07:00
Tony Parker
c2c1b8468a Add overloads for range types to IndexSet
The Swift 3 refactoring of the range type has led to its split into 4
different types. The IndexSet API should accept any of these as long as
they contain the element type (Int, which is inherently Countable). This
allows callers to use both the ... and ..< syntax, for example.

This commit also adds additional unit tests for some of the IndexSet
API, and turns a few methods with optional/default args into properties
or a method family, since otherwise callers would end up with an
ambigious method call as the range argument would have been defaulted to
nil.

<rdar://problem/26532614> Add overloads for range types to IndexSet
2016-07-08 10:17:03 -07:00
practicalswift
64b3c6c880 [gardening] Remove invisible ^H 2016-06-15 22:54:11 +02:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00