Commit Graph

431 Commits

Author SHA1 Message Date
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
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
200b89291c [stdlib] Array API review: privatize [bB]uffer
Swift SVN r18335
2014-05-18 17:32:00 +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
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
Ted Kremenek
92157d7d55 Change 'isSignMinus', 'isNormal', etc., in FloatingPointNumber to properties.
Swift SVN r18306
2014-05-18 04:20:09 +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
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
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
a4d9dcf1a7 stdlib: extinguish \brief and \c
Swift SVN r18261
2014-05-17 18:10:51 +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
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
3e8eb46f58 [stdlib] Improve comments and a name
Swift SVN r18242
2014-05-17 05:56:55 +00:00
Dave Abrahams
3dc699ee0d [stdlib] Remove asNSArray; it's obsolete
Swift SVN r18239
2014-05-17 05:33:26 +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
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
Dmitri Hrybenko
828acd2738 stdlib: hide _NSSwiftArray, _NSSwiftDictionary, _NSSwiftEnumerator
Swift SVN r18187
2014-05-16 08:29:17 +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
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
ad18ed81fb Start importing NSArray* as (AnyObject[])! by default <rdar://problem/16535097>.
Swift SVN r18157
2014-05-16 01:10:13 +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
Jordan Rose
3f782ceed3 Drop QuartzCore overlay.
The code is incorrect and depends on functions introduced in this year's OSs.
Additionally, CoreImage is a top-level framework on iOS, so we have to be
more careful if/when we add this back.

Swift SVN r18135
2014-05-15 22:59:15 +00:00
Fariborz Jahanian
ee401b6ed5 Fixes a typo.
Swift SVN r18134
2014-05-15 22:52:27 +00:00
Jordan Rose
6f8dbe907d [CMake] QuartzCore depends on Foundation.
Swift SVN r18130
2014-05-15 22:03:27 +00:00
Fariborz Jahanian
6635feb32b Provide sdk vararg overlays for CIFilter and
CISampler per rdar://16726822
(also removed a comment in Foundation.swift).


Swift SVN r18123
2014-05-15 20:13:55 +00:00
Doug Gregor
01f3f7777e Make _convertNSArrayToArray work for non-verbatim bridged types.
The runtime diagnostics here are awful, but the monkey dances
<rdar://problem/16899681>.



Swift SVN r18121
2014-05-15 19:25:58 +00:00
Joe Pamer
a74c44a6e4 Fix two crashing bugs related to checked downcasts - rdar://problem/16093456 and rdar://problem/16892211.
Swift SVN r18118
2014-05-15 18:36:44 +00:00
Dmitri Hrybenko
acb7465f4b stdlib: underscore-prefix NSContiguousString and NSOpaqueString
Swift SVN r18114
2014-05-15 18:02:30 +00:00
Dmitri Hrybenko
d50a8b476d stdlib/Foundation overlay: add Printable conformance to Selector
rdar://16897592


Swift SVN r18109
2014-05-15 17:25:43 +00:00
Dmitri Hrybenko
8ee468e974 stdlib/Foundation overlay: add Printable conformance to ObjCBool
rdar://16897579


Swift SVN r18108
2014-05-15 17:02:40 +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
aceb11edb1 [stdlib] bridgeFromObjectiveC for String
Seemed pretty obvious so I just did it.

Swift SVN r18073
2014-05-14 16:44:49 +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
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
Enrico Granata
8478cd9905 Add a mirror for NSSet
Part of the playgrounds effort



Swift SVN r18038
2014-05-13 23:20:32 +00:00
Doug Gregor
d5a9c2ab94 Only supersede initializers with other imported initializers when the types match.
This fixes a case where the Swift-variadic and C-varargs versions of
various initializers were superseding each other
<rdar://problem/16801456>.

It also uncovered some more cases where we weren't getting quite the
right semantics for factory-methods-as-initializers, which are also
fixed here.

Swift SVN r18010
2014-05-13 16:49:39 +00:00
Dmitri Hrybenko
de9a0c8ff0 stdlib/printing: remove ReplPrintable protocol
It is replaced by debugPrint() family of functions, that are called by REPL.

There is a regression in printing types that don't conform to Printable, this
is tracked by rdar://16898708


Swift SVN r18006
2014-05-13 16:22:56 +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