Skip to content

Commit 29d7627

Browse files
authored
Merge pull request #56 from Narsail/master
Swift 4 Update
2 parents d29577c + 6ad4150 commit 29d7627

File tree

8 files changed

+50
-33
lines changed

8 files changed

+50
-33
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1
1+
4.0

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ os:
44
language: generic
55
sudo: required
66
dist: trusty
7-
osx_image: xcode8
7+
osx_image: xcode9
88
install:
99
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
1010
script:

MessagePack.xcodeproj/project.pbxproj

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
825321CA1EFFCA2800914B55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
151151
825321CB1EFFCA2800914B55 /* MessagePack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessagePack.h; sourceTree = "<group>"; };
152152
825321CC1EFFCA2800914B55 /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
153-
825321D31EFFCAED00914B55 /* Messagepack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Messagepack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
153+
825321D31EFFCAED00914B55 /* MessagePack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MessagePack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
154154
825321E01EFFCAF900914B55 /* MessagePack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MessagePack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
155155
825321E81EFFCAFA00914B55 /* MessagePackTests-tvOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MessagePackTests-tvOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
156156
825321FC1EFFCB2A00914B55 /* MessagePack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MessagePack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -228,7 +228,7 @@
228228
children = (
229229
8253217D1EFFC9C400914B55 /* MessagePack.framework */,
230230
825321861EFFC9C500914B55 /* MessagePackTests-iOS.xctest */,
231-
825321D31EFFCAED00914B55 /* Messagepack.framework */,
231+
825321D31EFFCAED00914B55 /* MessagePack.framework */,
232232
825321E01EFFCAF900914B55 /* MessagePack.framework */,
233233
825321E81EFFCAFA00914B55 /* MessagePackTests-tvOS.xctest */,
234234
825321FC1EFFCB2A00914B55 /* MessagePack.framework */,
@@ -372,7 +372,7 @@
372372
);
373373
name = "MessagePack-watchOS";
374374
productName = MessagePack;
375-
productReference = 825321D31EFFCAED00914B55 /* Messagepack.framework */;
375+
productReference = 825321D31EFFCAED00914B55 /* MessagePack.framework */;
376376
productType = "com.apple.product-type.framework";
377377
};
378378
825321DF1EFFCAF900914B55 /* MessagePack-tvOS */ = {
@@ -480,6 +480,7 @@
480480
};
481481
825321FB1EFFCB2A00914B55 = {
482482
CreatedOnToolsVersion = 8.3.3;
483+
LastSwiftMigration = 0900;
483484
ProvisioningStyle = Automatic;
484485
};
485486
825322031EFFCB2B00914B55 = {
@@ -839,7 +840,7 @@
839840
PRODUCT_NAME = MessagePack;
840841
SKIP_INSTALL = YES;
841842
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
842-
SWIFT_VERSION = 3.0;
843+
SWIFT_VERSION = 4.0;
843844
};
844845
name = Debug;
845846
};
@@ -858,7 +859,7 @@
858859
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePack;
859860
PRODUCT_NAME = MessagePack;
860861
SKIP_INSTALL = YES;
861-
SWIFT_VERSION = 3.0;
862+
SWIFT_VERSION = 4.0;
862863
};
863864
name = Release;
864865
};
@@ -870,7 +871,7 @@
870871
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
871872
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePackTests;
872873
PRODUCT_NAME = "$(TARGET_NAME)";
873-
SWIFT_VERSION = 3.0;
874+
SWIFT_VERSION = 4.0;
874875
};
875876
name = Debug;
876877
};
@@ -882,7 +883,7 @@
882883
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
883884
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePackTests;
884885
PRODUCT_NAME = "$(TARGET_NAME)";
885-
SWIFT_VERSION = 3.0;
886+
SWIFT_VERSION = 4.0;
886887
};
887888
name = Release;
888889
};
@@ -899,10 +900,10 @@
899900
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
900901
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
901902
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePack;
902-
PRODUCT_NAME = Messagepack;
903+
PRODUCT_NAME = MessagePack;
903904
SDKROOT = watchos;
904905
SKIP_INSTALL = YES;
905-
SWIFT_VERSION = 3.0;
906+
SWIFT_VERSION = 4.0;
906907
TARGETED_DEVICE_FAMILY = 4;
907908
};
908909
name = Debug;
@@ -920,10 +921,10 @@
920921
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
921922
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
922923
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePack;
923-
PRODUCT_NAME = Messagepack;
924+
PRODUCT_NAME = MessagePack;
924925
SDKROOT = watchos;
925926
SKIP_INSTALL = YES;
926-
SWIFT_VERSION = 3.0;
927+
SWIFT_VERSION = 4.0;
927928
TARGETED_DEVICE_FAMILY = 4;
928929
};
929930
name = Release;
@@ -943,7 +944,7 @@
943944
PRODUCT_NAME = MessagePack;
944945
SDKROOT = appletvos;
945946
SKIP_INSTALL = YES;
946-
SWIFT_VERSION = 3.0;
947+
SWIFT_VERSION = 4.0;
947948
TARGETED_DEVICE_FAMILY = 3;
948949
};
949950
name = Debug;
@@ -963,7 +964,7 @@
963964
PRODUCT_NAME = MessagePack;
964965
SDKROOT = appletvos;
965966
SKIP_INSTALL = YES;
966-
SWIFT_VERSION = 3.0;
967+
SWIFT_VERSION = 4.0;
967968
TARGETED_DEVICE_FAMILY = 3;
968969
};
969970
name = Release;
@@ -977,7 +978,7 @@
977978
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePackTests;
978979
PRODUCT_NAME = "$(TARGET_NAME)";
979980
SDKROOT = appletvos;
980-
SWIFT_VERSION = 3.0;
981+
SWIFT_VERSION = 4.0;
981982
TVOS_DEPLOYMENT_TARGET = 10.2;
982983
};
983984
name = Debug;
@@ -991,7 +992,7 @@
991992
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePackTests;
992993
PRODUCT_NAME = "$(TARGET_NAME)";
993994
SDKROOT = appletvos;
994-
SWIFT_VERSION = 3.0;
995+
SWIFT_VERSION = 4.0;
995996
TVOS_DEPLOYMENT_TARGET = 10.2;
996997
};
997998
name = Release;
@@ -1013,7 +1014,8 @@
10131014
PRODUCT_NAME = MessagePack;
10141015
SDKROOT = macosx;
10151016
SKIP_INSTALL = YES;
1016-
SWIFT_VERSION = 3.0;
1017+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1018+
SWIFT_VERSION = 4.0;
10171019
};
10181020
name = Debug;
10191021
};
@@ -1034,7 +1036,8 @@
10341036
PRODUCT_NAME = MessagePack;
10351037
SDKROOT = macosx;
10361038
SKIP_INSTALL = YES;
1037-
SWIFT_VERSION = 3.0;
1039+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1040+
SWIFT_VERSION = 4.0;
10381041
};
10391042
name = Release;
10401043
};
@@ -1050,7 +1053,7 @@
10501053
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePackTests;
10511054
PRODUCT_NAME = "$(TARGET_NAME)";
10521055
SDKROOT = macosx;
1053-
SWIFT_VERSION = 3.0;
1056+
SWIFT_VERSION = 4.0;
10541057
};
10551058
name = Debug;
10561059
};
@@ -1066,7 +1069,7 @@
10661069
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.MessagePackTests;
10671070
PRODUCT_NAME = "$(TARGET_NAME)";
10681071
SDKROOT = macosx;
1069-
SWIFT_VERSION = 3.0;
1072+
SWIFT_VERSION = 4.0;
10701073
};
10711074
name = Release;
10721075
};
@@ -1107,6 +1110,7 @@
11071110
825321DA1EFFCAED00914B55 /* Release */,
11081111
);
11091112
defaultConfigurationIsVisible = 0;
1113+
defaultConfigurationName = Release;
11101114
};
11111115
825321F11EFFCAFA00914B55 /* Build configuration list for PBXNativeTarget "MessagePack-tvOS" */ = {
11121116
isa = XCConfigurationList;
@@ -1115,6 +1119,7 @@
11151119
825321F31EFFCAFA00914B55 /* Release */,
11161120
);
11171121
defaultConfigurationIsVisible = 0;
1122+
defaultConfigurationName = Release;
11181123
};
11191124
825321F41EFFCAFA00914B55 /* Build configuration list for PBXNativeTarget "MessagePackTests-tvOS" */ = {
11201125
isa = XCConfigurationList;
@@ -1123,6 +1128,7 @@
11231128
825321F61EFFCAFA00914B55 /* Release */,
11241129
);
11251130
defaultConfigurationIsVisible = 0;
1131+
defaultConfigurationName = Release;
11261132
};
11271133
8253220D1EFFCB2B00914B55 /* Build configuration list for PBXNativeTarget "MessagePack-macOS" */ = {
11281134
isa = XCConfigurationList;
@@ -1131,6 +1137,7 @@
11311137
8253220F1EFFCB2B00914B55 /* Release */,
11321138
);
11331139
defaultConfigurationIsVisible = 0;
1140+
defaultConfigurationName = Release;
11341141
};
11351142
825322101EFFCB2B00914B55 /* Build configuration list for PBXNativeTarget "MessagePackTests-macOS" */ = {
11361143
isa = XCConfigurationList;
@@ -1139,6 +1146,7 @@
11391146
825322121EFFCB2B00914B55 /* Release */,
11401147
);
11411148
defaultConfigurationIsVisible = 0;
1149+
defaultConfigurationName = Release;
11421150
};
11431151
/* End XCConfigurationList section */
11441152
};

