Commit Graph

371 Commits

Author SHA1 Message Date
Norio Nomura bc13691c24
Call `Parser.parse()` in closure for `Data.withUnsafeBytes(_:)`
Swift 5.0’s `Data.withUnsafeBytes(_:)` on Darwin seems to have changed to pass a pointer to a closure pointing to a valid buffer only within the closure.

fixes #143
2018-12-26 19:34:06 +09:00
Norio Nomura 0485bf5f6e
Silence warning: 'index(where:)' is deprecated: renamed to 'firstIndex(where:)' 2018-12-25 09:01:18 +09:00
Norio Nomura fed0c2a901
Silence warning: ’public' modifier is redundant for initializer declared in a public extension 2018-12-25 09:01:11 +09:00
Norio Nomura 7f9eff99a2
Let compiler synthesize `Equatable` and `Hashable` conformance 2018-06-17 08:56:09 +09:00
Norio Nomura 4424585492
Adapt to SE-0206
Conform `Node.Mapping`, `Node.Scalar`, `Node.Sequence` and `Tag` to new `Hashable` protocol
2018-06-17 08:52:59 +09:00
JP Simard 2fdfdac898
Merge pull request #122 from jpsim/docs
Add API docs
2018-05-09 20:56:16 -07:00
JP Simard 313b68d8dd
Docs formatting cleanup for consistency 2018-05-09 20:22:26 -07:00
JP Simard 0d3f24226e
Make Emitter.data publicly readable 2018-05-09 16:34:56 -07:00
JP Simard f540796d72
Remove extra word 2018-05-09 16:33:34 -07:00
JP Simard ebf789366c
Add docstrings for sortKeys 2018-05-09 16:32:35 -07:00
Norio Nomura 9eaf812eca
Use `import CoreFoundation` instead of defining `DBL_DECIMAL_DIG` on Linux 2018-05-07 10:21:22 +09:00
JP Simard f761dda3ef
Add docstrings to Resolver.swift 2018-05-06 11:14:26 -07:00
JP Simard 9bbd3a2c40
Add docstrings to Node.Sequence.swift 2018-05-06 11:07:16 -07:00
JP Simard 3708bcb0a4
Add docstrings for Node.Scalar.swift 2018-05-06 11:03:55 -07:00
JP Simard faa2541f53
Fix SwiftLint violation 2018-04-29 17:43:46 -07:00
JP Simard 35ca190308
More docstrings for Node.swift & Node.Mapping.swift 2018-04-29 17:38:54 -07:00
JP Simard e598f5c853
Allow nesting types 2 levels & add docstrings to Node.Mapping.swift 2018-04-29 17:22:50 -07:00
JP Simard 96a117eab2
Add doscstrings to Tag.swift 2018-04-29 17:18:41 -07:00
JP Simard ce43d9faad
Add docstrings to Parser.swift 2018-04-29 17:11:56 -07:00
JP Simard 42b94088a0
Add docstrings to Constructor.swift 2018-04-29 17:00:56 -07:00
JP Simard 2f3fe06fff
Add docstrings to Representer.swift 2018-04-29 16:49:40 -07:00
JP Simard 4c0ec3aa20
Fix typos 2018-04-29 16:43:32 -07:00
JP Simard b15f1bd0b9
Add docstrings to YamlError.swift 2018-04-29 16:40:20 -07:00
JP Simard 05fc492d44
Add docstrings to Node.swift 2018-04-29 16:37:33 -07:00
JP Simard cdea3d3d4b
Tweak docstrings in Mark.swift 2018-04-29 16:16:16 -07:00
JP Simard c971f1fb68
Add docstrings to Encoder.swift 2018-04-29 16:12:59 -07:00
JP Simard 50420f0a87
Adjust indentation in YamlError.swift 2018-04-29 16:03:38 -07:00
JP Simard de565215f4
Adjust indentation in Representer.swift 2018-04-29 16:02:54 -07:00
JP Simard d9416f03f8
Adjust indentation in Parser.swift 2018-04-29 16:02:27 -07:00
JP Simard 5f1f10fb52
Adjust indentation in Tag.swift 2018-04-29 16:01:27 -07:00
JP Simard eb4bb2a945
Adjust indentation in shim.swift 2018-04-29 16:01:01 -07:00
JP Simard 454544bd15
Add docstrings to Emitter.swift 2018-04-29 15:58:31 -07:00
JP Simard f851400e15
Add dosctrings to Emitter.swift 2018-04-29 15:42:59 -07:00
JP Simard 96ae475f29
Add docstrings to Decoder.swift 2018-04-29 15:14:12 -07:00
JP Simard 4f50d2101e
Add docstrings to Constructor.swift 2018-04-29 15:02:45 -07:00
Norio Nomura b0a7f7c945
Merge pull request #113 from jpsim/nn-refactor-constructor
Refactor Constructor
2018-04-02 18:12:56 +09:00
Norio Nomura 6c0443e46e
Merge pull request #114 from jpsim/nn-simplify-yamlencoder
Simplify `YAMLEncoder` by replacing methods required by protocol with generic methods
2018-04-02 18:12:12 +09:00
Norio Nomura ce04cd33a1
Use identifier in nanosecond calculation instead of `$0` 2018-04-02 09:21:30 +09:00
Norio Nomura f56723d392
Change `substring(from:)` to return `SubSequence` 2018-04-02 08:28:58 +09:00
Norio Nomura a9b24df987
Merge pull request #115 from jpsim/nn-simplify-yaml-decoder
Simplify `YAMLDecoder`
2018-04-02 07:59:28 +09:00
Norio Nomura 18e173301d
Simplify `YAMLEncoder`
- Rename `ScalarRepresentableCustomizedForCodable` to `YAMLEncodable`
- Replace methods required by protocol with generic methods
2018-04-01 09:07:47 +09:00
Norio Nomura 3041d16db2
Add overload method to `ScalarRepresentable` that returns `Node.Scalar` 2018-04-01 09:07:46 +09:00
Norio Nomura 064c2eee2f
Change from String manipulation to Int manipulation in nanosecond calculation
This improves performance.
`repeatElement(10, count: 9 - length).reduce($0, *)` is also faster than `$0 * Int(pow(10, Double(9 - length))`.
2018-04-01 09:04:49 +09:00
Norio Nomura 1de7657da1
Move `substring(from offset:)` to `StringProtocol` on Swift 4.1 2018-04-01 09:04:49 +09:00
Norio Nomura 0d89ed84b1
Add Swift version to conditions 2018-04-01 09:04:48 +09:00
Norio Nomura 2b6fd2e1ad
Move `Substring.hasPrefix(_:)` for Linux to shim.swift 2018-04-01 09:04:48 +09:00
Norio Nomura f0a9db5bea
Remove `Substring.components(separatedBy:)` for Linux since unused 2018-04-01 09:04:46 +09:00
Norio Nomura 9711d6b62a
Parse quoted values as strings
Fix #116
2018-03-27 09:17:54 +09:00
Norio Nomura 5fd4f2e99a
Simplify YAMLDecoder by delegating `decode()` methods to `SingleValueDecodingContainer` 2018-03-23 00:06:41 +09:00
Norio Nomura 08f3e0121f
Simplify `YAMLDecoder` by replacing methods required by protocol with generic methods 2018-03-23 00:06:41 +09:00
Norio Nomura e544b1614e
[gardening] Fix swiftlint violations 2018-03-17 21:01:40 +09:00
Norio Nomura 14f7405ba6
[gardening] Let compiler to infer associatedtype 2018-03-17 21:01:38 +09:00
Norio Nomura c78ae6852d
Change some internal Swift.Coders types to `private`(`fileprivate`) 2018-03-16 11:53:22 +09:00
Norio Nomura 8d8feee222
Prefer `private extension` over using `fileprivate` individually 2018-03-16 11:53:22 +09:00
Norio Nomura beacbcac35
Review `fileprivate` usage for SE-0169
https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.md
2018-03-16 11:53:21 +09:00
Norio Nomura f5c009c458
Remove conditional compilation blocks assuming Swift 3.x 2018-03-16 11:53:21 +09:00
Norio Nomura 3afbcfb489
Avoid overloading `decode(_:)` 2018-03-02 12:18:46 +09:00
Norio Nomura 73af0e2b75
Use concrete type parameter instead of generic type 2018-03-02 12:18:46 +09:00
Norio Nomura f5a45baf26
Use more effectively that `Node` is an enum
* Change parameter type of `ScalarConstructible.construct(from:)` from `Node` to `Node.Scalar`
* Change `Constructor`:
  * Split `Map` type into `ScalarMap`, `MappingMap` and `SequenceMap`
  * Split `defaultMap` static property into `defaultScalarMap`, `defaultMappingMap` and `defaultSequenceMap`
  * Change `init(_:)` to `init(_:_:_:)`
