Skip to content

Commit

Permalink
ProtoEnum/RawRepresentable/Codable synthesis patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Vaidyam committed Mar 8, 2018
1 parent e6d75dd commit 89cafd0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 0 additions & 1 deletion Hangouts/PBLiteDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public class PBLiteDecoder {
guard let outerValue = self.content[key.value()], !(outerValue is NSNull) else {
if "\(type)".starts(with: "Array<") {
return ([] as! T)
//print("\n\n", "GOT ARRAY FOR \(key) => \(type)", "\n\n")
}
let desc = "Expected type \(T.self) but container stored nil."
throw DecodingError.typeMismatch(T.self, DecodingError.Context(codingPath: self.codingPath, debugDescription: desc))
Expand Down
13 changes: 13 additions & 0 deletions Hangouts/ProtobufRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ public extension ProtoEnum {
}
}

// TODO: Unsure why, but in Swift 4.1+, RawRepresentable Codable synthesis yields CodingKeys?
// This should force-fix that just for ProtoEnum.
public extension ProtoEnum {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
self.init(try container.decode(Int.self))
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(self.rawValue)
}
}

//
// ProtoMessage
//
Expand Down
15 changes: 14 additions & 1 deletion Parrot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@
remoteGlobalIDString = 486DBB2F1F947FB900ECA84B;
remoteInfo = XPCTransport;
};
48C35B3A2051377A0056C3FB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 48834D8A1C1B3602009BC442 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 48D3CCE11DE94433003D6C02;
remoteInfo = Mocha;
};
48D3CCE71DE94433003D6C02 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 48834D8A1C1B3602009BC442 /* Project object */;
Expand Down Expand Up @@ -1304,6 +1311,7 @@
);
dependencies = (
48AFC0DD200B071A003E878D /* PBXTargetDependency */,
48C35B3B2051377A0056C3FB /* PBXTargetDependency */,
);
name = ParrotServiceExtension;
productName = ParrotServiceExtension;
Expand Down Expand Up @@ -1987,6 +1995,11 @@
target = 486DBB2F1F947FB900ECA84B /* XPCTransport */;
targetProxy = 48AFC0DC200B071A003E878D /* PBXContainerItemProxy */;
};
48C35B3B2051377A0056C3FB /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 48D3CCE11DE94433003D6C02 /* Mocha */;
targetProxy = 48C35B3A2051377A0056C3FB /* PBXContainerItemProxy */;
};
48D3CCE81DE94433003D6C02 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 48D3CCE11DE94433003D6C02 /* Mocha */;
Expand Down Expand Up @@ -2294,7 +2307,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
Expand Down

0 comments on commit 89cafd0

Please sign in to comment.