MessagePack.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.

MessagePack.xcodeproj/xcshareddata/xcschemes/MessagePack watchOS.xcscheme

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
1717
BlueprintIdentifier = "825321D21EFFCAED00914B55"
18-
BuildableName = "MessagePack-watchOS.framework"
18+
BuildableName = "MessagePack.framework"
1919
BlueprintName = "MessagePack-watchOS"
2020
ReferencedContainer = "container:MessagePack.xcodeproj">
2121
</BuildableReference>
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES"
3031
codeCoverageEnabled = "YES">
3132
<Testables>
@@ -37,6 +38,7 @@
3738
buildConfiguration = "Debug"
3839
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3940
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
41+
language = ""
4042
launchStyle = "0"
4143
useCustomWorkingDirectory = "NO"
4244
ignoresPersistentStateOnLaunch = "NO"
@@ -47,7 +49,7 @@
4749
<BuildableReference
4850
BuildableIdentifier = "primary"
4951
BlueprintIdentifier = "825321D21EFFCAED00914B55"
50-
BuildableName = "MessagePack-watchOS.framework"
52+
BuildableName = "MessagePack.framework"
5153
BlueprintName = "MessagePack-watchOS"
5254
ReferencedContainer = "container:MessagePack.xcodeproj">
5355
</BuildableReference>
@@ -65,7 +67,7 @@
6567
<BuildableReference
6668
BuildableIdentifier = "primary"
6769
BlueprintIdentifier = "825321D21EFFCAED00914B55"
68-
BuildableName = "MessagePack-watchOS.framework"
70+
BuildableName = "MessagePack.framework"
6971
BlueprintName = "MessagePack-watchOS"
7072
ReferencedContainer = "container:MessagePack.xcodeproj">
7173
</BuildableReference>

