Commit Graph

3245 Commits

Author SHA1 Message Date
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
Dave Abrahams
b00803bf6c [stdlib] 80-column fixes
Swift SVN r18318
2014-05-18 06:06:17 +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
Doug Gregor
01d3ccecb8 Add some more execution tests for array downcasts of non-verbatim bridged types.
Swift SVN r18304
2014-05-18 04:15:13 +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
eef618d1b5 Change some tests to compare against nil instead of using 'isNull()'.
Swift SVN r18300
2014-05-18 03:42:38 +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
937504bc5e Restrict the array-bridged conversion to non-verbatim bridging.
This allows, e.g., String[] -> NSString[] and String[] -> NSObject[]. Part of <rdar://problem/16952238>.

Swift SVN r18290
2014-05-18 00:42:00 +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
6e23f02a2b [stdlib] Fix T[].bridgeFromObjectiveC
Make the new test pass, and make the tests more robust

Swift SVN r18287
2014-05-18 00:25:56 +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
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
d213355030 stdlib/Dictionary: address internal API review
Add 'removeObjectForKey:'


Swift SVN r18265
2014-05-17 19:47:48 +00:00
Dmitri Hrybenko
5c453ce2bc stdlib/Dictionary: add tests for trapping during bridging a Dictionary
whose KeyType is not NSCopyable

Swift SVN r18259
2014-05-17 17:24:58 +00:00
Dmitri Hrybenko
6808737952 stdlib/CString printing: fix a null dereference in writeTo, similar to one that
was fixed in debugDescription


Swift SVN r18258
2014-05-17 17:15:52 +00:00
Dmitri Hrybenko
5369eaff1e stdlib/Array: add a basic test for trapping on out-of-bounds access
Swift SVN r18256
2014-05-17 17:06:12 +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
Joe Groff
e8f71c12a2 Rename ObjCMutablePointer to AutoreleasingUnsafePointer.
This relates its interface and behavior to that of UnsafePointer, and draws an analogy to '__autoreleasing *' in ARC.

Swift SVN r18236
2014-05-17 04:44:44 +00:00
Greg Parker
81c4e7392d [test] Fix Int size dependence in stdlib/Print.swift.
Swift SVN r18224
2014-05-16 23:06:24 +00:00
Dmitri Hrybenko
fbb9ed3729 stdlib/Dictionary: address internal API review
Add 'removeAtIndex:'


Swift SVN r18222
2014-05-16 22:42:09 +00:00
Greg Parker
cdadebb1c7 [test] Temporarily disable stdlib/Dictionary.swift on iOS simulator.
Swift SVN r18217
2014-05-16 22:13:53 +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
Dmitri Hrybenko
92335b2f91 tdlib/Dictionary: address internal API review
Removed 'find:'
Added 'indexForKey:'


Swift SVN r18197
2014-05-16 16:03:56 +00:00
Dmitri Hrybenko
2c1715fe78 stdlib/Dictionary: address internal API review: preallocate storage when
creating a Dictionary from a dictionary literal

Also fixes rdar://16876745, because once the code moved to using lower-level
interfaces, it became trivial to detect duplicate keys without a performance
hit.


Swift SVN r18193
2014-05-16 14:41:03 +00:00
Dmitri Hrybenko
f498fab1ca stdlib/Dictionary: add tests for Dictionary.{keys, values}
Swift SVN r18191
2014-05-16 12:02:44 +00:00
Dmitri Hrybenko
d35e487606 stdlib/Dictionary: add tests for Dictionary.subscript nil assignment. This
change went in without any tests.


Swift SVN r18189
2014-05-16 11:47:23 +00:00
Dmitri Hrybenko
9abf7a9fa3 stdlib/Dictionary: address internal API review requests
Removed 'add:value:'
Added 'updateValue:forKey:'


Swift SVN r18188
2014-05-16 11:37:25 +00:00
Ted Kremenek
178e2a32df Printing routines should append ".0" to floats, *not* taking locales into account.
Implements <rdar://problem/16895801>.

Swift SVN r18185
2014-05-16 07:27:54 +00:00
Ted Kremenek
4bb475a1c8 Rename UnsafePointer.get/set to a "ptr.pointee" property.
Implements <rdar://problem/16531067>.

