| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- // DO NOT EDIT.
- // swift-format-ignore-file
- // swiftlint:disable all
- //
- // Generated by the Swift generator plugin for the protocol buffer compiler.
- // Source: unittest_swift_oneof_merging.proto
- //
- // For information on using the generated types, please see the documentation:
- // https://github.com/apple/swift-protobuf/
- // Protos/unittest_swift_oneof_merging.proto - test proto
- //
- // This source file is part of the Swift.org open source project
- //
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
- // Licensed under Apache License v2.0 with Runtime Library Exception
- //
- // See http://swift.org/LICENSE.txt for license information
- // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
- //
- // -----------------------------------------------------------------------------
- ///
- /// This is based on unittest.proto's TestParsingMerge & RepeatedFieldsGenerator,
- /// but focused on oneofs to ensure the behaviors around merging/replaces on
- /// oneofs is correct.
- ///
- // -----------------------------------------------------------------------------
- import Foundation
- import SwiftProtobuf
- // If the compiler emits an error on this type, it is because this file
- // was generated by a version of the `protoc` Swift plug-in that is
- // incompatible with the version of SwiftProtobuf to which you are linking.
- // Please ensure that you are building against the same version of the API
- // that was used to generate this file.
- fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
- struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
- typealias Version = _2
- }
- struct SwiftProtoTesting_Merging_TestMessage: Sendable {
- // SwiftProtobuf.Message conformance is added in an extension below. See the
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
- // methods supported on all messages.
- var oneofField: SwiftProtoTesting_Merging_TestMessage.OneOf_OneofField? = nil
- var oneofUint32: UInt32 {
- get {
- if case .oneofUint32(let v)? = oneofField {return v}
- return 0
- }
- set {oneofField = .oneofUint32(newValue)}
- }
- var oneofNestedMessage: SwiftProtoTesting_Merging_TestMessage.NestedMessage {
- get {
- if case .oneofNestedMessage(let v)? = oneofField {return v}
- return SwiftProtoTesting_Merging_TestMessage.NestedMessage()
- }
- set {oneofField = .oneofNestedMessage(newValue)}
- }
- var oneofString: String {
- get {
- if case .oneofString(let v)? = oneofField {return v}
- return String()
- }
- set {oneofField = .oneofString(newValue)}
- }
- var oneofBytes: Data {
- get {
- if case .oneofBytes(let v)? = oneofField {return v}
- return Data()
- }
- set {oneofField = .oneofBytes(newValue)}
- }
- var unknownFields = SwiftProtobuf.UnknownStorage()
- enum OneOf_OneofField: Equatable, Sendable {
- case oneofUint32(UInt32)
- case oneofNestedMessage(SwiftProtoTesting_Merging_TestMessage.NestedMessage)
- case oneofString(String)
- case oneofBytes(Data)
- }
- struct NestedMessage: Sendable {
- // SwiftProtobuf.Message conformance is added in an extension below. See the
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
- // methods supported on all messages.
- var a: Int32 {
- get {_a ?? 0}
- set {_a = newValue}
- }
- /// Returns true if `a` has been explicitly set.
- var hasA: Bool {self._a != nil}
- /// Clears the value of `a`. Subsequent reads from it will return its default value.
- mutating func clearA() {self._a = nil}
- var b: Int32 {
- get {_b ?? 0}
- set {_b = newValue}
- }
- /// Returns true if `b` has been explicitly set.
- var hasB: Bool {self._b != nil}
- /// Clears the value of `b`. Subsequent reads from it will return its default value.
- mutating func clearB() {self._b = nil}
- var c: Int32 {
- get {_c ?? 0}
- set {_c = newValue}
- }
- /// Returns true if `c` has been explicitly set.
- var hasC: Bool {self._c != nil}
- /// Clears the value of `c`. Subsequent reads from it will return its default value.
- mutating func clearC() {self._c = nil}
- var unknownFields = SwiftProtobuf.UnknownStorage()
- init() {}
- fileprivate var _a: Int32? = nil
- fileprivate var _b: Int32? = nil
- fileprivate var _c: Int32? = nil
- }
- init() {}
- }
- struct SwiftProtoTesting_Merging_TestParsingMerge: Sendable {
- // SwiftProtobuf.Message conformance is added in an extension below. See the
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
- // methods supported on all messages.
- var optionalMessage: SwiftProtoTesting_Merging_TestMessage {
- get {_optionalMessage ?? SwiftProtoTesting_Merging_TestMessage()}
- set {_optionalMessage = newValue}
- }
- /// Returns true if `optionalMessage` has been explicitly set.
- var hasOptionalMessage: Bool {self._optionalMessage != nil}
- /// Clears the value of `optionalMessage`. Subsequent reads from it will return its default value.
- mutating func clearOptionalMessage() {self._optionalMessage = nil}
- var repeatedMessage: [SwiftProtoTesting_Merging_TestMessage] = []
- var unknownFields = SwiftProtobuf.UnknownStorage()
- struct RepeatedFieldsGenerator: Sendable {
- // SwiftProtobuf.Message conformance is added in an extension below. See the
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
- // methods supported on all messages.
- var field1: [SwiftProtoTesting_Merging_TestMessage] = []
- var field2: [SwiftProtoTesting_Merging_TestMessage] = []
- var unknownFields = SwiftProtobuf.UnknownStorage()
- init() {}
- }
- init() {}
- fileprivate var _optionalMessage: SwiftProtoTesting_Merging_TestMessage? = nil
- }
- // MARK: - Code below here is support for the SwiftProtobuf runtime.
- fileprivate let _protobuf_package = "swift_proto_testing.merging"
- extension SwiftProtoTesting_Merging_TestMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
- static let protoMessageName: String = _protobuf_package + ".TestMessage"
- static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{4}o\u{1}oneof_uint32\0\u{3}oneof_nested_message\0\u{3}oneof_string\0\u{3}oneof_bytes\0")
- mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
- while let fieldNumber = try decoder.nextFieldNumber() {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every case branch when no optimizations are
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
- switch fieldNumber {
- case 111: try {
- var v: UInt32?
- try decoder.decodeSingularUInt32Field(value: &v)
- if let v = v {
- if self.oneofField != nil {try decoder.handleConflictingOneOf()}
- self.oneofField = .oneofUint32(v)
- }
- }()
- case 112: try {
- var v: SwiftProtoTesting_Merging_TestMessage.NestedMessage?
- var hadOneofValue = false
- if let current = self.oneofField {
- hadOneofValue = true
- if case .oneofNestedMessage(let m) = current {v = m}
- }
- try decoder.decodeSingularMessageField(value: &v)
- if let v = v {
- if hadOneofValue {try decoder.handleConflictingOneOf()}
- self.oneofField = .oneofNestedMessage(v)
- }
- }()
- case 113: try {
- var v: String?
- try decoder.decodeSingularStringField(value: &v)
- if let v = v {
- if self.oneofField != nil {try decoder.handleConflictingOneOf()}
- self.oneofField = .oneofString(v)
- }
- }()
- case 114: try {
- var v: Data?
- try decoder.decodeSingularBytesField(value: &v)
- if let v = v {
- if self.oneofField != nil {try decoder.handleConflictingOneOf()}
- self.oneofField = .oneofBytes(v)
- }
- }()
- default: break
- }
- }
- }
- func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every if/case branch local when no optimizations
- // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
- // https://github.com/apple/swift-protobuf/issues/1182
- switch self.oneofField {
- case .oneofUint32?: try {
- guard case .oneofUint32(let v)? = self.oneofField else { preconditionFailure() }
- try visitor.visitSingularUInt32Field(value: v, fieldNumber: 111)
- }()
- case .oneofNestedMessage?: try {
- guard case .oneofNestedMessage(let v)? = self.oneofField else { preconditionFailure() }
- try visitor.visitSingularMessageField(value: v, fieldNumber: 112)
- }()
- case .oneofString?: try {
- guard case .oneofString(let v)? = self.oneofField else { preconditionFailure() }
- try visitor.visitSingularStringField(value: v, fieldNumber: 113)
- }()
- case .oneofBytes?: try {
- guard case .oneofBytes(let v)? = self.oneofField else { preconditionFailure() }
- try visitor.visitSingularBytesField(value: v, fieldNumber: 114)
- }()
- case nil: break
- }
- try unknownFields.traverse(visitor: &visitor)
- }
- static func ==(lhs: SwiftProtoTesting_Merging_TestMessage, rhs: SwiftProtoTesting_Merging_TestMessage) -> Bool {
- if lhs.oneofField != rhs.oneofField {return false}
- if lhs.unknownFields != rhs.unknownFields {return false}
- return true
- }
- }
- extension SwiftProtoTesting_Merging_TestMessage.NestedMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
- static let protoMessageName: String = SwiftProtoTesting_Merging_TestMessage.protoMessageName + ".NestedMessage"
- static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}a\0\u{1}b\0\u{1}c\0")
- mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
- while let fieldNumber = try decoder.nextFieldNumber() {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every case branch when no optimizations are
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
- switch fieldNumber {
- case 1: try { try decoder.decodeSingularInt32Field(value: &self._a) }()
- case 2: try { try decoder.decodeSingularInt32Field(value: &self._b) }()
- case 3: try { try decoder.decodeSingularInt32Field(value: &self._c) }()
- default: break
- }
- }
- }
- func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every if/case branch local when no optimizations
- // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
- // https://github.com/apple/swift-protobuf/issues/1182
- try { if let v = self._a {
- try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
- } }()
- try { if let v = self._b {
- try visitor.visitSingularInt32Field(value: v, fieldNumber: 2)
- } }()
- try { if let v = self._c {
- try visitor.visitSingularInt32Field(value: v, fieldNumber: 3)
- } }()
- try unknownFields.traverse(visitor: &visitor)
- }
- static func ==(lhs: SwiftProtoTesting_Merging_TestMessage.NestedMessage, rhs: SwiftProtoTesting_Merging_TestMessage.NestedMessage) -> Bool {
- if lhs._a != rhs._a {return false}
- if lhs._b != rhs._b {return false}
- if lhs._c != rhs._c {return false}
- if lhs.unknownFields != rhs.unknownFields {return false}
- return true
- }
- }
- extension SwiftProtoTesting_Merging_TestParsingMerge: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
- static let protoMessageName: String = _protobuf_package + ".TestParsingMerge"
- static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}optional_message\0\u{3}repeated_message\0")
- mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
- while let fieldNumber = try decoder.nextFieldNumber() {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every case branch when no optimizations are
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
- switch fieldNumber {
- case 1: try { try decoder.decodeSingularMessageField(value: &self._optionalMessage) }()
- case 2: try { try decoder.decodeRepeatedMessageField(value: &self.repeatedMessage) }()
- default: break
- }
- }
- }
- func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every if/case branch local when no optimizations
- // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
- // https://github.com/apple/swift-protobuf/issues/1182
- try { if let v = self._optionalMessage {
- try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
- } }()
- if !self.repeatedMessage.isEmpty {
- try visitor.visitRepeatedMessageField(value: self.repeatedMessage, fieldNumber: 2)
- }
- try unknownFields.traverse(visitor: &visitor)
- }
- static func ==(lhs: SwiftProtoTesting_Merging_TestParsingMerge, rhs: SwiftProtoTesting_Merging_TestParsingMerge) -> Bool {
- if lhs._optionalMessage != rhs._optionalMessage {return false}
- if lhs.repeatedMessage != rhs.repeatedMessage {return false}
- if lhs.unknownFields != rhs.unknownFields {return false}
- return true
- }
- }
- extension SwiftProtoTesting_Merging_TestParsingMerge.RepeatedFieldsGenerator: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
- static let protoMessageName: String = SwiftProtoTesting_Merging_TestParsingMerge.protoMessageName + ".RepeatedFieldsGenerator"
- static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}field1\0\u{1}field2\0")
- mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
- while let fieldNumber = try decoder.nextFieldNumber() {
- // The use of inline closures is to circumvent an issue where the compiler
- // allocates stack space for every case branch when no optimizations are
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
- switch fieldNumber {
- case 1: try { try decoder.decodeRepeatedMessageField(value: &self.field1) }()
- case 2: try { try decoder.decodeRepeatedMessageField(value: &self.field2) }()
- default: break
- }
- }
- }
- func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
- if !self.field1.isEmpty {
- try visitor.visitRepeatedMessageField(value: self.field1, fieldNumber: 1)
- }
- if !self.field2.isEmpty {
- try visitor.visitRepeatedMessageField(value: self.field2, fieldNumber: 2)
- }
- try unknownFields.traverse(visitor: &visitor)
- }
- static func ==(lhs: SwiftProtoTesting_Merging_TestParsingMerge.RepeatedFieldsGenerator, rhs: SwiftProtoTesting_Merging_TestParsingMerge.RepeatedFieldsGenerator) -> Bool {
- if lhs.field1 != rhs.field1 {return false}
- if lhs.field2 != rhs.field2 {return false}
- if lhs.unknownFields != rhs.unknownFields {return false}
- return true
- }
- }
|