Skip to content

Commit

Permalink
Merge pull request #44 from a2/swift-3.1
Browse files Browse the repository at this point in the history
Updates for Swift 3.1
  • Loading branch information
a2 committed Mar 29, 2017
2 parents 426ec0e + d36903e commit 3bb75f8
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .swift-version
@@ -1 +1 @@
3.0
3.1
2 changes: 1 addition & 1 deletion MessagePack.swift.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MessagePack.swift'
s.version = '2.0.1'
s.version = '2.0.2'
s.summary = "It's like JSON, but fast and small...and Swift!"
s.homepage = 'https://github.com/a2/MessagePack.swift'
s.license = 'MIT'
Expand Down
18 changes: 13 additions & 5 deletions MessagePack.xcodeproj/project.pbxproj
Expand Up @@ -53,8 +53,9 @@
children = (
OBJ_16,
);
path = "Tests";
sourceTree = "<group>";
name = "Tests";
path = "";
sourceTree = "SOURCE_ROOT";
};
OBJ_16 = {
isa = "PBXGroup";
Expand Down Expand Up @@ -158,6 +159,7 @@
OBJ_3 = {
isa = "XCBuildConfiguration";
buildSettings = {
CLANG_ENABLE_OBJC_ARC = "YES";
COMBINE_HIDPI_IMAGES = "YES";
COPY_PHASE_STRIP = "NO";
DEBUG_INFORMATION_FORMAT = "dwarf";
Expand Down Expand Up @@ -258,6 +260,7 @@
OBJ_4 = {
isa = "XCBuildConfiguration";
buildSettings = {
CLANG_ENABLE_OBJC_ARC = "YES";
COMBINE_HIDPI_IMAGES = "YES";
COPY_PHASE_STRIP = "YES";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand All @@ -279,7 +282,7 @@
"watchsimulator",
);
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "SWIFT_PACKAGE";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = "3.0";
USE_HEADERMAP = "NO";
};
Expand Down Expand Up @@ -309,6 +312,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "MessagePack";
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = "YES";
TARGET_NAME = "MessagePack";
};
name = "Debug";
Expand Down Expand Up @@ -337,6 +341,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "MessagePack";
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = "YES";
TARGET_NAME = "MessagePack";
};
name = "Release";
Expand Down Expand Up @@ -431,6 +436,7 @@
INFOPLIST_FILE = "MessagePack.xcodeproj/MessagePackTests_Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"@loader_path/../Frameworks",
"@loader_path/Frameworks",
);
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -456,6 +462,7 @@
INFOPLIST_FILE = "MessagePack.xcodeproj/MessagePackTests_Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"@loader_path/../Frameworks",
"@loader_path/Frameworks",
);
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -560,8 +567,9 @@
children = (
OBJ_8,
);
path = "Sources";
sourceTree = "<group>";
name = "Sources";
path = "";
sourceTree = "SOURCE_ROOT";
};
OBJ_70 = {
isa = "PBXBuildFile";
Expand Down
110 changes: 79 additions & 31 deletions MessagePack.xcodeproj/xcshareddata/xcschemes/MessagePack.xcscheme
@@ -1,33 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme LastUpgradeVersion = "9999" version = "1.3">
<BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BuildableName = "'lib$(TARGET_NAME)'"
BlueprintName = "MessagePack"
ReferencedContainer = "container:MessagePack.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "NO">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BuildableName = "'$(TARGET_NAME)'"
BlueprintName = "MessagePackTests"
ReferencedContainer = "container:MessagePack.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<Scheme
LastUpgradeVersion = "9999"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OBJ_38"
BuildableName = "MessagePack.framework"
BlueprintName = "MessagePack"
ReferencedContainer = "container:MessagePack.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OBJ_50"
BuildableName = "MessagePackTests.xctest"
BlueprintName = "MessagePackTests"
ReferencedContainer = "container:MessagePack.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OBJ_38"
BuildableName = "MessagePack.framework"
BlueprintName = "MessagePack"
ReferencedContainer = "container:MessagePack.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
6 changes: 2 additions & 4 deletions Sources/MessagePack/Pack.swift
Expand Up @@ -80,12 +80,10 @@ public func pack(_ value: MessagePackValue) -> Data {
return packPositiveInteger(value)

case .float(let value):
let integerValue = unsafeBitCast(value, to: UInt32.self)
return Data([0xca]) + packInteger(UInt64(integerValue), parts: 4)
return Data([0xca]) + packInteger(UInt64(value.bitPattern), parts: 4)

case .double(let value):
let integerValue = unsafeBitCast(value, to: UInt64.self)
return Data([0xcb]) + packInteger(integerValue, parts: 8)
return Data([0xcb]) + packInteger(value.bitPattern, parts: 8)

case .string(let string):
let utf8 = string.utf8
Expand Down
4 changes: 2 additions & 2 deletions Sources/MessagePack/Unpack.swift
Expand Up @@ -185,13 +185,13 @@ public func unpack(_ data: Data, compatibility: Bool = false) throws -> (value:
// float 32
case 0xca:
let (intValue, remainder) = try unpackInteger(data, count: 4)
let float = unsafeBitCast(UInt32(truncatingBitPattern: intValue), to: Float.self)
let float = Float(bitPattern: UInt32(truncatingBitPattern: intValue))
return (.float(float), remainder)

// float 64
case 0xcb:
let (intValue, remainder) = try unpackInteger(data, count: 8)
let double = unsafeBitCast(intValue, to: Double.self)
let double = Double(bitPattern: intValue)
return (.double(double), remainder)

// uint 8, 16, 32, 64
Expand Down

0 comments on commit 3bb75f8

Please sign in to comment.