2018-02-17 14:40:45 +09:00
Norio Nomura 5613e6afab
Merge pull request #104 from jpsim/nn-remove-overloaded-node.array
Remove overloaded `Node.array()`
2018-02-17 10:19:38 +09:00
Norio Nomura 1cf71924a1
Merge pull request #103 from jpsim/nn-refactor-serialize-methods-in-emitter
Refactor `serialize*()` methods in `Emitter`
2018-02-17 09:05:53 +09:00
Norio Nomura c241a3e757
Remove overloaded `Node.array()`
Same function can be achieved by adding default parameter to `Node.array(of:)`.
2018-02-17 09:05:20 +09:00
Norio Nomura 80c54fd5ca
Refactor `serialize*()` methods in `Emitter` 2018-01-31 09:19:07 +09:00
Norio Nomura 0cfaa20210
Delete unnecessary forece unwrapping 2018-01-30 08:46:41 +09:00
Norio Nomura 3f2db2c001
Merge pull request #101 from jpsim/nn-subscript-uses-destination-resolver
Change `subscript(string:)` to create `Node` from string using their own resolver
2018-01-30 08:46:10 +09:00
Norio Nomura d18166f53a
Remove `compactMap` shims from `Array` and `LazyMapCollection` 2018-01-30 08:15:52 +09:00
Norio Nomura b3345b7b26
Change `subscript(string:)` to create `Node` from string using their own resolver
fixes #100
2018-01-28 15:53:14 +09:00
Norio Nomura 52ac9a062a
`compactMap` should not be added on `swift(>=3.3)` 2018-01-27 22:36:42 +09:00
Norio Nomura 718ed26358
Change access level of `compactMap()` from `public` to `internal` 2018-01-27 22:25:42 +09:00
Norio Nomura 6ec137f1c7
Fix swiftlint violations 2018-01-27 00:55:23 +09:00
Norio Nomura 7816302aa1
'flatMap' is deprecated: renamed to 'compactMap(_:)' 2018-01-27 00:45:25 +09:00
David Hart 009d32d0e9 Remove isScalar assets 2018-01-15 07:12:29 +01:00
JP Simard 0beac74b08
Merge pull request #85 from jpsim/nn-add-doc-comments-to-yaml-errors
Add doc comments to `YamlError`
2017-11-28 14:01:11 -08:00
Norio Nomura ab2fa7c264
Apply feedbacks in review 2017-11-14 08:21:05 +09:00
Norio Nomura 5a0cea5050
Merge pull request #87 from jpsim/nn-minimize-expressible-by-string-literal-implementations
Minimize `ExpressibleByStringLiteral` implementations
2017-11-14 08:14:04 +09:00
Norio Nomura 5438bdf20c
Minimize `ExpressibleByStringLiteral` implementations 2017-11-13 23:50:57 +09:00
Norio Nomura 65d389707a
Use `Index` typealias instead of concrete type `Int` in `Node.Sequence` 2017-11-13 23:38:41 +09:00
Norio Nomura aa194acb5f
Use `Index` typealias instead of concrete type `Int` in `Node.Mapping` 2017-11-13 23:37:48 +09:00
Norio Nomura 8a49444004
Add doc comments to `YamlError` 2017-11-13 23:21:40 +09:00
Norio Nomura 5dc5062fc4
Use Multiline String Literals 2017-11-05 00:49:20 +09:00
Norio Nomura a1b5c93ddc
6bbc217fc7
> Fix unitialized value crash found by OSS Fuzz
>
> Google's OSS Fuzz project found input for libyaml that was capable of
> triggering an uninitialized value crash.
>
> Patch provided by Alex Gaynor
2017-11-04 10:04:35 +09:00
Norio Nomura 402c4ecf71
119b7b6adf
> Updates defs for MingGW support on Windows
>
> addresses issue #52
2017-11-04 10:04:35 +09:00
Norio Nomura 275f6afc26
6db69c72d4
> spec-1.2 rule [53]
>
> Support "\/" for JSON compatability.
2017-11-04 10:04:34 +09:00
Norio Nomura c92e72df1c
56400d976a
> This code is not needed and breaks tests
>
> This code was disabled in Perl binding for breaking tests.
>
> Kirill said on IRC:
>
> < rz> ingy: i'm not sure why i set open_ended in yaml_emitter_write_plain_scalar

