From f43317fdc8c537cb27c3662e7b9874e80d05a41b Mon Sep 17 00:00:00 2001 From: Alexey Khokhlov Date: Sat, 28 Oct 2017 17:55:18 +0300 Subject: [PATCH] 3.0.28 --- ProtocolBuffers.xcodeproj/project.pbxproj | 4 - .../xcschemes/ProtocolBuffers.xcscheme | 35 - ...oogle.Protobuf.Compiler.Plugin.proto.swift | 1876 ----------------- .../PBCompiler.xcodeproj/project.pbxproj | 56 +- plugin/Tests/PluginTest.swift | 42 +- plugin/compiler/google/protobuf/plugin.proto | 1 - 6 files changed, 29 insertions(+), 1985 deletions(-) delete mode 100644 Source/Google.Protobuf.Compiler.Plugin.proto.swift diff --git a/ProtocolBuffers.xcodeproj/project.pbxproj b/ProtocolBuffers.xcodeproj/project.pbxproj index f10e499..0a82800 100644 --- a/ProtocolBuffers.xcodeproj/project.pbxproj +++ b/ProtocolBuffers.xcodeproj/project.pbxproj @@ -72,7 +72,6 @@ OBJ_57 /* GeneratedMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* GeneratedMessage.swift */; }; OBJ_58 /* Google.Protobuf.Any.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_16 /* Google.Protobuf.Any.proto.swift */; }; OBJ_59 /* Google.Protobuf.Api.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_17 /* Google.Protobuf.Api.proto.swift */; }; - OBJ_60 /* Google.Protobuf.Compiler.Plugin.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_18 /* Google.Protobuf.Compiler.Plugin.proto.swift */; }; OBJ_61 /* Google.Protobuf.Descriptor.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_19 /* Google.Protobuf.Descriptor.proto.swift */; }; OBJ_62 /* Google.Protobuf.Duration.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_20 /* Google.Protobuf.Duration.proto.swift */; }; OBJ_63 /* Google.Protobuf.Empty.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_21 /* Google.Protobuf.Empty.proto.swift */; }; @@ -163,7 +162,6 @@ OBJ_15 /* GeneratedMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedMessage.swift; sourceTree = ""; }; OBJ_16 /* Google.Protobuf.Any.proto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Google.Protobuf.Any.proto.swift; sourceTree = ""; }; OBJ_17 /* Google.Protobuf.Api.proto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Google.Protobuf.Api.proto.swift; sourceTree = ""; }; - OBJ_18 /* Google.Protobuf.Compiler.Plugin.proto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Google.Protobuf.Compiler.Plugin.proto.swift; sourceTree = ""; }; OBJ_19 /* Google.Protobuf.Descriptor.proto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Google.Protobuf.Descriptor.proto.swift; sourceTree = ""; }; OBJ_20 /* Google.Protobuf.Duration.proto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Google.Protobuf.Duration.proto.swift; sourceTree = ""; }; OBJ_21 /* Google.Protobuf.Empty.proto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Google.Protobuf.Empty.proto.swift; sourceTree = ""; }; @@ -313,7 +311,6 @@ OBJ_15 /* GeneratedMessage.swift */, OBJ_16 /* Google.Protobuf.Any.proto.swift */, OBJ_17 /* Google.Protobuf.Api.proto.swift */, - OBJ_18 /* Google.Protobuf.Compiler.Plugin.proto.swift */, OBJ_19 /* Google.Protobuf.Descriptor.proto.swift */, OBJ_20 /* Google.Protobuf.Duration.proto.swift */, OBJ_21 /* Google.Protobuf.Empty.proto.swift */, @@ -511,7 +508,6 @@ OBJ_57 /* GeneratedMessage.swift in Sources */, OBJ_58 /* Google.Protobuf.Any.proto.swift in Sources */, OBJ_59 /* Google.Protobuf.Api.proto.swift in Sources */, - OBJ_60 /* Google.Protobuf.Compiler.Plugin.proto.swift in Sources */, OBJ_61 /* Google.Protobuf.Descriptor.proto.swift in Sources */, OBJ_62 /* Google.Protobuf.Duration.proto.swift in Sources */, OBJ_63 /* Google.Protobuf.Empty.proto.swift in Sources */, diff --git a/ProtocolBuffers.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/ProtocolBuffers.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme index 00664f6..d4517e5 100644 --- a/ProtocolBuffers.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme +++ b/ProtocolBuffers.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme @@ -38,41 +38,6 @@ BlueprintName = "Tests" ReferencedContainer = "container:ProtocolBuffers.xcodeproj"> - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Source/Google.Protobuf.Compiler.Plugin.proto.swift b/Source/Google.Protobuf.Compiler.Plugin.proto.swift deleted file mode 100644 index 586353b..0000000 --- a/Source/Google.Protobuf.Compiler.Plugin.proto.swift +++ /dev/null @@ -1,1876 +0,0 @@ -/// Generated by the Protocol Buffers 3.4.0 compiler. DO NOT EDIT! -/// Protobuf-swift version: 3.0.24 -/// Source file "plugin.proto" -/// Syntax "Proto2" - -import Foundation - -public extension Google.Protobuf{ public struct Compiler { }} - -public extension Google.Protobuf.Compiler { - public struct PluginRoot { - public static let `default` = PluginRoot() - public var extensionRegistry:ExtensionRegistry - - init() { - extensionRegistry = ExtensionRegistry() - registerAllExtensions(registry: extensionRegistry) - Google.Protobuf.DescriptorRoot.default.registerAllExtensions(registry: extensionRegistry) - Google.Protobuf.SwiftDescriptorRoot.default.registerAllExtensions(registry: extensionRegistry) - } - public func registerAllExtensions(registry: ExtensionRegistry) { - } - } - - /// The version number of protocol compiler. - final public class Version : GeneratedMessage { - public typealias BuilderType = Google.Protobuf.Compiler.Version.Builder - - public static func == (lhs: Google.Protobuf.Compiler.Version, rhs: Google.Protobuf.Compiler.Version) -> Bool { - if lhs === rhs { - return true - } - var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) - fieldCheck = fieldCheck && (lhs.hasMajor == rhs.hasMajor) && (!lhs.hasMajor || lhs.major == rhs.major) - fieldCheck = fieldCheck && (lhs.hasMinor == rhs.hasMinor) && (!lhs.hasMinor || lhs.minor == rhs.minor) - fieldCheck = fieldCheck && (lhs.hasPatch == rhs.hasPatch) && (!lhs.hasPatch || lhs.patch == rhs.patch) - fieldCheck = fieldCheck && (lhs.hasSuffix == rhs.hasSuffix) && (!lhs.hasSuffix || lhs.suffix == rhs.suffix) - fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) - return fieldCheck - } - - public fileprivate(set) var major:Int32! = nil - public fileprivate(set) var hasMajor:Bool = false - - public fileprivate(set) var minor:Int32! = nil - public fileprivate(set) var hasMinor:Bool = false - - public fileprivate(set) var patch:Int32! = nil - public fileprivate(set) var hasPatch:Bool = false - - /// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - /// be empty for mainline stable releases. - public fileprivate(set) var suffix:String! = nil - public fileprivate(set) var hasSuffix:Bool = false - - required public init() { - super.init() - } - override public func isInitialized() -> Bool { - return true - } - override public func writeTo(codedOutputStream: CodedOutputStream) throws { - if hasMajor { - try codedOutputStream.writeInt32(fieldNumber: 1, value:major) - } - if hasMinor { - try codedOutputStream.writeInt32(fieldNumber: 2, value:minor) - } - if hasPatch { - try codedOutputStream.writeInt32(fieldNumber: 3, value:patch) - } - if hasSuffix { - try codedOutputStream.writeString(fieldNumber: 4, value:suffix) - } - try unknownFields.writeTo(codedOutputStream: codedOutputStream) - } - override public func serializedSize() -> Int32 { - var serialize_size:Int32 = memoizedSerializedSize - if serialize_size != -1 { - return serialize_size - } - - serialize_size = 0 - if hasMajor { - serialize_size += major.computeInt32Size(fieldNumber: 1) - } - if hasMinor { - serialize_size += minor.computeInt32Size(fieldNumber: 2) - } - if hasPatch { - serialize_size += patch.computeInt32Size(fieldNumber: 3) - } - if hasSuffix { - serialize_size += suffix.computeStringSize(fieldNumber: 4) - } - serialize_size += unknownFields.serializedSize() - memoizedSerializedSize = serialize_size - return serialize_size - } - public class func getBuilder() -> Google.Protobuf.Compiler.Version.Builder { - return Google.Protobuf.Compiler.Version.classBuilder() as! Google.Protobuf.Compiler.Version.Builder - } - public func getBuilder() -> Google.Protobuf.Compiler.Version.Builder { - return classBuilder() as! Google.Protobuf.Compiler.Version.Builder - } - override public class func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.Version.Builder() - } - override public func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.Version.Builder() - } - public func toBuilder() throws -> Google.Protobuf.Compiler.Version.Builder { - return try Google.Protobuf.Compiler.Version.builderWithPrototype(prototype:self) - } - public class func builderWithPrototype(prototype:Google.Protobuf.Compiler.Version) throws -> Google.Protobuf.Compiler.Version.Builder { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(other:prototype) - } - override public func encode() throws -> Dictionary { - guard isInitialized() else { - throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") - } - - var jsonMap:Dictionary = Dictionary() - if hasMajor { - jsonMap["major"] = Int(major) - } - if hasMinor { - jsonMap["minor"] = Int(minor) - } - if hasPatch { - jsonMap["patch"] = Int(patch) - } - if hasSuffix { - jsonMap["suffix"] = suffix - } - return jsonMap - } - override class public func decode(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder.decodeToBuilder(jsonMap:jsonMap).build() - } - override class public func fromJSON(data:Data) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder.fromJSONToBuilder(data:data).build() - } - override public func getDescription(indent:String) throws -> String { - var output = "" - if hasMajor { - output += "\(indent) major: \(major) \n" - } - if hasMinor { - output += "\(indent) minor: \(minor) \n" - } - if hasPatch { - output += "\(indent) patch: \(patch) \n" - } - if hasSuffix { - output += "\(indent) suffix: \(suffix) \n" - } - output += unknownFields.getDescription(indent: indent) - return output - } - override public var hashValue:Int { - get { - var hashCode:Int = 7 - if hasMajor { - hashCode = (hashCode &* 31) &+ major.hashValue - } - if hasMinor { - hashCode = (hashCode &* 31) &+ minor.hashValue - } - if hasPatch { - hashCode = (hashCode &* 31) &+ patch.hashValue - } - if hasSuffix { - hashCode = (hashCode &* 31) &+ suffix.hashValue - } - hashCode = (hashCode &* 31) &+ unknownFields.hashValue - return hashCode - } - } - - - //Meta information declaration start - - override public class func className() -> String { - return "Google.Protobuf.Compiler.Version" - } - override public func className() -> String { - return "Google.Protobuf.Compiler.Version" - } - //Meta information declaration end - - final public class Builder : GeneratedMessageBuilder { - fileprivate var builderResult:Google.Protobuf.Compiler.Version = Google.Protobuf.Compiler.Version() - public func getMessage() -> Google.Protobuf.Compiler.Version { - return builderResult - } - - required override public init () { - super.init() - } - public var major:Int32 { - get { - return builderResult.major - } - set (value) { - builderResult.hasMajor = true - builderResult.major = value - } - } - public var hasMajor:Bool { - get { - return builderResult.hasMajor - } - } - @discardableResult - public func setMajor(_ value:Int32) -> Google.Protobuf.Compiler.Version.Builder { - self.major = value - return self - } - @discardableResult - public func clearMajor() -> Google.Protobuf.Compiler.Version.Builder{ - builderResult.hasMajor = false - builderResult.major = nil - return self - } - public var minor:Int32 { - get { - return builderResult.minor - } - set (value) { - builderResult.hasMinor = true - builderResult.minor = value - } - } - public var hasMinor:Bool { - get { - return builderResult.hasMinor - } - } - @discardableResult - public func setMinor(_ value:Int32) -> Google.Protobuf.Compiler.Version.Builder { - self.minor = value - return self - } - @discardableResult - public func clearMinor() -> Google.Protobuf.Compiler.Version.Builder{ - builderResult.hasMinor = false - builderResult.minor = nil - return self - } - public var patch:Int32 { - get { - return builderResult.patch - } - set (value) { - builderResult.hasPatch = true - builderResult.patch = value - } - } - public var hasPatch:Bool { - get { - return builderResult.hasPatch - } - } - @discardableResult - public func setPatch(_ value:Int32) -> Google.Protobuf.Compiler.Version.Builder { - self.patch = value - return self - } - @discardableResult - public func clearPatch() -> Google.Protobuf.Compiler.Version.Builder{ - builderResult.hasPatch = false - builderResult.patch = nil - return self - } - /// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - /// be empty for mainline stable releases. - public var suffix:String { - get { - return builderResult.suffix - } - set (value) { - builderResult.hasSuffix = true - builderResult.suffix = value - } - } - public var hasSuffix:Bool { - get { - return builderResult.hasSuffix - } - } - @discardableResult - public func setSuffix(_ value:String) -> Google.Protobuf.Compiler.Version.Builder { - self.suffix = value - return self - } - @discardableResult - public func clearSuffix() -> Google.Protobuf.Compiler.Version.Builder{ - builderResult.hasSuffix = false - builderResult.suffix = nil - return self - } - override public var internalGetResult:GeneratedMessage { - get { - return builderResult - } - } - @discardableResult - override public func clear() -> Google.Protobuf.Compiler.Version.Builder { - builderResult = Google.Protobuf.Compiler.Version() - return self - } - override public func clone() throws -> Google.Protobuf.Compiler.Version.Builder { - return try Google.Protobuf.Compiler.Version.builderWithPrototype(prototype:builderResult) - } - override public func build() throws -> Google.Protobuf.Compiler.Version { - try checkInitialized() - return buildPartial() - } - public func buildPartial() -> Google.Protobuf.Compiler.Version { - let returnMe:Google.Protobuf.Compiler.Version = builderResult - return returnMe - } - @discardableResult - public func mergeFrom(other:Google.Protobuf.Compiler.Version) throws -> Google.Protobuf.Compiler.Version.Builder { - if other == Google.Protobuf.Compiler.Version() { - return self - } - if other.hasMajor { - major = other.major - } - if other.hasMinor { - minor = other.minor - } - if other.hasPatch { - patch = other.patch - } - if other.hasSuffix { - suffix = other.suffix - } - try merge(unknownField: other.unknownFields) - return self - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.Version.Builder { - return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.Version.Builder { - let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) - while (true) { - let protobufTag = try codedInputStream.readTag() - switch protobufTag { - case 0: - self.unknownFields = try unknownFieldsBuilder.build() - return self - - case 8: - major = try codedInputStream.readInt32() - - case 16: - minor = try codedInputStream.readInt32() - - case 24: - patch = try codedInputStream.readInt32() - - case 34: - suffix = try codedInputStream.readString() - - default: - if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { - unknownFields = try unknownFieldsBuilder.build() - return self - } - } - } - } - class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.Version.Builder { - let resultDecodedBuilder = Google.Protobuf.Compiler.Version.Builder() - if let jsonValueMajor = jsonMap["major"] as? Int { - resultDecodedBuilder.major = Int32(jsonValueMajor) - } else if let jsonValueMajor = jsonMap["major"] as? String { - resultDecodedBuilder.major = Int32(jsonValueMajor)! - } - if let jsonValueMinor = jsonMap["minor"] as? Int { - resultDecodedBuilder.minor = Int32(jsonValueMinor) - } else if let jsonValueMinor = jsonMap["minor"] as? String { - resultDecodedBuilder.minor = Int32(jsonValueMinor)! - } - if let jsonValuePatch = jsonMap["patch"] as? Int { - resultDecodedBuilder.patch = Int32(jsonValuePatch) - } else if let jsonValuePatch = jsonMap["patch"] as? String { - resultDecodedBuilder.patch = Int32(jsonValuePatch)! - } - if let jsonValueSuffix = jsonMap["suffix"] as? String { - resultDecodedBuilder.suffix = jsonValueSuffix - } - return resultDecodedBuilder - } - override class public func fromJSONToBuilder(data:Data) throws -> Google.Protobuf.Compiler.Version.Builder { - let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) - guard let jsDataCast = jsonData as? Dictionary else { - throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") - } - return try Google.Protobuf.Compiler.Version.Builder.decodeToBuilder(jsonMap:jsDataCast) - } - } - - } - - /// An encoded CodeGeneratorRequest is written to the plugin's stdin. - final public class CodeGeneratorRequest : GeneratedMessage { - public typealias BuilderType = Google.Protobuf.Compiler.CodeGeneratorRequest.Builder - - public static func == (lhs: Google.Protobuf.Compiler.CodeGeneratorRequest, rhs: Google.Protobuf.Compiler.CodeGeneratorRequest) -> Bool { - if lhs === rhs { - return true - } - var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) - fieldCheck = fieldCheck && (lhs.fileToGenerate == rhs.fileToGenerate) - fieldCheck = fieldCheck && (lhs.hasParameter == rhs.hasParameter) && (!lhs.hasParameter || lhs.parameter == rhs.parameter) - fieldCheck = fieldCheck && (lhs.hasCompilerVersion == rhs.hasCompilerVersion) && (!lhs.hasCompilerVersion || lhs.compilerVersion == rhs.compilerVersion) - fieldCheck = fieldCheck && (lhs.protoFile == rhs.protoFile) - fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) - return fieldCheck - } - - /// The .proto files that were explicitly listed on the command-line. The - /// code generator should generate code only for these files. Each file's - /// descriptor will be included in proto_file, below. - public fileprivate(set) var fileToGenerate:Array = Array() - /// The generator parameter passed on the command-line. - public fileprivate(set) var parameter:String! = nil - public fileprivate(set) var hasParameter:Bool = false - - public fileprivate(set) var protoFile:Array = Array() - public fileprivate(set) var compilerVersion:Google.Protobuf.Compiler.Version! - public fileprivate(set) var hasCompilerVersion:Bool = false - required public init() { - super.init() - } - override public func isInitialized() -> Bool { - var isInitProtoFile:Bool = true - for oneElementProtoFile in protoFile { - if !oneElementProtoFile.isInitialized() { - isInitProtoFile = false - break - } - } - if !isInitProtoFile { - return isInitProtoFile - } - return true - } - override public func writeTo(codedOutputStream: CodedOutputStream) throws { - if !fileToGenerate.isEmpty { - for oneValuefileToGenerate in fileToGenerate { - try codedOutputStream.writeString(fieldNumber: 1, value:oneValuefileToGenerate) - } - } - if hasParameter { - try codedOutputStream.writeString(fieldNumber: 2, value:parameter) - } - if hasCompilerVersion { - try codedOutputStream.writeMessage(fieldNumber: 3, value:compilerVersion) - } - for oneElementProtoFile in protoFile { - try codedOutputStream.writeMessage(fieldNumber: 15, value:oneElementProtoFile) - } - try unknownFields.writeTo(codedOutputStream: codedOutputStream) - } - override public func serializedSize() -> Int32 { - var serialize_size:Int32 = memoizedSerializedSize - if serialize_size != -1 { - return serialize_size - } - - serialize_size = 0 - var dataSizeFileToGenerate:Int32 = 0 - for oneValuefileToGenerate in fileToGenerate { - dataSizeFileToGenerate += oneValuefileToGenerate.computeStringSizeNoTag() - } - serialize_size += dataSizeFileToGenerate - serialize_size += 1 * Int32(fileToGenerate.count) - if hasParameter { - serialize_size += parameter.computeStringSize(fieldNumber: 2) - } - if hasCompilerVersion { - if let varSizecompilerVersion = compilerVersion?.computeMessageSize(fieldNumber: 3) { - serialize_size += varSizecompilerVersion - } - } - for oneElementProtoFile in protoFile { - serialize_size += oneElementProtoFile.computeMessageSize(fieldNumber: 15) - } - serialize_size += unknownFields.serializedSize() - memoizedSerializedSize = serialize_size - return serialize_size - } - public class func getBuilder() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - return Google.Protobuf.Compiler.CodeGeneratorRequest.classBuilder() as! Google.Protobuf.Compiler.CodeGeneratorRequest.Builder - } - public func getBuilder() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - return classBuilder() as! Google.Protobuf.Compiler.CodeGeneratorRequest.Builder - } - override public class func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.CodeGeneratorRequest.Builder() - } - override public func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.CodeGeneratorRequest.Builder() - } - public func toBuilder() throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.builderWithPrototype(prototype:self) - } - public class func builderWithPrototype(prototype:Google.Protobuf.Compiler.CodeGeneratorRequest) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(other:prototype) - } - override public func encode() throws -> Dictionary { - guard isInitialized() else { - throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") - } - - var jsonMap:Dictionary = Dictionary() - if !fileToGenerate.isEmpty { - var jsonArrayFileToGenerate:Array = [] - for oneValueFileToGenerate in fileToGenerate { - jsonArrayFileToGenerate.append(oneValueFileToGenerate) - } - jsonMap["fileToGenerate"] = jsonArrayFileToGenerate - } - if hasParameter { - jsonMap["parameter"] = parameter - } - if !protoFile.isEmpty { - var jsonArrayProtoFile:Array> = [] - for oneValueProtoFile in protoFile { - let ecodedMessageProtoFile = try oneValueProtoFile.encode() - jsonArrayProtoFile.append(ecodedMessageProtoFile) - } - jsonMap["protoFile"] = jsonArrayProtoFile - } - if hasCompilerVersion { - jsonMap["compilerVersion"] = try compilerVersion.encode() - } - return jsonMap - } - override class public func decode(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder.decodeToBuilder(jsonMap:jsonMap).build() - } - override class public func fromJSON(data:Data) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder.fromJSONToBuilder(data:data).build() - } - override public func getDescription(indent:String) throws -> String { - var output = "" - var fileToGenerateElementIndex:Int = 0 - for oneValueFileToGenerate in fileToGenerate { - output += "\(indent) fileToGenerate[\(fileToGenerateElementIndex)]: \(oneValueFileToGenerate)\n" - fileToGenerateElementIndex += 1 - } - if hasParameter { - output += "\(indent) parameter: \(parameter) \n" - } - if hasCompilerVersion { - output += "\(indent) compilerVersion {\n" - if let outDescCompilerVersion = compilerVersion { - output += try outDescCompilerVersion.getDescription(indent: "\(indent) ") - } - output += "\(indent) }\n" - } - var protoFileElementIndex:Int = 0 - for oneElementProtoFile in protoFile { - output += "\(indent) protoFile[\(protoFileElementIndex)] {\n" - output += try oneElementProtoFile.getDescription(indent: "\(indent) ") - output += "\(indent)}\n" - protoFileElementIndex += 1 - } - output += unknownFields.getDescription(indent: indent) - return output - } - override public var hashValue:Int { - get { - var hashCode:Int = 7 - for oneValueFileToGenerate in fileToGenerate { - hashCode = (hashCode &* 31) &+ oneValueFileToGenerate.hashValue - } - if hasParameter { - hashCode = (hashCode &* 31) &+ parameter.hashValue - } - if hasCompilerVersion { - if let hashValuecompilerVersion = compilerVersion?.hashValue { - hashCode = (hashCode &* 31) &+ hashValuecompilerVersion - } - } - for oneElementProtoFile in protoFile { - hashCode = (hashCode &* 31) &+ oneElementProtoFile.hashValue - } - hashCode = (hashCode &* 31) &+ unknownFields.hashValue - return hashCode - } - } - - - //Meta information declaration start - - override public class func className() -> String { - return "Google.Protobuf.Compiler.CodeGeneratorRequest" - } - override public func className() -> String { - return "Google.Protobuf.Compiler.CodeGeneratorRequest" - } - //Meta information declaration end - - final public class Builder : GeneratedMessageBuilder { - fileprivate var builderResult:Google.Protobuf.Compiler.CodeGeneratorRequest = Google.Protobuf.Compiler.CodeGeneratorRequest() - public func getMessage() -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return builderResult - } - - required override public init () { - super.init() - } - /// The .proto files that were explicitly listed on the command-line. The - /// code generator should generate code only for these files. Each file's - /// descriptor will be included in proto_file, below. - public var fileToGenerate:Array { - get { - return builderResult.fileToGenerate - } - set (array) { - builderResult.fileToGenerate = array - } - } - @discardableResult - public func setFileToGenerate(_ value:Array) -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - self.fileToGenerate = value - return self - } - @discardableResult - public func clearFileToGenerate() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - builderResult.fileToGenerate.removeAll(keepingCapacity: false) - return self - } - /// The generator parameter passed on the command-line. - public var parameter:String { - get { - return builderResult.parameter - } - set (value) { - builderResult.hasParameter = true - builderResult.parameter = value - } - } - public var hasParameter:Bool { - get { - return builderResult.hasParameter - } - } - @discardableResult - public func setParameter(_ value:String) -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - self.parameter = value - return self - } - @discardableResult - public func clearParameter() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder{ - builderResult.hasParameter = false - builderResult.parameter = nil - return self - } - /// FileDescriptorProtos for all files in files_to_generate and everything - /// they import. The files will appear in topological order, so each file - /// appears before any file that imports it. - /// protoc guarantees that all proto_files will be written after - /// the fields above, even though this is not technically guaranteed by the - /// protobuf wire format. This theoretically could allow a plugin to stream - /// in the FileDescriptorProtos and handle them one by one rather than read - /// the entire set into memory at once. However, as of this writing, this - /// is not similarly optimized on protoc's end -- it will store all fields in - /// memory at once before sending them to the plugin. - /// Type names of fields and extensions in the FileDescriptorProto are always - /// fully qualified. - public var protoFile:Array { - get { - return builderResult.protoFile - } - set (value) { - builderResult.protoFile = value - } - } - @discardableResult - public func setProtoFile(_ value:Array) -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - self.protoFile = value - return self - } - @discardableResult - public func clearProtoFile() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - builderResult.protoFile.removeAll(keepingCapacity: false) - return self - } - /// The version number of protocol compiler. - public var compilerVersion:Google.Protobuf.Compiler.Version! { - get { - if compilerVersionBuilder_ != nil { - builderResult.compilerVersion = compilerVersionBuilder_.getMessage() - } - return builderResult.compilerVersion - } - set (value) { - builderResult.hasCompilerVersion = value != nil - builderResult.compilerVersion = value - } - } - public var hasCompilerVersion:Bool { - get { - return builderResult.hasCompilerVersion - } - } - fileprivate var compilerVersionBuilder_:Google.Protobuf.Compiler.Version.Builder! { - didSet { - builderResult.hasCompilerVersion = true - } - } - public func getCompilerVersionBuilder() -> Google.Protobuf.Compiler.Version.Builder { - if compilerVersionBuilder_ == nil { - compilerVersionBuilder_ = Google.Protobuf.Compiler.Version.Builder() - builderResult.compilerVersion = compilerVersionBuilder_.getMessage() - if compilerVersion != nil { - try! compilerVersionBuilder_.mergeFrom(other: compilerVersion) - } - } - return compilerVersionBuilder_ - } - @discardableResult - public func setCompilerVersion(_ value:Google.Protobuf.Compiler.Version!) -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - self.compilerVersion = value - return self - } - @discardableResult - public func mergeCompilerVersion(value:Google.Protobuf.Compiler.Version) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - if builderResult.hasCompilerVersion { - builderResult.compilerVersion = try Google.Protobuf.Compiler.Version.builderWithPrototype(prototype:builderResult.compilerVersion).mergeFrom(other: value).buildPartial() - } else { - builderResult.compilerVersion = value - } - builderResult.hasCompilerVersion = true - return self - } - @discardableResult - public func clearCompilerVersion() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - compilerVersionBuilder_ = nil - builderResult.hasCompilerVersion = false - builderResult.compilerVersion = nil - return self - } - override public var internalGetResult:GeneratedMessage { - get { - return builderResult - } - } - @discardableResult - override public func clear() -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - builderResult = Google.Protobuf.Compiler.CodeGeneratorRequest() - return self - } - override public func clone() throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.builderWithPrototype(prototype:builderResult) - } - override public func build() throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - try checkInitialized() - return buildPartial() - } - public func buildPartial() -> Google.Protobuf.Compiler.CodeGeneratorRequest { - let returnMe:Google.Protobuf.Compiler.CodeGeneratorRequest = builderResult - return returnMe - } - @discardableResult - public func mergeFrom(other:Google.Protobuf.Compiler.CodeGeneratorRequest) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - if other == Google.Protobuf.Compiler.CodeGeneratorRequest() { - return self - } - if !other.fileToGenerate.isEmpty { - builderResult.fileToGenerate += other.fileToGenerate - } - if other.hasParameter { - parameter = other.parameter - } - if !other.protoFile.isEmpty { - builderResult.protoFile += other.protoFile - } - if (other.hasCompilerVersion) { - try mergeCompilerVersion(value: other.compilerVersion) - } - try merge(unknownField: other.unknownFields) - return self - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) - while (true) { - let protobufTag = try codedInputStream.readTag() - switch protobufTag { - case 0: - self.unknownFields = try unknownFieldsBuilder.build() - return self - - case 10: - fileToGenerate += [try codedInputStream.readString()] - - case 18: - parameter = try codedInputStream.readString() - - case 26: - let subBuilder:Google.Protobuf.Compiler.Version.Builder = Google.Protobuf.Compiler.Version.Builder() - if hasCompilerVersion { - try subBuilder.mergeFrom(other: compilerVersion) - } - try codedInputStream.readMessage(builder: subBuilder, extensionRegistry:extensionRegistry) - compilerVersion = subBuilder.buildPartial() - - case 122: - let subBuilder = Google.Protobuf.FileDescriptorProto.Builder() - try codedInputStream.readMessage(builder: subBuilder,extensionRegistry:extensionRegistry) - protoFile.append(subBuilder.buildPartial()) - - default: - if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { - unknownFields = try unknownFieldsBuilder.build() - return self - } - } - } - } - class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - let resultDecodedBuilder = Google.Protobuf.Compiler.CodeGeneratorRequest.Builder() - if let jsonValueFileToGenerate = jsonMap["fileToGenerate"] as? Array { - var jsonArrayFileToGenerate:Array = [] - for oneValueFileToGenerate in jsonValueFileToGenerate { - jsonArrayFileToGenerate.append(oneValueFileToGenerate) - } - resultDecodedBuilder.fileToGenerate = jsonArrayFileToGenerate - } - if let jsonValueParameter = jsonMap["parameter"] as? String { - resultDecodedBuilder.parameter = jsonValueParameter - } - if let jsonValueProtoFile = jsonMap["protoFile"] as? Array> { - var jsonArrayProtoFile:Array = [] - for oneValueProtoFile in jsonValueProtoFile { - let messageFromStringProtoFile = try Google.Protobuf.FileDescriptorProto.Builder.decodeToBuilder(jsonMap:oneValueProtoFile).build() - - jsonArrayProtoFile.append(messageFromStringProtoFile) - } - resultDecodedBuilder.protoFile = jsonArrayProtoFile - } - if let jsonValueCompilerVersion = jsonMap["compilerVersion"] as? Dictionary { - resultDecodedBuilder.compilerVersion = try Google.Protobuf.Compiler.Version.Builder.decodeToBuilder(jsonMap:jsonValueCompilerVersion).build() - - } - return resultDecodedBuilder - } - override class public func fromJSONToBuilder(data:Data) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest.Builder { - let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) - guard let jsDataCast = jsonData as? Dictionary else { - throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") - } - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder.decodeToBuilder(jsonMap:jsDataCast) - } - } - - } - - /// The plugin writes an encoded CodeGeneratorResponse to stdout. - final public class CodeGeneratorResponse : GeneratedMessage { - public typealias BuilderType = Google.Protobuf.Compiler.CodeGeneratorResponse.Builder - - public static func == (lhs: Google.Protobuf.Compiler.CodeGeneratorResponse, rhs: Google.Protobuf.Compiler.CodeGeneratorResponse) -> Bool { - if lhs === rhs { - return true - } - var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) - fieldCheck = fieldCheck && (lhs.hasError == rhs.hasError) && (!lhs.hasError || lhs.error == rhs.error) - fieldCheck = fieldCheck && (lhs.file == rhs.file) - fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) - return fieldCheck - } - - - - //Nested type declaration start - - /// Represents a single generated file. - final public class File : GeneratedMessage { - public typealias BuilderType = Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder - - public static func == (lhs: Google.Protobuf.Compiler.CodeGeneratorResponse.File, rhs: Google.Protobuf.Compiler.CodeGeneratorResponse.File) -> Bool { - if lhs === rhs { - return true - } - var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) - fieldCheck = fieldCheck && (lhs.hasName == rhs.hasName) && (!lhs.hasName || lhs.name == rhs.name) - fieldCheck = fieldCheck && (lhs.hasInsertionPoint == rhs.hasInsertionPoint) && (!lhs.hasInsertionPoint || lhs.insertionPoint == rhs.insertionPoint) - fieldCheck = fieldCheck && (lhs.hasContent == rhs.hasContent) && (!lhs.hasContent || lhs.content == rhs.content) - fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) - return fieldCheck - } - - /// The file name, relative to the output directory. The name must not - /// contain "." or ".." components and must be relative, not be absolute (so, - /// the file cannot lie outside the output directory). "/" must be used as - /// the path separator, not "\". - /// If the name is omitted, the content will be appended to the previous - /// file. This allows the generator to break large files into small chunks, - /// and allows the generated text to be streamed back to protoc so that large - /// files need not reside completely in memory at one time. Note that as of - /// this writing protoc does not optimize for this -- it will read the entire - /// CodeGeneratorResponse before writing files to disk. - public fileprivate(set) var name:String! = nil - public fileprivate(set) var hasName:Bool = false - - /// If non-empty, indicates that the named file should already exist, and the - /// content here is to be inserted into that file at a defined insertion - /// point. This feature allows a code generator to extend the output - /// produced by another code generator. The original generator may provide - /// insertion points by placing special annotations in the file that look - /// like: - /// @@protoc_insertion_point(NAME) - /// The annotation can have arbitrary text before and after it on the line, - /// which allows it to be placed in a comment. NAME should be replaced with - /// an identifier naming the point -- this is what other generators will use - /// as the insertion_point. Code inserted at this point will be placed - /// immediately above the line containing the insertion point (thus multiple - /// insertions to the same point will come out in the order they were added). - /// The double-@ is intended to make it unlikely that the generated code - /// could contain things that look like insertion points by accident. - /// For example, the C++ code generator places the following line in the - /// .pb.h files that it generates: - /// // @@protoc_insertion_point(namespace_scope) - /// This line appears within the scope of the file's package namespace, but - /// outside of any particular class. Another plugin can then specify the - /// insertion_point "namespace_scope" to generate additional classes or - /// other declarations that should be placed in this scope. - /// Note that if the line containing the insertion point begins with - /// whitespace, the same whitespace will be added to every line of the - /// inserted text. This is useful for languages like Python, where - /// indentation matters. In these languages, the insertion point comment - /// should be indented the same amount as any inserted code will need to be - /// in order to work correctly in that context. - /// The code generator that generates the initial file and the one which - /// inserts into it must both run as part of a single invocation of protoc. - /// Code generators are executed in the order in which they appear on the - /// command line. - /// If |insertion_point| is present, |name| must also be present. - public fileprivate(set) var insertionPoint:String! = nil - public fileprivate(set) var hasInsertionPoint:Bool = false - - /// The file contents. - public fileprivate(set) var content:String! = nil - public fileprivate(set) var hasContent:Bool = false - - required public init() { - super.init() - } - override public func isInitialized() -> Bool { - return true - } - override public func writeTo(codedOutputStream: CodedOutputStream) throws { - if hasName { - try codedOutputStream.writeString(fieldNumber: 1, value:name) - } - if hasInsertionPoint { - try codedOutputStream.writeString(fieldNumber: 2, value:insertionPoint) - } - if hasContent { - try codedOutputStream.writeString(fieldNumber: 15, value:content) - } - try unknownFields.writeTo(codedOutputStream: codedOutputStream) - } - override public func serializedSize() -> Int32 { - var serialize_size:Int32 = memoizedSerializedSize - if serialize_size != -1 { - return serialize_size - } - - serialize_size = 0 - if hasName { - serialize_size += name.computeStringSize(fieldNumber: 1) - } - if hasInsertionPoint { - serialize_size += insertionPoint.computeStringSize(fieldNumber: 2) - } - if hasContent { - serialize_size += content.computeStringSize(fieldNumber: 15) - } - serialize_size += unknownFields.serializedSize() - memoizedSerializedSize = serialize_size - return serialize_size - } - public class func getBuilder() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - return Google.Protobuf.Compiler.CodeGeneratorResponse.File.classBuilder() as! Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder - } - public func getBuilder() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - return classBuilder() as! Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder - } - override public class func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder() - } - override public func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder() - } - public func toBuilder() throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.builderWithPrototype(prototype:self) - } - public class func builderWithPrototype(prototype:Google.Protobuf.Compiler.CodeGeneratorResponse.File) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(other:prototype) - } - override public func encode() throws -> Dictionary { - guard isInitialized() else { - throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") - } - - var jsonMap:Dictionary = Dictionary() - if hasName { - jsonMap["name"] = name - } - if hasInsertionPoint { - jsonMap["insertionPoint"] = insertionPoint - } - if hasContent { - jsonMap["content"] = content - } - return jsonMap - } - override class public func decode(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder.decodeToBuilder(jsonMap:jsonMap).build() - } - override class public func fromJSON(data:Data) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder.fromJSONToBuilder(data:data).build() - } - override public func getDescription(indent:String) throws -> String { - var output = "" - if hasName { - output += "\(indent) name: \(name) \n" - } - if hasInsertionPoint { - output += "\(indent) insertionPoint: \(insertionPoint) \n" - } - if hasContent { - output += "\(indent) content: \(content) \n" - } - output += unknownFields.getDescription(indent: indent) - return output - } - override public var hashValue:Int { - get { - var hashCode:Int = 7 - if hasName { - hashCode = (hashCode &* 31) &+ name.hashValue - } - if hasInsertionPoint { - hashCode = (hashCode &* 31) &+ insertionPoint.hashValue - } - if hasContent { - hashCode = (hashCode &* 31) &+ content.hashValue - } - hashCode = (hashCode &* 31) &+ unknownFields.hashValue - return hashCode - } - } - - - //Meta information declaration start - - override public class func className() -> String { - return "Google.Protobuf.Compiler.CodeGeneratorResponse.File" - } - override public func className() -> String { - return "Google.Protobuf.Compiler.CodeGeneratorResponse.File" - } - //Meta information declaration end - - final public class Builder : GeneratedMessageBuilder { - fileprivate var builderResult:Google.Protobuf.Compiler.CodeGeneratorResponse.File = Google.Protobuf.Compiler.CodeGeneratorResponse.File() - public func getMessage() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return builderResult - } - - required override public init () { - super.init() - } - /// The file name, relative to the output directory. The name must not - /// contain "." or ".." components and must be relative, not be absolute (so, - /// the file cannot lie outside the output directory). "/" must be used as - /// the path separator, not "\". - /// If the name is omitted, the content will be appended to the previous - /// file. This allows the generator to break large files into small chunks, - /// and allows the generated text to be streamed back to protoc so that large - /// files need not reside completely in memory at one time. Note that as of - /// this writing protoc does not optimize for this -- it will read the entire - /// CodeGeneratorResponse before writing files to disk. - public var name:String { - get { - return builderResult.name - } - set (value) { - builderResult.hasName = true - builderResult.name = value - } - } - public var hasName:Bool { - get { - return builderResult.hasName - } - } - @discardableResult - public func setName(_ value:String) -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - self.name = value - return self - } - @discardableResult - public func clearName() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder{ - builderResult.hasName = false - builderResult.name = nil - return self - } - /// If non-empty, indicates that the named file should already exist, and the - /// content here is to be inserted into that file at a defined insertion - /// point. This feature allows a code generator to extend the output - /// produced by another code generator. The original generator may provide - /// insertion points by placing special annotations in the file that look - /// like: - /// @@protoc_insertion_point(NAME) - /// The annotation can have arbitrary text before and after it on the line, - /// which allows it to be placed in a comment. NAME should be replaced with - /// an identifier naming the point -- this is what other generators will use - /// as the insertion_point. Code inserted at this point will be placed - /// immediately above the line containing the insertion point (thus multiple - /// insertions to the same point will come out in the order they were added). - /// The double-@ is intended to make it unlikely that the generated code - /// could contain things that look like insertion points by accident. - /// For example, the C++ code generator places the following line in the - /// .pb.h files that it generates: - /// // @@protoc_insertion_point(namespace_scope) - /// This line appears within the scope of the file's package namespace, but - /// outside of any particular class. Another plugin can then specify the - /// insertion_point "namespace_scope" to generate additional classes or - /// other declarations that should be placed in this scope. - /// Note that if the line containing the insertion point begins with - /// whitespace, the same whitespace will be added to every line of the - /// inserted text. This is useful for languages like Python, where - /// indentation matters. In these languages, the insertion point comment - /// should be indented the same amount as any inserted code will need to be - /// in order to work correctly in that context. - /// The code generator that generates the initial file and the one which - /// inserts into it must both run as part of a single invocation of protoc. - /// Code generators are executed in the order in which they appear on the - /// command line. - /// If |insertion_point| is present, |name| must also be present. - public var insertionPoint:String { - get { - return builderResult.insertionPoint - } - set (value) { - builderResult.hasInsertionPoint = true - builderResult.insertionPoint = value - } - } - public var hasInsertionPoint:Bool { - get { - return builderResult.hasInsertionPoint - } - } - @discardableResult - public func setInsertionPoint(_ value:String) -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - self.insertionPoint = value - return self - } - @discardableResult - public func clearInsertionPoint() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder{ - builderResult.hasInsertionPoint = false - builderResult.insertionPoint = nil - return self - } - /// The file contents. - public var content:String { - get { - return builderResult.content - } - set (value) { - builderResult.hasContent = true - builderResult.content = value - } - } - public var hasContent:Bool { - get { - return builderResult.hasContent - } - } - @discardableResult - public func setContent(_ value:String) -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - self.content = value - return self - } - @discardableResult - public func clearContent() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder{ - builderResult.hasContent = false - builderResult.content = nil - return self - } - override public var internalGetResult:GeneratedMessage { - get { - return builderResult - } - } - @discardableResult - override public func clear() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - builderResult = Google.Protobuf.Compiler.CodeGeneratorResponse.File() - return self - } - override public func clone() throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.builderWithPrototype(prototype:builderResult) - } - override public func build() throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - try checkInitialized() - return buildPartial() - } - public func buildPartial() -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - let returnMe:Google.Protobuf.Compiler.CodeGeneratorResponse.File = builderResult - return returnMe - } - @discardableResult - public func mergeFrom(other:Google.Protobuf.Compiler.CodeGeneratorResponse.File) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - if other == Google.Protobuf.Compiler.CodeGeneratorResponse.File() { - return self - } - if other.hasName { - name = other.name - } - if other.hasInsertionPoint { - insertionPoint = other.insertionPoint - } - if other.hasContent { - content = other.content - } - try merge(unknownField: other.unknownFields) - return self - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) - while (true) { - let protobufTag = try codedInputStream.readTag() - switch protobufTag { - case 0: - self.unknownFields = try unknownFieldsBuilder.build() - return self - - case 10: - name = try codedInputStream.readString() - - case 18: - insertionPoint = try codedInputStream.readString() - - case 122: - content = try codedInputStream.readString() - - default: - if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { - unknownFields = try unknownFieldsBuilder.build() - return self - } - } - } - } - class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - let resultDecodedBuilder = Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder() - if let jsonValueName = jsonMap["name"] as? String { - resultDecodedBuilder.name = jsonValueName - } - if let jsonValueInsertionPoint = jsonMap["insertionPoint"] as? String { - resultDecodedBuilder.insertionPoint = jsonValueInsertionPoint - } - if let jsonValueContent = jsonMap["content"] as? String { - resultDecodedBuilder.content = jsonValueContent - } - return resultDecodedBuilder - } - override class public func fromJSONToBuilder(data:Data) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder { - let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) - guard let jsDataCast = jsonData as? Dictionary else { - throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") - } - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder.decodeToBuilder(jsonMap:jsDataCast) - } - } - - } - - //Nested type declaration end - - /// Error message. If non-empty, code generation failed. The plugin process - /// should exit with status code zero even if it reports an error in this way. - /// This should be used to indicate errors in .proto files which prevent the - /// code generator from generating correct code. Errors which indicate a - /// problem in protoc itself -- such as the input CodeGeneratorRequest being - /// unparseable -- should be reported by writing a message to stderr and - /// exiting with a non-zero status code. - public fileprivate(set) var error:String! = nil - public fileprivate(set) var hasError:Bool = false - - public fileprivate(set) var file:Array = Array() - required public init() { - super.init() - } - override public func isInitialized() -> Bool { - return true - } - override public func writeTo(codedOutputStream: CodedOutputStream) throws { - if hasError { - try codedOutputStream.writeString(fieldNumber: 1, value:error) - } - for oneElementFile in file { - try codedOutputStream.writeMessage(fieldNumber: 15, value:oneElementFile) - } - try unknownFields.writeTo(codedOutputStream: codedOutputStream) - } - override public func serializedSize() -> Int32 { - var serialize_size:Int32 = memoizedSerializedSize - if serialize_size != -1 { - return serialize_size - } - - serialize_size = 0 - if hasError { - serialize_size += error.computeStringSize(fieldNumber: 1) - } - for oneElementFile in file { - serialize_size += oneElementFile.computeMessageSize(fieldNumber: 15) - } - serialize_size += unknownFields.serializedSize() - memoizedSerializedSize = serialize_size - return serialize_size - } - public class func getBuilder() -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - return Google.Protobuf.Compiler.CodeGeneratorResponse.classBuilder() as! Google.Protobuf.Compiler.CodeGeneratorResponse.Builder - } - public func getBuilder() -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - return classBuilder() as! Google.Protobuf.Compiler.CodeGeneratorResponse.Builder - } - override public class func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.CodeGeneratorResponse.Builder() - } - override public func classBuilder() -> ProtocolBuffersMessageBuilder { - return Google.Protobuf.Compiler.CodeGeneratorResponse.Builder() - } - public func toBuilder() throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.builderWithPrototype(prototype:self) - } - public class func builderWithPrototype(prototype:Google.Protobuf.Compiler.CodeGeneratorResponse) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(other:prototype) - } - override public func encode() throws -> Dictionary { - guard isInitialized() else { - throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") - } - - var jsonMap:Dictionary = Dictionary() - if hasError { - jsonMap["error"] = error - } - if !file.isEmpty { - var jsonArrayFile:Array> = [] - for oneValueFile in file { - let ecodedMessageFile = try oneValueFile.encode() - jsonArrayFile.append(ecodedMessageFile) - } - jsonMap["file"] = jsonArrayFile - } - return jsonMap - } - override class public func decode(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder.decodeToBuilder(jsonMap:jsonMap).build() - } - override class public func fromJSON(data:Data) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder.fromJSONToBuilder(data:data).build() - } - override public func getDescription(indent:String) throws -> String { - var output = "" - if hasError { - output += "\(indent) error: \(error) \n" - } - var fileElementIndex:Int = 0 - for oneElementFile in file { - output += "\(indent) file[\(fileElementIndex)] {\n" - output += try oneElementFile.getDescription(indent: "\(indent) ") - output += "\(indent)}\n" - fileElementIndex += 1 - } - output += unknownFields.getDescription(indent: indent) - return output - } - override public var hashValue:Int { - get { - var hashCode:Int = 7 - if hasError { - hashCode = (hashCode &* 31) &+ error.hashValue - } - for oneElementFile in file { - hashCode = (hashCode &* 31) &+ oneElementFile.hashValue - } - hashCode = (hashCode &* 31) &+ unknownFields.hashValue - return hashCode - } - } - - - //Meta information declaration start - - override public class func className() -> String { - return "Google.Protobuf.Compiler.CodeGeneratorResponse" - } - override public func className() -> String { - return "Google.Protobuf.Compiler.CodeGeneratorResponse" - } - //Meta information declaration end - - final public class Builder : GeneratedMessageBuilder { - fileprivate var builderResult:Google.Protobuf.Compiler.CodeGeneratorResponse = Google.Protobuf.Compiler.CodeGeneratorResponse() - public func getMessage() -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return builderResult - } - - required override public init () { - super.init() - } - /// Error message. If non-empty, code generation failed. The plugin process - /// should exit with status code zero even if it reports an error in this way. - /// This should be used to indicate errors in .proto files which prevent the - /// code generator from generating correct code. Errors which indicate a - /// problem in protoc itself -- such as the input CodeGeneratorRequest being - /// unparseable -- should be reported by writing a message to stderr and - /// exiting with a non-zero status code. - public var error:String { - get { - return builderResult.error - } - set (value) { - builderResult.hasError = true - builderResult.error = value - } - } - public var hasError:Bool { - get { - return builderResult.hasError - } - } - @discardableResult - public func setError(_ value:String) -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - self.error = value - return self - } - @discardableResult - public func clearError() -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder{ - builderResult.hasError = false - builderResult.error = nil - return self - } - public var file:Array { - get { - return builderResult.file - } - set (value) { - builderResult.file = value - } - } - @discardableResult - public func setFile(_ value:Array) -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - self.file = value - return self - } - @discardableResult - public func clearFile() -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - builderResult.file.removeAll(keepingCapacity: false) - return self - } - override public var internalGetResult:GeneratedMessage { - get { - return builderResult - } - } - @discardableResult - override public func clear() -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - builderResult = Google.Protobuf.Compiler.CodeGeneratorResponse() - return self - } - override public func clone() throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.builderWithPrototype(prototype:builderResult) - } - override public func build() throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - try checkInitialized() - return buildPartial() - } - public func buildPartial() -> Google.Protobuf.Compiler.CodeGeneratorResponse { - let returnMe:Google.Protobuf.Compiler.CodeGeneratorResponse = builderResult - return returnMe - } - @discardableResult - public func mergeFrom(other:Google.Protobuf.Compiler.CodeGeneratorResponse) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - if other == Google.Protobuf.Compiler.CodeGeneratorResponse() { - return self - } - if other.hasError { - error = other.error - } - if !other.file.isEmpty { - builderResult.file += other.file - } - try merge(unknownField: other.unknownFields) - return self - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) - } - @discardableResult - override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) - while (true) { - let protobufTag = try codedInputStream.readTag() - switch protobufTag { - case 0: - self.unknownFields = try unknownFieldsBuilder.build() - return self - - case 10: - error = try codedInputStream.readString() - - case 122: - let subBuilder = Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder() - try codedInputStream.readMessage(builder: subBuilder,extensionRegistry:extensionRegistry) - file.append(subBuilder.buildPartial()) - - default: - if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { - unknownFields = try unknownFieldsBuilder.build() - return self - } - } - } - } - class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - let resultDecodedBuilder = Google.Protobuf.Compiler.CodeGeneratorResponse.Builder() - if let jsonValueError = jsonMap["error"] as? String { - resultDecodedBuilder.error = jsonValueError - } - if let jsonValueFile = jsonMap["file"] as? Array> { - var jsonArrayFile:Array = [] - for oneValueFile in jsonValueFile { - let messageFromStringFile = try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder.decodeToBuilder(jsonMap:oneValueFile).build() - - jsonArrayFile.append(messageFromStringFile) - } - resultDecodedBuilder.file = jsonArrayFile - } - return resultDecodedBuilder - } - override class public func fromJSONToBuilder(data:Data) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.Builder { - let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) - guard let jsDataCast = jsonData as? Dictionary else { - throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") - } - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder.decodeToBuilder(jsonMap:jsDataCast) - } - } - - } - -} -extension Google.Protobuf.Compiler.Version: GeneratedMessageProtocol { - public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { - var mergedArray = Array() - while let value = try parseDelimitedFrom(inputStream: inputStream) { - mergedArray.append(value) - } - return mergedArray - } - public class func parseDelimitedFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.Version? { - return try Google.Protobuf.Compiler.Version.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() - } - public class func parseFrom(data: Data) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(data: data, extensionRegistry:Google.Protobuf.Compiler.PluginRoot.default.extensionRegistry).build() - } - public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(inputStream: inputStream).build() - } - public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(codedInputStream: codedInputStream).build() - } - public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.Version { - return try Google.Protobuf.Compiler.Version.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() - } - public subscript(key: String) -> Any? { - switch key { - case "major": return self.major - case "minor": return self.minor - case "patch": return self.patch - case "suffix": return self.suffix - default: return nil - } - } -} -extension Google.Protobuf.Compiler.Version.Builder: GeneratedMessageBuilderProtocol { - public typealias GeneratedMessageType = Google.Protobuf.Compiler.Version - public subscript(key: String) -> Any? { - get { - switch key { - case "major": return self.major - case "minor": return self.minor - case "patch": return self.patch - case "suffix": return self.suffix - default: return nil - } - } - set (newSubscriptValue) { - switch key { - case "major": - guard let newSubscriptValue = newSubscriptValue as? Int32 else { - return - } - self.major = newSubscriptValue - case "minor": - guard let newSubscriptValue = newSubscriptValue as? Int32 else { - return - } - self.minor = newSubscriptValue - case "patch": - guard let newSubscriptValue = newSubscriptValue as? Int32 else { - return - } - self.patch = newSubscriptValue - case "suffix": - guard let newSubscriptValue = newSubscriptValue as? String else { - return - } - self.suffix = newSubscriptValue - default: return - } - } - } -} -extension Google.Protobuf.Compiler.CodeGeneratorRequest: GeneratedMessageProtocol { - public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { - var mergedArray = Array() - while let value = try parseDelimitedFrom(inputStream: inputStream) { - mergedArray.append(value) - } - return mergedArray - } - public class func parseDelimitedFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest? { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() - } - public class func parseFrom(data: Data) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(data: data, extensionRegistry:Google.Protobuf.Compiler.PluginRoot.default.extensionRegistry).build() - } - public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(inputStream: inputStream).build() - } - public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(codedInputStream: codedInputStream).build() - } - public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorRequest { - return try Google.Protobuf.Compiler.CodeGeneratorRequest.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() - } - public subscript(key: String) -> Any? { - switch key { - case "fileToGenerate": return self.fileToGenerate - case "parameter": return self.parameter - case "protoFile": return self.protoFile - case "compilerVersion": return self.compilerVersion - default: return nil - } - } -} -extension Google.Protobuf.Compiler.CodeGeneratorRequest.Builder: GeneratedMessageBuilderProtocol { - public typealias GeneratedMessageType = Google.Protobuf.Compiler.CodeGeneratorRequest - public subscript(key: String) -> Any? { - get { - switch key { - case "fileToGenerate": return self.fileToGenerate - case "parameter": return self.parameter - case "protoFile": return self.protoFile - case "compilerVersion": return self.compilerVersion - default: return nil - } - } - set (newSubscriptValue) { - switch key { - case "fileToGenerate": - guard let newSubscriptValue = newSubscriptValue as? Array else { - return - } - self.fileToGenerate = newSubscriptValue - case "parameter": - guard let newSubscriptValue = newSubscriptValue as? String else { - return - } - self.parameter = newSubscriptValue - case "protoFile": - guard let newSubscriptValue = newSubscriptValue as? Array else { - return - } - self.protoFile = newSubscriptValue - case "compilerVersion": - guard let newSubscriptValue = newSubscriptValue as? Google.Protobuf.Compiler.Version else { - return - } - self.compilerVersion = newSubscriptValue - default: return - } - } - } -} -extension Google.Protobuf.Compiler.CodeGeneratorResponse: GeneratedMessageProtocol { - public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { - var mergedArray = Array() - while let value = try parseDelimitedFrom(inputStream: inputStream) { - mergedArray.append(value) - } - return mergedArray - } - public class func parseDelimitedFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse? { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() - } - public class func parseFrom(data: Data) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(data: data, extensionRegistry:Google.Protobuf.Compiler.PluginRoot.default.extensionRegistry).build() - } - public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(inputStream: inputStream).build() - } - public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(codedInputStream: codedInputStream).build() - } - public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() - } - public subscript(key: String) -> Any? { - switch key { - case "error": return self.error - case "file": return self.file - default: return nil - } - } -} -extension Google.Protobuf.Compiler.CodeGeneratorResponse.File: GeneratedMessageProtocol { - public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { - var mergedArray = Array() - while let value = try parseDelimitedFrom(inputStream: inputStream) { - mergedArray.append(value) - } - return mergedArray - } - public class func parseDelimitedFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File? { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() - } - public class func parseFrom(data: Data) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(data: data, extensionRegistry:Google.Protobuf.Compiler.PluginRoot.default.extensionRegistry).build() - } - public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(inputStream: InputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(inputStream: inputStream).build() - } - public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() - } - public class func parseFrom(codedInputStream: CodedInputStream) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(codedInputStream: codedInputStream).build() - } - public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Google.Protobuf.Compiler.CodeGeneratorResponse.File { - return try Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() - } - public subscript(key: String) -> Any? { - switch key { - case "name": return self.name - case "insertionPoint": return self.insertionPoint - case "content": return self.content - default: return nil - } - } -} -extension Google.Protobuf.Compiler.CodeGeneratorResponse.Builder: GeneratedMessageBuilderProtocol { - public typealias GeneratedMessageType = Google.Protobuf.Compiler.CodeGeneratorResponse - public subscript(key: String) -> Any? { - get { - switch key { - case "error": return self.error - case "file": return self.file - default: return nil - } - } - set (newSubscriptValue) { - switch key { - case "error": - guard let newSubscriptValue = newSubscriptValue as? String else { - return - } - self.error = newSubscriptValue - case "file": - guard let newSubscriptValue = newSubscriptValue as? Array else { - return - } - self.file = newSubscriptValue - default: return - } - } - } -} -extension Google.Protobuf.Compiler.CodeGeneratorResponse.File.Builder: GeneratedMessageBuilderProtocol { - public typealias GeneratedMessageType = Google.Protobuf.Compiler.CodeGeneratorResponse.File - public subscript(key: String) -> Any? { - get { - switch key { - case "name": return self.name - case "insertionPoint": return self.insertionPoint - case "content": return self.content - default: return nil - } - } - set (newSubscriptValue) { - switch key { - case "name": - guard let newSubscriptValue = newSubscriptValue as? String else { - return - } - self.name = newSubscriptValue - case "insertionPoint": - guard let newSubscriptValue = newSubscriptValue as? String else { - return - } - self.insertionPoint = newSubscriptValue - case "content": - guard let newSubscriptValue = newSubscriptValue as? String else { - return - } - self.content = newSubscriptValue - default: return - } - } - } -} - -// @@protoc_insertion_point(global_scope) diff --git a/plugin/PBCompiler/PBCompiler.xcodeproj/project.pbxproj b/plugin/PBCompiler/PBCompiler.xcodeproj/project.pbxproj index ca79221..5a97dc4 100644 --- a/plugin/PBCompiler/PBCompiler.xcodeproj/project.pbxproj +++ b/plugin/PBCompiler/PBCompiler.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 3F20C36C1F4DCE1500167D7F /* swift_enum_realm.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F20C36A1F4DCE1500167D7F /* swift_enum_realm.cc */; }; 3F6112741D85AB9500DE3C9D /* descriptor.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F6112231D85AB9500DE3C9D /* descriptor.pb.cc */; }; 3F6112751D85AB9500DE3C9D /* swift-descriptor.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F6112331D85AB9500DE3C9D /* swift-descriptor.pb.cc */; }; 3F6112761D85AB9500DE3C9D /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F6112541D85AB9500DE3C9D /* main.cc */; }; @@ -27,13 +26,8 @@ 3F70C87C1E9CEF7500C57091 /* swift_file.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F70C8711E9CEF7500C57091 /* swift_file.cc */; }; 3F70C87E1E9CEF7500C57091 /* swift_generator.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F70C8741E9CEF7500C57091 /* swift_generator.cc */; }; 3F70C8801E9CEF7500C57091 /* swift_react.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F70C8781E9CEF7500C57091 /* swift_react.cc */; }; - 3F70C8831E9CF3ED00C57091 /* swift_helpers_realm.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F70C8821E9CF3ED00C57091 /* swift_helpers_realm.cc */; }; 3F70C8871E9CF44A00C57091 /* swift_helpers_react.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F70C8851E9CF44A00C57091 /* swift_helpers_react.cc */; }; 3F70C88A1E9E783B00C57091 /* swift_react_enums.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F70C8881E9E783B00C57091 /* swift_react_enums.cc */; }; - 3F99B78C1E953CB20030784C /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F99B7661E953CB20030784C /* main.cc */; }; - 3F99B7951E953CB20030784C /* swift_file.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F99B7741E953CB20030784C /* swift_file.cc */; }; - 3F99B7971E953CB20030784C /* swift_generator.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F99B7771E953CB20030784C /* swift_generator.cc */; }; - 3F99B79C1E953CB20030784C /* swift_message_realm.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3F99B7801E953CB20030784C /* swift_message_realm.cc */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -49,8 +43,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 3F20C36A1F4DCE1500167D7F /* swift_enum_realm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_enum_realm.cc; sourceTree = ""; }; - 3F20C36B1F4DCE1500167D7F /* swift_enum_realm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_enum_realm.h; sourceTree = ""; }; + 3F263D5C1FA4D0BE00CC7718 /* plugin.proto */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = plugin.proto; sourceTree = ""; }; 3F6111791D85A7E000DE3C9D /* PBCompiler */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PBCompiler; sourceTree = BUILT_PRODUCTS_DIR; }; 3F61121F1D85AB9500DE3C9D /* .dirstamp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .dirstamp; sourceTree = ""; }; 3F6112201D85AB9500DE3C9D /* any.proto */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = any.proto; sourceTree = ""; }; @@ -140,19 +133,10 @@ 3F70C8751E9CEF7500C57091 /* swift_generator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_generator.h; sourceTree = ""; }; 3F70C8771E9CEF7500C57091 /* swift_react.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_react.h; sourceTree = ""; }; 3F70C8781E9CEF7500C57091 /* swift_react.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_react.cc; sourceTree = ""; }; - 3F70C8821E9CF3ED00C57091 /* swift_helpers_realm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_helpers_realm.cc; sourceTree = ""; }; - 3F70C8841E9CF43F00C57091 /* swift_helpers_realm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_helpers_realm.h; sourceTree = ""; }; 3F70C8851E9CF44A00C57091 /* swift_helpers_react.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_helpers_react.cc; sourceTree = ""; }; 3F70C8861E9CF44A00C57091 /* swift_helpers_react.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_helpers_react.h; sourceTree = ""; }; 3F70C8881E9E783B00C57091 /* swift_react_enums.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_react_enums.cc; sourceTree = ""; }; 3F70C8891E9E783B00C57091 /* swift_react_enums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_react_enums.h; sourceTree = ""; }; - 3F99B7661E953CB20030784C /* main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cc; sourceTree = ""; }; - 3F99B7741E953CB20030784C /* swift_file.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_file.cc; sourceTree = ""; }; - 3F99B7751E953CB20030784C /* swift_file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_file.h; sourceTree = ""; }; - 3F99B7771E953CB20030784C /* swift_generator.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_generator.cc; sourceTree = ""; }; - 3F99B7781E953CB20030784C /* swift_generator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_generator.h; sourceTree = ""; }; - 3F99B7801E953CB20030784C /* swift_message_realm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = swift_message_realm.cc; sourceTree = ""; }; - 3F99B7811E953CB20030784C /* swift_message_realm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swift_message_realm.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -186,7 +170,6 @@ isa = PBXGroup; children = ( 3F70C85D1E9CEF7500C57091 /* react_native */, - 3F99B7551E953CB20030784C /* realm */, 3F61121D1D85AB9500DE3C9D /* google */, 3F6112541D85AB9500DE3C9D /* main.cc */, 3F6112551D85AB9500DE3C9D /* Makefile.am */, @@ -233,8 +216,8 @@ isa = PBXGroup; children = ( 3F61121F1D85AB9500DE3C9D /* .dirstamp */, - 3F6112201D85AB9500DE3C9D /* any.proto */, 3F6112211D85AB9500DE3C9D /* any_test.proto */, + 3F6112201D85AB9500DE3C9D /* any.proto */, 3F6112221D85AB9500DE3C9D /* api.proto */, 3F6112231D85AB9500DE3C9D /* descriptor.pb.cc */, 3F6112241D85AB9500DE3C9D /* descriptor.pb.h */, @@ -242,6 +225,7 @@ 3F6112261D85AB9500DE3C9D /* duration.proto */, 3F6112271D85AB9500DE3C9D /* empty.proto */, 3F6112281D85AB9500DE3C9D /* field_mask.proto */, + 3F263D5C1FA4D0BE00CC7718 /* plugin.proto */, 3F6112291D85AB9500DE3C9D /* map_lite_unittest.proto */, 3F61122A1D85AB9500DE3C9D /* map_proto2_unittest.proto */, 3F61122B1D85AB9500DE3C9D /* map_unittest.proto */, @@ -254,7 +238,6 @@ 3F6112351D85AB9500DE3C9D /* swift-descriptor.proto */, 3F6112361D85AB9500DE3C9D /* timestamp.proto */, 3F6112371D85AB9500DE3C9D /* type.proto */, - 3F6112381D85AB9500DE3C9D /* unittest.proto */, 3F6112391D85AB9500DE3C9D /* unittest_arena.proto */, 3F61123A1D85AB9500DE3C9D /* unittest_custom_options.proto */, 3F61123B1D85AB9500DE3C9D /* unittest_drop_unknown_fields.proto */, @@ -262,16 +245,16 @@ 3F61123D1D85AB9500DE3C9D /* unittest_empty.proto */, 3F61123E1D85AB9500DE3C9D /* unittest_enormous_descriptor.proto */, 3F61123F1D85AB9500DE3C9D /* unittest_error_type.proto */, - 3F6112401D85AB9500DE3C9D /* unittest_import.proto */, 3F6112411D85AB9500DE3C9D /* unittest_import_lite.proto */, - 3F6112421D85AB9500DE3C9D /* unittest_import_public.proto */, 3F6112431D85AB9500DE3C9D /* unittest_import_public_lite.proto */, - 3F6112441D85AB9500DE3C9D /* unittest_lite.proto */, + 3F6112421D85AB9500DE3C9D /* unittest_import_public.proto */, + 3F6112401D85AB9500DE3C9D /* unittest_import.proto */, 3F6112451D85AB9500DE3C9D /* unittest_lite_imports_nonlite.proto */, + 3F6112441D85AB9500DE3C9D /* unittest_lite.proto */, 3F6112461D85AB9500DE3C9D /* unittest_maps.proto */, 3F6112471D85AB9500DE3C9D /* unittest_mset.proto */, - 3F6112481D85AB9500DE3C9D /* unittest_no_arena.proto */, 3F6112491D85AB9500DE3C9D /* unittest_no_arena_import.proto */, + 3F6112481D85AB9500DE3C9D /* unittest_no_arena.proto */, 3F61124A1D85AB9500DE3C9D /* unittest_no_field_presence.proto */, 3F61124B1D85AB9500DE3C9D /* unittest_no_generic_services.proto */, 3F61124C1D85AB9500DE3C9D /* unittest_optimize_for.proto */, @@ -280,6 +263,7 @@ 3F61124F1D85AB9500DE3C9D /* unittest_struct.proto */, 3F6112501D85AB9500DE3C9D /* unittest_threading.proto */, 3F6112511D85AB9500DE3C9D /* unittest_well_known_types.proto */, + 3F6112381D85AB9500DE3C9D /* unittest.proto */, 3F6112521D85AB9500DE3C9D /* unknown_enum_test.proto */, 3F6112531D85AB9500DE3C9D /* wrappers.proto */, ); @@ -339,24 +323,6 @@ path = react_native; sourceTree = ""; }; - 3F99B7551E953CB20030784C /* realm */ = { - isa = PBXGroup; - children = ( - 3F70C8841E9CF43F00C57091 /* swift_helpers_realm.h */, - 3F70C8821E9CF3ED00C57091 /* swift_helpers_realm.cc */, - 3F99B7661E953CB20030784C /* main.cc */, - 3F99B7741E953CB20030784C /* swift_file.cc */, - 3F99B7751E953CB20030784C /* swift_file.h */, - 3F99B7771E953CB20030784C /* swift_generator.cc */, - 3F99B7781E953CB20030784C /* swift_generator.h */, - 3F20C36A1F4DCE1500167D7F /* swift_enum_realm.cc */, - 3F20C36B1F4DCE1500167D7F /* swift_enum_realm.h */, - 3F99B7801E953CB20030784C /* swift_message_realm.cc */, - 3F99B7811E953CB20030784C /* swift_message_realm.h */, - ); - path = realm; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -414,20 +380,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3F99B78C1E953CB20030784C /* main.cc in Sources */, 3F70C8801E9CEF7500C57091 /* swift_react.cc in Sources */, 3F6112761D85AB9500DE3C9D /* main.cc in Sources */, 3F6112741D85AB9500DE3C9D /* descriptor.pb.cc in Sources */, 3F6112771D85AB9500DE3C9D /* swift_enum.cc in Sources */, 3F70C87A1E9CEF7500C57091 /* main.cc in Sources */, 3F70C87C1E9CEF7500C57091 /* swift_file.cc in Sources */, - 3F99B7951E953CB20030784C /* swift_file.cc in Sources */, 3F70C87E1E9CEF7500C57091 /* swift_generator.cc in Sources */, 3F70C8871E9CF44A00C57091 /* swift_helpers_react.cc in Sources */, - 3F70C8831E9CF3ED00C57091 /* swift_helpers_realm.cc in Sources */, 3F61127E1D85AB9500DE3C9D /* swift_map_field.cc in Sources */, - 3F99B7971E953CB20030784C /* swift_generator.cc in Sources */, - 3F99B79C1E953CB20030784C /* swift_message_realm.cc in Sources */, 3F6112821D85AB9500DE3C9D /* swift_primitive_field.cc in Sources */, 3F6112801D85AB9500DE3C9D /* swift_message_field.cc in Sources */, 3F61127A1D85AB9500DE3C9D /* swift_field.cc in Sources */, @@ -435,7 +396,6 @@ 3F6112811D85AB9500DE3C9D /* swift_oneof.cc in Sources */, 3F6112791D85AB9500DE3C9D /* swift_extension.cc in Sources */, 3F61127D1D85AB9500DE3C9D /* swift_helpers.cc in Sources */, - 3F20C36C1F4DCE1500167D7F /* swift_enum_realm.cc in Sources */, 3F61127B1D85AB9500DE3C9D /* swift_file.cc in Sources */, 3F6112751D85AB9500DE3C9D /* swift-descriptor.pb.cc in Sources */, 3F6112781D85AB9500DE3C9D /* swift_enum_field.cc in Sources */, diff --git a/plugin/Tests/PluginTest.swift b/plugin/Tests/PluginTest.swift index 2b82bd5..bcc03b5 100644 --- a/plugin/Tests/PluginTest.swift +++ b/plugin/Tests/PluginTest.swift @@ -10,26 +10,26 @@ import ProtocolBuffers class PluginTest: XCTestCase { - func testParse() { - let data = Data(base64Encoded: testData) - let request = try! Google.Protobuf.Compiler.CodeGeneratorRequest.parseFrom(data: data!) - let generate = request.protoFile.filter({ - return request.fileToGenerate.contains($0.name) - }) - - generate.forEach({ file in - file.messageType.forEach({ message in - if message.options != nil { - if message.options.hasExtension(extensions: Google.Protobuf.SwiftDescriptorRoot.swiftMessageOptions()) { - if let option = message.options.getExtension(extensions: Google.Protobuf.SwiftDescriptorRoot.swiftMessageOptions()) as? Google.Protobuf.SwiftMessageOptions { - print(option.generateRealmObject) - } - } - } - }) - }) - XCTAssertNotNil(request) - - } +// func testParse() { +// let data = Data(base64Encoded: testData) +// let request = try! Google.Protobuf.Compiler.CodeGeneratorRequest.parseFrom(data: data!) +// let generate = request.protoFile.filter({ +// return request.fileToGenerate.contains($0.name) +// }) +// +// generate.forEach({ file in +// file.messageType.forEach({ message in +// if message.options != nil { +// if message.options.hasExtension(extensions: Google.Protobuf.SwiftDescriptorRoot.swiftMessageOptions()) { +// if let option = message.options.getExtension(extensions: Google.Protobuf.SwiftDescriptorRoot.swiftMessageOptions()) as? Google.Protobuf.SwiftMessageOptions { +// print(option.generateRealmObject) +// } +// } +// } +// }) +// }) +// XCTAssertNotNil(request) +// +// } } diff --git a/plugin/compiler/google/protobuf/plugin.proto b/plugin/compiler/google/protobuf/plugin.proto index 8c6fb7f..5be4a03 100755 --- a/plugin/compiler/google/protobuf/plugin.proto +++ b/plugin/compiler/google/protobuf/plugin.proto @@ -54,7 +54,6 @@ option go_package = "github.com/golang/protobuf/protoc-gen-go/plugin;plugin_go"; import "google/protobuf/descriptor.proto"; import "google/protobuf/swift-descriptor.proto"; -option (.google.protobuf.swift_file_options).compile_for_framework = false; option (.google.protobuf.swift_file_options).entities_access_control = PublicEntities; // The version number of protocol compiler.