Skip to content

Commit

Permalink
4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Khokhlov committed Nov 20, 2017
1 parent c9300e1 commit 9f1cf99
Show file tree
Hide file tree
Showing 52 changed files with 4,082 additions and 11,049 deletions.
2 changes: 1 addition & 1 deletion ProtocolBuffers-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ProtocolBuffers-Swift"
s.version = "3.0.28"
s.version = "4.0.1"
s.summary = "Protocol Buffers for Swift"
s.homepage = "http://protobuf.io#swift"
s.license = "Apache 2.0"
Expand Down
10 changes: 4 additions & 6 deletions Source/AbstractMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public enum ProtocolBuffersError: Error {
public protocol ProtocolBuffersMessage:ProtocolBuffersMessageInit {
var unknownFields:UnknownFieldSet{get}
func serializedSize() -> Int32
func isInitialized() -> Bool
func isInitialized() throws
func writeTo(codedOutputStream:CodedOutputStream) throws
func writeTo(outputStream:OutputStream) throws
func data() throws -> Data
Expand All @@ -53,7 +53,7 @@ public protocol ProtocolBuffersMessage:ProtocolBuffersMessageInit {
public protocol ProtocolBuffersMessageBuilder {
var unknownFields:UnknownFieldSet{get set}
func clear() -> Self
func isInitialized()-> Bool
func isInitialized() throws
func build() throws -> AbstractProtocolBuffersMessage
func merge(unknownField:UnknownFieldSet) throws -> Self
func mergeFrom(codedInputStream:CodedInputStream) throws -> Self
Expand Down Expand Up @@ -90,8 +90,7 @@ open class AbstractProtocolBuffersMessage:Hashable, ProtocolBuffersMessage {
catch {}
return Data(bytes: stream.buffer.buffer, count: Int(ser_size))
}
open func isInitialized() -> Bool {
return false
open func isInitialized() throws {
}
open func serializedSize() -> Int32 {
return 0
Expand Down Expand Up @@ -173,8 +172,7 @@ open class AbstractProtocolBuffersMessageBuilder:ProtocolBuffersMessageBuilder {
return self
}

open func isInitialized() -> Bool {
return false
open func isInitialized() throws {
}
@discardableResult
open func mergeFrom(codedInputStream:CodedInputStream) throws -> Self {
Expand Down
52 changes: 16 additions & 36 deletions Source/ExtendableMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,28 @@ open class ExtendableMessage : GeneratedMessage
}
//

public func isInitialized(object:Any) -> Bool
public func isInitialized(object:Any) throws
{
switch object
{
case let array as Array<Any>:
for child in array
{
if (!isInitialized(object: child))
{
return false
}
for child in array {
try isInitialized(object: child)
}
case let array as Array<GeneratedMessage>:
for child in array
{
if (!isInitialized(object: child))
{
return false
}
for child in array {
try isInitialized(object: child)
}
case let message as GeneratedMessage:
return message.isInitialized()
try message.isInitialized()
default:
return true
return
}

return true
}

open func extensionsAreInitialized() -> Bool {
open func extensionsAreInitialized() throws {
let arr = Array(extensionMap.values)
return isInitialized(object:arr)
try isInitialized(object:arr)
}

internal func ensureExtensionIsRegistered(extensions:ConcreateExtensionField)
Expand Down Expand Up @@ -291,31 +281,21 @@ open class ExtendableMessageBuilder:GeneratedMessageBuilder
}


override open func checkInitialized() throws
{
override open func checkInitialized() throws {
let result = internalGetResult
if (!result.isInitialized())
{
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}
try result.isInitialized()
}

override open func checkInitializedParsed() throws
{
override open func checkInitializedParsed() throws {
let result = internalGetResult
if (!result.isInitialized())
{
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}
try result.isInitialized()
}

override open func isInitialized() -> Bool
{
return internalGetResult.isInitialized()
override open func isInitialized() throws {
try internalGetResult.isInitialized()
}
@discardableResult
override open func merge(unknownField: UnknownFieldSet) throws -> Self
{
override open func merge(unknownField: UnknownFieldSet) throws -> Self {
let result:GeneratedMessage = internalGetResult
result.unknownFields = try UnknownFieldSet.builderWithUnknownFields(copyFrom: result.unknownFields).merge(unknownFields: unknownField).build()
return self
Expand Down
23 changes: 7 additions & 16 deletions Source/GeneratedMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public protocol GeneratedMessageProtocol: ProtocolBuffersMessage {
subscript(key: String) -> Any? { get }
}


public protocol GeneratedEnum:RawRepresentable, CustomDebugStringConvertible, CustomStringConvertible, Hashable {
func toString() -> String
static func fromString(_ str:String) throws -> Self
Expand Down Expand Up @@ -90,28 +91,18 @@ open class GeneratedMessageBuilder:AbstractProtocolBuffersMessageBuilder
}

}
public func checkInitialized() throws
{
public func checkInitialized() throws {
let result = internalGetResult

guard result.isInitialized() else
{
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}
try result.isInitialized()
}

public func checkInitializedParsed() throws
{
public func checkInitializedParsed() throws {
let result = internalGetResult
guard result.isInitialized() else
{
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}
try result.isInitialized()
}

override open func isInitialized() -> Bool
{
return internalGetResult.isInitialized()
override open func isInitialized() throws {
try internalGetResult.isInitialized()
}
@discardableResult
override open func merge(unknownField: UnknownFieldSet) throws -> Self
Expand Down
10 changes: 3 additions & 7 deletions Source/Google.Protobuf.Any.proto.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Generated by the Protocol Buffers 3.4.0 compiler. DO NOT EDIT!
/// Generated by the Protocol Buffers 3.5.0 compiler. DO NOT EDIT!
/// Protobuf-swift version: 4.0.0
/// Source file "any.proto"
/// Syntax "Proto3"
Expand Down Expand Up @@ -91,8 +91,7 @@ public extension Google.Protobuf {
required public init() {
super.init()
}
override public func isInitialized() -> Bool {
return true
override public func isInitialized() throws {
}
override public func writeTo(codedOutputStream: CodedOutputStream) throws {
if hasTypeUrl {
Expand Down Expand Up @@ -139,10 +138,7 @@ public extension Google.Protobuf {
return try Google.Protobuf.`Any`.Builder().mergeFrom(other:prototype)
}
override public func encode() throws -> Dictionary<String,Any> {
guard isInitialized() else {
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}

try isInitialized()
var jsonMap:Dictionary<String,Any> = Dictionary<String,Any>()
if hasTypeUrl {
jsonMap["typeUrl"] = typeUrl
Expand Down
18 changes: 5 additions & 13 deletions Source/Google.Protobuf.Api.proto.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Generated by the Protocol Buffers 3.4.0 compiler. DO NOT EDIT!
/// Generated by the Protocol Buffers 3.5.0 compiler. DO NOT EDIT!
/// Protobuf-swift version: 4.0.0
/// Source file "api.proto"
/// Syntax "Proto3"
Expand Down Expand Up @@ -75,8 +75,7 @@ public extension Google.Protobuf {
required public init() {
super.init()
}
override public func isInitialized() -> Bool {
return true
override public func isInitialized() throws {
}
override public func writeTo(codedOutputStream: CodedOutputStream) throws {
if hasName {
Expand Down Expand Up @@ -143,10 +142,7 @@ public extension Google.Protobuf {
return try Google.Protobuf.Api.Builder().mergeFrom(other:prototype)
}
override public func encode() throws -> Dictionary<String,Any> {
guard isInitialized() else {
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}

try isInitialized()
var jsonMap:Dictionary<String,Any> = Dictionary<String,Any>()
if hasName {
jsonMap["name"] = name
Expand Down Expand Up @@ -599,8 +595,7 @@ public extension Google.Protobuf {
required public init() {
super.init()
}
override public func isInitialized() -> Bool {
return true
override public func isInitialized() throws {
}
override public func writeTo(codedOutputStream: CodedOutputStream) throws {
if hasName {
Expand Down Expand Up @@ -671,10 +666,7 @@ public extension Google.Protobuf {
return try Google.Protobuf.Method.Builder().mergeFrom(other:prototype)
}
override public func encode() throws -> Dictionary<String,Any> {
guard isInitialized() else {
throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message")
}

try isInitialized()
var jsonMap:Dictionary<String,Any> = Dictionary<String,Any>()
if hasName {
jsonMap["name"] = name
Expand Down
Loading

0 comments on commit 9f1cf99

Please sign in to comment.