Skip to content

Commit f458319

Browse files
Merge pull request #11 from SomeRandomiOSDev/1.2.0
1.2.0
2 parents b08ee2a + 9119255 commit f458319

30 files changed

+540
-292
lines changed

.github/workflows/swift.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
name: Swift
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
7-
8-
runs-on: macOS-latest
9-
7+
strategy:
8+
matrix:
9+
os: [macOS-latest, ubuntu-latest]
10+
swift: ["5.1"]
11+
runs-on: ${{ matrix.os }}
12+
env:
13+
SWIFT_VERSION: ${{ matrix.swift }}
14+
SWIFT_EXEC: .swiftenv/shims/swift
1015
steps:
1116
- uses: actions/checkout@v2
17+
- name: Install Swift
18+
run: |
19+
git clone https://github.com/kylef/swiftenv.git ~/.swiftenv
20+
~/.swiftenv/bin/swiftenv install $SWIFT_VERSION --skip-existing
21+
~/.swiftenv/bin/swiftenv rehash
1222
- name: Build
13-
run: swift build -v
14-
- name: Run Tests
15-
run: swift test -v
23+
run: |
24+
~/$SWIFT_EXEC --version
25+
~/$SWIFT_EXEC build -v
26+
- name: Test
27+
run: |
28+
~/$SWIFT_EXEC test -v

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CBORCoding.xcodeproj/project.xcworkspace
1+
CBORCoding.xcodeproj/project.xcworkspace/xcuserdata
22
CBORCoding.xcodeproj/xcuserdata
33
CBORCoding.xcworkspace/xcuserdata
44
.build

.swiftlint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ opt_in_rules:
4444
- multiple_closures_with_trailing_closure
4545
- nesting
4646
- notification_center_detachment
47-
- number_separator
4847
- object_literal
4948
- operator_usage_whitespace
5049
- override_in_extension
@@ -60,8 +59,9 @@ opt_in_rules:
6059
- yoda_condition
6160

6261
excluded:
63-
- Pods
64-
- Carthage
62+
- .build
63+
- Tests/LinuxMain.swift
64+
- Tests/CBORCodingTests/XCTestManifests.swift
6565

6666
reporter: "xcode"
6767

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ os: osx
22
language: swift
33
osx_image: xcode11.3
44
xcode_project: CBORCoding.xcodeproj
5-
addons:
6-
homebrew:
7-
packages:
8-
carthage
95

106
script:
11-
- carthage bootstrap
12-
137
- set -o pipefail && travis_retry xcodebuild -scheme "CBORCodingTests" -destination "platform=iOS Simulator,name=iPhone 11 Pro Max" -configuration Debug ONLY_ACTIVE_ARCH=YES -enableCodeCoverage YES test
148
- set -o pipefail && travis_retry xcodebuild -scheme "CBORCoding macOS Tests" -destination "platform=macOS" -configuration Debug ONLY_ACTIVE_ARCH=YES -enableCodeCoverage YES test
159
- set -o pipefail && travis_retry xcodebuild -scheme "CBORCoding tvOS Tests" -destination "platform=tvOS Simulator,name=Apple TV 4K" -configuration Debug ONLY_ACTIVE_ARCH=YES -enableCodeCoverage YES test

CBORCoding.podspec

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "CBORCoding"
4-
s.version = "1.1.0"
4+
s.version = "1.2.0"
55
s.summary = "A CBOR Encoder and Decoder"
66
s.description = <<-DESC
77
A lightweight framework containing a coder pair for encoding and decoding `Codable` conforming types to and from CBOR document format for iOS, macOS, tvOS, and watchOS.
@@ -16,12 +16,19 @@ Pod::Spec.new do |s|
1616
s.tvos.deployment_target = '9.0'
1717
s.watchos.deployment_target = '2.0'
1818

