unittest_proto3_optional.pb.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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 {_storage._optionalInt32 ?? 0}
  57. set {_uniqueStorage()._optionalInt32 = newValue}
  58. }
  59. /// Returns true if `optionalInt32` has been explicitly set.
  60. var hasOptionalInt32: Bool {_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 {_storage._optionalInt64 ?? 0}
  65. set {_uniqueStorage()._optionalInt64 = newValue}
  66. }
  67. /// Returns true if `optionalInt64` has been explicitly set.
  68. var hasOptionalInt64: Bool {_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 {_storage._optionalUint32 ?? 0}
  73. set {_uniqueStorage()._optionalUint32 = newValue}
  74. }
  75. /// Returns true if `optionalUint32` has been explicitly set.
  76. var hasOptionalUint32: Bool {_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 {_storage._optionalUint64 ?? 0}
  81. set {_uniqueStorage()._optionalUint64 = newValue}
  82. }
  83. /// Returns true if `optionalUint64` has been explicitly set.
  84. var hasOptionalUint64: Bool {_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 {_storage._optionalSint32 ?? 0}
  89. set {_uniqueStorage()._optionalSint32 = newValue}
  90. }
  91. /// Returns true if `optionalSint32` has been explicitly set.
  92. var hasOptionalSint32: Bool {_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 {_storage._optionalSint64 ?? 0}
  97. set {_uniqueStorage()._optionalSint64 = newValue}
  98. }
  99. /// Returns true if `optionalSint64` has been explicitly set.
  100. var hasOptionalSint64: Bool {_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 {_storage._optionalFixed32 ?? 0}
  105. set {_uniqueStorage()._optionalFixed32 = newValue}
  106. }
  107. /// Returns true if `optionalFixed32` has been explicitly set.
  108. var hasOptionalFixed32: Bool {_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 {_storage._optionalFixed64 ?? 0}
  113. set {_uniqueStorage()._optionalFixed64 = newValue}
  114. }
  115. /// Returns true if `optionalFixed64` has been explicitly set.
  116. var hasOptionalFixed64: Bool {_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 {_storage._optionalSfixed32 ?? 0}
  121. set {_uniqueStorage()._optionalSfixed32 = newValue}
  122. }
  123. /// Returns true if `optionalSfixed32` has been explicitly set.
  124. var hasOptionalSfixed32: Bool {_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 {_storage._optionalSfixed64 ?? 0}
  129. set {_uniqueStorage()._optionalSfixed64 = newValue}
  130. }
  131. /// Returns true if `optionalSfixed64` has been explicitly set.
  132. var hasOptionalSfixed64: Bool {_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 {_storage._optionalFloat ?? 0}
  137. set {_uniqueStorage()._optionalFloat = newValue}
  138. }
  139. /// Returns true if `optionalFloat` has been explicitly set.
  140. var hasOptionalFloat: Bool {_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 {_storage._optionalDouble ?? 0}
  145. set {_uniqueStorage()._optionalDouble = newValue}
  146. }
  147. /// Returns true if `optionalDouble` has been explicitly set.
  148. var hasOptionalDouble: Bool {_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 {_storage._optionalBool ?? false}
  153. set {_uniqueStorage()._optionalBool = newValue}
  154. }
  155. /// Returns true if `optionalBool` has been explicitly set.
  156. var hasOptionalBool: Bool {_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 {_storage._optionalString ?? String()}
  161. set {_uniqueStorage()._optionalString = newValue}
  162. }
  163. /// Returns true if `optionalString` has been explicitly set.
  164. var hasOptionalString: Bool {_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 {_storage._optionalBytes ?? Data()}
  169. set {_uniqueStorage()._optionalBytes = newValue}
  170. }
  171. /// Returns true if `optionalBytes` has been explicitly set.
  172. var hasOptionalBytes: Bool {_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 optionalNestedMessage: SwiftProtoTesting_TestProto3Optional.NestedMessage {
  176. get {_storage._optionalNestedMessage ?? SwiftProtoTesting_TestProto3Optional.NestedMessage()}
  177. set {_uniqueStorage()._optionalNestedMessage = newValue}
  178. }
  179. /// Returns true if `optionalNestedMessage` has been explicitly set.
  180. var hasOptionalNestedMessage: Bool {_storage._optionalNestedMessage != nil}
  181. /// Clears the value of `optionalNestedMessage`. Subsequent reads from it will return its default value.
  182. mutating func clearOptionalNestedMessage() {_uniqueStorage()._optionalNestedMessage = nil}
  183. var optionalNestedEnum: SwiftProtoTesting_TestProto3Optional.NestedEnum {
  184. get {_storage._optionalNestedEnum ?? .unspecified}
  185. set {_uniqueStorage()._optionalNestedEnum = newValue}
  186. }
  187. /// Returns true if `optionalNestedEnum` has been explicitly set.
  188. var hasOptionalNestedEnum: Bool {_storage._optionalNestedEnum != nil}
  189. /// Clears the value of `optionalNestedEnum`. Subsequent reads from it will return its default value.
  190. mutating func clearOptionalNestedEnum() {_uniqueStorage()._optionalNestedEnum = nil}
  191. /// Add some non-optional fields to verify we can mix them.
  192. var singularInt32: Int32 {
  193. get {_storage._singularInt32}
  194. set {_uniqueStorage()._singularInt32 = newValue}
  195. }
  196. var singularInt64: Int64 {
  197. get {_storage._singularInt64}
  198. set {_uniqueStorage()._singularInt64 = newValue}
  199. }
  200. var unknownFields = SwiftProtobuf.UnknownStorage()
  201. enum NestedEnum: SwiftProtobuf.Enum, Swift.CaseIterable {
  202. typealias RawValue = Int
  203. case unspecified // = 0
  204. case foo // = 1
  205. case bar // = 2
  206. case baz // = 3
  207. /// Intentionally negative.
  208. case neg // = -1
  209. case UNRECOGNIZED(Int)
  210. init() {
  211. self = .unspecified
  212. }
  213. init?(rawValue: Int) {
  214. switch rawValue {
  215. case -1: self = .neg
  216. case 0: self = .unspecified
  217. case 1: self = .foo
  218. case 2: self = .bar
  219. case 3: self = .baz
  220. default: self = .UNRECOGNIZED(rawValue)
  221. }
  222. }
  223. var rawValue: Int {
  224. switch self {
  225. case .neg: return -1
  226. case .unspecified: return 0
  227. case .foo: return 1
  228. case .bar: return 2
  229. case .baz: return 3
  230. case .UNRECOGNIZED(let i): return i
  231. }
  232. }
  233. // The compiler won't synthesize support with the UNRECOGNIZED case.
  234. static let allCases: [SwiftProtoTesting_TestProto3Optional.NestedEnum] = [
  235. .unspecified,
  236. .foo,
  237. .bar,
  238. .baz,
  239. .neg,
  240. ]
  241. }
  242. struct NestedMessage: Sendable {
  243. // SwiftProtobuf.Message conformance is added in an extension below. See the
  244. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  245. // methods supported on all messages.
  246. /// The field name "b" fails to compile in proto1 because it conflicts with
  247. /// a local variable named "b" in one of the generated methods. Doh.
  248. /// This file needs to compile in proto1 to test backwards-compatibility.
  249. var bb: Int32 {
  250. get {_bb ?? 0}
  251. set {_bb = newValue}
  252. }
  253. /// Returns true if `bb` has been explicitly set.
  254. var hasBb: Bool {self._bb != nil}
  255. /// Clears the value of `bb`. Subsequent reads from it will return its default value.
  256. mutating func clearBb() {self._bb = nil}
  257. var unknownFields = SwiftProtobuf.UnknownStorage()
  258. init() {}
  259. fileprivate var _bb: Int32? = nil
  260. }
  261. init() {}
  262. fileprivate var _storage = _StorageClass.defaultInstance
  263. }
  264. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  265. fileprivate let _protobuf_package = "swift_proto_testing"
  266. extension SwiftProtoTesting_TestProto3Optional: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  267. static let protoMessageName: String = _protobuf_package + ".TestProto3Optional"
  268. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}optional_int32\0\u{3}optional_int64\0\u{3}optional_uint32\0\u{3}optional_uint64\0\u{3}optional_sint32\0\u{3}optional_sint64\0\u{3}optional_fixed32\0\u{3}optional_fixed64\0\u{3}optional_sfixed32\0\u{3}optional_sfixed64\0\u{3}optional_float\0\u{3}optional_double\0\u{3}optional_bool\0\u{3}optional_string\0\u{3}optional_bytes\0\u{4}\u{3}optional_nested_message\0\u{4}\u{3}optional_nested_enum\0\u{3}singular_int32\0\u{3}singular_int64\0")
  269. fileprivate class _StorageClass {
  270. var _optionalInt32: Int32? = nil
  271. var _optionalInt64: Int64? = nil
  272. var _optionalUint32: UInt32? = nil
  273. var _optionalUint64: UInt64? = nil
  274. var _optionalSint32: Int32? = nil
  275. var _optionalSint64: Int64? = nil
  276. var _optionalFixed32: UInt32? = nil
  277. var _optionalFixed64: UInt64? = nil
  278. var _optionalSfixed32: Int32? = nil
  279. var _optionalSfixed64: Int64? = nil
  280. var _optionalFloat: Float? = nil
  281. var _optionalDouble: Double? = nil
  282. var _optionalBool: Bool? = nil
  283. var _optionalString: String? = nil
  284. var _optionalBytes: Data? = nil
  285. var _optionalNestedMessage: SwiftProtoTesting_TestProto3Optional.NestedMessage? = nil
  286. var _optionalNestedEnum: SwiftProtoTesting_TestProto3Optional.NestedEnum? = nil
  287. var _singularInt32: Int32 = 0
  288. var _singularInt64: Int64 = 0
  289. // This property is used as the initial default value for new instances of the type.
  290. // The type itself is protecting the reference to its storage via CoW semantics.
  291. // This will force a copy to be made of this reference when the first mutation occurs;
  292. // hence, it is safe to mark this as `nonisolated(unsafe)`.
  293. static nonisolated(unsafe) let defaultInstance = _StorageClass()
  294. private init() {}
  295. init(copying source: _StorageClass) {
  296. _optionalInt32 = source._optionalInt32
  297. _optionalInt64 = source._optionalInt64
  298. _optionalUint32 = source._optionalUint32
  299. _optionalUint64 = source._optionalUint64
  300. _optionalSint32 = source._optionalSint32
  301. _optionalSint64 = source._optionalSint64
  302. _optionalFixed32 = source._optionalFixed32
  303. _optionalFixed64 = source._optionalFixed64
  304. _optionalSfixed32 = source._optionalSfixed32
  305. _optionalSfixed64 = source._optionalSfixed64
  306. _optionalFloat = source._optionalFloat
  307. _optionalDouble = source._optionalDouble
  308. _optionalBool = source._optionalBool
  309. _optionalString = source._optionalString
  310. _optionalBytes = source._optionalBytes
  311. _optionalNestedMessage = source._optionalNestedMessage
  312. _optionalNestedEnum = source._optionalNestedEnum
  313. _singularInt32 = source._singularInt32
  314. _singularInt64 = source._singularInt64
  315. }
  316. }
  317. fileprivate mutating func _uniqueStorage() -> _StorageClass {
  318. if !isKnownUniquelyReferenced(&_storage) {
  319. _storage = _StorageClass(copying: _storage)
  320. }
  321. return _storage
  322. }
  323. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  324. _ = _uniqueStorage()
  325. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  326. while let fieldNumber = try decoder.nextFieldNumber() {
  327. // The use of inline closures is to circumvent an issue where the compiler
  328. // allocates stack space for every case branch when no optimizations are
  329. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  330. switch fieldNumber {
  331. case 1: try { try decoder.decodeSingularInt32Field(value: &_storage._optionalInt32) }()
  332. case 2: try { try decoder.decodeSingularInt64Field(value: &_storage._optionalInt64) }()
  333. case 3: try { try decoder.decodeSingularUInt32Field(value: &_storage._optionalUint32) }()
  334. case 4: try { try decoder.decodeSingularUInt64Field(value: &_storage._optionalUint64) }()
  335. case 5: try { try decoder.decodeSingularSInt32Field(value: &_storage._optionalSint32) }()
  336. case 6: try { try decoder.decodeSingularSInt64Field(value: &_storage._optionalSint64) }()
  337. case 7: try { try decoder.decodeSingularFixed32Field(value: &_storage._optionalFixed32) }()
  338. case 8: try { try decoder.decodeSingularFixed64Field(value: &_storage._optionalFixed64) }()
  339. case 9: try { try decoder.decodeSingularSFixed32Field(value: &_storage._optionalSfixed32) }()
  340. case 10: try { try decoder.decodeSingularSFixed64Field(value: &_storage._optionalSfixed64) }()
  341. case 11: try { try decoder.decodeSingularFloatField(value: &_storage._optionalFloat) }()
  342. case 12: try { try decoder.decodeSingularDoubleField(value: &_storage._optionalDouble) }()
  343. case 13: try { try decoder.decodeSingularBoolField(value: &_storage._optionalBool) }()
  344. case 14: try { try decoder.decodeSingularStringField(value: &_storage._optionalString) }()
  345. case 15: try { try decoder.decodeSingularBytesField(value: &_storage._optionalBytes) }()
  346. case 18: try { try decoder.decodeSingularMessageField(value: &_storage._optionalNestedMessage) }()
  347. case 21: try { try decoder.decodeSingularEnumField(value: &_storage._optionalNestedEnum) }()
  348. case 22: try { try decoder.decodeSingularInt32Field(value: &_storage._singularInt32) }()
  349. case 23: try { try decoder.decodeSingularInt64Field(value: &_storage._singularInt64) }()
  350. default: break
  351. }
  352. }
  353. }
  354. }
  355. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  356. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  357. // The use of inline closures is to circumvent an issue where the compiler
  358. // allocates stack space for every if/case branch local when no optimizations
  359. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  360. // https://github.com/apple/swift-protobuf/issues/1182
  361. try { if let v = _storage._optionalInt32 {
  362. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  363. } }()
  364. try { if let v = _storage._optionalInt64 {
  365. try visitor.visitSingularInt64Field(value: v, fieldNumber: 2)
  366. } }()
  367. try { if let v = _storage._optionalUint32 {
  368. try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
  369. } }()
  370. try { if let v = _storage._optionalUint64 {
  371. try visitor.visitSingularUInt64Field(value: v, fieldNumber: 4)
  372. } }()
  373. try { if let v = _storage._optionalSint32 {
  374. try visitor.visitSingularSInt32Field(value: v, fieldNumber: 5)
  375. } }()
  376. try { if let v = _storage._optionalSint64 {
  377. try visitor.visitSingularSInt64Field(value: v, fieldNumber: 6)
  378. } }()
  379. try { if let v = _storage._optionalFixed32 {
  380. try visitor.visitSingularFixed32Field(value: v, fieldNumber: 7)
  381. } }()
  382. try { if let v = _storage._optionalFixed64 {
  383. try visitor.visitSingularFixed64Field(value: v, fieldNumber: 8)
  384. } }()
  385. try { if let v = _storage._optionalSfixed32 {
  386. try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 9)
  387. } }()
  388. try { if let v = _storage._optionalSfixed64 {
  389. try visitor.visitSingularSFixed64Field(value: v, fieldNumber: 10)
  390. } }()
  391. try { if let v = _storage._optionalFloat {
  392. try visitor.visitSingularFloatField(value: v, fieldNumber: 11)
  393. } }()
  394. try { if let v = _storage._optionalDouble {
  395. try visitor.visitSingularDoubleField(value: v, fieldNumber: 12)
  396. } }()
  397. try { if let v = _storage._optionalBool {
  398. try visitor.visitSingularBoolField(value: v, fieldNumber: 13)
  399. } }()
  400. try { if let v = _storage._optionalString {
  401. try visitor.visitSingularStringField(value: v, fieldNumber: 14)
  402. } }()
  403. try { if let v = _storage._optionalBytes {
  404. try visitor.visitSingularBytesField(value: v, fieldNumber: 15)
  405. } }()
  406. try { if let v = _storage._optionalNestedMessage {
  407. try visitor.visitSingularMessageField(value: v, fieldNumber: 18)
  408. } }()
  409. try { if let v = _storage._optionalNestedEnum {
  410. try visitor.visitSingularEnumField(value: v, fieldNumber: 21)
  411. } }()
  412. if _storage._singularInt32 != 0 {
  413. try visitor.visitSingularInt32Field(value: _storage._singularInt32, fieldNumber: 22)
  414. }
  415. if _storage._singularInt64 != 0 {
  416. try visitor.visitSingularInt64Field(value: _storage._singularInt64, fieldNumber: 23)
  417. }
  418. }
  419. try unknownFields.traverse(visitor: &visitor)
  420. }
  421. static func ==(lhs: SwiftProtoTesting_TestProto3Optional, rhs: SwiftProtoTesting_TestProto3Optional) -> Bool {
  422. if lhs._storage !== rhs._storage {
  423. let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
  424. let _storage = _args.0
  425. let rhs_storage = _args.1
  426. if _storage._optionalInt32 != rhs_storage._optionalInt32 {return false}
  427. if _storage._optionalInt64 != rhs_storage._optionalInt64 {return false}
  428. if _storage._optionalUint32 != rhs_storage._optionalUint32 {return false}
  429. if _storage._optionalUint64 != rhs_storage._optionalUint64 {return false}
  430. if _storage._optionalSint32 != rhs_storage._optionalSint32 {return false}
  431. if _storage._optionalSint64 != rhs_storage._optionalSint64 {return false}
  432. if _storage._optionalFixed32 != rhs_storage._optionalFixed32 {return false}
  433. if _storage._optionalFixed64 != rhs_storage._optionalFixed64 {return false}
  434. if _storage._optionalSfixed32 != rhs_storage._optionalSfixed32 {return false}
  435. if _storage._optionalSfixed64 != rhs_storage._optionalSfixed64 {return false}
  436. if _storage._optionalFloat != rhs_storage._optionalFloat {return false}
  437. if _storage._optionalDouble != rhs_storage._optionalDouble {return false}
  438. if _storage._optionalBool != rhs_storage._optionalBool {return false}
  439. if _storage._optionalString != rhs_storage._optionalString {return false}
  440. if _storage._optionalBytes != rhs_storage._optionalBytes {return false}
  441. if _storage._optionalNestedMessage != rhs_storage._optionalNestedMessage {return false}
  442. if _storage._optionalNestedEnum != rhs_storage._optionalNestedEnum {return false}
  443. if _storage._singularInt32 != rhs_storage._singularInt32 {return false}
  444. if _storage._singularInt64 != rhs_storage._singularInt64 {return false}
  445. return true
  446. }
  447. if !storagesAreEqual {return false}
  448. }
  449. if lhs.unknownFields != rhs.unknownFields {return false}
  450. return true
  451. }
  452. }
  453. extension SwiftProtoTesting_TestProto3Optional.NestedEnum: SwiftProtobuf._ProtoNameProviding {
  454. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\u{7f}\u{7f}\u{7f}\u{7f}\u{7f}\u{3}NEG\0\u{1}UNSPECIFIED\0\u{1}FOO\0\u{1}BAR\0\u{1}BAZ\0")
  455. }
  456. extension SwiftProtoTesting_TestProto3Optional.NestedMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  457. static let protoMessageName: String = SwiftProtoTesting_TestProto3Optional.protoMessageName + ".NestedMessage"
  458. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}bb\0")
  459. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  460. while let fieldNumber = try decoder.nextFieldNumber() {
  461. // The use of inline closures is to circumvent an issue where the compiler
  462. // allocates stack space for every case branch when no optimizations are
  463. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  464. switch fieldNumber {
  465. case 1: try { try decoder.decodeSingularInt32Field(value: &self._bb) }()
  466. default: break
  467. }
  468. }
  469. }
  470. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  471. // The use of inline closures is to circumvent an issue where the compiler
  472. // allocates stack space for every if/case branch local when no optimizations
  473. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  474. // https://github.com/apple/swift-protobuf/issues/1182
  475. try { if let v = self._bb {
  476. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  477. } }()
  478. try unknownFields.traverse(visitor: &visitor)
  479. }
  480. static func ==(lhs: SwiftProtoTesting_TestProto3Optional.NestedMessage, rhs: SwiftProtoTesting_TestProto3Optional.NestedMessage) -> Bool {
  481. if lhs._bb != rhs._bb {return false}
  482. if lhs.unknownFields != rhs.unknownFields {return false}
  483. return true
  484. }
  485. }