Commit Graph

100 Commits

Author SHA1 Message Date
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
Xiaodi Wu
2c29408430 Merge branch 'master' into silence-warnings 2017-07-07 17:33:55 -05:00
Itai Ferber
b8dc826d41 Merge pull request #10766 from itaiferber/jsonencoder-conditional-conformance-workarounds
JSONEncoder conditional conformance workarounds
2017-07-07 13:20:54 -07:00
Itai Ferber
9f7506f002 Allow application of JSON strategies in all cases
One of the limitations of not having conditional conformance at the
moment is that the implementation of `init(from:)` and `encode(to:)` on
types which require it is that failure to cast dependent types to
`Encodable` or `Decodable` is a runtime failure. There is no way to
statically guarantee that the wrapped type is `Encodable` or
`Decodable`.

As such, in those implementations, at best we can directly call
`(element as! Encodable).encode(to: encoder)`, or similar. However, this
encodes the element directly into an encoder, without giving the encoder
a chance to intercept the type. This is problematic for `JSONEncoder`
because it cannot apply a strategy if it doesn't get to intercept the
type.

This gives a temporary workaround for JSON strategies because of
internal Foundation knowledge.
2017-07-07 09:38:07 -07:00
Philippe Hausler
56f509f059 [Foundation] Merge sequence initializer fast paths into one initializer 2017-07-06 19:24:17 -07:00
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
3528479730 Silence compiler warnings 2017-07-05 23:56:44 -05:00
Philippe Hausler
e5504cdf15 [Foundation] slices of slices that use range expressions incorrectly calculated relative indexing 2017-06-26 16:35:40 -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
Philippe Hausler
c40ba96328 [Foundation] Correct data subscript indexing to be offset from the base index (#9816) 2017-05-24 09:43:56 -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
Michael Ilseman
75c476b984 Revert "Add Codable conformance to common Foundation types"
This reverts commit dee889f4d0.
2017-05-17 11:56:31 -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
5b4d913a54 Merge branch 'master' into correct_unconditionally_bridge 2017-05-01 15:17:36 -07:00
swift-ci
c158056d1e Merge pull request #8559 from phausler/enumerate_bytes_index 2017-04-17 11:08:14 -07:00
Philippe Hausler
f88f624b9b [Foundation] Correct Data._unconditionallyBridgeFromObjectiveC to allow unexpected nil sources 2017-04-17 09:48:26 -07:00
Philippe Hausler
e422db587d [Foundation] Bridged dispatch_data_t to NSData to Data should enumerate bytes with the offset not the length parameter as the byte index 2017-04-05 10:31:43 -07:00
Philippe Hausler
32e461709e [Foundation] Ensure data can be subscripted with all range types 2017-04-05 08:56:07 -07:00
Philippe Hausler
ce3ccfbd9b Change shims to always be counted as system headers via -isystem instead of conditionally marking them in debug versus non debug builds. (#7979) 2017-03-09 16:09:16 -08: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
Philippe Hausler
525ffcc605 Merge pull request #7155 from phausler/Data_as_own_SubSequence
[Foundation] Convert Data’s SubSequence type to be Data
2017-02-15 11:02:27 -08:00
Slava Pestov
8b01cb6e24 Merge pull request #7243 from ikesyo/gardening-seq-to-array-conversion
[gardening] Prefer `Array(seq)` over `seq.map { $0 }`
2017-02-11 19:42:23 -08:00
Maxim Moiseev
8b95cc48de [stdlib] Fixing compilation warnings (#7314)
<rdar://problem/30320630>
2017-02-08 10:07:49 -08:00
Syo Ikeda
e2b03a98dd [gardening] Prefer Array(seq) over seq.map { $0 } 2017-02-04 10:37:22 +09:00
Philippe Hausler
1a2687a72e [Foundation] Convert Data’s SubSequence type to be Data
Data can encapsulate it’s own sub-sequence type by housing a range of the slice in the structural type for Data. By doing this it avoids the API explosion of supporting all APIs that take Data would need overloads to take a slice of Data. This does come at a small conceptual cost: any index based iteration should always account for the startIndex and endIndex of the Data (which was an implicit requirement previously by being a Collection). Moreover this prevents the requirement of O(n) copies of Data if it is never mutated while parsing sub sequences; so more than an API amelioration this also could offer a more effecient code-path for applications to use.
2017-02-01 08:50:23 -08:00
practicalswift
a9d6d8938c [gardening] Fix recently introduced typos 2017-01-22 20:40:45 +01:00
Syo Ikeda
b1011ca176 [Foundation][gardening] Remove unnecessary breaks 2017-01-12 02:06:56 +09:00
Tony Parker
3345050957 Merge pull request #6615 from phausler/data_append_truncation_fix
[Foundation] Correct sequence initializers for Data when repeating:count: is called and add a memset fast-path
2017-01-10 13:26:09 -08:00
Ben Cohen
578a52627a Merge branch 'master' into se-147 2017-01-07 13:19:15 -08:00
Philippe Hausler
45714e6263 [Foundation] Correct sequence initializers for Data when repeating:count: is called and add a memset fast-path 2017-01-06 13:56:08 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Ben Cohen
fefc2e40df Migrate _copyContents to be called from UnsafeMutableBufferPointer with checks for overrun. 2017-01-05 11:59:49 -08:00
JP Simard
65688bdc39 [gardening] replace unused closure parameters with '_' in stdlib source (#6522)
* replace unused closure parameters with '_' in stdlib source

* fold some _ closure arguments into line above

* fold more _ closure arguments into line above
2017-01-03 20:10:41 -07:00
Robert Widmann
fca7b66b7c Merge pull request #6521 from jpsim/jp-void-return
[gardening] prefer '-> Void' over '-> ()' in stdlib source
2017-01-03 20:10:13 -07:00
JP Simard
891729f6c2 remove redundant '-> Void' return types from functions in stdlib source
since omitting it appears to be the convention followed elsewhere in
the code base.
2017-01-03 16:38:57 -08:00
Robert Widmann
359a66488f Merge pull request #6520 from jpsim/jp-trailing-semicolon
[gardening] remove trailing semicolons in stdlib source
2017-01-03 17:31:34 -07:00
Robert Widmann
6dd2dda53e Merge pull request #6525 from jpsim/jp-omit-control-statement-parens
[gardening] remove superfluous parentheses in control statements in stdlib source
2017-01-03 17:27:23 -07:00
JP Simard
83b6d3c29c remove redundant optional nil assignment in stdlib source
since this appears to be the convention followed elsewhere in the code base.
2016-12-31 18:45:01 -08:00
JP Simard
7301b79342 remove superfluous parentheses in control statements in stdlib source
since this appears to be the convention followed elsewhere in the code base.
2016-12-31 18:40:15 -08:00
JP Simard
ea5b665afa prefer '-> Void' over '-> ()'
Apple and the Swift community has settled on this style:
https://devforums.apple.com/message/1133616#1133616

> FWIW, we've recently decided to standardize on () -> Void
> (generally, () for parameters and Void for return types) across all of our
> documentation.
2016-12-31 17:55:19 -08:00
JP Simard
bd34ea5e2d remove trailing semicolons in stdlib source 2016-12-31 17:51:18 -08:00
Philippe Hausler
b57752a67f [Foundation] Correct case of over-released data contents when specifying .none as a deallocator 2016-12-19 14:37:24 -08:00
practicalswift
16d6dce62e [gardening] Fix recently introduced typos. 2016-12-16 21:42:09 +01:00
Slava Pestov
30c81e862f Foundation overlay: Fix resilient build 2016-12-12 14:05:50 -08:00
Philippe Hausler
e8b19d9924 Merge pull request #6098 from phausler/additional_data_refinements
Merge the swift-corelibs-foundation version of Data
2016-12-06 15:16:51 -08:00
practicalswift
3e31a3ade4 [gardening] Fix typos. 2016-12-06 21:42:01 +01:00
Philippe Hausler
6134083d31 Merge the swift-corelibs-foundation version of Data in as a single source and correct initializers for copy variants as well as remove defers of _fixLifetime 2016-12-06 10:12:55 -08:00
Philippe Hausler
e27b2b0923 Account for nullability issues of bytes in NSData subclasses and return a placeholder value for now 2016-12-01 15:34:04 -08:00
Philippe Hausler
bdafb2dac0 Handle no-copy cases and custom deallocators as inline construction of swift Data 2016-12-01 12:27:57 -08:00