19-
s.source = { :git => "https://github.com/SomeRandomiOSDev/CBORCoding.git", :tag => s.version.to_s }
20-
s.source_files = 'CBORCoding/**/*.swift'
21-
s.frameworks = 'Foundation'
22-
s.swift_version = '5.0'
23-
s.requires_arc = true
19+
s.source = { :git => "https://github.com/SomeRandomiOSDev/CBORCoding.git", :tag => s.version.to_s }
20+
s.source_files = 'Sources/**/*.swift'
21+
s.swift_versions = ['4.2', '5.0']
22+
s.cocoapods_version = '>= 1.7.3'
2423

25-
s.dependency 'Half', '~> 1.0'
24+
s.dependency 'Half', '~> 1.2'
25+
26+
s.test_spec 'Tests' do |ts|
27+
ts.ios.deployment_target = '8.0'
28+
ts.macos.deployment_target = '10.10'
29+
ts.tvos.deployment_target = '9.0'
30+
31+
ts.source_files = 'Tests/CBORCodingTests/*Tests.swift'
32+
end
2633

2734
end

CBORCoding.xcodeproj/project.pbxproj

Lines changed: 234 additions & 247 deletions
Large diffs are not rendered by default.

CBORCoding.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CBORCoding.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cartfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cartfile.resolved

Lines changed: 0 additions & 1 deletion
This file was deleted.

Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ let package = Package(
1616
],
1717

1818
dependencies: [
19-
.package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.0.0")
19+
.package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.2.0")
2020
],
2121

2222
targets: [
23-
.target(name: "CBORCoding", dependencies: ["Half"], path: "CBORCoding"),
24-
.testTarget(name: "CBORCodingTests", dependencies: ["CBORCoding"], path: "CBORCodingTests")
25-
]
23+
.target(name: "CBORCoding", dependencies: ["Half"]),
24+
.testTarget(name: "CBORCodingTests", dependencies: ["CBORCoding", "Half"])
25+
],
26+
27+
swiftLanguageVersions: [.version("4.2"), .version("5")]
2628
)

