Commit Graph

21665 Commits

Author SHA1 Message Date
Dave Abrahams
fba449f83d [stdlib] Add an eager reverse() for Array
Swift SVN r18390
2014-05-19 04:40:39 +00:00
Dave Abrahams
13962588a9 [stdlib] add reverse(c), s/Reverse/ReverseView/g
Now reverse() is available as a peer to map() and filter()
Addresses <rdar://problem/15919204>

Swift SVN r18389
2014-05-19 04:30:16 +00:00
John McCall
f7c2aed668 Add an implicit conversion from CFString to String.
Unfortunately, we can't add an implicit conversion from
String to CFString, or anything analogous like string
literal support, without introducing ambiguities
when converting to AnyObject.

rdar://16271682

Swift SVN r18387
2014-05-19 04:00:46 +00:00
Dave Abrahams
d17c4171da [stdlib] 80-column fixes
Swift SVN r18382
2014-05-19 02:08:19 +00:00
Dave Abrahams
5a4891a2db [stdlib] make Array.replaceRange be a method
By beating the compiler into submission with a "bouncing through
non-methods" method, I have made it accept my crazed intention that
Array and friends should interoperate with all Sequences and
Collections!  Filing <rdar://problem/16954833> to document the failure
of the method method.

Swift SVN r18378
2014-05-19 01:08:08 +00:00
Dave Abrahams
6dade3f1c8 [stdlib] Test Array.removeLast
Also improve its failure message

Swift SVN r18376
2014-05-19 00:36:37 +00:00
Dave Abrahams
1622fa5b9d [stdlib] assert => _precondition/_sanityCheck
Swift SVN r18374
2014-05-19 00:27:37 +00:00
Doug Gregor
bb95a324f9 Introduce new entry point _arrayBridgeFromObjectiveC for checked T[] -> U[] conversions.
This entry point is used when T is bridged verbatim and U is bridged
non-verbatim. It attempts to bridge each T from Objective-C to a U,
and returns nil if any of the elements cannot be bridged back to a U.

For now, only _convertNSArrayToArray and Array.bridgeFromObjectiveC
depend on this. It will soon be used for checked casts from, e.g.,
AnyObject[] to String[].

This is part of <rdar://problem/16952771> and general array bridging.

Swift SVN r18369
2014-05-18 23:44:27 +00:00
Dave Abrahams
8537f014bf [stdlib] Add lazy and Array filter algorithm
This came up during API review

Swift SVN r18364
2014-05-18 22:24:43 +00:00
Dmitri Hrybenko
a3ef3a8671 stdlib: sort file list
Swift SVN r18360
2014-05-18 22:00:58 +00:00
Dave Zarzycki
94d5c81b4b Heap: ignore arena tail loss during enumeration
<rdar://problem/16953578> SwiftZone malloc enumeration is returning "PTR_IN_USE" blocks that extend past their VM region

Swift SVN r18352
2014-05-18 21:12:21 +00:00
Dave Abrahams
241f4e9b46 [stdlib] Avoid Suicide Sequences
In a naive implementation of a Sequence adapter, adapting a
non-self-destructive (multi-pass) Sequence having a reference-semantics
Generator produces a self-destructive adapted view.  This is technically
correct because Sequences are allowed to be self-destructive, and
theoretically every multi-pass Sequence would be a Collection.  However
Sequences are much easier to build than Collections, so users are likely
to make them, and it would be extremely surprising if adapting a
self-preserving Sequence yielded a self-destructive one.

Swift SVN r18350
2014-05-18 20:38:33 +00:00
Doug Gregor
4e5f69c259 Try to fix build on ARM32.
Swift SVN r18349
2014-05-18 20:36:39 +00:00
Dmitri Hrybenko
a80603f3bb stdlib/Floating point: switch infinity, NaN, quietNaN to properties
Swift SVN r18348
2014-05-18 20:30:57 +00:00
Dave Abrahams
e0d37be053 [stdlib] Rename (Indexed=>Permutation)Generator
It was too easily confused with IndexingGenerator, which, come to think
of it may be obsolete.  It's just a PermutationGenerator with
startIndex..endIndex in the indices sequence.

Swift SVN r18341
2014-05-18 19:03:26 +00:00
Dave Abrahams
215da18af9 [stdlib] Publicize Map, add lazy map()
As declared, Dictionary's keys and values were private.  Instead of
hiding Map away as _Map, give it a "nice" verbose name and expose it
through a "nice" lowercase global function called map(), which we
overload so it works on both Collections and Sequences, returning a
Collection when that's what it started on.

