unittest_swift_oneof_all_required.pb.swift 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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_swift_oneof_all_required.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 SwiftProtobuf
  40. // If the compiler emits an error on this type, it is because this file
  41. // was generated by a version of the `protoc` Swift plug-in that is
  42. // incompatible with the version of SwiftProtobuf to which you are linking.
  43. // Please ensure that you are building against the same version of the API
  44. // that was used to generate this file.
  45. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  46. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  47. typealias Version = _2
  48. }
  49. struct SwiftProtoTesting_OneOfOptionMessage1: Sendable {
  50. // SwiftProtobuf.Message conformance is added in an extension below. See the
  51. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  52. // methods supported on all messages.
  53. var requiredField: Int32 {
  54. get {_requiredField ?? 0}
  55. set {_requiredField = newValue}
  56. }
  57. /// Returns true if `requiredField` has been explicitly set.
  58. var hasRequiredField: Bool {self._requiredField != nil}
  59. /// Clears the value of `requiredField`. Subsequent reads from it will return its default value.
  60. mutating func clearRequiredField() {self._requiredField = nil}
  61. var unknownFields = SwiftProtobuf.UnknownStorage()
  62. init() {}
  63. fileprivate var _requiredField: Int32? = nil
  64. }
  65. struct SwiftProtoTesting_OneOfOptionMessage2: Sendable {
  66. // SwiftProtobuf.Message conformance is added in an extension below. See the
  67. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  68. // methods supported on all messages.
  69. var requiredField: Int32 {
  70. get {_requiredField ?? 0}
  71. set {_requiredField = newValue}
  72. }
  73. /// Returns true if `requiredField` has been explicitly set.
  74. var hasRequiredField: Bool {self._requiredField != nil}
  75. /// Clears the value of `requiredField`. Subsequent reads from it will return its default value.
  76. mutating func clearRequiredField() {self._requiredField = nil}
  77. var unknownFields = SwiftProtobuf.UnknownStorage()
  78. init() {}
  79. fileprivate var _requiredField: Int32? = nil
  80. }
  81. struct SwiftProtoTesting_OneOfContainer: Sendable {
  82. // SwiftProtobuf.Message conformance is added in an extension below. See the
  83. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  84. // methods supported on all messages.
  85. var option: SwiftProtoTesting_OneOfContainer.OneOf_Option? = nil
  86. var option1: SwiftProtoTesting_OneOfOptionMessage1 {
  87. get {
  88. if case .option1(let v)? = option {return v}
  89. return SwiftProtoTesting_OneOfOptionMessage1()
  90. }
  91. set {option = .option1(newValue)}
  92. }
  93. var option2: SwiftProtoTesting_OneOfOptionMessage2 {
  94. get {
  95. if case .option2(let v)? = option {return v}
  96. return SwiftProtoTesting_OneOfOptionMessage2()
  97. }
  98. set {option = .option2(newValue)}
  99. }
  100. var option3: SwiftProtoTesting_OneOfContainer.Option3 {
  101. get {
  102. if case .option3(let v)? = option {return v}
  103. return SwiftProtoTesting_OneOfContainer.Option3()
  104. }
  105. set {option = .option3(newValue)}
  106. }
  107. var option4: Int32 {
  108. get {
  109. if case .option4(let v)? = option {return v}
  110. return 0
  111. }
  112. set {option = .option4(newValue)}
  113. }
  114. var unknownFields = SwiftProtobuf.UnknownStorage()
  115. enum OneOf_Option: Equatable, Sendable {
  116. case option1(SwiftProtoTesting_OneOfOptionMessage1)
  117. case option2(SwiftProtoTesting_OneOfOptionMessage2)
  118. case option3(SwiftProtoTesting_OneOfContainer.Option3)
  119. case option4(Int32)
  120. fileprivate var isInitialized: Bool {
  121. // The use of inline closures is to circumvent an issue where the compiler
  122. // allocates stack space for every case branch when no optimizations are
  123. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  124. switch self {
  125. case .option1: return {
  126. guard case .option1(let v) = self else { preconditionFailure() }
  127. return v.isInitialized
  128. }()
  129. case .option2: return {
  130. guard case .option2(let v) = self else { preconditionFailure() }
  131. return v.isInitialized
  132. }()
  133. case .option3: return {
  134. guard case .option3(let v) = self else { preconditionFailure() }
  135. return v.isInitialized
  136. }()
  137. default: return true
  138. }
  139. }
  140. }
  141. struct Option3: Sendable {
  142. // SwiftProtobuf.Message conformance is added in an extension below. See the
  143. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  144. // methods supported on all messages.
  145. var a: Int32 {
  146. get {_a ?? 0}
  147. set {_a = newValue}
  148. }
  149. /// Returns true if `a` has been explicitly set.
  150. var hasA: Bool {self._a != nil}
  151. /// Clears the value of `a`. Subsequent reads from it will return its default value.
  152. mutating func clearA() {self._a = nil}
  153. var b: String {
  154. get {_b ?? String()}
  155. set {_b = newValue}
  156. }
  157. /// Returns true if `b` has been explicitly set.
  158. var hasB: Bool {self._b != nil}
  159. /// Clears the value of `b`. Subsequent reads from it will return its default value.
  160. mutating func clearB() {self._b = nil}
  161. var unknownFields = SwiftProtobuf.UnknownStorage()
  162. init() {}
  163. fileprivate var _a: Int32? = nil
  164. fileprivate var _b: String? = nil
  165. }
  166. init() {}
  167. }
  168. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  169. fileprivate let _protobuf_package = "swift_proto_testing"
  170. extension SwiftProtoTesting_OneOfOptionMessage1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  171. static let protoMessageName: String = _protobuf_package + ".OneOfOptionMessage1"
  172. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}requiredField\0")
  173. public var isInitialized: Bool {
  174. if self._requiredField == nil {return false}
  175. return true
  176. }
  177. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  178. while let fieldNumber = try decoder.nextFieldNumber() {
  179. // The use of inline closures is to circumvent an issue where the compiler
  180. // allocates stack space for every case branch when no optimizations are
  181. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  182. switch fieldNumber {
  183. case 1: try { try decoder.decodeSingularInt32Field(value: &self._requiredField) }()
  184. default: break
  185. }
  186. }
  187. }
  188. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  189. // The use of inline closures is to circumvent an issue where the compiler
  190. // allocates stack space for every if/case branch local when no optimizations
  191. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  192. // https://github.com/apple/swift-protobuf/issues/1182
  193. try { if let v = self._requiredField {
  194. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  195. } }()
  196. try unknownFields.traverse(visitor: &visitor)
  197. }
  198. static func ==(lhs: SwiftProtoTesting_OneOfOptionMessage1, rhs: SwiftProtoTesting_OneOfOptionMessage1) -> Bool {
  199. if lhs._requiredField != rhs._requiredField {return false}
  200. if lhs.unknownFields != rhs.unknownFields {return false}
  201. return true
  202. }
  203. }
  204. extension SwiftProtoTesting_OneOfOptionMessage2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  205. static let protoMessageName: String = _protobuf_package + ".OneOfOptionMessage2"
  206. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}requiredField\0")
  207. public var isInitialized: Bool {
  208. if self._requiredField == nil {return false}
  209. return true
  210. }
  211. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  212. while let fieldNumber = try decoder.nextFieldNumber() {
  213. // The use of inline closures is to circumvent an issue where the compiler
  214. // allocates stack space for every case branch when no optimizations are
  215. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  216. switch fieldNumber {
  217. case 1: try { try decoder.decodeSingularInt32Field(value: &self._requiredField) }()
  218. default: break
  219. }
  220. }
  221. }
  222. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  223. // The use of inline closures is to circumvent an issue where the compiler
  224. // allocates stack space for every if/case branch local when no optimizations
  225. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  226. // https://github.com/apple/swift-protobuf/issues/1182
  227. try { if let v = self._requiredField {
  228. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  229. } }()
  230. try unknownFields.traverse(visitor: &visitor)
  231. }
  232. static func ==(lhs: SwiftProtoTesting_OneOfOptionMessage2, rhs: SwiftProtoTesting_OneOfOptionMessage2) -> Bool {
  233. if lhs._requiredField != rhs._requiredField {return false}
  234. if lhs.unknownFields != rhs.unknownFields {return false}
  235. return true
  236. }
  237. }
  238. extension SwiftProtoTesting_OneOfContainer: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  239. static let protoMessageName: String = _protobuf_package + ".OneOfContainer"
  240. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}option1\0\u{1}option2\0\u{7}Option3\0\u{2}\u{3}option4\0")
  241. public var isInitialized: Bool {
  242. if let v = self.option, !v.isInitialized {return false}
  243. return true
  244. }
  245. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  246. while let fieldNumber = try decoder.nextFieldNumber() {
  247. // The use of inline closures is to circumvent an issue where the compiler
  248. // allocates stack space for every case branch when no optimizations are
  249. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  250. switch fieldNumber {
  251. case 1: try {
  252. var v: SwiftProtoTesting_OneOfOptionMessage1?
  253. var hadOneofValue = false
  254. if let current = self.option {
  255. hadOneofValue = true
  256. if case .option1(let m) = current {v = m}
  257. }
  258. try decoder.decodeSingularMessageField(value: &v)
  259. if let v = v {
  260. if hadOneofValue {try decoder.handleConflictingOneOf()}
  261. self.option = .option1(v)
  262. }
  263. }()
  264. case 2: try {
  265. var v: SwiftProtoTesting_OneOfOptionMessage2?
  266. var hadOneofValue = false
  267. if let current = self.option {
  268. hadOneofValue = true
  269. if case .option2(let m) = current {v = m}
  270. }
  271. try decoder.decodeSingularMessageField(value: &v)
  272. if let v = v {
  273. if hadOneofValue {try decoder.handleConflictingOneOf()}
  274. self.option = .option2(v)
  275. }
  276. }()
  277. case 3: try {
  278. var v: SwiftProtoTesting_OneOfContainer.Option3?
  279. var hadOneofValue = false
  280. if let current = self.option {
  281. hadOneofValue = true
  282. if case .option3(let m) = current {v = m}
  283. }
  284. try decoder.decodeSingularGroupField(value: &v)
  285. if let v = v {
  286. if hadOneofValue {try decoder.handleConflictingOneOf()}
  287. self.option = .option3(v)
  288. }
  289. }()
  290. case 6: try {
  291. var v: Int32?
  292. try decoder.decodeSingularInt32Field(value: &v)
  293. if let v = v {
  294. if self.option != nil {try decoder.handleConflictingOneOf()}
  295. self.option = .option4(v)
  296. }
  297. }()
  298. default: break
  299. }
  300. }
  301. }
  302. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  303. // The use of inline closures is to circumvent an issue where the compiler
  304. // allocates stack space for every if/case branch local when no optimizations
  305. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  306. // https://github.com/apple/swift-protobuf/issues/1182
  307. switch self.option {
  308. case .option1?: try {
  309. guard case .option1(let v)? = self.option else { preconditionFailure() }
  310. try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
  311. }()
  312. case .option2?: try {
  313. guard case .option2(let v)? = self.option else { preconditionFailure() }
  314. try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
  315. }()
  316. case .option3?: try {
  317. guard case .option3(let v)? = self.option else { preconditionFailure() }
  318. try visitor.visitSingularGroupField(value: v, fieldNumber: 3)
  319. }()
  320. case .option4?: try {
  321. guard case .option4(let v)? = self.option else { preconditionFailure() }
  322. try visitor.visitSingularInt32Field(value: v, fieldNumber: 6)
  323. }()
  324. case nil: break
  325. }
  326. try unknownFields.traverse(visitor: &visitor)
  327. }
  328. static func ==(lhs: SwiftProtoTesting_OneOfContainer, rhs: SwiftProtoTesting_OneOfContainer) -> Bool {
  329. if lhs.option != rhs.option {return false}
  330. if lhs.unknownFields != rhs.unknownFields {return false}
  331. return true
  332. }
  333. }
  334. extension SwiftProtoTesting_OneOfContainer.Option3: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  335. static let protoMessageName: String = SwiftProtoTesting_OneOfContainer.protoMessageName + ".Option3"
  336. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\u{4}a\0\u{1}b\0")
  337. public var isInitialized: Bool {
  338. if self._a == nil {return false}
  339. return true
  340. }
  341. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  342. while let fieldNumber = try decoder.nextFieldNumber() {
  343. // The use of inline closures is to circumvent an issue where the compiler
  344. // allocates stack space for every case branch when no optimizations are
  345. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  346. switch fieldNumber {
  347. case 4: try { try decoder.decodeSingularInt32Field(value: &self._a) }()
  348. case 5: try { try decoder.decodeSingularStringField(value: &self._b) }()
  349. default: break
  350. }
  351. }
  352. }
  353. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  354. // The use of inline closures is to circumvent an issue where the compiler
  355. // allocates stack space for every if/case branch local when no optimizations
  356. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  357. // https://github.com/apple/swift-protobuf/issues/1182
  358. try { if let v = self._a {
  359. try visitor.visitSingularInt32Field(value: v, fieldNumber: 4)
  360. } }()
  361. try { if let v = self._b {
  362. try visitor.visitSingularStringField(value: v, fieldNumber: 5)
  363. } }()
  364. try unknownFields.traverse(visitor: &visitor)
  365. }
  366. static func ==(lhs: SwiftProtoTesting_OneOfContainer.Option3, rhs: SwiftProtoTesting_OneOfContainer.Option3) -> Bool {
  367. if lhs._a != rhs._a {return false}
  368. if lhs._b != rhs._b {return false}
  369. if lhs.unknownFields != rhs.unknownFields {return false}
  370. return true
  371. }
  372. }