Commit Graph

1231 Commits

Author SHA1 Message Date
Joe Groff
3b30be2580 Revert "Turn on C function pointer imports by default."
This reverts commit r27598, because SourceKit tests need updating to match.

Swift SVN r27600
2015-04-22 20:37:35 +00:00
Joe Groff
b0497db5ec Turn on C function pointer imports by default.
Update tests to match, and rewrite SwiftPrivatePthreadExtras to take advantage of native C function pointer support instead of hacking it up through a stub C++ library.

Swift SVN r27598
2015-04-22 19:54:35 +00:00
Dave Abrahams
ee72b0dc2f [stdlib] Mirror: internal factorization
Swift SVN r27587
2015-04-22 17:23:54 +00:00
Chris Lattner
3ec09eec8e force adopt let/else and the Swift 1.2 if/let extensions in the stdlib a bit, for dogfooding
and cleanup.

I changes cases that had a non-trivial "then" body but a trivial else.  Most of the cases in
the stdlib have a trivial "then" clause, so I didn't change them.




Swift SVN r27567
2015-04-22 06:24:06 +00:00
Nadav Rotem
32211041d2 Rename @semantics -> @_semantics.
Swift SVN r27533
2015-04-21 17:10:06 +00:00
Dmitri Hrybenko
883ac4c11f stdlib: implement a defaulted CollectionType._prext_count() method
Swift SVN r27447
2015-04-18 04:25:15 +00:00
Dmitri Hrybenko
9b94063e29 Migrate away from the deprecated String.toInt()
Swift SVN r27441
2015-04-17 21:46:21 +00:00
Dmitri Hrybenko
0d6374bb58 stdlib/HashedCollections: skip computing the hash for lookups in empty
collections

Swift SVN r27395
2015-04-17 01:56:19 +00:00
Dmitri Hrybenko
8628a3d4e8 stdlib: _copyToNativeArrayBuffer(): use unsafe more
Now we initialize the array buffer from sequences using unsafe pointer
arithmetic, which avoids extra retain/release traffic.  But since the
size of the sequence is not known in advance, we only initialize as much
as underestimateCount() promises, and fall back to the slow approach for
the tail.  Nevertheless, for collections, where the size is known
precisely, this technique is suboptimal only by one branch.

rdar://20530390

Swift SVN r27380
2015-04-16 20:49:22 +00:00
Dmitri Hrybenko
c48d6aa0ab stdlib: change underestimateCount() into a method
rdar://19895265

Swift SVN r27346
2015-04-16 05:05:17 +00:00
Dmitri Hrybenko
d267b86cb6 stdlib: move the bulk of SequenceType algorithms to protocol extensions
rdar://19895265

Swift SVN r27269
2015-04-14 01:53:19 +00:00
Dmitri Hrybenko
3b57d578bf StdlibUnittest: hide state inside the function scope with a local type
... because Swift does not have C-style function-local statics, but
globally-visible state is bad in any case.

Swift SVN r27235
2015-04-11 06:13:54 +00:00
Dmitri Hrybenko
a84793c60b Fix and re-enable StdlibUnittestRunAllTestsCalledTwice.swift on iOS
Swift SVN r27234
2015-04-11 06:13:52 +00:00
Dmitri Hrybenko
a5d6aec352 StdlibUnittest: add a diagnostic for calling runAllTests() twice
... and fix this issue in the sort() test.

Swift SVN r27215
2015-04-10 21:54:56 +00:00
Dave Abrahams
ac3f047496 [stdlib] Renaming fallout from Mirror API review
toString(x)      => String(x)
toDebugString(x) => String(reflecting: x)
Printable        => CustomStringConvertible
DebugPrintable   => CustomDebugStringConvertible

Also updated comments to clarify these protocols

Swift SVN r27090
2015-04-07 20:32:26 +00:00
Dmitri Hrybenko
ff2dd6320a stdlib: fix coding style
When colon specifies is-a relationship between types, we put spaces on
both sides of the colon.

Swift SVN r27016
2015-04-05 05:54:55 +00:00
Joe Groff
0f3c1eeb22 RaceTest: Remove workaround for rdar://problem/20418117.
I just fixed this.

Swift SVN r27006
2015-04-05 03:38:27 +00:00
Joe Groff
41f73d43ae Runtime: Try to make lazy ErrorType-to-NSError bridging thread-safe.
Atomically initialize and load the NSError bridging fields within an ErrorType box so that we do the right thing when two threads concurrently coerce the box to NSError.

