Commit Graph

1358 Commits

Author SHA1 Message Date
Max Moiseev
d9117f560a [Foundation] Unbreaking the expression that used to be too complex 2017-05-18 17:43:53 -07:00
Jordan Rose
c117679695 [SDK] Remove accidentally-internal "renaming shims" from AppKit. (#9751)
These were supposed to help during the early days of Swift 3, when our
omission of needless words was being tempered by framework authors'
explicitly-specified names in API notes...but they were accidentally
not made public, and no one noticed. After checking with the AppKit
team, we decided to just drop them.
2017-05-18 17:24:39 -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
Doug Gregor
684bddf667 Merge pull request #9733 from DougGregor/cgcolor-color-literal
[CoreGraphics] Make CGColor adopt _ExpressibleByColorLiteral.
2017-05-18 11:06:36 -07:00
Doug Gregor
2a9867bf88 [CoreGraphics] Make CGColor adopt _ExpressibleByColorLiteral.
The backflips here are because we cannot add initializers to imported
CF types; they would be factory initializers. Fixes
rdar://problem/32196175.
2017-05-18 09:57:52 -07:00
Doug Gregor
663c747cc5 [CoreGraphics] Move == operators into their respective types. 2017-05-18 09:46:27 -07:00
Itai Ferber
012ea9373b Add Codable conformance to common Foundation types
Add conformances + unit tests for

* CGFloat
* AffineTransform
* Calendar
* CharacterSet
* DateComponents
* DateInterval
* Decimal
* IndexPath
* IndexSet
* Locale
* Measurement
* NSRange
* PersonNameComponents
* TimeZone
* URL
* UUID

along with some unit tests for each.
2017-05-18 07:56:03 -07:00
Ben Cohen
89515f8485 [Foundation] Add initializers for NSRange<-->Range (#9709)
* Add initializers to NSRange/Range

* Create Ranges unchecked
2017-05-17 19:29:45 -07:00
Nate Cook
c8f8e59b7e Merge pull request #9698 from natecook1000/nc-fixes-75-2
[stdlib] Documentation revisions
2017-05-17 15:00:09 -05:00
Michael Ilseman
75c476b984 Revert "Add Codable conformance to common Foundation types"
This reverts commit dee889f4d0.
2017-05-17 11:56:31 -07:00
Nate Cook
817a1efa3b [stdlib] Documentation revisions
- remove additional 'characters' references from String docs
- improved language around escaping pointer arguments
- key path type abstracts
- codable type abstract revisions
- a few more NSString API fixes
2017-05-17 11:58:08 -05:00
swift-ci
d0549ac42c Merge pull request #9632 from itaiferber/foundation-codable-conformances 2017-05-16 17:33:20 -07:00
Itai Ferber
dee889f4d0 Add Codable conformance to common Foundation types
Add conformances + unit tests for
* CGFloat
* AffineTransform
* Calendar
* CharacterSet
* DateComponents
* DateInterval
* Decimal
* IndexPath
* IndexSet
* Locale
* Measurement
* NSRange
* PersonNameComponents
* TimeZone
* URL
* UUID

along with some unit tests for each.
2017-05-16 16:57:46 -07:00
Philippe Hausler
caf5f68c94 [Foundation] Correct symbolic availability for CFURL component characer set accessors (#9626) 2017-05-16 09:35:56 -07:00
practicalswift
aae419ad30 [gardening] Fix word processing artefacts 2017-05-15 11:30:25 +02:00
Nate Cook
7fa74f590d [stdlib] Documentation revisions for string + ranges
* removing .characters from examples
* beginning new String doc revisions
* improvements to the String Foundation overlay docs
* minor revisions elsewhere
2017-05-13 10:06:05 -05:00
Dave Abrahams
2cb11675cf Merge pull request #9531 from apple/core-team-resolution-2017-05-10.1
Implementing resolutions of core team meeting 2017-05-10
2017-05-12 13:15:08 -07:00
swift-ci
2441b778f5 Merge pull request #9530 from itaiferber/foundation-codingpath-fixes 2017-05-12 10:25:31 -07:00
Matt Rajca
c6ac96ba78 Foundation Overlay: AffineTransform.rotate(byRadians:) is wrong (#9481)
Currently, AffineTransform.rotate(byRadians:) simply assigns the sines and cosines to
the transformation matrix, throwing away information about the current scale, rotation, etc.

This patch performs a proper rotation by concatenating the rotation matrix.
2017-05-12 09:27:31 -07:00
Itai Ferber
3a9d888972 Fix JSON+plist codingPaths for nested values
codingPath more often than not actually needs to be copied, not just
referenced. This makes a big difference for nested containers and
subobjects, which were getting the wrong codingPath values when asking
for them.

This also adds unit tests for JSONEncoder and PropertyListEncoder to
confirm expected behavior.
2017-05-11 17:02:46 -07:00
Dave Abrahams
ddf7ad517f UnicodeScalar => Unicode.Scalar 2017-05-11 15:23:25 -07:00
Philippe Hausler
9fa3cec738 [Foundation] IndexPath should not cause numeric overflow in addition to calculate hash values (#9476) 2017-05-11 09:00:25 -07:00
practicalswift
51e5c66076 [gardening] Use correct Swift URL 2017-05-09 10:35:27 +02:00
swift-ci
143fe2113a Merge pull request #9351 from eeckstein/archive-attrs 2017-05-08 16:26:13 -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
Erik Eckstein
b1d5c77cec Runtime support for the NSArchiver class attributes.
Register class names for NSKeyedArchiver and NSKeyedUnarchiver based on the @NSKeyedArchiveLegacy and @_staticInitializeObjCMetadata class attributes.

@NSKeyedArchiveLegacy registers a class name translation.
@_staticInitializeObjCMetadata just makes sure that the metadata of a class is instantiated.

This registration code is executed as a static initializer, like a C++ global constructor.
2017-05-08 14:00:03 -07:00
Philippe Hausler
ffc594bd20 [Foundation] Performance improvements for IndexPath bridging and comparison (#9339)
* [Foundation] Refactor the backing of IndexPath to favor stack allocations

The previous implementation of IndexPath would cause a malloc of the underlying array buffer upon bridging from ObjectiveC. This impacts graphical APIs (such as UICollectionView or AppKit equivalents) when calling delegation patterns. Since IndexPath itself can be a tagged pointer and most often just a pair of elements it can  be represented as an enum of common cases. Those common cases of empty, single, or pair can be represented respectively as no associated value, a single Int, and a tuple of Ints. These cases will be exclusively stack allocations, which is markably faster than the allocating code-path. IndexPaths that have a count greater than 2 will still fall into the array storage case. As an added performance benefit, accessing count and subscripting is now faster by aproximately 30% due to more tightly coupled inlining potential under whole module optimizations. Accessing count is also faster since it has better cache-line effeciency (lesson learned: the branch predictor is more optimized than pointer indirection chasing).

Benchmarks performed on x86_64, arm and arm64 still pending results but should be applicable across the board.

Resolves the following issues:
https://bugs.swift.org/browse/SR-3655
https://bugs.swift.org/browse/SR-2769

Resolves the following radars:
rdar://problem/28207534
rdar://problem/28209456

* [Foundation] remove temp IndexPath hashing that required bridging to ref types

* [Foundation] IndexPath does not guarentee hashing to be the same as objc
2017-05-06 12:39:45 -07:00
swift-ci
85e20af4f5 Merge pull request #7429 from phausler/correct_unconditionally_bridge 2017-05-05 18:41:25 -07:00
Doug Coleman
11efe61f9b Merge pull request #9357 from erg/overlays-round-7
overlays: Update dependencies and amend the script to add headers.
2017-05-05 18:27:23 -07:00
Philippe Hausler
0540022473 Merge pull request #7433 from phausler/nsrange_improvements
[Foundation] add additional conformances and functionality to NSRange
2017-05-05 16:31:31 -07:00
Doug Coleman
cfebb599cb overlays: Update dependencies and amend the script to add headers. 2017-05-05 15:32:24 -07:00
Doug Coleman
f0a384bcb7 Revert "overlays: Update dependencies and amend the script to add headers." 2017-05-05 15:24:09 -07:00
Doug Coleman
4a93c3bfb9 overlays: Update dependencies and amend the script to add headers. 2017-05-05 14:40:52 -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
3a6dbebba0 Fix container assertion in referencing encoders 2017-05-03 13:12:54 -07:00
Itai Ferber
813d756573 Referencing encoders should use parent codingPath 2017-05-03 09:49:10 -07:00
Philippe Hausler
0ab8bb330e [Foundation] improve hashing of NSRanges to collide less in reasonable values (and use the length too) 2017-05-02 13:49:21 -07:00
Philippe Hausler
0fd0be88e8 [Foundation] add additional conformances and functionality to NSRange 2017-05-02 10:37:04 -07:00
Philippe Hausler
5b4d913a54 Merge branch 'master' into correct_unconditionally_bridge 2017-05-01 15:17:36 -07:00
Itai Ferber
c5fc1e3f78 Use encode(contentsOf:) instead of a loop 2017-04-28 23:38:26 -07:00
Itai Ferber
c6f8834d26 Remove unnecessary CodingKey implementation 2017-04-28 23:38:26 -07:00
Itai Ferber
44682f7a72 Ensure all Dates can always round-trip by default 2017-04-28 23:38:26 -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
Maxim Moiseev
41b00c57ab Merge pull request #9044 from moiseev/substring-in
[stdlib] Substring
2017-04-26 19:25:59 -07:00
Doug Coleman
9a28931001 overlays: Update dependencies and amend the script to add headers. 2017-04-26 18:27:44 -07:00
Max Moiseev
457b8fcdb2 Substring conforms to _ObjectiveCBridgeable 2017-04-25 15:03:18 -07:00
Greg Parker
5eeb029371 [stdlib] sel_getName() never returns nil. 2017-04-25 13:09:48 -07:00
Maxim Moiseev
1c1b2b966d [stdlib] String : RangeReplaceableCollection & BidirectionalCollection (#8921)
* [stdlib] String : RangeReplaceableCollection & BidirectionalCollection

* Add source compatibility hack for Swift.max

* Add source compatibility hack for Swift.min

* Remove redundant conformance in benchmarks

* Fix stupid typo I thought I'd already pushed

* XFAIL testing now-redundant conformance

* XFAIL an IDE test for now
2017-04-23 20:04:54 -07:00
Andrew Bennett
ca31338e49 Simplifying implementation of ExpressibleByStringLiteral (#7125)
* Simplify conforming to ExpressibleByStringLiteral with default implementations

* attributes on default implementations

* ExpressibleByUnicodeScalarLiteral validation test

* more generic default implementations

* clean up test

* remove unneeded implementations

* remove test verification

* indent

* revert @effects and affected methods

* fix test generics with _ protocols

* Add semantic tests

* clean up tests

* Fix redundant conformance requirements
2017-04-21 20:45:28 -07:00