unittest_proto3_optional.pb.swift 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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/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. //
  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 Foundation
  17. import SwiftProtobuf
  18. // If the compiler emits an error on this type, it is because this file
  19. // was generated by a version of the `protoc` Swift plug-in that is
  20. // incompatible with the version of SwiftProtobuf to which you are linking.
  21. // Please ensure that you are building against the same version of the API
  22. // that was used to generate this file.
  23. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  24. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  25. typealias Version = _2
  26. }
  27. struct Proto2Unittest_TestProto3Optional: @unchecked Sendable {
  28. // SwiftProtobuf.Message conformance is added in an extension below. See the
  29. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  30. // methods supported on all messages.
  31. /// Singular
  32. var optionalInt32: Int32 {
  33. get {return _storage._optionalInt32 ?? 0}
  34. set {_uniqueStorage()._optionalInt32 = newValue}
  35. }
  36. /// Returns true if `optionalInt32` has been explicitly set.
  37. var hasOptionalInt32: Bool {return _storage._optionalInt32 != nil}
  38. /// Clears the value of `optionalInt32`. Subsequent reads from it will return its default value.
  39. mutating func clearOptionalInt32() {_uniqueStorage()._optionalInt32 = nil}
  40. var optionalInt64: Int64 {
  41. get {return _storage._optionalInt64 ?? 0}
  42. set {_uniqueStorage()._optionalInt64 = newValue}
  43. }
  44. /// Returns true if `optionalInt64` has been explicitly set.
  45. var hasOptionalInt64: Bool {return _storage._optionalInt64 != nil}
  46. /// Clears the value of `optionalInt64`. Subsequent reads from it will return its default value.
  47. mutating func clearOptionalInt64() {_uniqueStorage()._optionalInt64 = nil}
  48. var optionalUint32: UInt32 {
  49. get {return _storage._optionalUint32 ?? 0}
  50. set {_uniqueStorage()._optionalUint32 = newValue}
  51. }
  52. /// Returns true if `optionalUint32` has been explicitly set.
  53. var hasOptionalUint32: Bool {return _storage._optionalUint32 != nil}
  54. /// Clears the value of `optionalUint32`. Subsequent reads from it will return its default value.
  55. mutating func clearOptionalUint32() {_uniqueStorage()._optionalUint32 = nil}
  56. var optionalUint64: UInt64 {
  57. get {return _storage._optionalUint64 ?? 0}
  58. set {_uniqueStorage()._optionalUint64 = newValue}
  59. }
  60. /// Returns true if `optionalUint64` has been explicitly set.
  61. var hasOptionalUint64: Bool {return _storage._optionalUint64 != nil}
  62. /// Clears the value of `optionalUint64`. Subsequent reads from it will return its default value.
  63. mutating func clearOptionalUint64() {_uniqueStorage()._optionalUint64 = nil}
  64. var optionalSint32: Int32 {
  65. get {return _storage._optionalSint32 ?? 0}
  66. set {_uniqueStorage()._optionalSint32 = newValue}
  67. }
  68. /// Returns true if `optionalSint32` has been explicitly set.
  69. var hasOptionalSint32: Bool {return _storage._optionalSint32 != nil}
  70. /// Clears the value of `optionalSint32`. Subsequent reads from it will return its default value.
  71. mutating func clearOptionalSint32() {_uniqueStorage()._optionalSint32 = nil}
  72. var optionalSint64: Int64 {
  73. get {return _storage._optionalSint64 ?? 0}
  74. set {_uniqueStorage()._optionalSint64 = newValue}
  75. }
  76. /// Returns true if `optionalSint64` has been explicitly set.
  77. var hasOptionalSint64: Bool {return _storage._optionalSint64 != nil}
  78. /// Clears the value of `optionalSint64`. Subsequent reads from it will return its default value.
  79. mutating func clearOptionalSint64() {_uniqueStorage()._optionalSint64 = nil}
  80. var optionalFixed32: UInt32 {
  81. get {return _storage._optionalFixed32 ?? 0}
  82. set {_uniqueStorage()._optionalFixed32 = newValue}
  83. }
  84. /// Returns true if `optionalFixed32` has been explicitly set.
  85. var hasOptionalFixed32: Bool {return _storage._optionalFixed32 != nil}
  86. /// Clears the value of `optionalFixed32`. Subsequent reads from it will return its default value.
  87. mutating func clearOptionalFixed32() {_uniqueStorage()._optionalFixed32 = nil}
  88. var optionalFixed64: UInt64 {
  89. get {return _storage._optionalFixed64 ?? 0}
  90. set {_uniqueStorage()._optionalFixed64 = newValue}
  91. }
  92. /// Returns true if `optionalFixed64` has been explicitly set.
  93. var hasOptionalFixed64: Bool {return _storage._optionalFixed64 != nil}
  94. /// Clears the value of `optionalFixed64`. Subsequent reads from it will return its default value.
  95. mutating func clearOptionalFixed64() {_uniqueStorage()._optionalFixed64 = nil}
  96. var optionalSfixed32: Int32 {
  97. get {return _storage._optionalSfixed32 ?? 0}
  98. set {_uniqueStorage()._optionalSfixed32 = newValue}
  99. }
  100. /// Returns true if `optionalSfixed32` has been explicitly set.
  101. var hasOptionalSfixed32: Bool {return _storage._optionalSfixed32 != nil}
  102. /// Clears the value of `optionalSfixed32`. Subsequent reads from it will return its default value.
  103. mutating func clearOptionalSfixed32() {_uniqueStorage()._optionalSfixed32 = nil}
  104. var optionalSfixed64: Int64 {
  105. get {return _storage._optionalSfixed64 ?? 0}
  106. set {_uniqueStorage()._optionalSfixed64 = newValue}
  107. }
  108. /// Returns true if `optionalSfixed64` has been explicitly set.
  109. var hasOptionalSfixed64: Bool {return _storage._optionalSfixed64 != nil}
  110. /// Clears the value of `optionalSfixed64`. Subsequent reads from it will return its default value.
  111. mutating func clearOptionalSfixed64() {_uniqueStorage()._optionalSfixed64 = nil}
  112. var optionalFloat: Float {
  113. get {return _storage._optionalFloat ?? 0}
  114. set {_uniqueStorage()._optionalFloat = newValue}
  115. }
  116. /// Returns true if `optionalFloat` has been explicitly set.
  117. var hasOptionalFloat: Bool {return _storage._optionalFloat != nil}
  118. /// Clears the value of `optionalFloat`. Subsequent reads from it will return its default value.
  119. mutating func clearOptionalFloat() {_uniqueStorage()._optionalFloat = nil}
  120. var optionalDouble: Double {
  121. get {return _storage._optionalDouble ?? 0}
  122. set {_uniqueStorage()._optionalDouble = newValue}
  123. }
  124. /// Returns true if `optionalDouble` has been explicitly set.
  125. var hasOptionalDouble: Bool {return _storage._optionalDouble != nil}
  126. /// Clears the value of `optionalDouble`. Subsequent reads from it will return its default value.
  127. mutating func clearOptionalDouble() {_uniqueStorage()._optionalDouble = nil}
  128. var optionalBool: Bool {
  129. get {return _storage._optionalBool ?? false}
  130. set {_uniqueStorage()._optionalBool = newValue}
  131. }
  132. /// Returns true if `optionalBool` has been explicitly set.
  133. var hasOptionalBool: Bool {return _storage._optionalBool != nil}
  134. /// Clears the value of `optionalBool`. Subsequent reads from it will return its default value.
  135. mutating func clearOptionalBool() {_uniqueStorage()._optionalBool = nil}
  136. var optionalString: String {
  137. get {return _storage._optionalString ?? String()}
  138. set {_uniqueStorage()._optionalString = newValue}
  139. }
  140. /// Returns true if `optionalString` has been explicitly set.
  141. var hasOptionalString: Bool {return _storage._optionalString != nil}
  142. /// Clears the value of `optionalString`. Subsequent reads from it will return its default value.
  143. mutating func clearOptionalString() {_uniqueStorage()._optionalString = nil}
  144. var optionalBytes: Data {
  145. get {return _storage._optionalBytes ?? Data()}
  146. set {_uniqueStorage()._optionalBytes = newValue}
  147. }
  148. /// Returns true if `optionalBytes` has been explicitly set.
  149. var hasOptionalBytes: Bool {return _storage._optionalBytes != nil}
  150. /// Clears the value of `optionalBytes`. Subsequent reads from it will return its default value.
  151. mutating func clearOptionalBytes() {_uniqueStorage()._optionalBytes = nil}
  152. var optionalCord: String {
  153. get {return _storage._optionalCord ?? String()}
  154. set {_uniqueStorage()._optionalCord = newValue}
  155. }
  156. /// Returns true if `optionalCord` has been explicitly set.
  157. var hasOptionalCord: Bool {return _storage._optionalCord != nil}
  158. /// Clears the value of `optionalCord`. Subsequent reads from it will return its default value.
  159. mutating func clearOptionalCord() {_uniqueStorage()._optionalCord = nil}
  160. var optionalNestedMessage: Proto2Unittest_TestProto3Optional.NestedMessage {
  161. get {return _storage._optionalNestedMessage ?? Proto2Unittest_TestProto3Optional.NestedMessage()}
  162. set {_uniqueStorage()._optionalNestedMessage = newValue}
  163. }
  164. /// Returns true if `optionalNestedMessage` has been explicitly set.
  165. var hasOptionalNestedMessage: Bool {return _storage._optionalNestedMessage != nil}
  166. /// Clears the value of `optionalNestedMessage`. Subsequent reads from it will return its default value.
  167. mutating func clearOptionalNestedMessage() {_uniqueStorage()._optionalNestedMessage = nil}
  168. var lazyNestedMessage: Proto2Unittest_TestProto3Optional.NestedMessage {
  169. get {return _storage._lazyNestedMessage ?? Proto2Unittest_TestProto3Optional.NestedMessage()}
  170. set {_uniqueStorage()._lazyNestedMessage = newValue}
  171. }
  172. /// Returns true if `lazyNestedMessage` has been explicitly set.
  173. var hasLazyNestedMessage: Bool {return _storage._lazyNestedMessage != nil}
  174. /// Clears the value of `lazyNestedMessage`. Subsequent reads from it will return its default value.
  175. mutating func clearLazyNestedMessage() {_uniqueStorage()._lazyNestedMessage = nil}
  176. var optionalNestedEnum: Proto2Unittest_TestProto3Optional.NestedEnum {
  177. get {return _storage._optionalNestedEnum ?? .unspecified}
  178. set {_uniqueStorage()._optionalNestedEnum = newValue}
  179. }
  180. /// Returns true if `optionalNestedEnum` has been explicitly set.
  181. var hasOptionalNestedEnum: Bool {return _storage._optionalNestedEnum != nil}
  182. /// Clears the value of `optionalNestedEnum`. Subsequent reads from it will return its default value.
  183. mutating func clearOptionalNestedEnum() {_uniqueStorage()._optionalNestedEnum = nil}
  184. /// Add some non-optional fields to verify we can mix them.
  185. var singularInt32: Int32 {
  186. get {return _storage._singularInt32}
  187. set {_uniqueStorage()._singularInt32 = newValue}
  188. }
  189. var singularInt64: Int64 {
  190. get {return _storage._singularInt64}
  191. set {_uniqueStorage()._singularInt64 = newValue}
  192. }
  193. var unknownFields = SwiftProtobuf.UnknownStorage()
  194. enum NestedEnum: SwiftProtobuf.Enum, Swift.CaseIterable {
  195. typealias RawValue = Int
  196. case unspecified // = 0
  197. case foo // = 1
  198. case bar // = 2
  199. case baz // = 3
  200. /// Intentionally negative.
  201. case neg // = -1
  202. case UNRECOGNIZED(Int)
  203. init() {
  204. self = .unspecified
  205. }
  206. init?(rawValue: Int) {
  207. switch rawValue {
  208. case -1: self = .neg
  209. case 0: self = .unspecified
  210. case 1: self = .foo
  211. case 2: self = .bar
  212. case 3: self = .baz
  213. default: self = .UNRECOGNIZED(rawValue)
  214. }
  215. }
  216. var rawValue: Int {
  217. switch self {
  218. case .neg: return -1
  219. case .unspecified: return 0
  220. case .foo: return 1
  221. case .bar: return 2
  222. case .baz: return 3
  223. case .UNRECOGNIZED(let i): return i
  224. }
  225. }
  226. // The compiler won't synthesize support with the UNRECOGNIZED case.
  227. static let allCases: [Proto2Unittest_TestProto3Optional.NestedEnum] = [
  228. .unspecified,
  229. .foo,
  230. .bar,
  231. .baz,
  232. .neg,
  233. ]
  234. }
  235. struct NestedMessage: Sendable {
  236. // SwiftProtobuf.Message conformance is added in an extension below. See the
  237. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  238. // methods supported on all messages.
  239. /// The field name "b" fails to compile in proto1 because it conflicts with
  240. /// a local variable named "b" in one of the generated methods. Doh.
  241. /// This file needs to compile in proto1 to test backwards-compatibility.
  242. var bb: Int32 {
  243. get {return _bb ?? 0}
  244. set {_bb = newValue}
  245. }
  246. /// Returns true if `bb` has been explicitly set.
  247. var hasBb: Bool {return self._bb != nil}
  248. /// Clears the value of `bb`. Subsequent reads from it will return its default value.
  249. mutating func clearBb() {self._bb = nil}
  250. var unknownFields = SwiftProtobuf.UnknownStorage()
  251. init() {}
  252. fileprivate var _bb: Int32? = nil
  253. }
  254. init() {}
  255. fileprivate var _storage = _StorageClass.defaultInstance
  256. }
  257. struct Proto2Unittest_TestProto3OptionalMessage: Sendable {
  258. // SwiftProtobuf.Message conformance is added in an extension below. See the
  259. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  260. // methods supported on all messages.
  261. var nestedMessage: Proto2Unittest_TestProto3OptionalMessage.NestedMessage {
  262. get {return _nestedMessage ?? Proto2Unittest_TestProto3OptionalMessage.NestedMessage()}
  263. set {_nestedMessage = newValue}
  264. }
  265. /// Returns true if `nestedMessage` has been explicitly set.
  266. var hasNestedMessage: Bool {return self._nestedMessage != nil}
  267. /// Clears the value of `nestedMessage`. Subsequent reads from it will return its default value.
  268. mutating func clearNestedMessage() {self._nestedMessage = nil}
  269. var optionalNestedMessage: Proto2Unittest_TestProto3OptionalMessage.NestedMessage {
  270. get {return _optionalNestedMessage ?? Proto2Unittest_TestProto3OptionalMessage.NestedMessage()}
  271. set {_optionalNestedMessage = newValue}
  272. }
  273. /// Returns true if `optionalNestedMessage` has been explicitly set.
  274. var hasOptionalNestedMessage: Bool {return self._optionalNestedMessage != nil}
  275. /// Clears the value of `optionalNestedMessage`. Subsequent reads from it will return its default value.
  276. mutating func clearOptionalNestedMessage() {self._optionalNestedMessage = nil}
  277. var unknownFields = SwiftProtobuf.UnknownStorage()
  278. struct NestedMessage: Sendable {
  279. // SwiftProtobuf.Message conformance is added in an extension below. See the
  280. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  281. // methods supported on all messages.
  282. var s: String = String()
  283. var unknownFields = SwiftProtobuf.UnknownStorage()
  284. init() {}
  285. }
  286. init() {}
  287. fileprivate var _nestedMessage: Proto2Unittest_TestProto3OptionalMessage.NestedMessage? = nil
  288. fileprivate var _optionalNestedMessage: Proto2Unittest_TestProto3OptionalMessage.NestedMessage? = nil
  289. }
  290. struct Proto2Unittest_Proto3OptionalExtensions: Sendable {
  291. // SwiftProtobuf.Message conformance is added in an extension below. See the
  292. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  293. // methods supported on all messages.
  294. var unknownFields = SwiftProtobuf.UnknownStorage()
  295. init() {}
  296. }
  297. // MARK: - Extension support defined in unittest_proto3_optional.proto.
  298. // MARK: - Extension Properties
  299. // Swift Extensions on the extended Messages to add easy access to the declared
  300. // extension fields. The names are based on the extension field name from the proto
  301. // declaration. To avoid naming collisions, the names are prefixed with the name of
  302. // the scope where the extend directive occurs.
  303. extension SwiftProtobuf.Google_Protobuf_MessageOptions {
  304. var Proto2Unittest_Proto3OptionalExtensions_extNoOptional: Int32 {
  305. get {return getExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional) ?? 0}
  306. set {setExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional, value: newValue)}
  307. }
  308. /// Returns true if extension `Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional`
  309. /// has been explicitly set.
  310. var hasProto2Unittest_Proto3OptionalExtensions_extNoOptional: Bool {
  311. return hasExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional)
  312. }
  313. /// Clears the value of extension `Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional`.
  314. /// Subsequent reads from it will return its default value.
  315. mutating func clearProto2Unittest_Proto3OptionalExtensions_extNoOptional() {
  316. clearExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional)
  317. }
  318. var Proto2Unittest_Proto3OptionalExtensions_extWithOptional: Int32 {
  319. get {return getExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional) ?? 0}
  320. set {setExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional, value: newValue)}
  321. }
  322. /// Returns true if extension `Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional`
  323. /// has been explicitly set.
  324. var hasProto2Unittest_Proto3OptionalExtensions_extWithOptional: Bool {
  325. return hasExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional)
  326. }
  327. /// Clears the value of extension `Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional`.
  328. /// Subsequent reads from it will return its default value.
  329. mutating func clearProto2Unittest_Proto3OptionalExtensions_extWithOptional() {
  330. clearExtensionValue(ext: Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional)
  331. }
  332. }
  333. // MARK: - File's ExtensionMap: Proto2Unittest_UnittestProto3Optional_Extensions
  334. /// A `SwiftProtobuf.SimpleExtensionMap` that includes all of the extensions defined by
  335. /// this .proto file. It can be used any place an `SwiftProtobuf.ExtensionMap` is needed
  336. /// in parsing, or it can be combined with other `SwiftProtobuf.SimpleExtensionMap`s to create
  337. /// a larger `SwiftProtobuf.SimpleExtensionMap`.
  338. let Proto2Unittest_UnittestProto3Optional_Extensions: SwiftProtobuf.SimpleExtensionMap = [
  339. Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_no_optional,
  340. Proto2Unittest_Proto3OptionalExtensions.Extensions.ext_with_optional
  341. ]
  342. // Extension Objects - The only reason these might be needed is when manually
  343. // constructing a `SimpleExtensionMap`, otherwise, use the above _Extension Properties_
  344. // accessors for the extension fields on the messages directly.
  345. extension Proto2Unittest_Proto3OptionalExtensions {
  346. enum Extensions {
  347. static let ext_no_optional = SwiftProtobuf.MessageExtension<SwiftProtobuf.OptionalExtensionField<SwiftProtobuf.ProtobufInt32>, SwiftProtobuf.Google_Protobuf_MessageOptions>(
  348. _protobuf_fieldNumber: 355886728,
  349. fieldName: "proto2_unittest.Proto3OptionalExtensions.ext_no_optional"
  350. )
  351. static let ext_with_optional = SwiftProtobuf.MessageExtension<SwiftProtobuf.OptionalExtensionField<SwiftProtobuf.ProtobufInt32>, SwiftProtobuf.Google_Protobuf_MessageOptions>(
  352. _protobuf_fieldNumber: 355886729,
  353. fieldName: "proto2_unittest.Proto3OptionalExtensions.ext_with_optional"
  354. )
  355. }
  356. }
  357. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  358. fileprivate let _protobuf_package = "proto2_unittest"
  359. extension Proto2Unittest_TestProto3Optional: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  360. static let protoMessageName: String = _protobuf_package + ".TestProto3Optional"
  361. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  362. 1: .standard(proto: "optional_int32"),
  363. 2: .standard(proto: "optional_int64"),
  364. 3: .standard(proto: "optional_uint32"),
  365. 4: .standard(proto: "optional_uint64"),
  366. 5: .standard(proto: "optional_sint32"),
  367. 6: .standard(proto: "optional_sint64"),
  368. 7: .standard(proto: "optional_fixed32"),
  369. 8: .standard(proto: "optional_fixed64"),
  370. 9: .standard(proto: "optional_sfixed32"),
  371. 10: .standard(proto: "optional_sfixed64"),
  372. 11: .standard(proto: "optional_float"),
  373. 12: .standard(proto: "optional_double"),
  374. 13: .standard(proto: "optional_bool"),
  375. 14: .standard(proto: "optional_string"),
  376. 15: .standard(proto: "optional_bytes"),
  377. 16: .standard(proto: "optional_cord"),
  378. 18: .standard(proto: "optional_nested_message"),
  379. 19: .standard(proto: "lazy_nested_message"),
  380. 21: .standard(proto: "optional_nested_enum"),
  381. 22: .standard(proto: "singular_int32"),
  382. 23: .standard(proto: "singular_int64"),
  383. ]
  384. fileprivate class _StorageClass {
  385. var _optionalInt32: Int32? = nil
  386. var _optionalInt64: Int64? = nil
  387. var _optionalUint32: UInt32? = nil
  388. var _optionalUint64: UInt64? = nil
  389. var _optionalSint32: Int32? = nil
  390. var _optionalSint64: Int64? = nil
  391. var _optionalFixed32: UInt32? = nil
  392. var _optionalFixed64: UInt64? = nil
  393. var _optionalSfixed32: Int32? = nil
  394. var _optionalSfixed64: Int64? = nil
  395. var _optionalFloat: Float? = nil
  396. var _optionalDouble: Double? = nil
  397. var _optionalBool: Bool? = nil
  398. var _optionalString: String? = nil
  399. var _optionalBytes: Data? = nil
  400. var _optionalCord: String? = nil
  401. var _optionalNestedMessage: Proto2Unittest_TestProto3Optional.NestedMessage? = nil
  402. var _lazyNestedMessage: Proto2Unittest_TestProto3Optional.NestedMessage? = nil
  403. var _optionalNestedEnum: Proto2Unittest_TestProto3Optional.NestedEnum? = nil
  404. var _singularInt32: Int32 = 0
  405. var _singularInt64: Int64 = 0
  406. // This property is used as the initial default value for new instances of the type.
  407. // The type itself is protecting the reference to its storage via CoW semantics.
  408. // This will force a copy to be made of this reference when the first mutation occurs;
  409. // hence, it is safe to mark this as `nonisolated(unsafe)`.
  410. static nonisolated(unsafe) let defaultInstance = _StorageClass()
  411. private init() {}
  412. init(copying source: _StorageClass) {
  413. _optionalInt32 = source._optionalInt32
  414. _optionalInt64 = source._optionalInt64
  415. _optionalUint32 = source._optionalUint32
  416. _optionalUint64 = source._optionalUint64
  417. _optionalSint32 = source._optionalSint32
  418. _optionalSint64 = source._optionalSint64
  419. _optionalFixed32 = source._optionalFixed32
  420. _optionalFixed64 = source._optionalFixed64
  421. _optionalSfixed32 = source._optionalSfixed32
  422. _optionalSfixed64 = source._optionalSfixed64
  423. _optionalFloat = source._optionalFloat
  424. _optionalDouble = source._optionalDouble
  425. _optionalBool = source._optionalBool
  426. _optionalString = source._optionalString
  427. _optionalBytes = source._optionalBytes
  428. _optionalCord = source._optionalCord
  429. _optionalNestedMessage = source._optionalNestedMessage
  430. _lazyNestedMessage = source._lazyNestedMessage
  431. _optionalNestedEnum = source._optionalNestedEnum
  432. _singularInt32 = source._singularInt32
  433. _singularInt64 = source._singularInt64
  434. }
  435. }
  436. fileprivate mutating func _uniqueStorage() -> _StorageClass {
  437. if !isKnownUniquelyReferenced(&_storage) {
  438. _storage = _StorageClass(copying: _storage)
  439. }
  440. return _storage
  441. }
  442. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  443. _ = _uniqueStorage()
  444. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  445. while let fieldNumber = try decoder.nextFieldNumber() {
  446. // The use of inline closures is to circumvent an issue where the compiler
  447. // allocates stack space for every case branch when no optimizations are
  448. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  449. switch fieldNumber {
  450. case 1: try { try decoder.decodeSingularInt32Field(value: &_storage._optionalInt32) }()
  451. case 2: try { try decoder.decodeSingularInt64Field(value: &_storage._optionalInt64) }()
  452. case 3: try { try decoder.decodeSingularUInt32Field(value: &_storage._optionalUint32) }()
  453. case 4: try { try decoder.decodeSingularUInt64Field(value: &_storage._optionalUint64) }()
  454. case 5: try { try decoder.decodeSingularSInt32Field(value: &_storage._optionalSint32) }()
  455. case 6: try { try decoder.decodeSingularSInt64Field(value: &_storage._optionalSint64) }()
  456. case 7: try { try decoder.decodeSingularFixed32Field(value: &_storage._optionalFixed32) }()
  457. case 8: try { try decoder.decodeSingularFixed64Field(value: &_storage._optionalFixed64) }()
  458. case 9: try { try decoder.decodeSingularSFixed32Field(value: &_storage._optionalSfixed32) }()
  459. case 10: try { try decoder.decodeSingularSFixed64Field(value: &_storage._optionalSfixed64) }()
  460. case 11: try { try decoder.decodeSingularFloatField(value: &_storage._optionalFloat) }()
  461. case 12: try { try decoder.decodeSingularDoubleField(value: &_storage._optionalDouble) }()
  462. case 13: try { try decoder.decodeSingularBoolField(value: &_storage._optionalBool) }()
  463. case 14: try { try decoder.decodeSingularStringField(value: &_storage._optionalString) }()
  464. case 15: try { try decoder.decodeSingularBytesField(value: &_storage._optionalBytes) }()
  465. case 16: try { try decoder.decodeSingularStringField(value: &_storage._optionalCord) }()
  466. case 18: try { try decoder.decodeSingularMessageField(value: &_storage._optionalNestedMessage) }()
  467. case 19: try { try decoder.decodeSingularMessageField(value: &_storage._lazyNestedMessage) }()
  468. case 21: try { try decoder.decodeSingularEnumField(value: &_storage._optionalNestedEnum) }()
  469. case 22: try { try decoder.decodeSingularInt32Field(value: &_storage._singularInt32) }()
  470. case 23: try { try decoder.decodeSingularInt64Field(value: &_storage._singularInt64) }()
  471. default: break
  472. }
  473. }
  474. }
  475. }
  476. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  477. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  478. // The use of inline closures is to circumvent an issue where the compiler
  479. // allocates stack space for every if/case branch local when no optimizations
  480. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  481. // https://github.com/apple/swift-protobuf/issues/1182
  482. try { if let v = _storage._optionalInt32 {
  483. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  484. } }()
  485. try { if let v = _storage._optionalInt64 {
  486. try visitor.visitSingularInt64Field(value: v, fieldNumber: 2)
  487. } }()
  488. try { if let v = _storage._optionalUint32 {
  489. try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
  490. } }()
  491. try { if let v = _storage._optionalUint64 {
  492. try visitor.visitSingularUInt64Field(value: v, fieldNumber: 4)
  493. } }()
  494. try { if let v = _storage._optionalSint32 {
  495. try visitor.visitSingularSInt32Field(value: v, fieldNumber: 5)
  496. } }()
  497. try { if let v = _storage._optionalSint64 {
  498. try visitor.visitSingularSInt64Field(value: v, fieldNumber: 6)
  499. } }()
  500. try { if let v = _storage._optionalFixed32 {
  501. try visitor.visitSingularFixed32Field(value: v, fieldNumber: 7)
  502. } }()
  503. try { if let v = _storage._optionalFixed64 {
  504. try visitor.visitSingularFixed64Field(value: v, fieldNumber: 8)
  505. } }()
  506. try { if let v = _storage._optionalSfixed32 {
  507. try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 9)
  508. } }()
  509. try { if let v = _storage._optionalSfixed64 {
  510. try visitor.visitSingularSFixed64Field(value: v, fieldNumber: 10)
  511. } }()
  512. try { if let v = _storage._optionalFloat {
  513. try visitor.visitSingularFloatField(value: v, fieldNumber: 11)
  514. } }()
  515. try { if let v = _storage._optionalDouble {
  516. try visitor.visitSingularDoubleField(value: v, fieldNumber: 12)
  517. } }()
  518. try { if let v = _storage._optionalBool {
  519. try visitor.visitSingularBoolField(value: v, fieldNumber: 13)
  520. } }()
  521. try { if let v = _storage._optionalString {
  522. try visitor.visitSingularStringField(value: v, fieldNumber: 14)
  523. } }()
  524. try { if let v = _storage._optionalBytes {
  525. try visitor.visitSingularBytesField(value: v, fieldNumber: 15)
  526. } }()
  527. try { if let v = _storage._optionalCord {
  528. try visitor.visitSingularStringField(value: v, fieldNumber: 16)
  529. } }()
  530. try { if let v = _storage._optionalNestedMessage {
  531. try visitor.visitSingularMessageField(value: v, fieldNumber: 18)
  532. } }()
  533. try { if let v = _storage._lazyNestedMessage {
  534. try visitor.visitSingularMessageField(value: v, fieldNumber: 19)
  535. } }()
  536. try { if let v = _storage._optionalNestedEnum {
  537. try visitor.visitSingularEnumField(value: v, fieldNumber: 21)
  538. } }()
  539. if _storage._singularInt32 != 0 {
  540. try visitor.visitSingularInt32Field(value: _storage._singularInt32, fieldNumber: 22)
  541. }
  542. if _storage._singularInt64 != 0 {
  543. try visitor.visitSingularInt64Field(value: _storage._singularInt64, fieldNumber: 23)
  544. }
  545. }
  546. try unknownFields.traverse(visitor: &visitor)
  547. }
  548. static func ==(lhs: Proto2Unittest_TestProto3Optional, rhs: Proto2Unittest_TestProto3Optional) -> Bool {
  549. if lhs._storage !== rhs._storage {
  550. let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
  551. let _storage = _args.0
  552. let rhs_storage = _args.1
  553. if _storage._optionalInt32 != rhs_storage._optionalInt32 {return false}
  554. if _storage._optionalInt64 != rhs_storage._optionalInt64 {return false}
  555. if _storage._optionalUint32 != rhs_storage._optionalUint32 {return false}
  556. if _storage._optionalUint64 != rhs_storage._optionalUint64 {return false}
  557. if _storage._optionalSint32 != rhs_storage._optionalSint32 {return false}
  558. if _storage._optionalSint64 != rhs_storage._optionalSint64 {return false}
  559. if _storage._optionalFixed32 != rhs_storage._optionalFixed32 {return false}
  560. if _storage._optionalFixed64 != rhs_storage._optionalFixed64 {return false}
  561. if _storage._optionalSfixed32 != rhs_storage._optionalSfixed32 {return false}
  562. if _storage._optionalSfixed64 != rhs_storage._optionalSfixed64 {return false}
  563. if _storage._optionalFloat != rhs_storage._optionalFloat {return false}
  564. if _storage._optionalDouble != rhs_storage._optionalDouble {return false}
  565. if _storage._optionalBool != rhs_storage._optionalBool {return false}
  566. if _storage._optionalString != rhs_storage._optionalString {return false}
  567. if _storage._optionalBytes != rhs_storage._optionalBytes {return false}
  568. if _storage._optionalCord != rhs_storage._optionalCord {return false}
  569. if _storage._optionalNestedMessage != rhs_storage._optionalNestedMessage {return false}
  570. if _storage._lazyNestedMessage != rhs_storage._lazyNestedMessage {return false}
  571. if _storage._optionalNestedEnum != rhs_storage._optionalNestedEnum {return false}
  572. if _storage._singularInt32 != rhs_storage._singularInt32 {return false}
  573. if _storage._singularInt64 != rhs_storage._singularInt64 {return false}
  574. return true
  575. }
  576. if !storagesAreEqual {return false}
  577. }
  578. if lhs.unknownFields != rhs.unknownFields {return false}
  579. return true
  580. }
  581. }
  582. extension Proto2Unittest_TestProto3Optional.NestedEnum: SwiftProtobuf._ProtoNameProviding {
  583. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  584. -1: .same(proto: "NEG"),
  585. 0: .same(proto: "UNSPECIFIED"),
  586. 1: .same(proto: "FOO"),
  587. 2: .same(proto: "BAR"),
  588. 3: .same(proto: "BAZ"),
  589. ]
  590. }
  591. extension Proto2Unittest_TestProto3Optional.NestedMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  592. static let protoMessageName: String = Proto2Unittest_TestProto3Optional.protoMessageName + ".NestedMessage"
  593. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  594. 1: .same(proto: "bb"),
  595. ]
  596. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  597. while let fieldNumber = try decoder.nextFieldNumber() {
  598. // The use of inline closures is to circumvent an issue where the compiler
  599. // allocates stack space for every case branch when no optimizations are
  600. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  601. switch fieldNumber {
  602. case 1: try { try decoder.decodeSingularInt32Field(value: &self._bb) }()
  603. default: break
  604. }
  605. }
  606. }
  607. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  608. // The use of inline closures is to circumvent an issue where the compiler
  609. // allocates stack space for every if/case branch local when no optimizations
  610. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  611. // https://github.com/apple/swift-protobuf/issues/1182
  612. try { if let v = self._bb {
  613. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  614. } }()
  615. try unknownFields.traverse(visitor: &visitor)
  616. }
  617. static func ==(lhs: Proto2Unittest_TestProto3Optional.NestedMessage, rhs: Proto2Unittest_TestProto3Optional.NestedMessage) -> Bool {
  618. if lhs._bb != rhs._bb {return false}
  619. if lhs.unknownFields != rhs.unknownFields {return false}
  620. return true
  621. }
  622. }
  623. extension Proto2Unittest_TestProto3OptionalMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  624. static let protoMessageName: String = _protobuf_package + ".TestProto3OptionalMessage"
  625. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  626. 1: .standard(proto: "nested_message"),
  627. 2: .standard(proto: "optional_nested_message"),
  628. ]
  629. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  630. while let fieldNumber = try decoder.nextFieldNumber() {
  631. // The use of inline closures is to circumvent an issue where the compiler
  632. // allocates stack space for every case branch when no optimizations are
  633. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  634. switch fieldNumber {
  635. case 1: try { try decoder.decodeSingularMessageField(value: &self._nestedMessage) }()
  636. case 2: try { try decoder.decodeSingularMessageField(value: &self._optionalNestedMessage) }()
  637. default: break
  638. }
  639. }
  640. }
  641. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  642. // The use of inline closures is to circumvent an issue where the compiler
  643. // allocates stack space for every if/case branch local when no optimizations
  644. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  645. // https://github.com/apple/swift-protobuf/issues/1182
  646. try { if let v = self._nestedMessage {
  647. try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
  648. } }()
  649. try { if let v = self._optionalNestedMessage {
  650. try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
  651. } }()
  652. try unknownFields.traverse(visitor: &visitor)
  653. }
  654. static func ==(lhs: Proto2Unittest_TestProto3OptionalMessage, rhs: Proto2Unittest_TestProto3OptionalMessage) -> Bool {
  655. if lhs._nestedMessage != rhs._nestedMessage {return false}
  656. if lhs._optionalNestedMessage != rhs._optionalNestedMessage {return false}
  657. if lhs.unknownFields != rhs.unknownFields {return false}
  658. return true
  659. }
  660. }
  661. extension Proto2Unittest_TestProto3OptionalMessage.NestedMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  662. static let protoMessageName: String = Proto2Unittest_TestProto3OptionalMessage.protoMessageName + ".NestedMessage"
  663. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  664. 1: .same(proto: "s"),
  665. ]
  666. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  667. while let fieldNumber = try decoder.nextFieldNumber() {
  668. // The use of inline closures is to circumvent an issue where the compiler
  669. // allocates stack space for every case branch when no optimizations are
  670. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  671. switch fieldNumber {
  672. case 1: try { try decoder.decodeSingularStringField(value: &self.s) }()
  673. default: break
  674. }
  675. }
  676. }
  677. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  678. if !self.s.isEmpty {
  679. try visitor.visitSingularStringField(value: self.s, fieldNumber: 1)
  680. }
  681. try unknownFields.traverse(visitor: &visitor)
  682. }
  683. static func ==(lhs: Proto2Unittest_TestProto3OptionalMessage.NestedMessage, rhs: Proto2Unittest_TestProto3OptionalMessage.NestedMessage) -> Bool {
  684. if lhs.s != rhs.s {return false}
  685. if lhs.unknownFields != rhs.unknownFields {return false}
  686. return true
  687. }
  688. }
  689. extension Proto2Unittest_Proto3OptionalExtensions: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  690. static let protoMessageName: String = _protobuf_package + ".Proto3OptionalExtensions"
  691. static let _protobuf_nameMap = SwiftProtobuf._NameMap()
  692. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  693. // Load everything into unknown fields
  694. while try decoder.nextFieldNumber() != nil {}
  695. }
  696. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  697. try unknownFields.traverse(visitor: &visitor)
  698. }
  699. static func ==(lhs: Proto2Unittest_Proto3OptionalExtensions, rhs: Proto2Unittest_Proto3OptionalExtensions) -> Bool {
  700. if lhs.unknownFields != rhs.unknownFields {return false}
  701. return true
  702. }
  703. }