pluginlib_descriptor_delimited.pb.swift 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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: pluginlib_descriptor_delimited.proto
  7. //
  8. // For information on using the generated types, please see the documentation:
  9. // https://github.com/apple/swift-protobuf/
  10. // Protos/pluginlib_descriptor_test.proto - test proto
  11. //
  12. // This source file is part of the Swift.org open source project
  13. //
  14. // Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
  15. // Licensed under Apache License v2.0 with Runtime Library Exception
  16. //
  17. // See http://swift.org/LICENSE.txt for license information
  18. // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
  19. //
  20. // -----------------------------------------------------------------------------
  21. ///
  22. /// Test proto for Tests/SwiftProtobufPluginLibraryTests/Test_Descriptor.swift
  23. ///
  24. // -----------------------------------------------------------------------------
  25. import Foundation
  26. import SwiftProtobuf
  27. // If the compiler emits an error on this type, it is because this file
  28. // was generated by a version of the `protoc` Swift plug-in that is
  29. // incompatible with the version of SwiftProtobuf to which you are linking.
  30. // Please ensure that you are building against the same version of the API
  31. // that was used to generate this file.
  32. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  33. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  34. typealias Version = _2
  35. }
  36. struct SwiftDescriptorTest_EditionsMessageForDelimited: @unchecked Sendable {
  37. // SwiftProtobuf.Message conformance is added in an extension below. See the
  38. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  39. // methods supported on all messages.
  40. var scalarField: Int32 {
  41. get {return _storage._scalarField ?? 0}
  42. set {_uniqueStorage()._scalarField = newValue}
  43. }
  44. /// Returns true if `scalarField` has been explicitly set.
  45. var hasScalarField: Bool {return _storage._scalarField != nil}
  46. /// Clears the value of `scalarField`. Subsequent reads from it will return its default value.
  47. mutating func clearScalarField() {_uniqueStorage()._scalarField = nil}
  48. var mapField: Dictionary<Int32,String> {
  49. get {return _storage._mapField}
  50. set {_uniqueStorage()._mapField = newValue}
  51. }
  52. var messageMapField: Dictionary<Int32,SwiftDescriptorTest_EditionsMessageForDelimited> {
  53. get {return _storage._messageMapField}
  54. set {_uniqueStorage()._messageMapField = newValue}
  55. }
  56. var delimitedField: SwiftDescriptorTest_EditionsMessageForDelimited {
  57. get {return _storage._delimitedField ?? SwiftDescriptorTest_EditionsMessageForDelimited()}
  58. set {_uniqueStorage()._delimitedField = newValue}
  59. }
  60. /// Returns true if `delimitedField` has been explicitly set.
  61. var hasDelimitedField: Bool {return _storage._delimitedField != nil}
  62. /// Clears the value of `delimitedField`. Subsequent reads from it will return its default value.
  63. mutating func clearDelimitedField() {_uniqueStorage()._delimitedField = nil}
  64. var lengthPrefixedField: SwiftDescriptorTest_EditionsMessageForDelimited {
  65. get {return _storage._lengthPrefixedField ?? SwiftDescriptorTest_EditionsMessageForDelimited()}
  66. set {_uniqueStorage()._lengthPrefixedField = newValue}
  67. }
  68. /// Returns true if `lengthPrefixedField` has been explicitly set.
  69. var hasLengthPrefixedField: Bool {return _storage._lengthPrefixedField != nil}
  70. /// Clears the value of `lengthPrefixedField`. Subsequent reads from it will return its default value.
  71. mutating func clearLengthPrefixedField() {_uniqueStorage()._lengthPrefixedField = nil}
  72. var unknownFields = SwiftProtobuf.UnknownStorage()
  73. init() {}
  74. fileprivate var _storage = _StorageClass.defaultInstance
  75. }
  76. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  77. fileprivate let _protobuf_package = "swift_descriptor_test"
  78. extension SwiftDescriptorTest_EditionsMessageForDelimited: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  79. static let protoMessageName: String = _protobuf_package + ".EditionsMessageForDelimited"
  80. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  81. 1: .standard(proto: "scalar_field"),
  82. 2: .standard(proto: "map_field"),
  83. 3: .standard(proto: "message_map_field"),
  84. 4: .standard(proto: "delimited_field"),
  85. 5: .standard(proto: "length_prefixed_field"),
  86. ]
  87. fileprivate class _StorageClass {
  88. var _scalarField: Int32? = nil
  89. var _mapField: Dictionary<Int32,String> = [:]
  90. var _messageMapField: Dictionary<Int32,SwiftDescriptorTest_EditionsMessageForDelimited> = [:]
  91. var _delimitedField: SwiftDescriptorTest_EditionsMessageForDelimited? = nil
  92. var _lengthPrefixedField: SwiftDescriptorTest_EditionsMessageForDelimited? = nil
  93. #if swift(>=5.10)
  94. // This property is used as the initial default value for new instances of the type.
  95. // The type itself is protecting the reference to its storage via CoW semantics.
  96. // This will force a copy to be made of this reference when the first mutation occurs;
  97. // hence, it is safe to mark this as `nonisolated(unsafe)`.
  98. static nonisolated(unsafe) let defaultInstance = _StorageClass()
  99. #else
  100. static let defaultInstance = _StorageClass()
  101. #endif
  102. private init() {}
  103. init(copying source: _StorageClass) {
  104. _scalarField = source._scalarField
  105. _mapField = source._mapField
  106. _messageMapField = source._messageMapField
  107. _delimitedField = source._delimitedField
  108. _lengthPrefixedField = source._lengthPrefixedField
  109. }
  110. }
  111. fileprivate mutating func _uniqueStorage() -> _StorageClass {
  112. if !isKnownUniquelyReferenced(&_storage) {
  113. _storage = _StorageClass(copying: _storage)
  114. }
  115. return _storage
  116. }
  117. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  118. _ = _uniqueStorage()
  119. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  120. while let fieldNumber = try decoder.nextFieldNumber() {
  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 fieldNumber {
  125. case 1: try { try decoder.decodeSingularInt32Field(value: &_storage._scalarField) }()
  126. case 2: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufString>.self, value: &_storage._mapField) }()
  127. case 3: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufInt32,SwiftDescriptorTest_EditionsMessageForDelimited>.self, value: &_storage._messageMapField) }()
  128. case 4: try { try decoder.decodeSingularGroupField(value: &_storage._delimitedField) }()
  129. case 5: try { try decoder.decodeSingularMessageField(value: &_storage._lengthPrefixedField) }()
  130. default: break
  131. }
  132. }
  133. }
  134. }
  135. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  136. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  137. // The use of inline closures is to circumvent an issue where the compiler
  138. // allocates stack space for every if/case branch local when no optimizations
  139. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  140. // https://github.com/apple/swift-protobuf/issues/1182
  141. try { if let v = _storage._scalarField {
  142. try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
  143. } }()
  144. if !_storage._mapField.isEmpty {
  145. try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufInt32,SwiftProtobuf.ProtobufString>.self, value: _storage._mapField, fieldNumber: 2)
  146. }
  147. if !_storage._messageMapField.isEmpty {
  148. try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufInt32,SwiftDescriptorTest_EditionsMessageForDelimited>.self, value: _storage._messageMapField, fieldNumber: 3)
  149. }
  150. try { if let v = _storage._delimitedField {
  151. try visitor.visitSingularGroupField(value: v, fieldNumber: 4)
  152. } }()
  153. try { if let v = _storage._lengthPrefixedField {
  154. try visitor.visitSingularMessageField(value: v, fieldNumber: 5)
  155. } }()
  156. }
  157. try unknownFields.traverse(visitor: &visitor)
  158. }
  159. static func ==(lhs: SwiftDescriptorTest_EditionsMessageForDelimited, rhs: SwiftDescriptorTest_EditionsMessageForDelimited) -> Bool {
  160. if lhs._storage !== rhs._storage {
  161. let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
  162. let _storage = _args.0
  163. let rhs_storage = _args.1
  164. if _storage._scalarField != rhs_storage._scalarField {return false}
  165. if _storage._mapField != rhs_storage._mapField {return false}
  166. if _storage._messageMapField != rhs_storage._messageMapField {return false}
  167. if _storage._delimitedField != rhs_storage._delimitedField {return false}
  168. if _storage._lengthPrefixedField != rhs_storage._lengthPrefixedField {return false}
  169. return true
  170. }
  171. if !storagesAreEqual {return false}
  172. }
  173. if lhs.unknownFields != rhs.unknownFields {return false}
  174. return true
  175. }
  176. }