any_test.pb.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // DO NOT EDIT.
  2. // swift-format-ignore-file
  3. // swiftlint:disable all
  4. //
  5. // Generated by the Swift generator plugin for the protocol buffer compiler.
  6. // Source: google/protobuf/any_test.proto
  7. //
  8. // For information on using the generated types, please see the documentation:
  9. // https://github.com/apple/swift-protobuf/
  10. // Protocol Buffers - Google's data interchange format
  11. // Copyright 2008 Google Inc. All rights reserved.
  12. //
  13. // Use of this source code is governed by a BSD-style
  14. // license that can be found in the LICENSE file or at
  15. // https://developers.google.com/open-source/licenses/bsd
  16. import SwiftProtobuf
  17. // If the compiler emits an error on this type, it is because this file
  18. // was generated by a version of the `protoc` Swift plug-in that is
  19. // incompatible with the version of SwiftProtobuf to which you are linking.
  20. // Please ensure that you are building against the same version of the API
  21. // that was used to generate this file.
  22. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  23. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  24. typealias Version = _2
  25. }
  26. struct Proto2Unittest_TestAny: Sendable {
  27. // SwiftProtobuf.Message conformance is added in an extension below. See the
  28. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  29. // methods supported on all messages.
  30. var int32Value: Int32 = 0
  31. var anyValue: SwiftProtobuf.Google_Protobuf_Any {
  32. get {_anyValue ?? SwiftProtobuf.Google_Protobuf_Any()}
  33. set {_anyValue = newValue}
  34. }
  35. /// Returns true if `anyValue` has been explicitly set.
  36. var hasAnyValue: Bool {self._anyValue != nil}
  37. /// Clears the value of `anyValue`. Subsequent reads from it will return its default value.
  38. mutating func clearAnyValue() {self._anyValue = nil}
  39. var repeatedAnyValue: [SwiftProtobuf.Google_Protobuf_Any] = []
  40. var text: String = String()
  41. var unknownFields = SwiftProtobuf.UnknownStorage()
  42. init() {}
  43. fileprivate var _anyValue: SwiftProtobuf.Google_Protobuf_Any? = nil
  44. }
  45. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  46. fileprivate let _protobuf_package = "proto2_unittest"
  47. extension Proto2Unittest_TestAny: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  48. static let protoMessageName: String = _protobuf_package + ".TestAny"
  49. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}int32_value\0\u{3}any_value\0\u{3}repeated_any_value\0\u{1}text\0")
  50. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  51. while let fieldNumber = try decoder.nextFieldNumber() {
  52. // The use of inline closures is to circumvent an issue where the compiler
  53. // allocates stack space for every case branch when no optimizations are
  54. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  55. switch fieldNumber {
  56. case 1: try { try decoder.decodeSingularInt32Field(value: &self.int32Value) }()
  57. case 2: try { try decoder.decodeSingularMessageField(value: &self._anyValue) }()
  58. case 3: try { try decoder.decodeRepeatedMessageField(value: &self.repeatedAnyValue) }()
  59. case 4: try { try decoder.decodeSingularStringField(value: &self.text) }()
  60. default: break
  61. }
  62. }
  63. }
  64. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  65. // The use of inline closures is to circumvent an issue where the compiler
  66. // allocates stack space for every if/case branch local when no optimizations
  67. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  68. // https://github.com/apple/swift-protobuf/issues/1182
  69. if self.int32Value != 0 {
  70. try visitor.visitSingularInt32Field(value: self.int32Value, fieldNumber: 1)
  71. }
  72. try { if let v = self._anyValue {
  73. try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
  74. } }()
  75. if !self.repeatedAnyValue.isEmpty {
  76. try visitor.visitRepeatedMessageField(value: self.repeatedAnyValue, fieldNumber: 3)
  77. }
  78. if !self.text.isEmpty {
  79. try visitor.visitSingularStringField(value: self.text, fieldNumber: 4)
  80. }
  81. try unknownFields.traverse(visitor: &visitor)
  82. }
  83. static func ==(lhs: Proto2Unittest_TestAny, rhs: Proto2Unittest_TestAny) -> Bool {
  84. if lhs.int32Value != rhs.int32Value {return false}
  85. if lhs._anyValue != rhs._anyValue {return false}
  86. if lhs.repeatedAnyValue != rhs.repeatedAnyValue {return false}
  87. if lhs.text != rhs.text {return false}
  88. if lhs.unknownFields != rhs.unknownFields {return false}
  89. return true
  90. }
  91. }