[email protected]

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// swift-tools-version:4.2
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "CBORCoding",
6+
7+
products: [
8+
.library(name: "CBORCoding", targets: ["CBORCoding"])
9+
],
10+
11+
dependencies: [
12+
.package(url: "https://github.com/SomeRandomiOSDev/Half", from: "1.2.0")
13+
],
14+
15+
targets: [
16+
.target(name: "CBORCoding", dependencies: ["Half"]),
17+
.testTarget(name: "CBORCodingTests", dependencies: ["CBORCoding", "Half"])
18+
],
19+
20+
swiftLanguageVersions: [.v4_2]
21+
)
File renamed without changes.
File renamed without changes.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CBORCoding
55
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CBORCoding.svg)](https://cocoapods.org/pods/CBORCoding)
66
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
77
[![Platform](https://img.shields.io/cocoapods/p/CBORCoding.svg)](https://cocoapods.org/pods/CBORCoding)
8+
![Linux](https://img.shields.io/badge/platform-linux-lightgrey)
89
[![Build](https://travis-ci.com/SomeRandomiOSDev/CBORCoding.svg?branch=master)](https://travis-ci.com/SomeRandomiOSDev/CBORCoding)
910
[![Code Coverage](https://codecov.io/gh/SomeRandomiOSDev/CBORCoding/branch/master/graph/badge.svg)](https://codecov.io/gh/SomeRandomiOSDev/CBORCoding)
1011
[![Codacy](https://api.codacy.com/project/badge/Grade/8ad52c117e4a46d9aa4699d22fc0bf49)](https://app.codacy.com/app/SomeRandomiOSDev/CBORCoding?utm_source=github.com&utm_medium=referral&utm_content=SomeRandomiOSDev/CBORCoding&utm_campaign=Badge_Grade_Dashboard)
@@ -94,8 +95,6 @@ Contributing
9495

9596
If you have need for a specific feature or you encounter a bug, please open an issue. If you extend the functionality of **CBORCoding** yourself or you feel like fixing a bug yourself, please submit a pull request.
9697

97-
Note: You'll need to run `carthage bootstrap` upon downloading to resolve and build **CBORCoding**'s dependencies before being able to develop locally. Please look [here](https://github.com/Carthage/Carthage) for more info on installing Carthage on your local machine.
98-
9998
Author
10099
--------
101100

File renamed without changes.

CBORCoding/CBOR+Equatable.swift renamed to Sources/CBORCoding/CBOR+Equatable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension CBOR.Bignum: Equatable {
4343

4444
// MARK: - CBOR.DecimalFraction Extension
4545

46-
extension CBOR.DecimalFraction: Equatable where I1: Equatable, I2: Equatable {
46+
extension CBOR.DecimalFraction: Equatable {
4747

4848
public static func == (lhs: CBOR.DecimalFraction<I1, I2>, rhs: CBOR.DecimalFraction<I1, I2>) -> Bool {
4949
return lhs.exponent == rhs.exponent && lhs.mantissa == rhs.mantissa
@@ -52,7 +52,7 @@ extension CBOR.DecimalFraction: Equatable where I1: Equatable, I2: Equatable {
5252

5353
// MARK: - CBOR.Bigfloat Extension
5454

55-
extension CBOR.Bigfloat: Equatable where I1: Equatable, I2: Equatable {
55+
extension CBOR.Bigfloat: Equatable {
5656

5757
public static func == (lhs: CBOR.Bigfloat<I1, I2>, rhs: CBOR.Bigfloat<I1, I2>) -> Bool {
5858
return lhs.exponent == rhs.exponent && lhs.mantissa == rhs.mantissa
File renamed without changes.

CBORCoding/CBORDecoder.swift renamed to Sources/CBORCoding/CBORDecoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ private struct __CBORKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContaine
757757
throw DecodingError._typeMismatch(at: codingPath, expectation: [String: Any].self, reality: value)
758758
}
759759

760-
let container = __CBORKeyedDecodingContainer<NestedKey>(referencing: decoder, wrapping: dictionary)
761-
return KeyedDecodingContainer(container)
760+
let keyedContainer = __CBORKeyedDecodingContainer<NestedKey>(referencing: decoder, wrapping: dictionary)
761+
return KeyedDecodingContainer(keyedContainer)
762762
}
763763

764764
func nestedUnkeyedContainer(forKey key: Key) throws -> UnkeyedDecodingContainer {

CBORCoding/CBOREncoder.swift renamed to Sources/CBORCoding/CBOREncoder.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,8 @@ private struct __CBORKeyedEncodingContainer<K>: KeyedEncodingContainerProtocol w
965965
self.codingPath.append(key)
966966
defer { self.codingPath.removeLast() }
967967

968-
let container = __CBORKeyedEncodingContainer<NestedKey>(referencing: encoder, codingPath: codingPath, wrapping: dictionary)
969-
return KeyedEncodingContainer<NestedKey>(container)
968+
let keyedContainer = __CBORKeyedEncodingContainer<NestedKey>(referencing: encoder, codingPath: codingPath, wrapping: dictionary)
969+
return KeyedEncodingContainer<NestedKey>(keyedContainer)
970970
}
971971

972972
mutating func nestedUnkeyedContainer(forKey key: Key) -> UnkeyedEncodingContainer {
@@ -1046,8 +1046,8 @@ private struct __CBORUnkeyedEncodingContainer: UnkeyedEncodingContainer {
10461046
let dictionary = CodingKeyDictionary<Any>(indefiniteLength: encoder.newContainerLength.contains(.indefinite))
10471047
container.append(dictionary)
10481048

1049-
let container = __CBORKeyedEncodingContainer<NestedKey>(referencing: encoder, codingPath: codingPath, wrapping: dictionary)
1050-
return KeyedEncodingContainer<NestedKey>(container)
1049+
let keyedContainer = __CBORKeyedEncodingContainer<NestedKey>(referencing: encoder, codingPath: codingPath, wrapping: dictionary)
1050+
return KeyedEncodingContainer<NestedKey>(keyedContainer)
10511051
}
10521052

10531053
mutating func nestedUnkeyedContainer() -> UnkeyedEncodingContainer {
@@ -1117,7 +1117,7 @@ private class __CBORReferencingEncoder: __CBOREncoder {
11171117
}
11181118

11191119
switch reference {
1120-
case .array(var array, let index):
1120+
case let .array(array, index):
11211121
array.insert(value, at: index)
11221122

11231123
case let .dictionary(dictionary, key):

CBORCoding/CBORParser.swift renamed to Sources/CBORCoding/CBORParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ internal class CBORParser {
10651065

10661066
let index = containers.count - 1
10671067

1068-
if var array = containers[index] as? (container: ArrayWrapper<Any>, length: UInt64?) {
1068+
if let array = containers[index] as? (container: ArrayWrapper<Any>, length: UInt64?) {
10691069
array.container.append(value)
10701070
containers[index].length -= 1
10711071
} else if let dictionary = containers[index] as? (container: CodingKeyDictionary<Any>, length: UInt64?) {
@@ -1207,7 +1207,7 @@ internal class CBORParser {
12071207

12081208
// MARK: - Optional Extension
12091209

1210-
extension Optional where Wrapped: AdditiveArithmetic {
1210+
extension Optional where Wrapped == UInt64 {
12111211

12121212
fileprivate static func -= (lhs: inout Wrapped?, rhs: Wrapped) {
12131213
if let value = lhs {

CBORCoding/Containers.swift renamed to Sources/CBORCoding/Containers.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ internal class ArrayWrapper<Element>: MutableCollection, RandomAccessCollection,
7171
func replaceSubrange<C, R>(_ subrange: R, with newElements: __owned C) where C: Collection, R: RangeExpression, Element == C.Element, Index == R.Bound {
7272
array.replaceSubrange(subrange, with: newElements)
7373
}
74+
75+
func insert(_ newElement: __owned Element, at i: Int) {
76+
array.insert(newElement, at: i)
77+
}
78+
79+
func append(_ newElement: __owned Element) {
80+
array.append(newElement)
81+
}
7482
}
7583

7684
// MARK: - CodingKeyDictionary Definition
@@ -151,7 +159,6 @@ internal class CodingKeyDictionary<Value>: Sequence, ExpressibleByDictionaryLite
151159
// MARK: - ExpressibleByDictionaryLiteral Protocol Requirements
152160

153161
typealias Key = CodingKey
154-
typealias Value = Value
155162

156163
required init(dictionaryLiteral elements: (Key, Value)...) {
157164
self.keyValuePairs = elements

CBORCodingTests/CBOREncoderTests.swift renamed to Tests/CBORCodingTests/CBOREncoderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CBOREncoderTests: XCTestCase {
3333
(try! encoder.encode(UInt64(1000)), "0x1903E8"),
3434
(try! encoder.encode(UInt64(1000000)), "0x1A000F4240"),
3535
(try! encoder.encode(UInt64(1000000000000)), "0x1B000000E8D4A51000"),
36-
(try! encoder.encode(UInt64(18446744073709551615)), "0x1BFFFFFFFFFFFFFFFF"),
36+
(try! encoder.encode(18446744073709551615 as UInt64), "0x1BFFFFFFFFFFFFFFFF"),
3737
(try! encoder.encode(CBOR.Bignum(isPositive: true,
3838
content: Data([UInt8(0x01), 0x00, 0x00, 0x00,
3939
0x00, 0x00, 0x00, 0x00, 0x00]))), "0xC249010000000000000000"), // 18446744073709551616

0 commit comments

Comments
 (0)