Commit Graph

21665 Commits

Author SHA1 Message Date
Dave Abrahams
2c3ab47cf2 [stdlib] O(1) Array<non-verbatim> round-tripping
Arrays of non-verbatim-bridged types (such as Int, and today's String)
are converted to Objective-C lazily, with the objects created due to
element conversion being autoreleased when necessary.

Fixes <rdar://problem/17360154>

Note: test/SIL/Parser/array_roundtrip.swift was XFAIL'd;
see <rdar://problem/17758203>

Swift SVN r20293
2014-07-22 04:42:47 +00:00
Enrico Granata
c06a072270 After investigating, there is no actual reason why the SpriteKit mirrors had to be disabled on iOS. So, just do the right thing. One change, of course, is to use UIImage on-device instead of NSImage. Both can be built from an NSData, and according to purplefish, the NSData we get back is of the correct image format to be reconstructed on either platform. Fixes rdar://17593122
Swift SVN r20289
2014-07-22 01:37:01 +00:00
Joe Groff
436acb00f3 Foundation: Remove the prepareWithInvocationTarget overlay.
Giving the invocation target proxy a type will be bogus when we turn on 'dynamic'. This breaks the NSUndoManager tests because we still can't work with lvalues through AnyObject. <rdar://problem/17755906>

Swift SVN r20283
2014-07-22 00:23:34 +00:00
Fariborz Jahanian
5197fe0f9d Move noErr to Darwin with OSStatus as its type.
rdar://17285288


Swift SVN r20279
2014-07-21 21:14:27 +00:00
Fariborz Jahanian
55e3e4b028 declare 'noErr' in the overlay to be of type Int32
(to make it compatible with OSStatus) rdar://17285288
This line, and those below, will be ignored--

M    stdlib/objc/Foundation/Foundation.swift


Swift SVN r20278
2014-07-21 20:43:55 +00:00
Dave Abrahams
079b5e57ef [stdlib] += no longer appends array elements
+= only extends arrays with another sequence of the same element type.

Fixes <rdar://problem/17151420> The use of the overloaded += operator in
Swift is inconsistent and confusing with Arrays.

Note that this commits generated 3 new radars against the type checker:

  <rdar://problem/17751308>
  <rdar://problem/17750582>
  <rdar://problem/17751359>

Swift SVN r20274
2014-07-21 20:07:13 +00:00
Fariborz Jahanian
ff02defe06 Adding "typealias NSRectEdge = CGRectEdge" in the
overlay. rdar://16593744


Swift SVN r20269
2014-07-21 19:06:35 +00:00
Doug Gregor
b502010365 s/auto_closure/autoclosure in XCTest
Swift SVN r20255
2014-07-21 15:36:57 +00:00
Doug Gregor
4c49802c15 Drop the ~= overload for NSObject <rdar://problem/17639977>.
Swift SVN r20254
2014-07-21 15:32:06 +00:00
Chris Lattner
bc481f0fe1 implement <rdar://problem/16859927> remove the underscore in "auto_closure"
autoclosure is one work, not two.



Swift SVN r20253
2014-07-21 15:23:50 +00:00
Doug Gregor
eed37dc92e Remove bridging of NSPoint, NSSize, and NSRect because they are OSX-only.
This effectively reverts all but the NSRange part of r20241, because
it's better to have consistent behavior across the platforms than have
this feature on just one platform.

Swift SVN r20252
2014-07-21 15:13:37 +00:00
Dmitri Hrybenko
2af9bc954a stdlib/Dictionary: underscore-prefix implementation details (even not
marked as public)

Swift SVN r20245
2014-07-21 08:31:32 +00:00
Dmitri Hrybenko
e6d2194b22 stdlib/String: trap when attempting to increment or index using
String.UTF8View.endIndex

rdar://17539993

Swift SVN r20244
2014-07-21 08:31:30 +00:00
Dave Abrahams
3731a0d1d2 [stdlib] Deal with various zero-division scenarios
Primarily, this means becoming resilient to Builtin.strideof(x) == 0.
Pretty much the only way to get pointers and arrays to make sense is to
treat zero-sized elements as having a stride of 1, so we do that in our
wrapper for Builtin.strideof.  Other points include precondition checks
for radixes in number formatting.

Fixes <rdar://problem/17097768>

Swift SVN r20242
2014-07-21 05:21:22 +00:00
Dave Abrahams
8091436114 [stdlib] Bridge the types NSValue wraps explicitly
NSRange, NSPoint, NSSize, and NSRect.  This time, using Jordan's
suggestion for iOS portability.

Fixes <rdar://problem/16973060>


Conflicts:
	stdlib/objc/Foundation/CMakeLists.txt
	stdlib/objc/Foundation/Foundation.swift

Swift SVN r20241
2014-07-21 04:18:40 +00:00
Ben Langmuir
9c267d5dc7 Add some missing cmake dependencies
The only interesting bit is that for stdlib/objc to build reliably, its
.o files all need to depend on the generated swiftmodule files for any
of its library dependencies.  It looks like cmake treats
target_link_libraries as only implying a dependency between the
resulting libraries, and not the objects.  For now, I've achieved this
by making the objects depend on the whole target (which includes
linking), but only the swiftmodule is actually necessary.

Swift SVN r20240
2014-07-21 04:07:50 +00:00
Dave Abrahams
8e853fd0d4 [stdlib] Add isEmpty first() and last() to lazy collections
<rdar://problem/16953693> part 3 of 3

Swift SVN r20239
2014-07-21 03:27:17 +00:00
Dave Abrahams
c9e55b48c4 [stdlib] Add first() and last() to Array types
Also, tests for the isEmpty property

<rdar://problem/16953693> part 2 of 3

Swift SVN r20238
2014-07-21 03:27:17 +00:00
Dave Abrahams
a1c1d09c6c [stdlib] Add first, last, and isEmpty algorithms
<rdar://problem/16953693> part 1 of 3

Swift SVN r20237
2014-07-21 03:27:15 +00:00
Chris Lattner
56dbab6421 move prefix+ up to being next to prefix-, NFC.
Swift SVN r20235
2014-07-20 22:18:35 +00:00
Jordan Rose
8f520414b7 [Accessibility] A private class cannot contain public methods.
There's no meaningful way in which these methods are public, since they
can't be accessed through any value of the type

<rdar://problem/17647878>

Swift SVN r20224
2014-07-20 17:26:24 +00:00
Ted Kremenek
3075dee511 Mark 'NSConstantString' unavailable. Implements <rdar://problem/17306671>.
Swift SVN r20208
2014-07-19 05:14:06 +00:00
Dave Abrahams
de368b9070 [stdlib] Make algorithms safe with illegal predicates
Even if the user supplies an ordering predicate that isn't a strict-weak
ordering, algorithms should not index beyond their bounds.  Otherwise, a
use of withUnsafeMutableStorage for optimization purposes could easily
do an unsafe memory access.

This commit comments and tests our algorithms that require strict weak
orderings, and fixes safety problems in partition().  Most benchmarks
are unaffected, but the rewrite of partition produces a 27% speedup in
the Phonebook benchmark at -O3 and a 22% speedup at -Ofast.

Also, at -Ofast, QuickSort lost 6% and RC4 gained 6%.  These benchmarks
were not noticeably affected at -O3

====================`PrecommitBench_O3`====================
````benchmark`,`baserun0`,`baserun1`,`baserun2`,``optrun0`,``optrun1`,``optrun2`,``delta`,`speedup`
````Phonebook`,``1608.00`,``1676.00`,``1651.00`,``1265.00`,``1278.00`,``1281.00`,`343.00`,```27.1%`
````QuickSort`,```430.00`,```448.00`,```429.00`,```428.00`,```431.00`,```428.00`,```1.00`,````0.2%`
``````````RC4`,```925.00`,```924.00`,```922.00`,```916.00`,```919.00`,```917.00`,```6.00`,````0.7%`
====================`PrecommitBench_Ofast`====================
````benchmark`,`baserun0`,`baserun1`,`baserun2`,``optrun0`,``optrun1`,``optrun2`,``delta`,`speedup`
````Phonebook`,``1521.00`,``1546.00`,``1591.00`,``1252.00`,``1255.00`,``1256.00`,`269.00`,```21.5%`
````QuickSort`,```478.00`,```477.00`,```476.00`,```506.00`,```510.00`,```513.00`,``30.00`,```-5.9%`
``````````RC4`,``1033.00`,``1874.00`,``1030.00`,```974.00`,```982.00`,```975.00`,``56.00`,````5.7%`

Swift SVN r20202
2014-07-19 01:51:03 +00:00
Dave Abrahams
6bbbf052a3 [stdlib] _partition doesn't need to be public!
Thanks, Jordan

Swift SVN r20194
2014-07-19 00:38:48 +00:00
Dave Abrahams
ec8b29cdf1 [stdlib] Fix the public interface of partition
It should not take the predicate as inout!

Swift SVN r20193
2014-07-19 00:35:45 +00:00
Joe Groff
c556d92ccd SILGen: Implement codegen for lvalue ForceValueExprs.
Add a set of _preconditionOptionalHasValue intrinsics that merely test that an optional has a case. Emit an lvalue ForceValueExpr as a physical lvalue, first asserting the precondition then projecting out the Some payload.

Swift SVN r20188
2014-07-18 22:49:49 +00:00
Dave Abrahams
ac1a050732 [stdlib] make some bridging classes final
Swift SVN r20186
2014-07-18 22:07:07 +00:00
Dave Abrahams
71913ae085 [stdlib] Rename @semantics for array bounds checks
There are two kinds of bounds check: valid for subscripting, and valid
as an index.  Rename the semantics accordingly.

Swift SVN r20181
2014-07-18 20:54:26 +00:00
Enrico Granata
e4cfd3ae0a Reflect ranges in the half-open format - it's not always consistent with what the user typed, but at least it resembles language syntax, and is more consistent with what LLDB already does too. Last chunk of work for rdar://16117421
Swift SVN r20168
2014-07-18 18:26:17 +00:00
Enrico Granata
7bf01a5caf Add a Mirror for NSCursor. This should be the last Cocoa Mirror that we need to write for this release - barring any last-minute critical incoming. Fixes rdar://16681585
Swift SVN r20160
2014-07-18 18:01:45 +00:00
Dave Abrahams
3a90aaf8a3 [stdlib] Ensure full bounds checking for Array
Swift SVN r20132
2014-07-18 02:40:24 +00:00
Dave Abrahams
4d704c3574 Revert "[stdlib] Array resilient slicing"
We've decided resilience is wrong for Swift given current constraints;
see rdar://problem/11940897 for more detail.

This reverts commit r20052

Swift SVN r20127
2014-07-18 00:21:22 +00:00
Dave Abrahams
a84f46ca26 [stdlib] Add prefix/suffix functions on Sliceable
Also, improve comments in Collection.swift

Swift SVN r20125
2014-07-18 00:11:44 +00:00
Dave Abrahams
11e196abcf [StdlibUnittest] expectEqualSequence, refactor
Swift SVN r20124
2014-07-18 00:11:43 +00:00
Dave Abrahams
4e54fafb35 [stdlib] Fix symmetry of bounded advance()
It wasn't properly handling the cases where the bound was in the
opposite direction from the amount, when advancing random access
indices.

Swift SVN r20123
2014-07-18 00:11:43 +00:00
Doug Gregor
716d548806 Start generating .apinotes files for each of the frameworks that have them.
.apinotes files provide API annotations alongside the Swift overlays
for Objective-C modules, and will be handled by the Clang
importer. Start generating these files from the current in-compiler
source (KnownObjCMethods.def).

The eventual goal is to switch from KnownObjCMethods.def to the
currently-being-defined textual format for API notes, and to replace
the silly swift-ide-test invocations with a Swift driver mode.


Swift SVN r20085
2014-07-17 14:34:20 +00:00
Dmitri Hrybenko
c4138bd192 stdlib/Dictionary: coding style, remove unneeded line breaks
Swift SVN r20080
2014-07-17 09:54:40 +00:00
Dmitri Hrybenko
4c4f83fb52 stdlib: underscore-prefix requirements of _BridgedToObjectiveCType and
_ConditionallyBridgedToObjectiveCType protocols

rdar://17283639


Swift SVN r20079
2014-07-17 09:42:19 +00:00
Chris Hanson
877367add5 Have XCTest use string interpolation everywhere.
Instead of using reflect(), use string interpolation now that it should work everywhere.

Addresses <rdar://problem/17415068>.

Swift SVN r20061
2014-07-16 23:58:07 +00:00
Dave Abrahams
e2d9f6f6a5 [stdlib] Fix clamp parameter name
Thanks, Jordan!

Swift SVN r20053
2014-07-16 22:33:01 +00:00
Dave Abrahams
304f27218b [stdlib] Array resilient slicing
Partially addresses <rdar://problem/11940897> #Seed 4: Slicing should
limit to valid slices

Swift SVN r20052
2014-07-16 22:27:09 +00:00
Dave Abrahams
3d61398376 [stdlib] Add clamp method to Interval
Swift SVN r20051
2014-07-16 22:16:26 +00:00
Dave Abrahams
c4f798e246 [stdlib] Make our BidirectionalIndexTypes Comparable
This will allow more error checking, resilient slicing, and occasionally
other useful capabilities.

Step 1 of <rdar://problem/11940897>

Swift SVN r20036
2014-07-16 20:43:42 +00:00
Dmitri Hrybenko
d125ac1e24 stdlib/runtime: stdlib casts to existentials: correctly project the buffer as
required

rdar://17628745


Swift SVN r20024
2014-07-16 15:17:46 +00:00
Dmitri Hrybenko
f04a37ffd3 stdlib: make NSDictionary.Generator initializer private (users should call
NSDictionary.generate())


Swift SVN r20022
2014-07-16 09:05:22 +00:00
Dmitri Hrybenko
d9d789f418 stdlib: rename NSDictionaryGenerator to NSDictionary.Generator
rdar://17674077


Swift SVN r20021
2014-07-16 08:59:37 +00:00
Mark Lacey
41643d0ef3 Revert "Remove @transparent from a few functions in the stdlib."
This reverts commit r19996.

I'll either fix <rdar://problem/17687851>, or work around it in a
different way.

Swift SVN r20020
2014-07-16 08:09:56 +00:00
Mark Lacey
36b035b93b Remove @transparent from a few functions in the stdlib.
Marking these generic functions as transparent results in our not
emitting diagnostics for unreachable code if these functions are the
only code in a block and inlining generic code is enabled (due to
<rdar://problem/17687851>).

I don't believe other diagnostics benefit in any way from having these
marked as @transparent, and removing @transparent actually improved
Ackerman at -O3 by 15%.

Swift SVN r19996
2014-07-16 01:22:59 +00:00
Chris Hanson
c3c1489a1c Declare access control for XCTest overlay.
Now that Swift has an access control model, we need to apply it to the XCTest overlay.

This is handy in that it lets us hide some implementation details of the overlay.

Addresses <rdar://problem/17653535>.

Swift SVN r19989
2014-07-15 23:03:29 +00:00
Enrico Granata
e67251392e Now that CGFloat is a struct, it needs to be reflected separately. We can still just reflect its native buffer, but an explicit Reflectable conformace is required. Fixes rdar://17682337
Swift SVN r19984
2014-07-15 20:42:08 +00:00