unittest_embed_optimize_for.pb.swift 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_embed_optimize_for.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. // Author: kenton@google.com (Kenton Varda)
  17. // Based on original Protocol Buffers design by
  18. // Sanjay Ghemawat, Jeff Dean, and others.
  19. //
  20. // A proto file which imports a proto file that uses optimize_for = CODE_SIZE.
  21. import SwiftProtobuf
  22. // If the compiler emits an error on this type, it is because this file
  23. // was generated by a version of the `protoc` Swift plug-in that is
  24. // incompatible with the version of SwiftProtobuf to which you are linking.
  25. // Please ensure that you are building against the same version of the API
  26. // that was used to generate this file.
  27. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  28. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  29. typealias Version = _2
  30. }
  31. struct Proto2Unittest_TestEmbedOptimizedForSize: Sendable {
  32. // SwiftProtobuf.Message conformance is added in an extension below. See the
  33. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  34. // methods supported on all messages.
  35. /// Test that embedding a message which has optimize_for = CODE_SIZE into
  36. /// one optimized for speed works.
  37. var optionalMessage: Proto2Unittest_TestOptimizedForSize {
  38. get {_optionalMessage ?? Proto2Unittest_TestOptimizedForSize()}
  39. set {_optionalMessage = newValue}
  40. }
  41. /// Returns true if `optionalMessage` has been explicitly set.
  42. var hasOptionalMessage: Bool {self._optionalMessage != nil}
  43. /// Clears the value of `optionalMessage`. Subsequent reads from it will return its default value.
  44. mutating func clearOptionalMessage() {self._optionalMessage = nil}
  45. var repeatedMessage: [Proto2Unittest_TestOptimizedForSize] = []
  46. var unknownFields = SwiftProtobuf.UnknownStorage()
  47. init() {}
  48. fileprivate var _optionalMessage: Proto2Unittest_TestOptimizedForSize? = nil
  49. }
  50. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  51. fileprivate let _protobuf_package = "proto2_unittest"
  52. extension Proto2Unittest_TestEmbedOptimizedForSize: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  53. static let protoMessageName: String = _protobuf_package + ".TestEmbedOptimizedForSize"
  54. static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}optional_message\0\u{3}repeated_message\0")
  55. public var isInitialized: Bool {
  56. if let v = self._optionalMessage, !v.isInitialized {return false}
  57. if !SwiftProtobuf.Internal.areAllInitialized(self.repeatedMessage) {return false}
  58. return true
  59. }
  60. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  61. while let fieldNumber = try decoder.nextFieldNumber() {
  62. // The use of inline closures is to circumvent an issue where the compiler
  63. // allocates stack space for every case branch when no optimizations are
  64. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  65. switch fieldNumber {
  66. case 1: try { try decoder.decodeSingularMessageField(value: &self._optionalMessage) }()
  67. case 2: try { try decoder.decodeRepeatedMessageField(value: &self.repeatedMessage) }()
  68. default: break
  69. }
  70. }
  71. }
  72. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  73. // The use of inline closures is to circumvent an issue where the compiler
  74. // allocates stack space for every if/case branch local when no optimizations
  75. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  76. // https://github.com/apple/swift-protobuf/issues/1182
  77. try { if let v = self._optionalMessage {
  78. try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
  79. } }()
  80. if !self.repeatedMessage.isEmpty {
  81. try visitor.visitRepeatedMessageField(value: self.repeatedMessage, fieldNumber: 2)
  82. }
  83. try unknownFields.traverse(visitor: &visitor)
  84. }
  85. static func ==(lhs: Proto2Unittest_TestEmbedOptimizedForSize, rhs: Proto2Unittest_TestEmbedOptimizedForSize) -> Bool {
  86. if lhs._optionalMessage != rhs._optionalMessage {return false}
  87. if lhs.repeatedMessage != rhs.repeatedMessage {return false}
  88. if lhs.unknownFields != rhs.unknownFields {return false}
  89. return true
  90. }
  91. }