Swift SVN r26996
2015-04-05 00:17:34 +00:00
Doug Gregor
707e288978 Delete some unnecessary default cases we now warn about.
Swift SVN r26687
2015-03-29 05:42:28 +00:00
Ben Langmuir
784a05faf2 [cmake] Replace a bunch of OSX checks with Darwin checks
These should all apply to any Darwin platform, and the current behaviour
was breaking cross-compilation.

Introduces a SWIFT_DARWIN_VARIANTS pattern, to be used as follows:
    if(SWIFT_HOST_VARIANT MATCHES "${SWIFT_DARWIN_VARIANTS}")

Also fix one place where I checked the CMAKE_SYSTEM_NAME instead of the
host variant that I recently introduced.  I haven't attempted to find
the rest of the places we're doing this though.

Swift SVN r26554
2015-03-25 21:15:30 +00:00
Dmitri Hrybenko
ab408d4dc3 Update the compiler and SDK overlay for nullability and generics in Foundation
We have an SPI between the Swift compiler and Foundation based on the
SWIFT_SDK_OVERLAY_FOUNDATION_EPOCH preprocessor macro that allows us to
request the new API.  rdar://20270080 tracks removing it.

Swift SVN r26475
2015-03-24 02:18:06 +00:00
Dmitri Hrybenko
759b2f07e3 Add a cast that would allow us to build using old and new SDKs
Swift SVN r26398
2015-03-21 23:07:28 +00:00
Dmitri Hrybenko
c421c51a42 StdlibUnittest: add facilities to replace NSLocale.currentLocale()
Will use this API to write tests for rdar://20171815.

Swift SVN r26391
2015-03-21 05:41:46 +00:00
Graham Batty
c01f032512 Take more unnecessary things out of glibc modulemap.
This also takes out the last /usr/include/sys that isn't
present on ubuntu 14.04.

Swift SVN r26281
2015-03-18 22:43:54 +00:00
David Farler
544ef4002d Merge tvOS and watchOS Support
- Add frontend and standard library build support for tvOS.
- Add frontend support for watchOS.

watchOS standard library builds are still disabled during SDK bring-up.

To build for TVOS, specify --tvos to build-script.
To build for watchOS, specify --watchos to build-script (not yet supported).

This patch does not include turning on full tests for TVOS or watchOS, and
will be included in a follow-up patch.

Swift SVN r26278
2015-03-18 21:35:07 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Graham Batty
477becd359 Remove unnecessary parts of glibc modulemap.
This should hopefully make it more portable to different
versions of glibc-using platforms.

Swift SVN r25964
2015-03-10 22:35:50 +00:00
Dmitri Hrybenko
e460eb6264 Revert "[stdlib] Replace aString.toInt() with Int(aString)"
This reverts commit r25636.  It depends on integer parsing APIs, which
are being moved to SwiftExperimental.

Swift SVN r25889
2015-03-09 19:04:18 +00:00
Dmitri Hrybenko
abd0b72638 SwiftPrivateSerialization: refuse to deserialize extremely large arrays
and dictionaries on 32-bit platforms, where size does not fit into an
Int

Swift SVN r25886
2015-03-09 17:10:07 +00:00
Dmitri Hrybenko
b7498a1efd stdlib: add a private serialization API
These APIs will be used for writing automation tools in Swift.  Just
like other private APIs, this module is not exposed to extrenal users.

The primary motivation for doing instead of using NSCoder this is that
NSCoder does not work with structs and Swift containers.  Using classes
for everything just to satisfy NSCoder forces unnatural code.

This API requires two times (!) less boilerplate than NSCoding, since
the same method is used for serialization and deserialization.  This API
is also more type-safe, it does not require the user to write 'as' type
casts, unlike NSCoding.

Please take a look at
validation-test/stdlib/SwiftPrivateSerialization.swift to see the
intended use pattern.

The performance of the underlying implementation is already decent, and
there's a lot of room for improvement.

This is a re-commit of r25678, with a fix for 32-bit platforms.

Swift SVN r25877
2015-03-09 06:55:19 +00:00
Dmitri Hrybenko
350248dae5 Reorganize the directory structure under 'stdlib'
The standard library has grown significantly, and we need a new
directory structure that clearly reflects the role of the APIs, and
allows future growth.

See stdlib/{public,internal,private}/README.txt for more information.

Swift SVN r25876
2015-03-09 05:26:05 +00:00