Commit Graph

101 Commits

Author SHA1 Message Date
Dmitri Gribenko
99d3f96c6d Rename IndexingGenerator to CollectionDefaultIterator 2015-12-09 17:12:07 -08:00
Dmitri Gribenko
1c0047829a Rename SequenceType.generate() to SequenceType.iterator() 2015-12-09 17:11:17 -08:00
Dmitri Gribenko
2cf172160c Rename SequenceType.Generator associated type to SequenceType.Iterator 2015-12-09 17:11:05 -08:00
Arnold Schwaighofer
4b22a31154 ArraySemantics: Remove getArrayPropertyIsNative - we are only using
hoistableIsNativeTypeChecked these days.
2015-12-08 07:34:25 -08:00
Dmitri Gribenko
31598d41bf Rename GeneratorType to IteratorProtocol 2015-12-07 17:08:32 -08:00
Dmitri Hrybenko
6536edd68c stdlib: fix coding style
Swift SVN r32425
2015-10-03 21:13:15 +00:00
Arnold Schwaighofer
3e984d25d9 Change test name - we test non unique arrays here
Swift SVN r32282
2015-09-28 21:20:22 +00:00
Arnold Schwaighofer
599a438015 Don't force to grow the buffer everytime we make it unique
rdar://22873620

Swift SVN r32280
2015-09-28 20:47:23 +00:00
Dmitri Hrybenko
67944589d6 stdlib: improve index invalidation guarantees for removeFirst()
Slice types that are RangeReplaceable (like ArraySlice) now slice
themselves in removeFirst().  Previously, these types were picking up
the wrong default implementation, and they were going through
replaceRange(), which caused all indices to be invalidated.  The new
implementation preserves all indices.

rdar://22536664

Swift SVN r31918
2015-09-12 04:35:51 +00:00
Dmitri Hrybenko
217ef5aa12 stdlib: fix legacy Mirror for ArraySlice
The mirror wasn't adjusted to account for non-zero-based indices of
ArraySlice.

rdar://problem/22373053

Swift SVN r31409
2015-08-22 08:04:58 +00:00
Dave Abrahams
ad43a596bd [stdlib] Retire the old lazy subsystem...
...replacing it with the new, after passing API review!

* The lazy free function has become a property.

* Before we could extend protocols, we lacked a means for value types to
  share implementations, and each new lazy algorithm had to be added to
  each of up to four types: LazySequence, LazyForwardCollection,
  LazyBidirectionalCollection, and LazyRandomAccessCollection. These
  generic adapters hid the usual algorithms by defining their own
  versions that returned new lazy generic adapters. Now users can extend
  just one of two protocols to do the same thing: LazySequenceType or
  LazyCollectionType.

* To avoid making the code duplication worse than it already was, the
  generic adapters mentioned above were used to add the lazy generic
  algorithms around simpler adapters such as MapSequence that just
  provided the basic requirements of SequenceType by applying a
  transformation to some base sequence, resulting in deeply nested
  generic types as shown here. Now, MapSequence is an instance of
  LazySequenceType (and is renamed LazyMapSequence), and thus transmits
  laziness to its algorithms automatically.

* Documentation comments have been rewritten.

* The .array property was retired

* various renamings

* A bunch of Gyb files were retired.

Swift SVN r30902
2015-08-01 03:52:13 +00:00
Dmitri Hrybenko
d9088afe4b stdlib: add MutableSlice
See doc comments on MutableSlice for more information about what it is.

MutableSlice was one of the reasons to clarify and tighten index
invalidation rules.  After that change, existing MinimalCollection
test types were performing checks that are too strict according to the
model.  Existing algorithms and collections could provide them, but not
MutableSlice.  This commit updates MinimalCollection types to perform
index invalidation checks that correspond to new rules.

Part of rdar://20722366.  This commit adds the type, but does not wire
it up completely yet.

Swift SVN r30839
2015-07-31 03:21:56 +00:00
Dmitri Hrybenko
61b93564e9 Eliminate UnsafeMutableBufferPointer from _withUnsafeMutableBufferPointerIfSupported
The type checker hits a recursion when checking the conformance to
CollectionType in UnsafeMutableBufferPointer, which requires
_withUnsafeMutableBufferPointerIfSupported, which mentions
UnsafeMutableBufferPointer.  The easiest fix for now is to break the
recursion in the library.

Reverting this change is tracked by: <rdar://problem/21933004> Restore
the signature of _withUnsafeMutableBufferPointerIfSupported() that
mentions UnsafeMutableBufferPointer