We'll follow this pattern for filter, which was requested on Array.  The
implementation is easy once you have a lazy view!

Swift SVN r18340
2014-05-18 19:00:42 +00:00
Dave Abrahams
b763aedd47 [stdlib] Array API Review: privatization
Swift SVN r18339
2014-05-18 17:48:12 +00:00
Dave Abrahams
bec80488d0 [stdlib] Array API Review: insert:newElement:=>insert:AtIndex:
Swift SVN r18338
2014-05-18 17:43:16 +00:00
Dave Abrahams
69e1b1f515 [stdlib] Array API review: (new=>minimum)Capacity
Also some 80-column fixups

Swift SVN r18337
2014-05-18 17:39:31 +00:00
Dave Abrahams
200b89291c [stdlib] Array API review: privatize [bB]uffer
Swift SVN r18335
2014-05-18 17:32:00 +00:00
Dave Abrahams
8344b6dbb9 [stdlib] Array API Review: removeAt=>removeAtIndex
Swift SVN r18334
2014-05-18 17:32:00 +00:00
Dave Abrahams
5846923729 [stdlib] Array API review: popLast => removeLast
Swift SVN r18331
2014-05-18 17:03:38 +00:00
Dave Abrahams
68abebdffb [stdlib] withUnsafePointerToElements for Array
Also privatize ArrayType's elementStorage. Per Array API review.

Swift SVN r18330
2014-05-18 16:59:46 +00:00
Dave Abrahams
35d22e9ffb [stdlib] Array API Review: owner -> _owner
Swift SVN r18326
2014-05-18 15:58:15 +00:00
Dave Abrahams
92307dee66 [stdlib] Array API Review: swap init parameters
Swift SVN r18325
2014-05-18 15:54:33 +00:00
Dave Abrahams
3119144292 [stdlib] Array API Review: clear() -> removeAll()
Swift SVN r18324
2014-05-18 15:49:52 +00:00
Dmitri Hrybenko
948ddb3a39 Revert "Make 'maybeGet' and 'assertingGet' private API."
These are private APIs already because they are inside private types.


Swift SVN r18322
2014-05-18 14:01:24 +00:00
Dave Abrahams
2746a7d558 Another Array bridge/cast test from Doug
Applied that same workaround for <rdar://problem/16953026> in one more
place.

Swift SVN r18321
2014-05-18 06:15:45 +00:00
Dave Abrahams
25dc6e7625 Two Array bridge/cast tests from Doug
Added a workaround for <rdar://problem/16953026> that allows them to
pass and flipped the sense of a test that was failing because we can now
downcast an Array that we couldn't downcast before.

Swift SVN r18319
2014-05-18 06:06:18 +00:00
Ted Kremenek
d83b68bea5 Rename class method 'infinite()' to 'infinity()'.
Swift SVN r18311
2014-05-18 04:49:03 +00:00
Ted Kremenek
e5aa1a8edb Change func 'inf()' to 'infinite()' to match 'isInfinite'.
Swift SVN r18309
2014-05-18 04:24:41 +00:00
Ted Kremenek
92157d7d55 Change 'isSignMinus', 'isNormal', etc., in FloatingPointNumber to properties.
Swift SVN r18306
2014-05-18 04:20:09 +00:00
Ted Kremenek
a8c2b61cdb Always make 'allKeys' a property (coincides with Foundation).
Swift SVN r18305
2014-05-18 04:20:07 +00:00
Ted Kremenek
ef2d73fb16 Make 'maybeGet' and 'assertingGet' private API.
Swift SVN r18303
2014-05-18 04:07:20 +00:00
Ted Kremenek
16dea15a24 Hide CocoaArray ('_' to mark as private API).
Swift SVN r18302
2014-05-18 04:03:32 +00:00
Ted Kremenek
074150571f Rename isNull() to _isNull() (making them private), and make pointers
conform to LogicValue.

This approach was taken to keep _isNull because I first tried
to just use comparisons to nil instead of isNull().  Apparently
that led to some circular definitions, so it was easier to just
stage it this way.

