unittest_proto3_optional.pb.swift 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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: unittest_proto3_optional.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. // https://developers.google.com/protocol-buffers/
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions are
  16. // met:
  17. //
  18. // * Redistributions of source code must retain the above copyright
  19. // notice, this list of conditions and the following disclaimer.
  20. // * Redistributions in binary form must reproduce the above
  21. // copyright notice, this list of conditions and the following disclaimer
  22. // in the documentation and/or other materials provided with the
  23. // distribution.
  24. // * Neither the name of Google Inc. nor the names of its
  25. // contributors may be used to endorse or promote products derived from
  26. // this software without specific prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. import Foundation
  40. import SwiftProtobuf
  41. // If the compiler emits an error on this type, it is because this file
  42. // was generated by a version of the `protoc` Swift plug-in that is
  43. // incompatible with the version of SwiftProtobuf to which you are linking.
  44. // Please ensure that you are building against the same version of the API
  45. // that was used to generate this file.
  46. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  47. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  48. typealias Version = _2
  49. }
  50. struct SwiftProtoTesting_TestProto3Optional: @unchecked Sendable {
  51. // SwiftProtobuf.Message conformance is added in an extension below. See the
  52. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  53. // methods supported on all messages.
  54. /// Singular
  55. var optionalInt32: Int32 {
  56. get {return _storage._optionalInt32 ?? 0}
  57. set {_uniqueStorage()._optionalInt32 = newValue}
  58. }
  59. /// Returns true if `optionalInt32` has been explicitly set.
  60. var hasOptionalInt32: Bool {return _storage._optionalInt32 != nil}
  61. /// Clears the value of `optionalInt32`. Subsequent reads from it will return its default value.
  62. mutating func clearOptionalInt32() {_uniqueStorage()._optionalInt32 = nil}
  63. var optionalInt64: Int64 {
  64. get {return _storage._optionalInt64 ?? 0}
  65. set {_uniqueStorage()._optionalInt64 = newValue}
  66. }
  67. /// Returns true if `optionalInt64` has been explicitly set.
  68. var hasOptionalInt64: Bool {return _storage._optionalInt64 != nil}
  69. /// Clears the value of `optionalInt64`. Subsequent reads from it will return its default value.
  70. mutating func clearOptionalInt64() {_uniqueStorage()._optionalInt64 = nil}
  71. var optionalUint32: UInt32 {
  72. get {return _storage._optionalUint32 ?? 0}
  73. set {_uniqueStorage()._optionalUint32 = newValue}
  74. }
  75. /// Returns true if `optionalUint32` has been explicitly set.
  76. var hasOptionalUint32: Bool {return _storage._optionalUint32 != nil}
  77. /// Clears the value of `optionalUint32`. Subsequent reads from it will return its default value.
  78. mutating func clearOptionalUint32() {_uniqueStorage()._optionalUint32 = nil}
  79. var optionalUint64: UInt64 {
  80. get {return _storage._optionalUint64 ?? 0}
  81. set {_uniqueStorage()._optionalUint64 = newValue}
  82. }
  83. /// Returns true if `optionalUint64` has been explicitly set.
  84. var hasOptionalUint64: Bool {return _storage._optionalUint64 != nil}
  85. /// Clears the value of `optionalUint64`. Subsequent reads from it will return its default value.
  86. mutating func clearOptionalUint64() {_uniqueStorage()._optionalUint64 = nil}
  87. var optionalSint32: Int32 {
  88. get {return _storage._optionalSint32 ?? 0}
  89. set {_uniqueStorage()._optionalSint32 = newValue}
  90. }
  91. /// Returns true if `optionalSint32` has been explicitly set.
  92. var hasOptionalSint32: Bool {return _storage._optionalSint32 != nil}
  93. /// Clears the value of `optionalSint32`. Subsequent reads from it will return its default value.
  94. mutating func clearOptionalSint32() {_uniqueStorage()._optionalSint32 = nil}
  95. var optionalSint64: Int64 {
  96. get {return _storage._optionalSint64 ?? 0}
  97. set {_uniqueStorage()._optionalSint64 = newValue}
  98. }
  99. /// Returns true if `optionalSint64` has been explicitly set.
  100. var hasOptionalSint64: Bool {return _storage._optionalSint64 != nil}
  101. /// Clears the value of `optionalSint64`. Subsequent reads from it will return its default value.
  102. mutating func clearOptionalSint64() {_uniqueStorage()._optionalSint64 = nil}
  103. var optionalFixed32: UInt32 {
  104. get {return _storage._optionalFixed32 ?? 0}
  105. set {_uniqueStorage()._optionalFixed32 = newValue}
  106. }
  107. /// Returns true if `optionalFixed32` has been explicitly set.
  108. var hasOptionalFixed32: Bool {return _storage._optionalFixed32 != nil}
  109. /// Clears the value of `optionalFixed32`. Subsequent reads from it will return its default value.
  110. mutating func clearOptionalFixed32() {_uniqueStorage()._optionalFixed32 = nil}
  111. var optionalFixed64: UInt64 {
  112. get {return _storage._optionalFixed64 ?? 0}
  113. set {_uniqueStorage()._optionalFixed64 = newValue}
  114. }
  115. /// Returns true if `optionalFixed64` has been explicitly set.
  116. var hasOptionalFixed64: Bool {return _storage._optionalFixed64 != nil}
  117. /// Clears the value of `optionalFixed64`. Subsequent reads from it will return its default value.
  118. mutating func clearOptionalFixed64() {_uniqueStorage()._optionalFixed64 = nil}
  119. var optionalSfixed32: Int32 {
  120. get {return _storage._optionalSfixed32 ?? 0}
  121. set {_uniqueStorage()._optionalSfixed32 = newValue}
  122. }
  123. /// Returns true if `optionalSfixed32` has been explicitly set.
  124. var hasOptionalSfixed32: Bool {return _storage._optionalSfixed32 != nil}
  125. /// Clears the value of `optionalSfixed32`. Subsequent reads from it will return its default value.
  126. mutating func clearOptionalSfixed32() {_uniqueStorage()._optionalSfixed32 = nil}
  127. var optionalSfixed64: Int64 {
  128. get {return _storage._optionalSfixed64 ?? 0}
  129. set {_uniqueStorage()._optionalSfixed64 = newValue}
  130. }
  131. /// Returns true if `optionalSfixed64` has been explicitly set.
  132. var hasOptionalSfixed64: Bool {return _storage._optionalSfixed64 != nil}
  133. /// Clears the value of `optionalSfixed64`. Subsequent reads from it will return its default value.
  134. mutating func clearOptionalSfixed64() {_uniqueStorage()._optionalSfixed64 = nil}
  135. var optionalFloat: Float {
  136. get {return _storage._optionalFloat ?? 0}
  137. set {_uniqueStorage()._optionalFloat = newValue}
  138. }
  139. /// Returns true if `optionalFloat` has been explicitly set.
  140. var hasOptionalFloat: Bool {return _storage._optionalFloat != nil}
  141. /// Clears the value of `optionalFloat`. Subsequent reads from it will return its default value.
  142. mutating func clearOptionalFloat() {_uniqueStorage()._optionalFloat = nil}
  143. var optionalDouble: Double {
  144. get {return _storage._optionalDouble ?? 0}
  145. set {_uniqueStorage()._optionalDouble = newValue}
  146. }
  147. /// Returns true if `optionalDouble` has been explicitly set.
  148. var hasOptionalDouble: Bool {return _storage._optionalDouble != nil}
  149. /// Clears the value of `optionalDouble`. Subsequent reads from it will return its default value.
  150. mutating func clearOptionalDouble() {_uniqueStorage()._optionalDouble = nil}
  151. var optionalBool: Bool {
  152. get {return _storage._optionalBool ?? false}
  153. set {_uniqueStorage()._optionalBool = newValue}
  154. }
  155. /// Returns true if `optionalBool` has been explicitly set.
  156. var hasOptionalBool: Bool {return _storage._optionalBool != nil}
  157. /// Clears the value of `optionalBool`. Subsequent reads from it will return its default value.
  158. mutating func clearOptionalBool() {_uniqueStorage()._optionalBool = nil}
  159. var optionalString: String {
  160. get {return _storage._optionalString ?? String()}
  161. set {_uniqueStorage()._optionalString = newValue}
  162. }
  163. /// Returns true if `optionalString` has been explicitly set.
  164. var hasOptionalString: Bool {return _storage._optionalString != nil}
  165. /// Clears the value of `optionalString`. Subsequent reads from it will return its default value.
  166. mutating func clearOptionalString() {_uniqueStorage()._optionalString = nil}
  167. var optionalBytes: Data {
  168. get {return _storage._optionalBytes ?? Data()}
  169. set {_uniqueStorage()._optionalBytes = newValue}
  170. }
  171. /// Returns true if `optionalBytes` has been explicitly set.
  172. var hasOptionalBytes: Bool {return _storage._optionalBytes != nil}
  173. /// Clears the value of `optionalBytes`. Subsequent reads from it will return its default value.
  174. mutating func clearOptionalBytes() {_uniqueStorage()._optionalBytes = nil}
  175. var optionalCord: String {
  176. get {return _storage._optionalCord ?? String()}
  177. set {_uniqueStorage()._optionalCord = newValue}
  178. }
  179. /// Returns true if `optionalCord` has been explicitly set.
  180. var hasOptionalCord: Bool {return _storage._optionalCord != nil}
  181. /// Clears the value of `optionalCord`. Subsequent reads from it will return its default value.
  182. mutating func clearOptionalCord() {_uniqueStorage()._optionalCord = nil}
  183. var optionalNestedMessage: SwiftProtoTesting_TestProto3Optional.NestedMessage {
  184. get {return _storage._optionalNestedMessage ?? SwiftProtoTesting_TestProto3Optional.NestedMessage()}
  185. set {_uniqueStorage()._optionalNestedMessage = newValue}
  186. }
  187. /// Returns true if `optionalNestedMessage` has been explicitly set.
  188. var hasOptionalNestedMessage: Bool {return _storage._optionalNestedMessage != nil}
  189. /// Clears the value of `optionalNestedMessage`. Subsequent reads from it will return its default value.
  190. mutating func clearOptionalNestedMessage() {_uniqueStorage()._optionalNestedMessage = nil}
  191. var lazyNestedMessage: SwiftProtoTesting_TestProto3Optional.NestedMessage {
  192. get {return _storage._lazyNestedMessage ?? SwiftProtoTesting_TestProto3Optional.NestedMessage()}
  193. set {_uniqueStorage()._lazyNestedMessage = newValue}
  194. }
  195. /// Returns true if `lazyNestedMessage` has been explicitly set.
  196. var hasLazyNestedMessage: Bool {return _storage._lazyNestedMessage != nil}
  197. /// Clears the value of `lazyNestedMessage`. Subsequent reads from it will return its default value.
  198. mutating func clearLazyNestedMessage() {_uniqueStorage()._lazyNestedMessage = nil}
  199. var optionalNestedEnum: SwiftProtoTesting_TestProto3Optional.NestedEnum {
  200. get {return _storage._optionalNestedEnum ?? .unspecified}
  201. set {_uniqueStorage()._optionalNestedEnum = newValue}
  202. }
  203. /// Returns true if `optionalNestedEnum` has been explicitly set.
  204. var hasOptionalNestedEnum: Bool {return _storage._optionalNestedEnum != nil}
  205. /// Clears the value of `optionalNestedEnum`. Subsequent reads from it will return its default value.
  206. mutating func clearOptionalNestedEnum() {_uniqueStorage()._optionalNestedEnum = nil}
  207. /// Add some non-optional fields to verify we can mix them.
  208. var singularInt32: Int32 {
  209. get {return _storage._singularInt32}
  210. set {_uniqueStorage()._singularInt32 = newValue}
  211. }
  212. var singularInt64: Int64 {
  213. get {return _storage._singularInt64}
  214. set {_uniqueStorage()._singularInt64 = newValue}
  215. }
  216. var unknownFields = SwiftProtobuf.UnknownStorage()
  217. enum NestedEnum: SwiftProtobuf.Enum, Swift.CaseIterable {
  218. typealias RawValue = Int
  219. case unspecified // = 0
  220. case foo // = 1
  221. case bar // = 2
  222. case baz // = 3
  223. /// Intentionally negative.
  224. case neg // = -1
  225. case UNRECOGNIZED(Int)
  226. init() {
  227. self = .unspecified
  228. }
  229. init?(rawValue: Int) {
  230. switch rawValue {
  231. case -1: self = .neg
  232. case 0: self = .unspecified
  233. case 1: self = .foo
  234. case 2: self = .bar
  235. case 3: self = .baz
  236. default: self = .UNRECOGNIZED(rawValue)
  237. }
  238. }
  239. var rawValue: Int {
  240. switch self {
  241. case .neg: return -1
  242. case .unspecified: return 0
  243. case .foo: return 1
  244. case .bar: return 2
  245. case .baz: return 3
  246. case .UNRECOGNIZED(let i): return i
  247. }
  248. }
  249. // The compiler won't synthesize support with the UNRECOGNIZED case.
  250. static let allCases: [SwiftProtoTesting_TestProto3Optional.NestedEnum] = [
  251. .unspecified,
  252. .foo,
  253. .bar,
  254. .baz,
  255. .neg,
  256. ]
  257. }
  258. struct NestedMessage: Sendable {
  259. // SwiftProtobuf.Message conformance is added in an extension below. See the
  260. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  261. // methods supported on all messages.
  262. /// The field name "b" fails to compile in proto1 because it conflicts with
  263. /// a local variable named "b" in one of the generated methods. Doh.
  264. /// This file needs to compile in proto1 to test backwards-compatibility.
  265. var bb: Int32 {
  266. get {return _bb ?? 0}
  267. set {_bb = newValue}
  268. }
  269. /// Returns true if `bb` has been explicitly set.
  270. var hasBb: Bool {return self._bb != nil}
  271. /// Clears the value of `bb`. Subsequent reads from it will return its default value.
  272. mutating func clearBb() {self._bb = nil}
  273. var unknownFields = SwiftProtobuf.UnknownStorage()
  274. init() {}
  275. fileprivate var _bb: Int32? = nil
  276. }
  277. init() {}
  278. fileprivate var _storage = _StorageClass.defaultInstance
  279. }
  280. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  281. fileprivate let _protobuf_package = "swift_proto_testing"
  282. extension SwiftProtoTesting_TestProto3Optional: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  283. static let protoMessageName: String = _protobuf_package + ".TestProto3Optional"
  284. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  285. 1: .standard(proto: "optional_int32"),
  286. 2: .standard(proto: "optional_int64"),
  287. 3: .standard(proto: "optional_uint32"),
  288. 4: .standard(proto: "optional_uint64"),
  289. 5: .standard(proto: "optional_sint32"),
  290. 6: .standard(proto: "optional_sint64"),
  291. 7: .standard(proto: "optional_fixed32"),
  292. 8: .standard(proto: "optional_fixed64"),
  293. 9: .standard(proto: "optional_sfixed32"),
  294. 10: .standard(proto: "optional_sfixed64"),
  295. 11: .standard(proto: "optional_float"),
  296. 12: .standard(proto: "optional_double"),
  297. 13: .standard(proto: "optional_bool"),
  298. 14: .standard(proto: "optional_string"),
  299. 15: .standard(proto: "optional_bytes"),
  300. 16: .standard(proto: "optional_cord"),
  301. 18: .standard(proto: "optional_nested_message"),
  302. 19: .standard(proto: "lazy_nested_message"),
  303. 21: .standard(proto: "optional_nested_enum"),
  304. 22: .standard(proto: "singular_int32"),
  305. 23: .standard(proto: "singular_int64"),
  306. ]
  307. fileprivate class _StorageClass {
  308. var _optionalInt32: Int32? = nil
  309. var _optionalInt64: Int64? = nil
  310. var _optionalUint32: UInt32? = nil
  311. var _optionalUint64: UInt64? = nil
  312. var _optionalSint32: Int32? = nil
  313. var _optionalSint64: Int64? = nil
  314. var _optionalFixed32: UInt32? = nil
  315. var _optionalFixed64: UInt64? = nil
  316. var _optionalSfixed32: Int32? = nil
  317. var _optionalSfixed64: Int64? = nil
  318. var _optionalFloat: Float? = nil
  319. var _optionalDouble: Double? = nil
  320. var _optionalBool: Bool? = nil
  321. var _optionalString: String? = nil
  322. var _optionalBytes: Data? = nil
  323. var _optionalCord: String? = nil
  324. var _optionalNestedMessage: SwiftProtoTesting_TestProto3Optional.NestedMessage? = nil
  325. var _lazyNestedMessage: SwiftProtoTesting_TestProto3Optional.NestedMessage? = nil
  326. var _optionalNestedEnum: SwiftProtoTesting_TestProto3Optional.NestedEnum? = nil
  327. var _singularInt32: Int32 = 0
  328. var _singularInt64: Int64 = 0
  329. // This property is used as the initial default value for new instances of the type.
  330. // The type itself is protecting the reference to its storage via CoW semantics.
  331. // This will force a copy to be made of this reference when the first mutation occurs;
  332. // hence, it is safe to mark this as `nonisolated(unsafe)`.
  333. static nonisolated(unsafe) let defaultInstance = _StorageClass()
  334. private init() {}
  335. init(copying source: _StorageClass) {
  336. _optionalInt32 = source._optionalInt32
  337. _optionalInt64 = source._optionalInt64
  338. _optionalUint32 = source._optionalUint32
  339. _optionalUint64 = source._optionalUint64
  340. _optionalSint32 = source._optionalSint32
  341. _optionalSint64 = source._optionalSint64
  342. _optionalFixed32 = source._optionalFixed32
  343. _optionalFixed64 = source._optionalFixed64
  344. _optionalSfixed32 = source._optionalSfixed32
  345. _optionalSfixed64 = source._optionalSfixed64
  346. _optionalFloat = source._optionalFloat
  347. _optionalDouble = source._optionalDouble
  348. _optionalBool = source._optionalBool
  349. _optionalString = source._optionalString
  350. _optionalBytes = source._optionalBytes
  351. _optionalCord = source._optionalCord
  352. _optionalNestedMessage = source._optionalNestedMessage
  353. _lazyNestedMessage = source._lazyNestedMessage
  354. _optionalNestedEnum = source._optionalNestedEnum
  355. _singularInt32 = source._singularInt32
  356. _singularInt64 = source._singularInt64
  357. }
  358. }
  359. fileprivate mutating func _uniqueStorage() -> _StorageClass {
  360. if !isKnownUniquelyReferenced(&_storage) {
  361. _storage = _StorageClass(copying: _storage)
  362. }
  363. return _storage
  364. }
  365. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  366. _ = _uniqueStorage()
  367. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  368. while let fieldNumber = try decoder.nextFieldNumber() {
  369. // The use of inline closures is to circumvent an issue where the compiler
  370. // allocates stack space for every case branch when no optimizations are
  371. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  372. switch fieldNumber {
  373. case 1: try { try decoder.decodeSingularInt32Field(value: &_storage._optionalInt32) }()
  374. case 2: try { try decoder.decodeSingularInt64Field(value: &_storage._optionalInt64) }()
  375. case 3: try { try decoder.decodeSingularUInt32Field(value: &_storage._optionalUint32) }()
  376. case 4: try { try decoder.decodeSingularUInt64Field(value: &_storage._optionalUint64) }()
  377. case 5: try { try decoder.decodeSingularSInt32Field(value: &_storage._optionalSint32) }()
  378. case 6: try { try decoder.decodeSingularSInt64Field(value: &_storage._optionalSint64) }()
  379. case 7: try { try decoder.decodeSingularFixed32Field(value: &_storage._optionalFixed32) }()
  380. case 8: try { try decoder.decodeSingularFixed64Field(value: &_storage._optionalFixed64) }()
  381. case 9: try { try decoder.decodeSingularSFixed32Field(value: &_storage._optionalSfixed32) }()
  382. case 10: try { try decoder.decodeSingularSFixed64Field(value: &_storage._optionalSfixed64) }()
  383. case 11: try { try decoder.decodeSingularFloatField(value: &_storage._optionalFloat) }()
  384. case 12: try { try decoder.decodeSingularDoubleField(value: &_storage._optionalDouble) }()
  385. case 13: try { try decoder.decodeSingularBoolField(value: &_storage._optionalBool) }()
  386. case 14: try { try decoder.decodeSingularStringField(value: &_storage._optionalString) }()
  387. case 15: try { try decoder.decodeSingularBytesField(value: &_storage._optionalBytes) }()
  388. case 16: try { try decoder.decodeSingularStringField(value: &_storage._optionalCord) }()
  389. case 18: try { try decoder.decodeSingularMessageField(value: &_storage._optionalNestedMessage) }()
  390. case 19: try { try decoder.decodeSingularMessageField(value: &_storage._lazyNestedMessage) }()
  391. case 21: try { try decoder.decodeSingularEnumField(value: &_storage._optionalNestedEnum) }()
  392. case 22: try { try decoder.decodeSingularInt32Field(value: &_storage._singularInt32) }()
  393. case 23: try { try decoder.decodeSingularInt64Field(value: &_storage._singularInt64) }()
  394. default: break
  395. }
  396. }
  397. }
  398. }
  399. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  400. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  401. // The use of inline closures is to circumvent an issue where the compiler
  402. // allocates stack space for every if/case branch local when no optimizations
  403. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  404. // https://github.com/apple/swift-protobuf/issues/1182
  405. try { if let v = _storage._optionalInt32 {
  406. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  407. } }()
  408. try { if let v = _storage._optionalInt64 {
  409. try visitor.visitSingularInt64Field(value: v, fieldNumber: 2)
  410. } }()
  411. try { if let v = _storage._optionalUint32 {
  412. try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
  413. } }()
  414. try { if let v = _storage._optionalUint64 {
  415. try visitor.visitSingularUInt64Field(value: v, fieldNumber: 4)
  416. } }()
  417. try { if let v = _storage._optionalSint32 {
  418. try visitor.visitSingularSInt32Field(value: v, fieldNumber: 5)
  419. } }()
  420. try { if let v = _storage._optionalSint64 {
  421. try visitor.visitSingularSInt64Field(value: v, fieldNumber: 6)
  422. } }()
  423. try { if let v = _storage._optionalFixed32 {
  424. try visitor.visitSingularFixed32Field(value: v, fieldNumber: 7)
  425. } }()
  426. try { if let v = _storage._optionalFixed64 {
  427. try visitor.visitSingularFixed64Field(value: v, fieldNumber: 8)
  428. } }()
  429. try { if let v = _storage._optionalSfixed32 {
  430. try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 9)
  431. } }()
  432. try { if let v = _storage._optionalSfixed64 {
  433. try visitor.visitSingularSFixed64Field(value: v, fieldNumber: 10)
  434. } }()
  435. try { if let v = _storage._optionalFloat {
  436. try visitor.visitSingularFloatField(value: v, fieldNumber: 11)
  437. } }()
  438. try { if let v = _storage._optionalDouble {
  439. try visitor.visitSingularDoubleField(value: v, fieldNumber: 12)
  440. } }()
  441. try { if let v = _storage._optionalBool {
  442. try visitor.visitSingularBoolField(value: v, fieldNumber: 13)
  443. } }()
  444. try { if let v = _storage._optionalString {
  445. try visitor.visitSingularStringField(value: v, fieldNumber: 14)
  446. } }()
  447. try { if let v = _storage._optionalBytes {
  448. try visitor.visitSingularBytesField(value: v, fieldNumber: 15)
  449. } }()
  450. try { if let v = _storage._optionalCord {
  451. try visitor.visitSingularStringField(value: v, fieldNumber: 16)
  452. } }()
  453. try { if let v = _storage._optionalNestedMessage {
  454. try visitor.visitSingularMessageField(value: v, fieldNumber: 18)
  455. } }()
  456. try { if let v = _storage._lazyNestedMessage {
  457. try visitor.visitSingularMessageField(value: v, fieldNumber: 19)
  458. } }()
  459. try { if let v = _storage._optionalNestedEnum {
  460. try visitor.visitSingularEnumField(value: v, fieldNumber: 21)
  461. } }()
  462. if _storage._singularInt32 != 0 {
  463. try visitor.visitSingularInt32Field(value: _storage._singularInt32, fieldNumber: 22)
  464. }
  465. if _storage._singularInt64 != 0 {
  466. try visitor.visitSingularInt64Field(value: _storage._singularInt64, fieldNumber: 23)
  467. }
  468. }
  469. try unknownFields.traverse(visitor: &visitor)
  470. }
  471. static func ==(lhs: SwiftProtoTesting_TestProto3Optional, rhs: SwiftProtoTesting_TestProto3Optional) -> Bool {
  472. if lhs._storage !== rhs._storage {
  473. let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
  474. let _storage = _args.0
  475. let rhs_storage = _args.1
  476. if _storage._optionalInt32 != rhs_storage._optionalInt32 {return false}
  477. if _storage._optionalInt64 != rhs_storage._optionalInt64 {return false}
  478. if _storage._optionalUint32 != rhs_storage._optionalUint32 {return false}
  479. if _storage._optionalUint64 != rhs_storage._optionalUint64 {return false}
  480. if _storage._optionalSint32 != rhs_storage._optionalSint32 {return false}
  481. if _storage._optionalSint64 != rhs_storage._optionalSint64 {return false}
  482. if _storage._optionalFixed32 != rhs_storage._optionalFixed32 {return false}
  483. if _storage._optionalFixed64 != rhs_storage._optionalFixed64 {return false}
  484. if _storage._optionalSfixed32 != rhs_storage._optionalSfixed32 {return false}
  485. if _storage._optionalSfixed64 != rhs_storage._optionalSfixed64 {return false}
  486. if _storage._optionalFloat != rhs_storage._optionalFloat {return false}
  487. if _storage._optionalDouble != rhs_storage._optionalDouble {return false}
  488. if _storage._optionalBool != rhs_storage._optionalBool {return false}
  489. if _storage._optionalString != rhs_storage._optionalString {return false}
  490. if _storage._optionalBytes != rhs_storage._optionalBytes {return false}
  491. if _storage._optionalCord != rhs_storage._optionalCord {return false}
  492. if _storage._optionalNestedMessage != rhs_storage._optionalNestedMessage {return false}
  493. if _storage._lazyNestedMessage != rhs_storage._lazyNestedMessage {return false}
  494. if _storage._optionalNestedEnum != rhs_storage._optionalNestedEnum {return false}
  495. if _storage._singularInt32 != rhs_storage._singularInt32 {return false}
  496. if _storage._singularInt64 != rhs_storage._singularInt64 {return false}
  497. return true
  498. }
  499. if !storagesAreEqual {return false}
  500. }
  501. if lhs.unknownFields != rhs.unknownFields {return false}
  502. return true
  503. }
  504. }
  505. extension SwiftProtoTesting_TestProto3Optional.NestedEnum: SwiftProtobuf._ProtoNameProviding {
  506. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  507. -1: .same(proto: "NEG"),
  508. 0: .same(proto: "UNSPECIFIED"),
  509. 1: .same(proto: "FOO"),
  510. 2: .same(proto: "BAR"),
  511. 3: .same(proto: "BAZ"),
  512. ]
  513. }
  514. extension SwiftProtoTesting_TestProto3Optional.NestedMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  515. static let protoMessageName: String = SwiftProtoTesting_TestProto3Optional.protoMessageName + ".NestedMessage"
  516. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  517. 1: .same(proto: "bb"),
  518. ]
  519. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  520. while let fieldNumber = try decoder.nextFieldNumber() {
  521. // The use of inline closures is to circumvent an issue where the compiler
  522. // allocates stack space for every case branch when no optimizations are
  523. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  524. switch fieldNumber {
  525. case 1: try { try decoder.decodeSingularInt32Field(value: &self._bb) }()
  526. default: break
  527. }
  528. }
  529. }
  530. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  531. // The use of inline closures is to circumvent an issue where the compiler
  532. // allocates stack space for every if/case branch local when no optimizations
  533. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  534. // https://github.com/apple/swift-protobuf/issues/1182
  535. try { if let v = self._bb {
  536. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  537. } }()
  538. try unknownFields.traverse(visitor: &visitor)
  539. }
  540. static func ==(lhs: SwiftProtoTesting_TestProto3Optional.NestedMessage, rhs: SwiftProtoTesting_TestProto3Optional.NestedMessage) -> Bool {
  541. if lhs._bb != rhs._bb {return false}
  542. if lhs.unknownFields != rhs.unknownFields {return false}
  543. return true
  544. }
  545. }