Commit Graph

455 Commits

Author SHA1 Message Date
Greg Parker
dc5f3c2090 <rdar://16878510> Add definitions of stdin/stdout/stderr to the Darwin overlay.
Swift SVN r18766
2014-06-10 00:33:02 +00:00
Dmitri Hrybenko
a69e341aa2 stdlib/NSString APIs on String: fix a bug and add tests for
rangeOfCharacterFromSet(_:options:range:)

The underlying Objective-C API could return an NSRange of NSNotFound.  Swift's
String.Index can not represent that, so change the API to return an optional
Swift Range<Index> instead.


Swift SVN r18679
2014-05-30 23:07:21 +00:00
Dmitri Hrybenko
df71a47fe4 stdlib/NSString APIs on String: fix two bugs and add more tests
stringWithBytes(_:length:encoding:) was passing an array to Objective-C
incorrectly, and a garbage NSString was being constructed as a result.

Unhide the initializer was accidentally hidden.


Swift SVN r18674
2014-05-30 20:30:57 +00:00
Dmitri Hrybenko
ea7758f40d stdlib/String: implement UTF-8 encoding for Strings that wrap NSStrings for
which Foundation can not give us a UTF-8 encoding in O(1)

rdar://17041741


Swift SVN r18660
2014-05-29 00:41:42 +00:00
Enrico Granata
c44731ac31 B&I updated the builders to a new iOS SDK - the new SDK means that the Unmanaged<> is unwrapped automatically on our behalf
This patch is required to unbreak the build



Swift SVN r18651
2014-05-27 23:53:26 +00:00
Dmitri Hrybenko
470fee7838 stdlib: correct a comment to be more explicit that this is a hack
Swift SVN r18644
2014-05-26 23:49:50 +00:00
Enrico Granata
30341ed401 The B&I-sanctioned iOS SDK does not have the right annotations for this to be automatically unwrapped. The Graphics Context comes back to us as Unamanged<> and we need to manually extract the value out of it. Do so for now
Swift SVN r18643
2014-05-26 23:22:59 +00:00
Enrico Granata
3e1ed25aa7 Add a mirror for UIView
There are a couple caveats to this Mirror, discussed in detail in the radar

Fixes rdar://17029335



Swift SVN r18642
2014-05-26 20:26:57 +00:00
Dmitri Hrybenko
f179e4cbc0 stdlib/Foundation overlay: hide NSSimpleCString
rdar://17024122


Swift SVN r18636
2014-05-26 18:39:26 +00:00
Enrico Granata
0134c6d197 Allow user-defined Swift classes to implement our API for QuickLooks, and have the result of that API be picked up by the Mirrors
This is our public API for how quicklooks work in the debugger, and the plan is to have this same API work in playgrounds as well

Fixes rdar://17023157


Swift SVN r18609
2014-05-24 01:00:46 +00:00
Chris Hanson
3298bebb2c Make XCTestCase.className demangle its result.
XCTest needs a way to get the demangled name of a test case class,
so provide one by overriding NSObject.className.

Addresses <rdar://problem/17010812>.

Swift SVN r18606
2014-05-23 22:07:29 +00:00
Dmitri Hrybenko
fce7a8c4ff stdlib/NSString APIs on String: dataUsingEncoding:allowLossyConversion: can
return nil, change our API and add tests


Swift SVN r18597
2014-05-23 16:38:53 +00:00
Dmitri Hrybenko
c5f21546db stdlib/CString: fix two issues with CString.persist():
1. it crashed on a null pointer;

2. it crashed on a non-ASCII strings.

rdar://17016284


Swift SVN r18594
2014-05-23 15:18:21 +00:00
Dmitri Hrybenko
04dae74cd6 stdlib: correct comment
Swift SVN r18592
2014-05-23 13:07:46 +00:00
Dmitri Hrybenko
83f7bdc30e stdlib/NSString APIs for String: allow a nil locale to be passed to
capitalizedStringWithLocale(_:)


Swift SVN r18591
2014-05-23 09:51:30 +00:00
Doug Gregor
f305cd7946 Look through bridgeFromObjectiveC calls to find forced casts within optional injections.
Fixes <rdar://problem/17003302>.


Swift SVN r18563
2014-05-22 15:47:13 +00:00
Doug Gregor
67ca1c9ea1 Implement the new casting syntaxes "as" and "as?".
There's a bit of a reshuffle of the ExplicitCastExpr subclasses:
  - The existing ConditionalCheckedCastExpr expression node now represents