Swift SVN r30838
2015-07-31 03:21:54 +00:00
Joe Groff
73b7f89499 Also, don't test for a trap message in release builds that don't trap with messages.
Fixes rdar://problem/22081452.

Swift SVN r30825
2015-07-30 23:47:48 +00:00
Joe Groff
7f86227350 Don't expect crash output if test isn't expected to crash.
Speculative fix for rdar://problem/22081452.

Swift SVN r30822
2015-07-30 23:35:42 +00:00
Joe Groff
4cb34410fc stdlib: Don't reserve capacity for filter result array.
Swift SVN r30802
2015-07-30 17:07:37 +00:00
Joe Groff
0c39db22bc stdlib: Implement strict 'map', 'filter', and 'flatMap' as 'rethrows' operations.
Replace the Lazy-based implementations with open-coded implementations based on the _UnsafePartiallyInitializedContiguousArrayBuffer builder from the previous commit, so that we have control over the early-exit flow when an error interrupts the operation.

Swift SVN r30794
2015-07-30 05:28:34 +00:00
Joe Groff
eec59477ae stdlib: Factor _copy*ToNativeArrayBuffer into a general-purpose "builder" for ContiguousArrayBuffer.
This makes the code for efficiently initializing array buffers in-place more accessible to the rest of the standard library, and should also provide a performance boost for _copySequenceToNativeArrayBuffer, which had been implemented as a naive append loop, by handling reallocating the buffer when necessary when initializing from a sequence that underestimates its count.

Swift SVN r30793
2015-07-30 05:28:30 +00:00
Dmitri Hrybenko
f5de8757e4 stdlib: remove Word and UWord
These types are leftovers from the early pre-1.0 times when Int and UInt
were always 64-bit on all platforms.  They serve no useful purpose
today.  Int and UInt are defined to be word-sized and should be used
instead.

rdar://18693488

Swift SVN r30564
2015-07-24 05:01:32 +00:00
Dmitri Hrybenko
08a84ca5a1 stdlib tests: simplify map() calls with currying
Swift SVN r30379
2015-07-19 01:49:10 +00:00
Joe Groff
6608221a72 stdlib: Remove _UnitTestArray.
rdar://problem/20246497

Swift SVN r30348
2015-07-18 00:14:28 +00:00
David Farler
241de1a1c3 Add popFirst/popLast implementations for some collections
Add the following non-customizable implementations:

- popFirst/popLast for Collections whose SubSequence == Self.
- Array.popLast
- ContiguousArray.popLast
- Set.popFirst
- Dictionary.popFirst

Swift SVN r30278
2015-07-16 22:52:05 +00:00
Dave Abrahams
ce93b0a9e0 [stdlibunittest] Still more de-boilerplating WIP
Swift SVN r29951
2015-07-08 00:28:33 +00:00
Dave Abrahams
9abf32d521 [stdlibunittest] WIP uniformity/de-boilerplating
The way we pass and compose source locations, messages, etc. needs to be
brought under control before too many more tests get written.  This is
the first step.

Swift SVN r29928
2015-07-07 00:46:54 +00:00
Dmitri Hrybenko
51e236c609 stdlib: rename Array's generic parameter from T to Element
Same for ArraySlice and ContiguousArray.

Part of rdar://21429126

Swift SVN r29618
2015-06-24 20:41:49 +00:00
Arnold Schwaighofer
f003bc754d validation-test: Make this test pass in optimized mode
Some test cases where assuming to be compiled in Debug assert configuration.

The test relies on return autorelease optimization to happen. This does not
happen reliable in optimize mode.

I ran the test case under the leaks runner and no leaks are reported yet the
object count is positive. This can happen if some objects are still in a
autorelease pool at the time we count them. Which seems to happen.

I surrounded the code with "autoreleasepool {}" and it would pass which confirms
this assumption. I have looked at both the generated LLVM IR and the otool -tvV
asssembly output and did not see anything that would block the return
autorelease optimization (i.e instructions between the returnautorelease
function call and the retain_returnautorelease call) so I don't believe there is
something the compiler could do better.

rdar://21193916

Swift SVN r29369
2015-06-12 18:41:50 +00:00
Dmitri Hrybenko
41934b5433 stdlib: Add some basic array bridging tests
Swift SVN r29307
2015-06-04 20:13:11 +00:00
Arnold Schwaighofer
4d4329b0e0 Add executable_test to the validation test suite
Swift SVN r29278
2015-06-03 23:28:43 +00:00
Dmitri Hrybenko
cca4f4e3ff Revert "stdlib: Add some basic array bridging tests"
This reverts commit 29268.  The tests don't pass on the 32-bit
simulator.

