Skip to content

Commit 46e8b66

Browse files
committed
updated to Swift 5; added tests for some "items"; removed some obsolete types; version bump
1 parent d60de41 commit 46e8b66

26 files changed

+714
-230
lines changed

AutoAPI.xcodeproj/AutoAPI_Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>10.0.1</string>
18+
<string>10.0.2</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSHumanReadableCopyright</key>

AutoAPI.xcodeproj/project.pbxproj

Lines changed: 56 additions & 20 deletions
Large diffs are not rendered by default.

AutoAPI.xcodeproj/xcshareddata/xcschemes/AutoAPI iOS Universal.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

AutoAPI.xcodeproj/xcshareddata/xcschemes/AutoAPI.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

AutoAPI.xcodeproj/xcshareddata/xcschemes/AutoAPICLT.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Sources/AutoAPI/AAAutoAPI.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ public struct AAAutoAPI {
9898
// MARK: Type Methods
9999

100100
public static func parseBinary<C>(_ binary: C) -> AACapability? where C: Collection, C.Element == UInt8 {
101-
let capabilities = AAAutoAPI.capabilities.compactMap { $0 as? AACapabilityClass.Type }
102-
103-
return capabilities.compactMap { $0.init(bytes: binary.bytes) as? AACapability }.first
101+
return AAAutoAPI.capabilities.compactMap { $0.init(bytes: binary.bytes) }.first
104102
}
105103
}

Sources/AutoAPI/AACapability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ extension AACapability {
136136
var string = string
137137
var subString: String?
138138

139-
string.removeFirst(firstParenthesis.encodedOffset + 1)
139+
string.removeFirst(firstParenthesis.utf16Offset(in: string) + 1)
140140
string.removeLast()
141141

142142
// "Clean" the label

Sources/AutoAPI/Capabilities/AAHistorical.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ public class AAHistorical: AACapabilityClass, AACapability {
4040

4141

4242
required init(properties: AAProperties) {
43-
let capabilities = AAAutoAPI.capabilities.compactMap { $0 as? AACapabilityClass.Type }
44-
4543
/* Level 8 */
4644
states = properties.filter {
4745
$0.identifier == 0x01
4846
}.compactMap {
4947
$0.valueBytes
50-
}.compactMap { bytes in
51-
capabilities.compactMap {
52-
$0.init(bytes: bytes) as? AACapability
53-
}.first
48+
}.compactMap {
49+
AAAutoAPI.parseBinary($0)
5450
}
5551

5652
super.init(properties: properties)

Sources/AutoAPI/Capabilities/AAMultiCommand.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,13 @@ public class AAMultiCommand: AACapabilityClass, AACapability {
4141

4242

4343
required init(properties: AAProperties) {
44-
let capabilities = AAAutoAPI.capabilities.compactMap { $0 as? AACapabilityClass.Type }
45-
4644
/* Level 9 */
4745
states = properties.filter {
4846
$0.identifier == 0x01
4947
}.compactMap {
5048
$0.valueBytes
51-
}.compactMap { bytes in
52-
capabilities.compactMap {
53-
$0.init(bytes: bytes) as? AACapability
54-
}.first
49+
}.compactMap {
50+
AAAutoAPI.parseBinary($0)
5551
}
5652

5753
super.init(properties: properties)

Sources/AutoAPI/Capabilities/AAVehicleStatus.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public class AAVehicleStatus: AACapabilityClass, AACapability {
5858

5959

6060
required init(properties: AAProperties) {
61-
let capabilities = AAAutoAPI.capabilities.compactMap { $0 as? AACapabilityClass.Type }
62-
6361
// Ordered by the ID
6462
vin = properties.property(forIdentifier: 0x01)
6563
powerTrain = properties.property(forIdentifier: 0x02)
@@ -87,10 +85,8 @@ public class AAVehicleStatus: AACapabilityClass, AACapability {
8785
$0.identifier == 0x99
8886
}.compactMap {
8987
$0.valueBytes
90-
}.compactMap { bytes in
91-
capabilities.compactMap {
92-
$0.init(bytes: bytes) as? AACapability
93-
}.first
88+
}.compactMap {
89+
AAAutoAPI.parseBinary($0)
9490
}
9591

9692
super.init(properties: properties)

0 commit comments

Comments
 (0)