"as?". 
  - A new ForcedCheckedCastExpr node represents "as" when it is a
  downcast.
  - CoerceExpr represents "as" when it is a coercion.
  - A new UnresolvedCheckedCastExpr node describes "as" before it has
  been type-checked down to ForcedCheckedCastExpr or CoerceExpr. This
  wasn't a strictly necessary change, but it helps us detangle what's
  going on.

There are a few new diagnostics to help users avoid getting bitten by
as/as? mistakes:
  - Custom errors when a forced downcast (as) is used as the operand
  of postfix '!' or '?', with Fix-Its to remove the '!' or make the
  downcast conditional (with as?), respectively.
  - A warning when a forced downcast is injected into an optional,
  with a suggestion to use a conditional downcast.
  - A new error when the postfix '!' is used for a contextual
  downcast, with a Fix-It to replace it with "as T" with the
  contextual type T.

Lots of test updates, none of which felt like regressions. The new
tests are in test/expr/cast/optionals.swift. 

Addresses <rdar://problem/17000058>


Swift SVN r18556
2014-05-22 06:15:29 +00:00
Dave Abrahams
0f9edadc41 [stdlib] String API Review: NSString API
Many changes in how we're presenting the NSString APIs on String, most
notably that we now traffic in String.Index and Range<String.Index>
rather than Int and NSRange.  Also we present NSString initializers that
can fail only as factory functions, and factory functions that can't
fail only as init functions.

About 25% of the API changes here have been reviewd by the Foundation
guys, and testing is, as it has always been, admittedly spotty.  Dmitri
is going to be writing some more comprehensive tests.

Swift SVN r18553
2014-05-22 04:21:55 +00:00
Joe Pamer
1d34a88477 Revert "Fix two problems with implicit conversions: - rdar://problem/16776273, wherein conversions between nil and .None were permitted due to an implicit conversion between nil and COpaquePointer. - rdar://problem/16877526, where we needed to add new equality overloads to handle conversions between nil and .None given the supression of user conversions. (Thanks to Ted for the overloads and test.)"
This reverts commit r18473.

Swift SVN r18477
2014-05-21 00:28:46 +00:00
Joe Pamer
f469d8f1f6 Fix two problems with implicit conversions:
- rdar://problem/16776273, wherein conversions between nil and .None were permitted
due to an implicit conversion between nil and COpaquePointer.
- rdar://problem/16877526, where we needed to add new equality overloads to handle
conversions between nil and .None given the supression of user conversions.
(Thanks to Ted for the overloads and test.)

Swift SVN r18473
2014-05-20 23:53:34 +00:00
Greg Parker
e2ca13c993 <rdar://16529903> Make UIViewController's nib search find Swift class names.
UIViewController is able to find nib files that have names derived from the 
UIViewController subclass's name. This change modifies UIViewController's 
lookup so it is able to find nib files for Swift class names.


Swift SVN r18470
2014-05-20 23:14:52 +00:00
Dmitri Hrybenko
8910632338 stdlib/Dictionary: allow NSDictionary to be bridged to Dictionary<K, V> non-verbatim
Dictionary's isBridgedToObjectiveC() was overly restrictive.  This went
unnoticed because the tests were using internal Dictionary APIs to construct
the desired state, instead of going thourgh casts.

rdar://16973429


Swift SVN r18454
2014-05-20 16:06:52 +00:00
Doug Gregor
5c532d6111 Introduce a fast path for Array.bridgeFromObjectiveC()
We were using the bridged non-verbatim path
(_arrayBridgeFromObjectiveC) for bridged-verbatim types. While that
path can do the right thing (and does when the standard library's
internal checking is turned off), it's unnecessarily inefficient.

Swift SVN r18418
2014-05-19 14:18:39 +00:00
Doug Gregor
57f75b7448 Implement bridging from NSNumber to Int/UInt/Float/Double/Bool.
This makes fun bridging like

  var obj: AnyObject! = [3.14159, 2.71828, 0] as Double[]
  if let intArr = obj as Int[] {
    println("Array of doubles as ints is \(intArr)")
  }

"work", given that NSNumber is the common class type through which we
are bridging.




Swift SVN r18398
2014-05-19 07:33:15 +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
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