Commit Graph

68 Commits

Author SHA1 Message Date
Lance Parker
414614cf88 Revert "Revert "[stdlib]Enable Swift 4 mode for the overlays (#12608)"" (#12751)
This reverts commit bcf5d66c8e.
2017-11-06 14:03:48 -08:00
Mishal Shah
bcf5d66c8e Revert "[stdlib]Enable Swift 4 mode for the overlays (#12608)"
This reverts commit f54d8b4ef2.
2017-11-03 11:52:30 -07:00
Lance Parker
f54d8b4ef2 [stdlib]Enable Swift 4 mode for the overlays (#12608)
Enable Swift 4 mode for the overlays
2017-11-03 10:11:45 -07:00
Dave Rahardja
340447ac64 [overlay] Add NSItemProvider overlay
<rdar://problem/32138540>
2017-07-14 22:13:30 -07:00
Mishal Shah
c5ff1f2cac Update master to build with Xcode 9 beta 1, OS X 10.13, iOS 11, tvOS 11, and watchOS 4 SDKs. 2017-06-14 16:20:35 -07:00
Erik Eckstein
488c43c825 runtime: add a runtime function _swift_checkClassAndWarnForKeyedArchiving
This function checks if a mangled class name is going to be written into an NSArchive.
If yes, a warning should be printed and the return value should indicate that.

TODO: print the actual warning

rdar://problem/32414508
2017-06-07 17:02:00 -07:00
Erik Eckstein
e69ab79348 Enable generic inlining and partial specialization in libswiftFoundation.
This brings back performance for ObjC bridging.
2017-05-18 17:13:50 -07:00
Jordan Rose
01cb554387 Re-apply "Make all CF types Equatable and Hashable." (#4568)
Like NSObject, CFType has primitive operations CFEqual and CFHash,
so Swift should allow those types to show up in Hashable positions
(like dictionaries). The most general way to do this was to
introduce a new protocol, _CFObject, and then have the importer
automatically make all CF types conform to it.

This did require one additional change: the == implementation that
calls through to CFEqual is in a new CoreFoundation overlay, but the
conformance is in the underlying Clang module. Therefore, operator
lookup for conformances has been changed to look in the overlay for
an imported declaration (if there is one).

This re-applies 361ab62454, reverted in
f50b1e73dc, after a /very/ long interval
where we decided if it was worth breaking people who've added these
conformances on their own. Since the workaround isn't too difficult---
use `#if swift(>=3.2)` to guard the extension introducing the
conformance---it was deemed acceptable.

https://bugs.swift.org/browse/SR-2388
2017-05-08 14:05:11 -07:00
Doug Coleman
cfebb599cb overlays: Update dependencies and amend the script to add headers. 2017-05-05 15:32:24 -07:00
Ted Kremenek
cb7ad7d785 Merge pull request #9162 from phausler/safe_nsnumber
[Foundation] Implementation of SE-0170 for safer NSNumber bridging
2017-05-04 13:30:31 -07:00
Itai Ferber
2ce58c1eb3 Add JSON and property list encoders and decoders
* Integrate {JSON,PropertyList}{Encoder,Decoder} types to facilitate
  encoding types in JSON and property list formats
* Adds Foundation-specific extensions to allow errors exposed from the
  stdlib to bridge to NSErrors
2017-04-28 23:38:25 -07:00
Arnold Schwaighofer
9fca4ccc37 Revert "Merge pull request #9057 from erg/overlay-deps-round5"
This reverts commit ea82bd19ec, reversing
changes made to ffdc8e15d9.

It broke the i386 build.
2017-04-27 07:23:08 -07:00
Doug Coleman
9a28931001 overlays: Update dependencies and amend the script to add headers. 2017-04-26 18:27:44 -07:00
Philippe Hausler
24469a9512 [Foundation] NSNumber bridging and Numeric types (SE-0170) 2017-04-17 15:01:02 -07:00
Doug Coleman
8c2bd5ae23 cmake: Initial standalone overlays builds.
./utils/build-overlay AVFoundation OSX macosx
rdar://problem/28707246
2017-03-14 12:51:42 -07:00
Philippe Hausler
dc783c064c [Foundation] Remove @_silgen thunks and replace them with shims instead
This avoids indirection by making calls directly to the C implementations which prevents potentials of mismatched intent or changes of calling convention of @_silgen. The added benefit is that all of the shims in this case are no longer visible symbols (anyone using them was not authorized out side of the Foundation overlay). Also the callout methods in the headers now all share similar naming shcemes for easier refactoring and searching in the style of __NS<class><action> style. The previous compiled C/Objective-C source files were built with MRR the new headers MUST be ARC by Swift import rules.

The one caveat is that certain functions MUST avoid the bridge case (since they are part of the bridging code-paths and that would incur a recursive potential) which have the types erased up to NSObject * via the macro NS_NON_BRIDGED.

The remaining @_silgen declarations are either swift functions exposed externally to the rest of Swift’s runtime or are included in NSNumber.gyb which the Foundation team has other plans for removing those @_silgen functions at a later date and Data.swift has one external function left with @_silgen which is blocked by a bug in the compiler which seems to improperly import that particular method as an inline c function.
2017-03-06 09:59:37 -08:00
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
Doug Coleman
692bc1c031 cmake: Allow requiring minimum versions using sdk-os-version triples on
Darwin.

Example:
--darwin-sdk-deployment-targets=fookit-ios-8.0;barkit-tvos-9.2
2016-11-15 16:43:37 -08:00
Philippe Hausler
2ffc3d52f2 [Foundation] Extract NSURL extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
b9da412ddd [Foundation] Extract NSDate extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
da84c29707 [Foundation] Extract NSCoder/NSKeyed(Un)Archiver extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
d1ebf836c9 [Foundation] Extract NSUndoManager extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
1050bc4f1d [Foundation] Extract NSExpression extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
16dce5a76f [Foundation] Extract NSPredicate extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
c3f87ce097 [Foundation] Extract geometry extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
8017c7abc0 [Foundation] Extract NSRange extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
91f3bb4f55 [Foundation] Extract NSIndexSet extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
cb5b894ac0 [Foundation] Extract NSEnumerator/NSFastEnumeration extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
3522fa8f6e [Foundation] Extract NSSet extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
574f1d068c [Foundation] Extract NSTextCheckingResult extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
c3bcd0dc18 [Foundation] Extract NSDictionary extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
5d28920d8e [Foundation] Extract NSArray extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
4ce31cc7c0 [Foundation] Extract NSNumber extensions into a seperate file
Non functional change; purely organization/gardening (this also extracts the gyb requirement from Foundation.swift)
2016-10-03 12:37:25 -07:00
Philippe Hausler
a1fd6ee38b [Foundation] Extract String extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
7dc60d535a [Foundation] Extract NSString extensions into a seperate file
Non functional change; purely organization/gardening
2016-10-03 12:37:25 -07:00
Philippe Hausler
4e843ff20c [Foundation] Sort the cmake build list for the Foundation overlay 2016-10-03 12:37:25 -07:00
Doug Coleman
2747d1eed8 Overlays: Fix tool not to find os as a dependency unless it depends on
os/activity.h or os/log.h. Update cmake files again, hardcoding a Darwin
dependency. The script does not notice that Foundation depends on
CoreGraphics, so add that manually.

Also found that MapKit is supported on WATCHOS but we didn't have dependencies
for that.

Favor one line per supported SDK instead of catch-all dependency lines.

Distinguish from SDKs which have no dependencies vs SDKs which are
unsupported on a particular platform by printing `unsupported` to the
console and remove the line in the cmake file because it should
not exist anyway.

This full cleanup was not done before because of circularity detected by the
util, which has since been fixed.

Support directories with spaces.
2016-09-28 10:28:02 -07:00
Doug Coleman
6c6f30b6af Overlays: The dependencies right now are approximate, and when new overlays are
added the build breaks. There's already a tool to get proper
dependencies, `utils/find-overlay-dependencies.sh`, so this patch
allows that tool to update the `CMakeLists.txt` files in-place.

Also it adds a line to the `CMakeLists.txt` files for each SDK so that the tool works.
2016-09-26 12:23:47 -07:00
Joe Groff
9b1f238e5b SE-0139: Bridge all standard number types to NSNumber.
Extend NSNumber bridging to cover not only `Int`, `UInt`, `Double`, and `Bool`, but all of the standard types as well. Extend the `TypePreservingNSNumber` subclass to accommodate all of these types, so that we preserve type identity for `AnyHashable` and dynamic casting of Swift-bridged NSNumbers. If a pure Cocoa NSNumber is cast, just trust that the user knows what they're doing.

This XFAILs a couple of serialization tests that attempt to build the Foundation overlay, but which don't properly handle `gyb` files.
2016-09-23 10:34:22 -07:00
Joe Groff
86fbeee285 SE-0139: Bridge Cocoa framework structs to NSValue.
For every struct type for which the frameworks provides an NSValue category for boxing and unboxing values of that type, provide an _ObjectiveCBridgeable conformance in the Swift overlay that bridges that struct to NSValue, allowing the structs to be used naturally with id-as-Any APIs and Cocoa container classes. This is mostly a matter of gyb-ing out boilerplate using `NSValue.init(bytes:objCType:)` to construct the instance, `NSValue.objCType` to check its type when casting, and `NSValue.getValue(_:)` to extract the unboxed value, though there are a number of special snowflake cases that need special accommodation:

- To maintain proper layering, CoreGraphics structs need to be bridged in the Foundation overlay.
- AVFoundation provides the NSValue boxing categories for structs owned by CoreMedia, but it does so using its own internal subclasses of NSValue, and these subclasses do not interop properly with the standard `NSValue` subclasses instantiated by Foundation. To do the right thing, we therefore have to let AVFoundation provide the bridging implementation for the CoreMedia types, and we have to use its category methods to do so.
- SceneKit provides NSValue categories to box and unbox SCNVector3, SCNVector4, and SCNMatrix4; however, the methods it provides do so in an unusual way. SCNVector3 and SCNVector4 are packaged into `CGRect`s and then the CGRect is boxed using `valueWithCGRect:`. SCNMatrix4 is copied into a CATransform3D, which is then boxed using `valueWithCATransform3D:` from CoreAnimation. To be consistent with what SceneKit does, use its category methods for these types as well, and when casting, check the type against the type encoding SceneKit uses rather than the type encoding of the expected type.
2016-09-21 19:26:10 -07:00
Greg Parker
f50b1e73dc Revert "Make all CF types Equatable and Hashable." 2016-08-20 04:33:55 -07:00
Jordan Rose
361ab62454 Make all CF types Equatable and Hashable. (#4394)
Like NSObject, CFType has primitive operations CFEqual and CFHash,
so Swift should allow those types to show up in Hashable positions
(like dictionaries). The most general way to do this was to
introduce a new protocol, _CFObject, and then have the importer
automatically make all CF types conform to it.

This did require one additional change: the == implementation that
calls through to CFEqual is in a new CoreFoundation overlay, but the
conformance is in the underlying Clang module. Therefore, operator
lookup for conformances has been changed to look in the overlay for
an imported declaration (if there is one).

https://bugs.swift.org/browse/SR-2388
2016-08-19 13:21:24 -07:00
Ted Kremenek
2bea707e75 Merge pull request #3977 from phausler/Notification_userInfo
[Foundation] Scale back struct Notification's userInfo to be in-line …
2016-08-05 11:12:18 -07:00
Michael Gottesman
06a70d3942 [cmake] Add cmake support for only applying tsan to the swift stdlib/runtime. 2016-08-03 17:53:57 -07:00
Philippe Hausler
f96159b582 [Foundation] Scale back struct Notification's userInfo to be in-line with NSNotification
This simplifies the bridging story for Notifications to their objc counterparts since the id -> Any and AnyHashable changes have now been applied (which makes the previous boxing strategy no longer needed). Previous consumers of Notification that were using String keys should still work, however any explicit dictionary types should migrate from Swift 2.2 -> Swift 3 from userInfo as [NSObject:AnyObject] to [AnyHashable:Any]. The condition of distributed notifications (in non sandboxed apps) requiring plist types still applies and will fail at runtime if incorrect types are passed into the objective-c layer, and in the case of sandboxed apps userInfo still is forbidden (this change is a non functional change in the respect to those behaviors).

Resolves the following issues:
<rdar://problem/27426757>
<rdar://problem/27561621>
<rdar://problem/27259984>
2016-08-03 16:27:06 -07:00
Mishal Shah
d28ff854b9 Update master to build with Xcode 8 beta 4, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-08-02 11:47:10 -07:00
Dmitri Gribenko
a3254b7990 Foundation: add custom AnyHashable representations to NSNumber and NSString
We want NSNumbers bridged from Swift types to bridge back to the same
Swift type.
2016-07-26 03:10:52 -07:00
Tony Parker
8e814ac875 New value types for Calendar, TimeZone, and Locale
As part of the extensive work on value types in Foundation this year, we
decided to also add value types for these three key classes. In addition
to adding value semantics, the API was extensively audited to improve
Swift interop (especially Calendar).

rdar://26628184
2016-07-17 09:42:37 -07:00
Andrew Trick
888ff1ae99 Revert "New value types for Calendar, TimeZone, and Locale"
This reverts commit 46a9f57329.

This broke Swift CI, OSS incremental RA:

./swift/stdlib/public/SDK/Foundation/TimeZone.swift:228:45: error: 'NSTimeZone' is not implicitly convertible to 'TimeZone'; did you mean to use 'as' to explicitly convert?
        return lhs._wrapped.isEqual(to: rhs._wrapped)
2016-07-16 18:34:32 -07:00