Commit Graph

36 Commits

Author SHA1 Message Date
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
Brent Royal-Gordon
0c478b6be6 Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
This reverts commit 43a3ab7e35, reversing
changes made to 4f39d9c749.

# Conflicts:
#	include/swift/AST/Attr.def
#	lib/AST/Attr.cpp
#	lib/Serialization/Deserialization.cpp
#	lib/Serialization/ModuleFormat.h
#	lib/Serialization/Serialization.cpp
2020-01-15 15:28:42 -08:00
Robert Widmann
3bda241b11 State CodingKeys as an explicit requirement
The presence of this attribute will be used to guide the protocol derivation machinery to synthesize CodingKeys.
2019-12-10 16:28:51 -08:00
Azoy
eebf8825f9 post de-gyb formatting 2019-12-07 11:05:45 -05:00
Azoy
eb8bd16ca5 de-gyb codable 2019-12-07 11:05:44 -05:00
Nate Cook
158b1a498d [NFC] Convert Codable.swift to .swift.gyb 2017-12-01 15:25:55 -06:00
Doug Gregor
89343e2c98 [Coding] Make Codable conformances for Optional and collections conditional.
Array, Set, Dictionary, and Optional all provide unconditional conformances
to Encodable & Decodable that dynamically check whether their type arguments
are Encodable/Decodable. Now that we have conditional conformances, make
these unconditional conformances properly conditional, removing all of
the Swift 4-era type-erasure hacks.

Fixes rdar://problem/34989162.
2017-11-30 11:06:29 -08:00
Nate Cook
0b62b0608d [stdlib] Doc revisions
- Add missing docs & parameter lists
- Remove deprecated `characters` usage in examples
- Revise documentation for Mirror and CVarArg
- Revise documentation for swap(_:_:)
- Various typo and grammar fixes
2017-11-07 11:11:23 -06:00
Max Moiseev
a24998a5b1 [stdlib] Add missing @_fixed_layout attributes to fix resilience build 2017-10-02 15:19:06 -07:00
Max Moiseev
67005f4047 Add inlineable init/deinits to 🐟able 2017-09-29 11:26:56 -07:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Itai Ferber
e3da1b4254 Rename methods to not conflict w/ existing names
Fixes unit test failues stemming from fileprivate "init(from:)" visibility on Decodable things.
2017-08-02 16:03:02 -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
Nate Cook
781f6326bd [stdlib] Various documentation revisions and fixes
- Revisions to unsafeDowncast and withVaList
- Fix the Int64/UInt64 discussion
- Buffer pointer revisions
- Fix Optional example to use new integer methods
- Revise and correct some UnsafeRawBufferPointer docs
- Fix symmetricDifference examples
- Fix wording in FloatingPoint.nextDown
- Update ImplicitlyUnwrappedOptional
- Clarify elementsEqual
- Minor integer doc fixes
- Comment for _AppendKeyPath
- Clarification re collection indices
- Revise RangeExpression.relative(to:)
- Codable revisions
2017-07-31 10:56:53 -05:00
Itai Ferber
580332b062 Rename encodeWeak to encodeConditional
As part of updates to the Codable API, we are renaming encodeWeak to encodeConditional for clarity.
2017-07-21 10:55:05 -07:00
Yasuhiro Inami
e017508a9b Simplify CodingKey description 2017-07-17 12:02:56 +09:00
Yasuhiro Inami
98ed5f97de Improve CodingKey description (add double-quote) 2017-07-16 12:50:08 +09:00
Yasuhiro Inami
33582e61e7 Improve CodingKey description 2017-07-16 12:46:37 +09:00
Yasuhiro Inami
f4e8cbb4e5 Let CodingKey inherit CustomStringConvertible for better debugging 2017-07-16 12:13:10 +09: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
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
f088cfbdfe Add DecodingError.dataCorrupted conveniences
DecodingError.dataCorrupted is an error most commonly thrown from user code. We can expose conveniences to more easily throw .dataCorrupted errors.
2017-06-28 14:34:35 -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
8f38678911 Expose underlyingError on coding errors
Some errors are caused by others — this allows us to expose the underlying problem.
2017-06-28 14:31:53 -07:00
Itai Ferber
60b6faaae2 Add new nil encoding methods to containers
* Add encodeNil(forKey:)/encodeNil() for keyed/unkeyed encoding
  containers
* Add decodeNil(forKey:)/decodeNil() for keyed/unkeyed decoding
  containers
* Give default implementation of decodeIfPresent(forKey:)/
  decodeIfPresent(_:) on keyed/unkeyed decoding containers instead of
  decode(forKey:)/decode(_:)
* Expose all encode/decode methods on keyed encoding & decoding
  containers to allow overriding default methods (which were previously
  not forwarding)
2017-06-28 10:10:21 -07:00
Itai Ferber
41f93ca9d3 Improve runtime errors for conditional types 2017-06-21 15:52:31 -07:00
Roman Levenstein
890c2d5015 Re-factor Codable.decode functions to reduce the standard library code size
Move the error reporting slow-path into a separate function, which is not inlined or specialized.
This reduced the stdlib code size by almost 1%.
2017-06-05 16:28:37 -07:00
sushangjin
279f4d9f8e ditionary-decodable-fix 2017-06-05 11:40:12 +08:00
Itai Ferber
d16297dad5 Introduces changes to Codable stdlib API
* Adds conformance of Optional to Codable
* encode(...) arguments are no longer Optional; Optional values go
  through generic version
* encodeIfPresent added to KeyedEncodingContainerProtocol to mirror
  decodeIfPresent
* JSONEncoder and PropertyListEncoder updated to reflect these changes
2017-05-22 09:29:36 -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
Itai Ferber
1eb73b3b62 Add Dictionary and Set {En,De}codable conformance 2017-05-02 17:03:48 -07:00
Itai Ferber
7778fc2fb3 Fix encoding container linker errors
The box types were previously fileprivate because they lived in
the Foundation overlay. As part of the Swift stdlib, though, they need
to be internal so they can be linked against.
2017-04-29 12:18:49 -07:00
Itai Ferber
f7cd0a6343 Add Codable conformance to Array 2017-04-28 23:38:25 -07:00
Itai Ferber
e1e67844a8 Split RawRep extensions for Encodable + Decodable
You shouldn't need to be Codable in order to get these implementations;
being either Encodable or Decodable should be enough to get the relevant
default implementation
2017-04-28 11:15:04 -07:00
Itai Ferber
53d82b1923 Rename sequence type to avoid ambiguity 2017-04-27 10:22:03 -07:00
Itai Ferber
cecf00d1f1 Integrate *Codable protocols and associated types
Add Encodable and Decodable protocols, along with associated container
types, default implementations, and extensions to the standard library
2017-04-25 13:04:27 -07:00