Came from 1b27059328 (diff-b6d9f250b293c4770d32bf81d93a66e8R1947)
2017-11-04 10:04:34 +09:00
Norio Nomura c4d58a4bba
Removed trailing-whitespaces 2017-11-04 09:28:13 +09:00
Norio Nomura 8a3a0cb782
Fix misspells 2017-11-04 09:26:34 +09:00
JP Simard efe8f946e7
Refactor Constructor.swift
to reuse code by extending FixedWidthInteger
2017-11-01 23:33:48 -07:00
JP Simard 5d0fb7e62c
Drop support for Swift < 3.2 in source files 2017-11-01 18:15:39 -07:00
JP Simard 08a54775a1
Refactor String.sexagesimal()
* to use single initialization
* to reduce protocol requirements
* to use Sequence.reduce() rather than forEach with two vars
2017-11-01 11:29:27 -07:00
Norio Nomura 5e897a5f27
Merge pull request #67 from jpsim/nn-use-basic-resolver-in-decode
Use `Resolver.basic` in `YAMLDecoder.decode()`
2017-11-01 14:14:49 +09:00
Norio Nomura fca1884689
Use `Resolver.basic` in `YAMLDecoder.decode()`
Since `YAMLDecoder` does not need to resolve type,` Resolver.basic` which does not resolve type is enough.
2017-11-01 11:08:59 +09:00
Norio Nomura 57bea50b1f
Add `appending()`, `replacing()` and `removing()` methods to `Resolver` 2017-11-01 10:49:52 +09:00
Norio Nomura 7abb7a2d34
Add `Resolver.Rule` 2017-11-01 10:19:25 +09:00
Norio Nomura 1c69640458
Merge pull request #43 from jpsim/nn-SE-0166
Support SE-0166 Swift Archival & Serialization
2017-10-30 12:28:13 +09:00
Norio Nomura 9103e0454a Merge pull request #63 from jpsim/nn-remove-unused-libyaml-files
Remove unused libYAML files
2017-10-27 13:23:59 +09:00
Norio Nomura 697b6d7a39
Use `sortKeys` option on `testEncodingTopLevelStructuredSingleClass()`
For stabilizing the test on Linux.
2017-10-27 12:32:15 +09:00
Norio Nomura 0690a078a6
Fix wording 2017-10-27 12:32:15 +09:00
Norio Nomura e316e16870
Move `swiftlint:disable` to the actual actual position of violation 2017-10-27 12:32:15 +09:00
Norio Nomura 1608f122af
Fix compilation issue on Swift 3.x 2017-10-27 12:32:14 +09:00
Norio Nomura c856831266
Apply patch created by jpsim 2017-10-27 12:32:14 +09:00
Norio Nomura 21e59d2976
Change `_YAML` prefix of coders types to `_` other than `_YAMLCodingKey`
Some types already be changed.
2017-10-27 12:32:12 +09:00
Norio Nomura d1f55a10d7
Merge `_YAMLDecodingKey` and `_YAMLEncodingKey` 2017-10-27 12:32:12 +09:00
Norio Nomura 3524624e81
Remove `Substring.sexagesimal()` 2017-10-27 12:32:11 +09:00
Norio Nomura 2b9779286f
Unify `ScalarConstructible` implementations of `Double` and `Float` 2017-10-27 12:32:10 +09:00
Norio Nomura d0b0f1f728
DBL_DECIMAL_DIG = 17 2017-10-27 12:32:10 +09:00
Norio Nomura 20476bd78d
Apply patch created by jpsim 2017-10-27 12:32:09 +09:00
Norio Nomura f2001b9855
Fix compilation issue on Swift 3.x 2017-10-27 12:32:09 +09:00
Norio Nomura a8c730ee2c
Encoding/Decoding `Double` and `Float` with full precision are supported only on Apple platforms 2017-10-27 12:32:08 +09:00
Norio Nomura dfbff63386
Fix encoding `Double` and `Float`
Double and Float are now encoded with sufficient precision for decoding.
2017-10-27 12:32:07 +09:00
Norio Nomura d0f2102535
Fix decoding `max` of `UnsignedInteger` 2017-10-27 12:32:06 +09:00
Norio Nomura b15a46ae09
Inline some simple methods 2017-10-27 12:32:05 +09:00
Norio Nomura 2171c92313
Remove unneeded method 2017-10-27 12:32:04 +09:00
Norio Nomura d03eb6eae5
Revise access levels 2017-10-27 12:32:03 +09:00
Norio Nomura dc7cee5205
Add default to `type` parameter of `YAMLDecoder.decode` method 2017-10-27 12:32:03 +09:00
Norio Nomura ab9039aca4
Refactor `YAMLEncoder` 2017-10-27 12:32:02 +09:00
Norio Nomura e4d5cf67b3
Refactor `YAMLDecoder` 2017-10-27 12:32:02 +09:00
Norio Nomura cddbcad16d
Add `Emitter.Options` to `YAMLEncoder` as `Options` 2017-10-27 12:32:02 +09:00
Norio Nomura 1e1a7bd783
Change type of payload from `Data` to `String` 2017-10-27 12:32:01 +09:00
Norio Nomura df02b7024f
Fix swiftlint violations 2017-10-27 12:31:59 +09:00
Norio Nomura 9ab288a274
Fix private_over_fileprivate violations 2017-10-27 12:31:59 +09:00
Norio Nomura 48cf441274
Wrap `YamlError` into `EncodingError` or `DecodingError` 2017-10-27 12:31:59 +09:00
Norio Nomura 8833d3a683
Add specialization for `Decimal` and `URL` 2017-10-27 12:31:57 +09:00
Norio Nomura 0e5ef0762e
Fix `Float.construct(from:)` 2017-10-27 12:31:56 +09:00
Norio Nomura d50249f384
Add `mapping` and `sequence` to `_YAMLEncoder`
Fix codingPath had duplicated entries in `_UnkeyedEncodingContainer`.
2017-10-27 12:31:56 +09:00
Norio Nomura d94119b453
Use `.unused` instead of `""` as initial value of `_YAMLEncoder.node` 2017-10-27 12:31:55 +09:00
Norio Nomura a6396a9d3e
Stop expecting non null on `SingleValueDecodingContainer.decode(_:)` 2017-10-27 12:31:55 +09:00
Norio Nomura 97c6f72dcd
Remove `_YAMLEncoder.with(pushedKey:)` and fix invalid `_YAMLReferencingEncoder.codingPath` 2017-10-27 12:31:53 +09:00
Norio Nomura d6cab350ce
Update to latest Coders protocol 2017-10-27 12:31:53 +09:00
Norio Nomura a396a13050
Loose requirement that `Node` is `scalar` in `NSNull.construct(from:)`
This allows checking `node.null == NSNull()`.
2017-10-27 12:31:52 +09:00
Norio Nomura adae047a2f
Add `ScalarRepresentable` protocol that is representable as `Node.scalar` 2017-10-27 12:31:51 +09:00
Norio Nomura 116f5b2761
Conform to latest Coders protocol 2017-10-27 12:31:50 +09:00
Norio Nomura a72a47b107
Change `Date` encoding for `Codable` to preserve nanosecond without truncation 2017-10-27 12:31:49 +09:00
Norio Nomura d06d6e03e6
Add SE-0166 support 2017-10-27 12:31:49 +09:00
Norio Nomura 57ac824a76
Add `ScalarRepresentable` protocol that is representable as `Node.scalar` 2017-10-27 12:31:47 +09:00
Norio Nomura dad95c8fdc
Remove unused libYAML files
fixes #62
2017-10-27 09:40:09 +09:00
Norio Nomura 2f8317cefd
Change from `sortedKeys` to `sortKeys` 2017-10-27 08:25:30 +09:00
Norio Nomura 677851d6a5
Add `Emitter.Options.sortedKeys`
Set if emitter should sort keys in lexicographic order.
2017-10-26 16:10:54 +09:00
Norio Nomura 44a4559d41
Fix failed on `Int.min` 2017-10-25 09:50:16 +09:00
Norio Nomura 556911e888
Add negative Int support to other formats in addition to canonical 2017-10-25 09:23:59 +09:00
Norio Nomura ff1309dc4c
'characters' is deprecated: Please use String or Substring directly 2017-10-24 11:14:23 +09:00
Norio Nomura e19764db26
Fix comment 2017-10-20 16:04:23 +09:00
Norio Nomura 81506f564d
Add `Emitter.Options` 2017-10-20 15:35:16 +09:00
Norio Nomura db42c6ae7c
Fix swiftlint violations 2017-10-20 11:06:27 +09:00
JP Simard 66680328f4
Fix -Wconditional-uninitialized warning
See https://circleci.com/gh/realm/SwiftLint/1899
2017-10-05 14:51:56 -07:00
JP Simard 7851ecb90d
Remove superfluous SwiftLint disable command
since this file doesn't trigger a file_length violation.
2017-09-09 16:52:34 -07:00
Norio Nomura 58fae96c42
Use `..<` instead of `...` as equivalent to `substring(to:)`
Fix https://travis-ci.org/jpsim/Yams/jobs/263299535#L102
> Test Case '-[YamsTests.EncoderTests testEncodingDate]' started.
> fatal error: cannot increment beyond endIndex
2017-08-11 09:48:15 +09:00
JP Simard d5dd1decd9
updates for latest Swift 4 from Xcode 9 beta 5 2017-08-07 10:54:10 -07:00
JP Simard e4c2678a9c
backwards-compatible update to compile with 4020170725a snapshot 2017-07-27 12:58:33 -07:00
JP Simard b1b18ed175
update to compile with Xcode 9 beta 4 in Swift 4 mode 2017-07-27 12:48:19 -07:00
JP Simard fdf1f718bb
update to compile with Xcode 9 beta 2 2017-06-24 11:46:13 -07:00