Sources/MessagePack/ConvenienceInitializers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ extension MessagePackValue {
1010
}
1111

1212
public init<S: SignedInteger>(_ value: S) {
13-
self = .int(value.toIntMax())
13+
self = .int(Int64(value))
1414
}
1515

1616
public init<U: UnsignedInteger>(_ value: U) {
17-
self = .uint(value.toUIntMax())
17+
self = .uint(UInt64(value))
1818
}
1919

2020
public init(_ value: Float) {

Sources/MessagePack/Pack.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
func packInteger(_ value: UInt64, parts: Int) -> Data {
1010
precondition(parts > 0)
1111
let bytes = stride(from: (8 * (parts - 1)), through: 0, by: -8).map { shift in
12-
return UInt8(truncatingBitPattern: value >> UInt64(shift))
12+
return UInt8(truncatingIfNeeded: value >> UInt64(shift))
1313
}
1414
return Data(bytes)
1515
}
@@ -21,9 +21,9 @@ func packInteger(_ value: UInt64, parts: Int) -> Data {
2121
/// - returns: A MessagePack byte representation.
2222
func packPositiveInteger(_ value: UInt64) -> Data {
2323
if value <= 0x7f {
24-
return Data([UInt8(truncatingBitPattern: value)])
24+
return Data([UInt8(truncatingIfNeeded: value)])
2525
} else if value <= 0xff {
26-
return Data([0xcc, UInt8(truncatingBitPattern: value)])
26+
return Data([0xcc, UInt8(truncatingIfNeeded: value)])
2727
} else if value <= 0xffff {
2828
return Data([0xcd]) + packInteger(value, parts: 2)
2929
} else if value <= 0xffff_ffff as UInt64 {
@@ -41,7 +41,7 @@ func packPositiveInteger(_ value: UInt64) -> Data {
4141
func packNegativeInteger(_ value: Int64) -> Data {
4242
precondition(value < 0)
4343
if value >= -0x20 {
44-
return Data([0xe0 + 0x1f & UInt8(truncatingBitPattern: value)])
44+
return Data([0xe0 + 0x1f & UInt8(truncatingIfNeeded: value)])
4545
} else if value >= -0x7f {
4646
return Data([0xd0, UInt8(bitPattern: Int8(value))])
4747
} else if value >= -0x7fff {

Sources/MessagePack/Unpack.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public func unpack(_ data: Subdata, compatibility: Bool = false) throws -> (valu
187187
// float 32
188188
case 0xca:
189189
let (intValue, remainder) = try unpackInteger(data, count: 4)
190-
let float = Float(bitPattern: UInt32(truncatingBitPattern: intValue))
190+
let float = Float(bitPattern: UInt32(truncatingIfNeeded: intValue))
191191
return (.float(float), remainder)
192192

193193
// float 64
@@ -214,13 +214,13 @@ public func unpack(_ data: Subdata, compatibility: Bool = false) throws -> (valu
214214
// int 16
215215
case 0xd1:
216216
let (bytes, remainder) = try unpackInteger(data, count: 2)
217-
let integer = Int16(bitPattern: UInt16(truncatingBitPattern: bytes))
217+
let integer = Int16(bitPattern: UInt16(truncatingIfNeeded: bytes))
218218
return (.int(Int64(integer)), remainder)
219219

220220
// int 32
221221
case 0xd2:
222222
let (bytes, remainder) = try unpackInteger(data, count: 4)
223-
let integer = Int32(bitPattern: UInt32(truncatingBitPattern: bytes))
223+
let integer = Int32(bitPattern: UInt32(truncatingIfNeeded: bytes))
224224
return (.int(Int64(integer)), remainder)
225225

226226
// int 64

0 commit comments

Comments
 (0)