Swift SVN r29273
2015-06-03 05:07:42 +00:00
Dmitri Hrybenko
6b9e73aa09 stdlib: Add some basic array bridging tests
Swift SVN r29268
2015-06-03 03:10:06 +00:00
Arnold Schwaighofer
bd9108157c This test currently fails in optimized mode
rdar://21193916

Swift SVN r29220
2015-06-02 02:09:49 +00:00
Dmitri Hrybenko
ffe26aa69c stdlib: dissolve the Array.swift test in other tests
Swift SVN r29129
2015-05-29 01:33:07 +00:00
Dmitri Hrybenko
53f3ccf850 stdlib: change CollectionType.count() into a property
Swift SVN r28829
2015-05-20 09:14:43 +00:00
Greg Parker
15b99a26d9 Test: Add %target-clang substitution.
Swift SVN r28758
2015-05-19 06:08:36 +00:00
Dmitri Hrybenko
47595ee1db stdlib: change sort() and sorted() into protocol extensions
Swift SVN r28736
2015-05-19 01:55:29 +00:00
Dmitri Hrybenko
17cafb6b3a Revert "stdlib: don't use doc comment markup for non-doc comments"
This reverts commit 28724.  It contains unintended changes.

Swift SVN r28725
2015-05-18 21:51:53 +00:00
Dmitri Hrybenko
e964eb7384 stdlib: don't use doc comment markup for non-doc comments
rdar://problem/20976063

Swift SVN r28724
2015-05-18 21:50:24 +00:00
Dmitri Hrybenko
25d9a4fe32 stdlib: protocol extensions: de-underscore filter()
The API was adjusted according to the API review previously.

Swift SVN r28592
2015-05-15 00:37:01 +00:00
Dmitri Hrybenko
843d8a4eb7 stdlib: protocol extensions: de-underscore map()
Swift SVN r28502
2015-05-13 01:58:46 +00:00
Dmitri Hrybenko
bdd9250f12 stdlib: add tests for ${ArrayType}.init(SequenceType)
Swift SVN r28362
2015-05-09 03:32:37 +00:00
Dmitri Hrybenko
10ab07ade5 Revert "Remove {Dictionary,Set,UnsafeMutableBufferPointer,UnsafeBufferPointer}.count"
This reverts commit r28248 while we discuss the change.

Swift SVN r28291
2015-05-07 21:45:28 +00:00
Dmitri Hrybenko
8ac6c7cf8f Remove {Dictionary,Set,UnsafeMutableBufferPointer,UnsafeBufferPointer}.count
These APIs are redundant with APIs that come from protocol extensions.

Swift SVN r28248
2015-05-07 00:30:43 +00:00
Dmitri Hrybenko
c109ec9125 stdlib: protocol extensions: de-underscore count()
Swift SVN r28246
2015-05-07 00:30:38 +00:00
Dmitri Hrybenko
97db2def53 stdlib: protocol extensions: de-underscore flatMap()
Swift SVN r28239
2015-05-07 00:30:27 +00:00
Dmitri Hrybenko
4d197dc5b2 Revert "stdlib: change sort() and sorted() into methods"
This reverts commits r27885, r27876.  It looks like they broke iOS on
arm64.

Swift SVN r27893
2015-04-28 23:58:50 +00:00
Dmitri Hrybenko
b05c372c4f stdlib: change sort() and sorted() into methods
Swift SVN r27876
2015-04-28 18:05:37 +00:00
Dave Abrahams
1badcbc14b [stdlib] Rename Slice => ArraySlice
Leave room for a generic Slice type in a later release.

Swift SVN r25493
2015-02-24 00:18:58 +00:00
Maxwell Swadling
b1857d2452 [stdlib] added flatMap
fixes rdar://problem/19338087

Swift SVN r25378
2015-02-18 22:58:35 +00:00
Dmitri Hrybenko
64ffcf43bf tests: check that array generators traverse a snapshot of the array
Swift SVN r25172
2015-02-11 07:12:26 +00:00
Dmitri Hrybenko
6f6ca68aaf stdlib: mark closures in Array.map() and Array.filter() with @noescape
rdar://19389247

Swift SVN r25131
2015-02-10 19:54:28 +00:00