Commit Graph

1487 Commits

Author SHA1 Message Date
Philippe Hausler
a842c6d43d [Foundation] Update Data sequence initializer to use initialize(from:) and add _copyContents 2017-07-06 09:45:53 -07:00
Philippe Hausler
aeb61e361b [Foundation] Add fast paths for Data initialization for common sequences 2017-07-06 09:45:53 -07:00
Xiaodi Wu
590ce5314d Restore indentation (partially) 2017-07-06 00:15:17 -05:00
Xiaodi Wu
3528479730 Silence compiler warnings 2017-07-05 23:56:44 -05:00
Maxim Moiseev
f2dbd65fec Merge pull request #10713 from ktopley-apple/dispatch-sync-fixup
Fix warnings in DispatchQueue.sync() implementation when using a comp…
2017-07-05 09:42:42 -07:00
Itai Ferber
e1007a2e3b Make coding paths non-optional
For the benefit of unkeyed containers, coding paths currently contain optional `CodingKey`s — unkeyed containers are allowed to report a `nil` key in a path. However, this is unhelpful for debugging purposes, or inspecting the coding path for context, since any unkeyed container simply reports `nil`, whether it’s at index 1 or 1000.

Now all containers are required to report a non-optional CodingKey for their segment of the coding path, and coding paths are now exposed as `[CodingKey]`.
2017-06-30 12:43:40 -07:00
Kim Topley
6194f37e1a Fix warnings in DispatchQueue.sync() implementation when using a compiler with SE-0176 support. 2017-06-30 08:45:15 -07:00
Itai Ferber
aa91b7273d Merge pull request #10667 from itaiferber/codable-encode-decode-nil-changes
Optionality updates to Codable API
2017-06-29 13:15:25 -07:00
Itai Ferber
b40c0bd3db Merge pull request #10685 from itaiferber/codingerror-bridging-and-conveniences
EncodingError/DecodingError bridging fixes and conveniences
2017-06-29 10:05:35 -07:00
Itai Ferber
cf0ebc195d Expose underlying serialization errors
If JSONSerialization or PropertyListSerialization throw errors during encoding or decoding, the error should be exposed as an EncodingError or DecodingError
2017-06-28 15:10:19 -07:00
Itai Ferber
92fccf964b Fix coding error bridging to NSError
CustomNSError briding only works when the CustomNSError conformance is in the same module as the original error declaration. We need to sink these down into the standard library.
2017-06-28 14:33:15 -07:00
Itai Ferber
850b21f50d JSONEncoder data encoding strategy tweaks
* Add deferredToData strategy on encode and decode
* Rename base64{Encode,Decode} to base64 (missed this in previous fixes)
* Add unit test to confirm behavior
2017-06-28 14:17:23 -07:00
Itai Ferber
baca811820 Ensure values are decodable from nil
* Eliminate null checks from unboxing in the general case (so types
  can at least attempt to decode from nil)
* Add unit tests to confirm this behavior
2017-06-28 11:23:22 -07:00
Maxim Moiseev
a2b89a7a2d Merge pull request #10585 from moiseev/modelio-overlay
[overlay] Add ModelIO overlay
2017-06-28 10:11:53 -07:00
Itai Ferber
692a893e16 Allow superDecoder to wrap null values
* Update {JSON,PropertyList}Decoder to allow superDecoder()s to wrap
  null value so current implementations of collections can decode
  contained objects from nil