Swift SVN r18301
2014-05-18 03:42:40 +00:00
Doug Gregor
0aba627a86 Reinstate "Drive a wedge between array upcasts and array bridged
upcasts." 
Reinstate "Restrict the array-bridged conversion to non-verbatim
bridging." 
Reinstate "[stdlib] Fix T[].bridgeFromObjectiveC" 
Reinstate "[stdlib] Fix T[].bridgeFromObjectiveC" 
Reinstate "[stdlib] Move _arrayBridgedDownCast to Foundation"
 Reinstate "Replace "can" with "cannot" in a message." 
Reinstate "Implement support for non-verbatim T[] -> AnyObject[]
upcasts."  

This reinstates commit r18291. 
This reinstates commit r18290. 
This reinstates commit r18288. 
This reinstates commit r18287. 
This reinstates commit r18286. 
This reinstates commit r18293. 
This reinstates commit r18283.

John fixed the issue in r18294.


Swift SVN r18299
2014-05-18 03:36:09 +00:00
Michael Gottesman
263dca4b47 Revert "Drive a wedge between array upcasts and array bridged upcasts."
Revert "Restrict the array-bridged conversion to non-verbatim bridging."
Revert "[stdlib] Fix T[].bridgeFromObjectiveC"
Revert "[stdlib] Fix T[].bridgeFromObjectiveC"
Revert "[stdlib] Move _arrayBridgedDownCast to Foundation"
Revert "Replace "can" with "cannot" in a message."
Revert "Implement support for non-verbatim T[] -> AnyObject[] upcasts."

This reverts commit r18291.
This reverts commit r18290.
This reverts commit r18288.
This reverts commit r18287.
This reverts commit r18286.
This reverts commit r18293.
This reverts commit r18283.

Sorry for the number of reverts, but I needed to do this many to get a clean
revert to r18283.

Swift SVN r18296
2014-05-18 02:42:56 +00:00
Doug Gregor
323ac07bf1 Replace "can" with "cannot" in a message.
Swift SVN r18293
2014-05-18 01:30:03 +00:00
Dave Abrahams
30c170606c [stdlib] Fix T[].bridgeFromObjectiveC
Make the new test pass, and make the tests more robust

Swift SVN r18288
2014-05-18 00:38:37 +00:00
Dave Abrahams
5fd71e0cca [stdlib] Move _arrayBridgedDownCast to Foundation
That's the only place it's used, as a helper.  Next up: correct the
semantics

Swift SVN r18286
2014-05-18 00:25:55 +00:00
Doug Gregor
df657180f4 Implement support for non-verbatim T[] -> AnyObject[] upcasts.
One of my recent type-checker changes starting passing all array
upcasts, including "bridged" ones like String[] -> AnyObject[],
through the library entry point _arrayUpCast, which is only meant for
class/ObjC existential types that are bridged verbatim.

Fixes part of <rdar://problem/16952238>; more cleanup to follow.

Swift SVN r18283
2014-05-17 23:27:44 +00:00
Dmitri Hrybenko
26630dbdc4 stdlib/NSString APIs for String: change hash() function into a property
Swift SVN r18281
2014-05-17 22:27:35 +00:00
Dmitri Hrybenko
9b29be7da0 stdlib/Dictionary bridging: change check for NSCopying key conformance to also
happen eagerly in Release builds, according to Dave's review


Swift SVN r18279
2014-05-17 22:17:24 +00:00
Ted Kremenek
26320dc0ed Per API review, rename 'reserve' to 'reserveCapacity'.
Swift SVN r18272
2014-05-17 21:00:28 +00:00
Ted Kremenek
f0b112288f Per design discussion today, add back type sugar NSError** out parameters.
The new sugar is 'NSErrorPointer', which hides 'AutoreleasingUnsafePointer<NSError?>'.

I have not yet tested this on iOS, which previously had problems
with the type sugar import.  I'll try and test that now.

Swift SVN r18270
2014-05-17 20:50:40 +00:00
Ted Kremenek
eab7f90a81 Per design discussion today, rename UnsafePointer ".pointee" to ".memory".
Swift SVN r18269
2014-05-17 20:35:16 +00:00
Dmitri Hrybenko
0d5b40a0e8 stdlib/Dictionary: s/removeObjectForKey/removeValueForKey/ per API review
emails


Swift SVN r18268
2014-05-17 20:15:40 +00:00
Dmitri Hrybenko
6a2192f76f stdlib/Dictionary: add doc comments for new APIs
Swift SVN r18267
2014-05-17 20:11:40 +00:00
Ted Kremenek
dce90aed78 Change remaining standard library cases of isEmpty() to a property isEmpty.
Swift SVN r18266
2014-05-17 20:01:17 +00:00