Commit Graph

1358 Commits

Author SHA1 Message Date
Max Moiseev
6803cda05c Merge branch 'master' into new-integer-protocols 2016-09-26 11:39:46 -07:00
Jordan Rose
cb15745b9c [CMake] Yet another missing dependency. (#4983)
More convinced than ever of the need to automate.
2016-09-26 09:40:02 -07:00
swift-ci
69925cd54c Merge pull request #5010 from practicalswift/redundant-nil-init 2016-09-25 10:42:55 -07:00
practicalswift
a75ce9b45f [gardening] Remove redundant nil-initialization of optional variables 2016-09-25 18:53:13 +02:00
practicalswift
69b0f622f3 [gardening] Fix inconsistent headers 2016-09-25 18:00:39 +02:00
Joe Groff
a506af06c7 Merge pull request #4933 from jckarter/nsnumber-bridging
SE-0139: Bridge all standard number types to NSNumber.
2016-09-23 13:06:43 -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
Jordan Rose
ba2f720e81 [CMake] More dependency updates. (#4962)
Things that depend on MapKit and QuartzCore also need to be updated.
2016-09-23 10:31:15 -07:00
swift-ci
96e078f9ce Merge pull request #4952 from DougGregor/ckerror-bridging-27936562 2016-09-23 00:37:01 -07:00
Doug Gregor
661df18a88 [CloudKit overlay] Work around an NSError bridging issue specific to CKError.
While here, fix up the type signature of
CKError.partialErrorsByItemID; it doesn't make sense to use NSObject
now that we have AnyHashable. Fixes rdar://problem/27936562.
2016-09-22 23:52:03 -07:00
Jordan Rose
21e3abe247 [CMake] Fix up QuartzCore dependencies on macOS. (#4945)
CoreImage used to be part of QuartzCore on macOS, so QuartzCore
automatically re-exports it.
2016-09-22 20:36:20 -07:00
Joe Groff
d103d8f452 Attempt to tighten up dependencies for new MapKit and QuartzCore overlays. 2016-09-22 16:21:43 -07:00
Joe Groff
b0e3c0be59 Merge pull request #4865 from jckarter/nsvalue-bridging
SE-0139: NSValue bridging
2016-09-22 09:13:47 -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
Max Moiseev
06dfb51c3b [integers] making stdlib compile after merging master 2016-09-21 15:09:18 -07:00
Max Moiseev
ea8e0f0e15 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-09-21 14:48:35 -07:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
practicalswift
2ee3c45b5b Merge pull request #4852 from practicalswift/optionals-set-to-nil
[gardening] Remove redundant nil-initialization of optional variables
2016-09-19 11:14:31 +02:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Dmitri Gribenko
75fb1747d1 Foundation: change Data.Indices to be a CountableRange<Int>, that is much faster than the default 2016-09-18 03:57:07 +03:00
Dmitri Gribenko
573ed96ba2 Set Foundation.Data.SubSequence to be RangeReplaceable
RangeReplaceableCollection.SubSequence should be a
RangeReplaceableCollection.  Data implements RangeReplaceableCollection,
but sets SubSequence to MutableRandomAccessSlice that is not a
RangeReplaceableCollection.

This commit changes Foundation.Data.SubSequence to
MutableRangeReplaceableRandomAccessSlice.

Fixes rdar://problem/28330713.
2016-09-18 03:57:07 +03:00
swift-ci
16ff6ab227 Merge pull request #4847 from practicalswift/code-style-ii 2016-09-17 06:04:52 -07:00
practicalswift
710d8416f1 [gardening] Fix minor spacing issue in Data.swift 2016-09-17 13:28:34 +02:00
practicalswift
8d6251de66 [gardening] Fix accidental uses of \t 2016-09-17 13:15:26 +02:00
practicalswift
3a4ee89034 [gardening] Use consistent formatting. 2016-09-17 12:12:49 +02:00
practicalswift
89276cc07e [gardening] Replace "a NSFoo" with "an NSFoo". 2016-09-16 21:49:18 +02:00
practicalswift
7c63623ffc [gardening] Fix 13 recently introduced typos. 2016-09-16 20:30:57 +02:00
practicalswift
f250a2349b [gardening] Remove duplicate words. 2016-09-16 20:09:34 +02:00
Dmitri Gribenko
30c1695aeb Foundation: add a custom AnyHashable representation for NSSet 2016-09-15 13:27:36 -07:00
Doug Gregor
fa4331b729 [Foundation overlay] Enable custom AnyHashable representation for NSMeasurement
Enables the overlay behavior blocked by rdar://problem/27539951.
2016-09-14 22:22:36 -07:00
Joe Groff
2acf98ffd5 Merge pull request #4664 from jckarter/rdar27905230
Foundation overlay: Remove unnecessary precondition that array elements be ObjectiveCBridgeable.
2016-09-07 11:38:06 -07:00
Joe Groff
8232d3355b Foundation overlay: Remove unnecessary precondition that array elements be ObjectiveCBridgeable.
This caused a crash when arrays were bridged from ObjC with `Any` or other non-bridged value type elements. Fixes rdar://problem/27905230.
2016-09-07 10:39:05 -07:00
Doug Gregor
77a360907f Tighten up and document the type of Error._userInfo somewhat.
The implementation-detail requirement Error._userInfo is always an
NSDictionary?. However, because this requirement is declared within
the standard library, it cannot be typed as such. So, use
'AnyObject?', comment that this is always 'NSDictionary?' in practice,
and fix up the uses.

Addresses rdar://problem/27824194 as much as we can.
2016-09-06 16:54:25 -07:00
Doug Gregor
73e2143213 [SE-0112] Provide default implementations for CustomNSError requirements.
Provide default implementations for all of the CustomNSError requirements:
  * errorDomain: default to the name of the enum type
  * errorCode: default to the same thing "_code" gets, e.g., the enum tag or
    raw value
  * errorUserInfo: default to empty

This makes it significantly easier to customize just one aspect of the
NSError view of an error type, e.g., just the user-info dictionary,
without having to write boilerplate for the others. This was actually
part of SE-0112, but I missed it in the original implementation and we
thought it was an amendment.

Fixes rdar://problem/23511842.
2016-09-02 10:33:15 -07:00
Dave Abrahams
5c13e35f29 [stdlib] Suppress noisy warnings
We don't have a way yet to say "this is deprecated for users, but let
the stdlib use it without complaining" so we need to do refactoring
shenanigans.
2016-08-28 15:06:42 -07:00
Xiaodi Wu
cd32f345ec Fix Decimal 2016-08-26 03:54:28 -05:00
Doug Gregor
57f1090a11 Revert "[Set/Dictionary] Eliminate "bridging" collection entrypoints."
This reverts commit dc0ae675bc. The
change here (presumably the change to Foundation) caused a regression
in several of the bridging-related benchmarks, e.g.,
ObjectiveCBridgeFromNSSetAnyObjectToString, DictionaryBridge,
ObjectiveCBridgeFromNSDictionaryAnyObjectToString.
2016-08-24 13:20:03 -07:00
Doug Gregor
dc0ae675bc [Set/Dictionary] Eliminate "bridging" collection entrypoints.
Remove the functions
_(set|dictionary)Bridge(From|To)ObjectiveC(Conditional) from the
standard library. These entrypoints are no longer used by the compiler
(thanks to generalized collection up/downcasting), so stop using them
in Foundation and in tests.
2016-08-22 15:14:09 -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
Jordan Rose
ba3de9ee3b NSNumber already preserves whether a value was originally boolean. (#4366)
Use that instead of rolling it up in _SwiftTypePreservingNSNumber so that we
get the right behavior when we go to write plists.

https://bugs.swift.org/browse/SR-2381
2016-08-18 15:45:30 -07:00
Maxim Moiseev
3757b36c37 [overlay] Nest CallKit enum types within their associated classes (#4312)
Addresses the <rdar://problem/27553337>
2016-08-18 12:24:00 -07:00
Doug Gregor
27515b623e Revert "NSNumber bridging: use BOOL rather than _Bool when bridging Bools." 2016-08-18 10:36:43 -07:00
Doug Gregor
d68e59371a NSNumber bridging: use BOOL rather than _Bool when bridging Bools.
The Objective-C type encoding of Boolean values in NSNumber is that of
BOOL, which is either signed char or _Bool depending on the
platform. _SwiftTypePreservingNSNumber was using _Bool, which led to
inconsistencies when bridging vs. creating an NSNumber directly. Use
BOOL consistently.

Fixes rdar://problem/27894308.
2016-08-17 16:49:30 -07:00
Doug Gregor
24a361b7a9 [SDK Overlays] Drop redundant "Error" from AppKit and CoreData CocoaError codes.
Fixes the rest of rdar://problem/27778189.
2016-08-17 10:49:00 -07:00
Ted Kremenek
e706666857 Merge pull request #4168 from phausler/CharacterSet
[Foundation] Ensure _SwiftNSCharacterSet overrides all abstract metho…
2016-08-17 06:18:35 -07:00
Doug Gregor
394094f732 [Foundation overlay] Drop redundant 'Error' in the CocoaError code names.
Note: we leave all of the old names in as deprecated (with a rename),
so that we don't actually break any existing source code. Fixes
rdar://problem/27778189.
2016-08-16 21:10:21 -07:00
Joe Groff
e8346935ea Foundation overlay: Fix optionality mismatch in NSMutableDictionary subscript.
`setObject:forKey:` takes a nonnull object, causing us to accidentally pass in a boxed Optional-in-an-Any from the Swift subscript's optional newValue. Fixes rdar://problem/27875914.
2016-08-16 18:05:09 -07:00
Jordan Rose
af1a8154a3 Guard against racy access to NSError.setUserInfoValueProvider. (#4280)
This API is documented in its headers to only allow being called once
for a particular domain, so we have to make sure our check for an
existing provider is synchronized with the setting.

rdar://problem/27541751
2016-08-15 13:34:30 -07:00
Dave Abrahams
e6dec58cc5 Merge pull request #4041 from xwu/memory-layout-of-value
[stdlib] Implement SE-0136 (Restore MemoryLayout.*(ofValue:))
2016-08-12 11:09:17 -07:00