2017-06-28 10:10:21 -07:00
Itai Ferber
bf1d2a745e Accessibility cleanup in {JSON,Plist}Encoder
To make it slightly easier to tell at a glance if a method is
implemented as part of API (public/open), shared implementation detail
(fileprivate), or implementation detail meaningful only to a given type
(private).
2017-06-28 10:10:21 -07:00
Itai Ferber
0a0e6b7397 Update PlistEncoder with proposed nil changes
* Add encodeNil/decodeNil variants on keyed and unkeyed containers
* Give implementations of decode() variants instead of decodeIfPresent()
2017-06-28 10:10:21 -07:00
Itai Ferber
f20d4425e5 Update JSONEncoder with proposed nil changes
* Add encodeNil/decodeNil variants on keyed and unkeyed containers
* Give implementations of decode() variants instead of decodeIfPresent()
2017-06-28 10:10:21 -07:00
swift-ci
e2327f62a2 Merge pull request #10619 from ianpartridge/patch-1 2017-06-27 10:01:45 -07:00
Maxim Moiseev
59c5e5623f Merge pull request #10598 from moiseev/dispatch-oneshot
[overlay] Rename scheduleOneShot and scheduleRepeating
2017-06-27 09:44:23 -07:00
Ian Partridge
ad2311d9e2 PropertyListEncoder: Typo in documentation of encode<Value>(Value) 2017-06-27 10:24:25 +01:00
Ian Partridge
399caebf11 JSONEncoder: Typo in documentation of encode<T>(T) 2017-06-27 10:18:08 +01:00
Philippe Hausler
e5504cdf15 [Foundation] slices of slices that use range expressions incorrectly calculated relative indexing 2017-06-26 16:35:40 -07:00
Max Moiseev
eaf20b23ba [overlay] Rename scheduleOneShot and scheduleRepeating
rdar://29587696
2017-06-26 15:38:21 -07:00
Max Moiseev
9cd60fa2ae [overlay] Adding ModelIO dependency to GLKit overlay 2017-06-26 15:26:38 -07:00
Maxim Moiseev
1fc6db7e68 Merge pull request #10551 from moiseev/inparameter
[overlay] Introducing INParameter
2017-06-26 14:27:59 -07:00
wmattelaer
a724284455 [overlay] Introducing INParameter
<rdar://problem/32409847>
2017-06-26 11:21:10 -07:00
Max Moiseev
46af654271 [overlay] Add ModelIO overlay 2017-06-26 10:56:13 -07:00
Itai Ferber
da27019800 Merge pull request #10539 from itaiferber/foundation-json-decimal
Encode Decimal as a numeric value in JSON
2017-06-23 15:41:51 -07:00
Itai Ferber
07d396b712 Encode Decimal as a numeric value in JSON
Allow JSONEncoder/JSONDecoder to intercept Decimal values so they get
a numeric representation in JSON (instead of their default keyed
implementation).
2017-06-23 13:02:13 -07:00
Itai Ferber
72d62af309 Merge pull request #10520 from itaiferber/foundation-shared-encoders
Allow Codable classes to share an Encoder with superclass
2017-06-23 12:48:09 -07:00
Maxim Moiseev
3c9481b4a6 Merge pull request #10521 from moiseev/intents-availability
[overlay] Fix availability in INSearchCallHistoryIntent
2017-06-23 11:06:10 -07:00
Maxim Moiseev
6c4379f8b3 [overlay] Fix availability in INSearchCallHistoryIntent 2017-06-22 15:55:22 -07:00
Itai Ferber
25fc3ed34f Merge pull request #10515 from itaiferber/nskeyedarchiver-data-overloads
Change NSKeyedUnarchiver method instead of adding overloads
2017-06-22 15:54:49 -07:00
Itai Ferber
184efb085c Allow classes to share an Encoder with superclass
On encode, we previously treated every container request as a push;
instead, we should allow the same container type to be requested
multiple times so a class can pass its Encoder directly to its
superclass if it needs to.
2017-06-22 15:45:02 -07:00
Itai Ferber
a5df6fa484 Change modified method instead of adding overloads
The unarchiveTopLevelObjectWithData which returns Any? (instead of
AnyObject?) was added in Swift 4 and has only shipped in the betas so
far. Instead of adding new overloads which take different types, we
should just fix this one and call it a day.
2017-06-22 14:23:21 -07:00
Philippe Hausler
d31ffc7d5e [Foundation] Validate indexes and ranges passed into Data so that bounding conditions are respected 2017-06-22 11:25:57 -07:00
Itai Ferber
004a98b76f Merge pull request #10474 from itaiferber/nskeyedarchiver-data-overloads
NSKeyedUnarchiver methods should take Data (instead of just NSData)
2017-06-22 10:44:54 -07:00
Philippe Hausler
6d7c49ff61 [Foundation] Prevent incorrect slice access when dropping elements 2017-06-22 07:23:46 -07:00
Itai Ferber
cc313da8ab NSKeyedUnarchiver methods should take Data
We missed a few NSKeyedUnarchiver methods during our original renaming
for Swift — some of these methods still take NSData when they can take
Data. We can add Data variants which bridge to NSData to fix this in a
backwards-compatible way.
2017-06-21 16:23:29 -07:00
Maxim Moiseev
b5f28bfb35 Merge pull request #10430 from moiseev/focus-shim
[overlay] Implement UIFocusEnvironment.contains using a shim
2017-06-21 08:56:29 -07:00
Jordan Rose
e9622db324 [Foundation] Make CocoaError.Code and URLError.Code Hashable. (#10437)
This is consistent with imported error codes, which are always
Hashable. URLError.Code was also Hashable in Swift 3.1 by virtue of
being defined as an enum; the change to a struct broke that.

rdar://problem/32066434
2017-06-20 20:15:48 -07:00
Jordan Rose
f868d6dffe Fix up 08c2a7a3ac for 32-bit platforms. (#10433)
...where swift::TwoWordPair is defined a little less freely.
2017-06-20 19:24:36 -07:00
Jordan Rose
08c2a7a3ac Finish off the log part of _swift_checkClassAndWarnForKeyedArchiving. (#10418)
Logs a warning the first time a problematic class is archived or
unarchived. We expect people to actually fix these issues, so the
performance of the warning isn't too important.

Sample output:

  [timestamp] Attempting to archive Swift class '_Test.Outer.ArchivedThenUnarchived', which does not have a stable runtime name.
  [timestamp] Use the 'objc' attribute to ensure that the runtime name will not change: "@objc(_TtCC5_Test5Outer22ArchivedThenUnarchived)"
  [timestamp] If there are no existing archives containing this class, you can choose a unique, prefixed name instead: "@objc(ABCArchivedThenUnarchived)"

Finishes rdar://problem/32414508
2017-06-20 17:15:28 -07:00
Max Moiseev
52522f118c [overlay] Implement UIFocusEnvironment.contains using a shim
Addresses: <rdar://problem/32538412>
2017-06-20 17:14:24 -07:00
Itai Ferber
e0f75bf841 Merge pull request #10343 from itaiferber/cg-types-codable-conformance
Add Codable conformance to common CG types
2017-06-20 09:32:56 -07:00
Roman Levenstein
2f920c4ad2 Add a new frontend option -sil-serialize-witness-tables to force serialization of SIL witness tables
This option is supposed to be used only for compiling overlays. User code should never be compiled with this option.
2017-06-19 19:49:01 -07:00
Itai Ferber
fedf8e6908 Add Codable conformance to common CG types
Give custom Codable implementations for CGAffineTransform, CGPoint,
CGSize, CGRect, and CGVector, along with unit tests.
2017-06-19 17:23:11 -07:00
Philippe Hausler
29f080f0c3 [Foundation] 1-ary IndexPath forms invalid range on slices 2017-06-16 17:41:19 -07:00
Philippe Hausler
c358afe655 [Foundation] Adjust Double and Float bridges to be more lenient 2017-06-16 15:18:27 -07:00