Commit Graph

47 Commits

Author SHA1 Message Date
Dave Abrahams
eab43d72d6 [emacs support] swift-mode: support break labels
Also use it to fix indentation in Arrays.swift.gyb

Swift SVN r18507
2014-05-21 20:08:26 +00:00
Dmitri Hrybenko
9a4004ab61 stdlib/Join: add forwarding join() instance functions to array and string types
rdar://16388632


Swift SVN r18493
2014-05-21 13:15:30 +00:00
Dmitri Hrybenko
652859f301 stdlib/Array: reduce duplication in ExtensibleCollection conformances
Swift SVN r18452
2014-05-20 12:45:03 +00:00
Dave Abrahams
418bec853f [stdlib] 1-character fix for Array.reserve
...plus the testing that makes that fix stick.  Fixes <rdar://16958865>

Swift SVN r18429
2014-05-19 21:20:48 +00:00
Dave Abrahams
fba449f83d [stdlib] Add an eager reverse() for Array
Swift SVN r18390
2014-05-19 04:40:39 +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
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
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
Ted Kremenek
16dea15a24 Hide CocoaArray ('_' to mark as private API).
Swift SVN r18302
2014-05-18 04:03:32 +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
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
Ted Kremenek
26320dc0ed Per API review, rename 'reserve' to 'reserveCapacity'.
Swift SVN r18272
2014-05-17 21:00:28 +00:00
Doug Gregor
bed81488c1 Revert r18232, r18220: we're not doing T* now.
Swift SVN r18250
2014-05-17 16:36:02 +00:00
Dave Abrahams
d6e4964ace [stdlib] Make _convertNSArrayToArray meet spec
I believe this correctly implements the "forced conversion" part of the
Arrays.rst document.

Swift SVN r18248
2014-05-17 14:08:33 +00:00
Dave Abrahams
2fc6414b5d [stdlib/Array] Improve another comment
Swift SVN r18245
2014-05-17 06:25:56 +00:00
Dave Abrahams
6b0c79a0f2 [stdlib/Array] Eliminate or label unused functions
Swift SVN r18244
2014-05-17 06:25:56 +00:00
Dave Abrahams
f57c2b8e47 [stdlib] Remove unused functions
Swift SVN r18240
2014-05-17 05:33:26 +00:00
Doug Gregor
73f02d1a69 Switch a bunch of UnsafePointer<T>'s over to T*
Swift SVN r18220
2014-05-16 22:32:01 +00:00
Arnold Schwaighofer
da6d9152b6 Differentiate between user assertion and preconditions and the like
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.

_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.

_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.

_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.

I modified the code in the standard library to the best of my judgement.

rdar://16477198

Swift SVN r18212
2014-05-16 20:49:54 +00:00
Doug Gregor
b756fc29ec Don't require paretheses when mixing optional types and array types...
... unless we actually hit one of the confusing cases involving
multi-dimensional arrays (e.g., Int[]?[]), at which point one needs to
write parentheses <rdar://problem/16737035>.



Swift SVN r18181
2014-05-16 06:03:26 +00:00
Ted Kremenek
172cc3c984 Fix my last commit to accommodate for rename of NativeArray.
Swift SVN r18151
2014-05-16 00:45:48 +00:00
Ted Kremenek
5e966fdd52 Add basic '==' for Array, NativeArray, and Slice.
I suspect this can be made much better.  It only
works for comparing Array<T> and Array<T>,
NativeArray<T> and NativeArray<T>, etc., not
NativeArray<T> and Array<T>.  I also suspect
the implementation can be made better.  The goal
was to make this functional, as this basic
functionality was missing.

Implements <rdar://problem/16768095>.

Swift SVN r18150
2014-05-16 00:32:00 +00:00
Dave Abrahams
b666651e3f [stdlib] Rename NativeArray => ContiguousArray
Per API review feedback.

Swift SVN r18140
2014-05-15 23:24:09 +00:00
Dmitri Hrybenko
b966c9583f stdlib/{Array, Dictionary}: make debugDescription forward to debugDescription
of container elements

rdar://16929672


Swift SVN r18132
2014-05-15 22:08:07 +00:00
Dave Abrahams
8e1a85490b [stdlib] More infrastructure for Array bridging
Totally untested; tests are next.

Swift SVN r18096
2014-05-15 04:32:13 +00:00
Ted Kremenek
9eea282719 Switch range operators ".." and "...".
- 1..3 now means 1,2
- 1...3 now means 1,2,3

Implements <rdar://problem/16839891>

Swift SVN r18066
2014-05-14 07:36:00 +00:00
Dave Abrahams
0222047dda [stdlib] A couple of Array changes...
...that managed to sneak out of my last commit.

Swift SVN r18028
2014-05-13 22:03:57 +00:00
Dave Abrahams
34edde40ca [stdlib] Array bridging/bridge-cast entry points
Still needs lots of testing, but at least we have the code in and
building, finally.

Swift SVN r18027
2014-05-13 21:33:40 +00:00
Dmitri Hrybenko
2cc8fe40d4 stdlib/printing: replace four printing systems with one new one
The old ones were:

- print/println
- printAny
- printf
- Console

The new printing story is just print/println.  Every object can be printed.
You can customize the way it is printed by adopting Printable protocol.  Full
details in comments inside stdlib/core/OutputStream.swift.

Printing is not completely finished yet.  We still have ReplPrintable, which
should be removed, string interpolation still uses String constructors, and
printing objects that don't conform to Printable will result in printing
mangled names.


Swift SVN r18001
2014-05-13 13:07:59 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Dave Abrahams
079821c8cc [stdlib] Start generating actual (new) Array types
Swift SVN r15769
2014-04-02 02:47:38 +00:00