Swift SVN r18178
2014-05-16 05:48:05 +00:00
Doug Gregor
df4429fc5d Perform the class-or-ObjC-existential checks first in the runtime bridging entrypoints.
We decided that classes and Objective-C existentials are always going
to be bridged verbatim, ignoring any _BridgedToObjectiveC conformances.
While the compiler isn't preventing conformance of a class type to
_BridgedToObjectiveC, we ignore this case and will find a way to lock
it down if _BridgedToObjectiveC loses its underscore.

The motivation here is that (1) we don't really have a use case for a
class that bridges to Objective-C in any way other than just being an
Objective-C class, and (2) the class-or-ObjC-existential check is
ridiculously cheap compared to the
thread-safe-hash-table-over-a-dlsym-call used to find witness tables,
so do the cheap, common check first.



Swift SVN r18177
2014-05-16 05:18:34 +00:00
Ted Kremenek
fe0dbb701d Remove shorthand "x as T!" instead of "(x as T)!"
Implements <rdar://problem/16806243>.

Swift SVN r18156
2014-05-16 01:07:53 +00:00
Greg Parker
3b0e45b497 Fix -[NSUndoManager prepareWithInvocationTarget:].
This method returns a proxy object. Swift cannot current cast proxy objects 
to their proxied types. The workaround for now is to add a generic overlay 
for -prepareWithInvocationTarget: so the declared type of the returned 
proxy is the proxied type. This is good enough to make undo proxies work with 
objc-dispatched calls.


Swift SVN r18155
2014-05-16 01:07:22 +00:00
Dave Abrahams
10c1961755 [stdlib] Make test work on iOS
Thanks for the hint, Jordan!

Swift SVN r18146
2014-05-16 00:15:35 +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
e1b37a8d91 [stdlib] WIP: complete up/down-cast testing for Arrays of verbatim-bridged elements
Swift SVN r18119
2014-05-15 18:37:06 +00:00
Dmitri Hrybenko
acb7465f4b stdlib: underscore-prefix NSContiguousString and NSOpaqueString
Swift SVN r18114
2014-05-15 18:02:30 +00:00
Dave Abrahams
8cce55bdb4 [stdlib] WIP on Array Bridge/Cast Testing
Swift SVN r18113
2014-05-15 18:01:31 +00:00
Dave Abrahams
fed492b650 [stdlib] Don't assert on empty NSArrays
Empty NSArrays are usually represented by emptyNSSwiftArray, whose
element type is irrelevant.  So when doing a getObjects:range: on that,
presumably the range's length is zero and we shouldn't do any sanity
checking w.r.t. the element type.

Fixes <rdar://problem/16914909> Assertion failed attempting to append
arrays when subclassing Cocoa class

Swift SVN r18110
2014-05-15 17:25:48 +00:00
Dmitri Hrybenko
2a956966ac stdlib/runtime: teach DynamicCastToExistential1 to handle source values that
are existentials

rdar://16925792


Swift SVN r18107
2014-05-15 16:32:13 +00:00
Dmitri Hrybenko
011584a0b6 stdlib/pritning: untie string interpolation from string initializers
String interpolation invokes convertFromStringInterpolationSegment() function
now.  There is no need to add extensions to String to allow custom types to
participate in string interpolation.  Just implementing Printable will do the
right thing.


Swift SVN r18104
2014-05-15 09:56:02 +00:00
Ted Kremenek
7da31bdfdd Disable parsing of single quoted character literals, enabling under a flag.
I didn't want to rip this logic out wholesale.  There is a possibility
the character lexing can be reborn/revisited later, and
disabling it in the parser was easy.

Swift SVN r18102
2014-05-15 07:05:59 +00:00
Dmitri Hrybenko
f183e493bf stdlib/bridging: bridgeFromObjectiveC() can fail to bridge the Objective-C
object to the desired type.  Model this with an optional return type.


Swift SVN r18077
2014-05-14 19:49:22 +00:00
Dave Abrahams
a8bbc4c89b [stdlib] String internal API review changes
I had to XFAIL test/ClangModules/cf.swift, which is failing for reasons
I can't understand.  <rdar://problem/16911496>

Swift SVN r18071
2014-05-14 14:18:52 +00:00
Dmitri Hrybenko
eb9c3a406d stdlib/runtime: implement bridgeFromObjectiveC()
Swift SVN r18070
2014-05-14 13:40:46 +00:00