Commit Graph

812 Commits

Author SHA1 Message Date
Maxim Moiseev
128092a7d6 Rename filterMap to compactMap 2017-12-18 09:22:41 -08:00
Max Moiseev
8ec6c45d2d Use filterMap to avoid deprecation warnings 2017-12-18 09:16:37 -08:00
Thomas Roughton
c5bf2ec553 [runtime] Remove TwoWordPair and use the Swift calling convention instead. (#13299) 2017-12-07 19:27:24 -08:00
swift-ci
f767040b4a Merge pull request #13316 from ikesyo/nsrange-init 2017-12-07 19:19:37 -08:00
Sho Ikeda
4438834529 Merge pull request #13266 from ikesyo/sync-measurement-overlay
[overlay] Synchronize Measurement.swift with swift-corelibs-foundation
2017-12-08 08:53:40 +09:00
Sho Ikeda
dacd46c95e [overlay][gardening] Use NSRange.init over NSMakeRange 2017-12-07 22:03:14 +09:00
Sho Ikeda
5682993d7c [overlay][gardening] Use optional binding 2017-12-07 21:35:39 +09:00
Ben Cohen
85d190cd7d [stdlib] Replace various uses of BlahSlice with Slice to reduce warnings (#13263)
* Kill the slice variants from the gybbed collection test types

* Handful more SDK instances

* Fix SequencesCollections.swift.gyb
2017-12-05 19:09:56 -08:00
Philippe Hausler
beffbc6ce5 [Foundation] Discontiguous data slices should not heap corrupt (#13252)
* [Foundation] Byte access and methods that funnel to byte access for slices of discontiguous data (ala backed by dispatch_data_t) should void heap corruption and walking off the ends of buffers

* add missing parens on test_byte_access_of_discontiguousData

* Use the proper byte count in testing
2017-12-05 09:55:22 -08:00
Sho Ikeda
c1f7e236d9 Synchronize Measurement.swift with swift-corelibs-foundation 2017-12-05 13:51:34 +09:00
swift-ci
6f19f4d1c3 Merge pull request #13189 from ikesyo/os-macos 2017-12-02 08:48:58 -08:00
Nate Cook
956e793ef0 Improve consistency in NSNumber bridging
This makes sure casts of NaN succeed, and init(exactly: NaN) fails.
2017-12-01 13:44:33 -06:00
Sho Ikeda
e2b8bec138 [Overlay/Foundation][gardening] Prefer os(macOS) over os(OSX) 2017-12-01 09:00:49 +09:00
Jordan Rose
8f8f00012a Merge pull request #12834 from jrose-apple/restrict-cross-module-struct-initializers-2
Implementation of SE-0189 "Restrict cross-module struct initializers to be delegating"

rdar://problem/34777878
2017-11-30 13:32:45 -08:00
taylor swift
c85880899d implement SE 184: add allocation methods to Unsafe buffer pointers, drop all parameters from deallocation, adjust namings, and add repeated-value assignment methods 2017-11-17 21:28:03 -08:00
Tony Parker
7b20be2c1c Merge pull request #12779 from parkera/parkera/json_key_strategy
Add key encoding strategy to JSONEncoder
2017-11-16 15:48:32 -08:00
Greg Parker
1e894cd80b [runtime] Clean up symbols in error machinery. (#12853)
* [runtime] Clean up symbols in error machinery.

* [runtime] Clean up symbols in Foundation overlay.

* [runtime] Clean up symbols in collections and hashing.

* [runtime] Remove symbol controls from the Linux definition of swift_allocError.

* [tests] Add more stub functions for tests that link directly to the runtime.
2017-11-15 22:20:11 -08:00
Tony Parker
b87a8ea007 Add key encoding strategy to JSONEncoder 2017-11-15 16:44:28 -08:00
Tony Parker
b57a9cb8a9 Merge pull request #12898 from sashabelonogov/sashabelonogov/SR-6361
[SR-6361] Fix Data.withUnsafeMutableBytes() for slices with length < range.lowerBound
2017-11-15 11:26:49 -08:00
Alexander Belonogov
bf56b09395 [SR-6361] Fix Data.withUnsafeMutableBytes() for slices with length < range.lowerBound 2017-11-14 09:08:21 +01:00
Itai Ferber
ae8f815f64 Use the concrete type parameter passed to JSON/plist decode 2017-11-09 13:06:00 -08:00
Jordan Rose
1598a21e43 DI: Warn on non-delegating cross-module struct initializers
...as detected by initializing an individual field without having
initialized the whole object (via `self = value`).

This only applies in pre-Swift-5 mode because the next commit will
treat all cross-module struct initializers as delegating in Swift 5.
2017-11-09 11:24:28 -08:00
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
Philippe Hausler
b78b438897 Ensure that hashing data with zero bytes avoids empty allocations and fix bridged empty data hashes from de-referencing null values (#12509) 2017-10-19 17:53:19 -07:00
Doug Gregor
42968b2069 Eliminate a number of uses of the *Indexable protocols. 2017-10-01 15:08:23 -07:00
Max Moiseev
7322b63c44 [overlay] Fix Foundation extensions to Substring
When a substring gets bridged to NSString, it loses the initial offset,
therefore APIs that accept or return StringIndex ranges should handle
this case explicitly by adding/subtracting the substring start offset.

Fixes <rdar://problem/33873277>
2017-09-27 20:09:01 -07:00
Itai Ferber
1457e4da9d Merge pull request #11885 from cpwhidden/decoding-bool-coercion
[stdlib] Prevent coercion from Bool to numerical types when decoding JSON and plist
2017-09-18 09:15:18 -07:00
Philippe Hausler
c8bbce6ef1 Data slice mutation support (#11939)
* Mutations of slices of data should preserve relative indexing as well as cow semantics of slices

* Ensure hashes of ranges are uniform to the expected hash for Data

* Correct a few mistakes in the slice mutation tests

* Update sequence initializations to avoid directly calling mutableCopy which prevents slice offset mismatches

* Avoid invalid index slices in creating mirrors

* Restore the original Data description

* Resetting a slice region should expand the slice to the maximum of the region (not a out of bounds index of the backing buffer)

* Remove stray comment and use a stack buffer for sequence appending

* Return false when allocations fail in _resizeConditionalAllocationBuffer (not yet in use)

* Enumeration of regions of a slice should be limited to the slice range in the case of custom backing (e.g. dispatch_data_t)

* adjust assertion warnings for data indexes that are negative
2017-09-16 13:22:01 -07:00
cpwhidden
997fe01809 [stdlib] Prevent type coercion from Bool to numerical types when decoding JSON and plist
JSONEncoder and PropertyListEncoder both use NSNumber to box Bool values.  An encoded Bool can be coerced to any numerical type during decoding because (false as NSNumber).intValue == 0.  As a remedy, all of the unbox(_:as:) methods of _JSONDecoder and _PlistDecoder for numerical types include a check that the value is not identical to either kCFBooleanTrue or kCFBooleanFalse, and throw a DecodingError._typeMismatch(at:expectation:) if this check fails.
2017-09-12 15:31:04 -05:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
Itai Ferber
ee39ff7f2f Allow top-level Codable strategy/type interception
At the top level, JSONEncoder/PropertyListEncoder (and the decoders) directly encoded values into an encoder instead of following the logic to box the values (and thus dispatch based on the type, potentially intercepting representations or applying strategies). This led to top-level values having a different representation than similar values throughout a payload.
2017-08-24 13:31:08 -07:00
Ian Partridge
96a3b9709c Sync NSStringAPI.swift from overlay 2017-08-22 09:49:07 -07:00
Itai Ferber
273dd8740e Merge pull request #11368 from itaiferber/urlcomponents-codable-adoption
Adopt Codable on URLComponents
2017-08-11 12:15:37 -07:00
Philippe Hausler
d2926cfb05 Replicate NSAffineTransform logic for rotation to AffineTransform 2017-08-04 09:58:11 -07:00
Itai Ferber
bf4a12568a Add Codable conformance for URLComponents
Adopt Codable on URLComponents and add associated unit tests
2017-08-03 14:28:18 -07:00
Itai Ferber
2e5817ebe1 Merge pull request #11315 from itaiferber/fix-sr-5206-hack
Remove previous hack for SR-5206
2017-08-03 10:37:56 -07:00
Itai Ferber
db5133b21b Use encodeIfPresent in DateComponents.encode
Now that encodeIfPresent is available as API, we can use it to make DateComponents.encode slightly more digestible.
2017-08-02 14:56:39 -07:00
Itai Ferber
fbdcbee7a2 Remove previous hack for SR-5206
As a temporary workaround for SR-5206, certain Foundation types which had custom behavior in JSONEncoder and JSONDecoder were granted special knowledge of those types internally in order to preserve strategies on encode/decode.

This replaces that special knowledge with a more general-purpose fix that works for all types and all encoders/decoders.
2017-08-02 14:11:29 -07:00
Itai Ferber
c962bdb56c Merge pull request #11148 from itaiferber/indexset-rangeview-fixes
Fix IndexSet.RangeView indexing with subranges
2017-07-24 19:32:50 -07:00
Itai Ferber
b05866a92f Fix IndexSet.RangeView indexing with subranges
On initialization, IndexSet.RangeView made the erroneous assumption that given an intersection range, a nil _indexOfRange(containing: bound) indicated that the bound was beyond the beginning or end of the index set. Instead, the index could simply not exist.

We now calculate the actual intersection of the parent index set with the given intersection range and use that as the index set to view.

This also makes the unit tests for testing range views more comprehensive.
2017-07-24 15:32:03 -07:00
Itai Ferber
5252f3b2f8 Fix NSNumber's custom AnyHashable representation
When we give NSNumber a custom AnyHashable representation, we want to
give it as large a box as possible. When we want to compare it against
other AnyHashable boxes such as Int or UInt, it's always possible to
upcast the Int/UInt to a larger integer size like Int64 or UInt64 for
the comparison. By eliminating the smaller boxes we create, we can
maintain the existing behavior that _SwiftTypePreservingNSNumber gave
us.
2017-07-24 12:22:45 -07:00
Itai Ferber
f6e48dceb6 Merge pull request #11025 from michael-lehew/codable_support_for_nsarchival
NSKeyed{Una,A}rchiver should support Codable
2017-07-19 19:11:57 -07:00
Michael LeHew
ef35a001e6 NSKeyed{Una,A}rchiver should support Codable 2017-07-19 16:43:55 -07:00
Maxim Moiseev
3a1d6e1ebf Merge pull request #10980 from moiseev/uikit-drag-drop
[overlay] Add NSItemProviderReading/Writing methods to UIKit overlay
2017-07-17 10:44:14 -07:00
Dave Rahardja
340447ac64 [overlay] Add NSItemProvider overlay
<rdar://problem/32138540>
2017-07-14 22:13:30 -07:00
Philippe Hausler
5dfa9160f9 [Foundation] replaceSubrange in the cases of immutable and mutable backing stores should recalculate length per the reference backing store change and not the length of the replacement 2017-07-14 18:34:57 -07:00
swift-ci
efb7d75489 Merge pull request #10970 from apple/rdar-33307780 2017-07-14 17:14:44 -07:00
Dave Abrahams
e59cb97048 [stdlib/Foundation] Swift 3 backward compatibility hack
Since samePosition(in:) now unconditionally returns optionals,
String.UTF16View.Index.distance(to: String.UTF16View.Index) must accept an
optional to keep some code working.

Fixes <rdar://33307780>.
2017-07-14 15:30:06 -07:00