Browse Source

fix(ml): Re-generate MLModelDownloader proto (#15239)

Nick Cooke 7 months ago
parent
commit
52ae69acb7
1 changed files with 72 additions and 138 deletions
  1. 72 138
      FirebaseMLModelDownloader/Sources/proto/firebase_ml_log_sdk.pb.swift

+ 72 - 138
FirebaseMLModelDownloader/Sources/proto/firebase_ml_log_sdk.pb.swift

@@ -1,5 +1,6 @@
 // DO NOT EDIT.
 // swift-format-ignore-file
+// swiftlint:disable all
 //
 // Generated by the Swift generator plugin for the protocol buffer compiler.
 // Source: firebase_ml_log_sdk.proto
@@ -21,7 +22,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import Foundation
 import SwiftProtobuf
 
 // If the compiler emits an error on this type, it is because this file
@@ -34,7 +34,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
   typealias Version = _2
 }
 
-enum EventName: SwiftProtobuf.Enum {
+enum EventName: SwiftProtobuf.Enum, Swift.CaseIterable {
   typealias RawValue = Int
   case unknownEvent // = 0
   case modelDownload // = 100
@@ -66,25 +66,19 @@ enum EventName: SwiftProtobuf.Enum {
     }
   }
 
-}
-
-#if swift(>=4.2)
-
-extension EventName: CaseIterable {
   // The compiler won't synthesize support with the UNRECOGNIZED case.
-  static var allCases: [EventName] = [
+  static let allCases: [EventName] = [
     .unknownEvent,
     .modelDownload,
     .modelUpdate,
     .remoteModelDeleteOnDevice,
   ]
-}
 
-#endif  // swift(>=4.2)
+}
 
 /// A list of error codes for various components of the system. For model downloading, the
 /// range of error codes is 100 to 199.
-enum ErrorCode: SwiftProtobuf.Enum {
+enum ErrorCode: SwiftProtobuf.Enum, Swift.CaseIterable {
   typealias RawValue = Int
 
   /// No error at all.
@@ -156,13 +150,8 @@ enum ErrorCode: SwiftProtobuf.Enum {
     }
   }
 
-}
-
-#if swift(>=4.2)
-
-extension ErrorCode: CaseIterable {
   // The compiler won't synthesize support with the UNRECOGNIZED case.
-  static var allCases: [ErrorCode] = [
+  static let allCases: [ErrorCode] = [
     .noError,
     .uriExpired,
     .noNetworkConnection,
@@ -173,12 +162,11 @@ extension ErrorCode: CaseIterable {
     .modelHashMismatch,
     .unknownError,
   ]
-}
 
-#endif  // swift(>=4.2)
+}
 
 /// Information about various parts of the system: app, Firebase, SDK.
-struct SystemInfo {
+struct SystemInfo: Sendable {
   // SwiftProtobuf.Message conformance is added in an extension below. See the
   // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
   // methods supported on all messages.
@@ -206,7 +194,7 @@ struct SystemInfo {
 }
 
 /// Information about models.
-struct ModelInfo {
+struct ModelInfo: Sendable {
   // SwiftProtobuf.Message conformance is added in an extension below. See the
   // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
   // methods supported on all messages.
@@ -229,7 +217,7 @@ struct ModelInfo {
 
   /// The model type is currently envisioned to be used mainly for model
   /// download/update.
-  enum ModelType: SwiftProtobuf.Enum {
+  enum ModelType: SwiftProtobuf.Enum, Swift.CaseIterable {
     typealias RawValue = Int
     case typeUnknown // = 0
     case custom // = 1
@@ -255,26 +243,20 @@ struct ModelInfo {
       }
     }
 
+    // The compiler won't synthesize support with the UNRECOGNIZED case.
+    static let allCases: [ModelInfo.ModelType] = [
+      .typeUnknown,
+      .custom,
+    ]
+
   }
 
   init() {}
 }
 
-#if swift(>=4.2)
-
-extension ModelInfo.ModelType: CaseIterable {
-  // The compiler won't synthesize support with the UNRECOGNIZED case.
-  static var allCases: [ModelInfo.ModelType] = [
-    .typeUnknown,
-    .custom,
-  ]
-}
-
-#endif  // swift(>=4.2)
-
 /// Detailed information about a model.
 /// The message used to be named "CustomModelOptions".
-struct ModelOptions {
+struct ModelOptions: Sendable {
   // SwiftProtobuf.Message conformance is added in an extension below. See the
   // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
   // methods supported on all messages.
@@ -303,7 +285,7 @@ struct ModelOptions {
 /// result in multiple log entries. "download_status" in the log entry indicates
 /// during which stage it is logged.
 /// This message used to be named "CustomModelDownloadLogEvent".
-struct ModelDownloadLogEvent {
+struct ModelDownloadLogEvent: Sendable {
   // SwiftProtobuf.Message conformance is added in an extension below. See the
   // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
   // methods supported on all messages.
@@ -352,7 +334,7 @@ struct ModelDownloadLogEvent {
   /// or explicitly does not affect the later stages of the download. As a
   /// result, later stages (i.e. enum tag 3+) do not distinguish between explicit
   /// and implicit triggering.
-  enum DownloadStatus: SwiftProtobuf.Enum {
+  enum DownloadStatus: SwiftProtobuf.Enum, Swift.CaseIterable {
     typealias RawValue = Int
     case unknownStatus // = 0
 
@@ -422,6 +404,20 @@ struct ModelDownloadLogEvent {
       }
     }
 
+    // The compiler won't synthesize support with the UNRECOGNIZED case.
+    static let allCases: [ModelDownloadLogEvent.DownloadStatus] = [
+      .unknownStatus,
+      .explicitlyRequested,
+      .implicitlyRequested,
+      .modelInfoRetrievalSucceeded,
+      .modelInfoRetrievalFailed,
+      .scheduled,
+      .downloading,
+      .succeeded,
+      .failed,
+      .updateAvailable,
+    ]
+
   }
 
   init() {}
@@ -429,28 +425,8 @@ struct ModelDownloadLogEvent {
   fileprivate var _options: ModelOptions? = nil
 }
 
-#if swift(>=4.2)
-
-extension ModelDownloadLogEvent.DownloadStatus: CaseIterable {
-  // The compiler won't synthesize support with the UNRECOGNIZED case.
-  static var allCases: [ModelDownloadLogEvent.DownloadStatus] = [
-    .unknownStatus,
-    .explicitlyRequested,
-    .implicitlyRequested,
-    .modelInfoRetrievalSucceeded,
-    .modelInfoRetrievalFailed,
-    .scheduled,
-    .downloading,
-    .succeeded,
-    .failed,
-    .updateAvailable,
-  ]
-}
-
-#endif  // swift(>=4.2)
-
 /// Information about deleting a downloaded model on device.
-struct DeleteModelLogEvent {
+struct DeleteModelLogEvent: Sendable {
   // SwiftProtobuf.Message conformance is added in an extension below. See the
   // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
   // methods supported on all messages.
@@ -469,7 +445,7 @@ struct DeleteModelLogEvent {
 /// Main log event for FirebaseMl, that contains individual API events, like model
 /// download.
 /// NEXT ID: 44.
-struct FirebaseMlLogEvent {
+struct FirebaseMlLogEvent: @unchecked Sendable {
   // SwiftProtobuf.Message conformance is added in an extension below. See the
   // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
   // methods supported on all messages.
@@ -520,37 +496,16 @@ struct FirebaseMlLogEvent {
 // MARK: - Code below here is support for the SwiftProtobuf runtime.
 
 extension EventName: SwiftProtobuf._ProtoNameProviding {
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    0: .same(proto: "UNKNOWN_EVENT"),
-    100: .same(proto: "MODEL_DOWNLOAD"),
-    101: .same(proto: "MODEL_UPDATE"),
-    252: .same(proto: "REMOTE_MODEL_DELETE_ON_DEVICE"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0UNKNOWN_EVENT\0\u{2}d\u{1}MODEL_DOWNLOAD\0\u{1}MODEL_UPDATE\0\u{2}W\u{2}REMOTE_MODEL_DELETE_ON_DEVICE\0")
 }
 
 extension ErrorCode: SwiftProtobuf._ProtoNameProviding {
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    0: .same(proto: "NO_ERROR"),
-    101: .same(proto: "URI_EXPIRED"),
-    102: .same(proto: "NO_NETWORK_CONNECTION"),
-    104: .same(proto: "DOWNLOAD_FAILED"),
-    105: .same(proto: "MODEL_INFO_DOWNLOAD_UNSUCCESSFUL_HTTP_STATUS"),
-    106: .same(proto: "MODEL_INFO_DOWNLOAD_NO_HASH"),
-    107: .same(proto: "MODEL_INFO_DOWNLOAD_CONNECTION_FAILED"),
-    116: .same(proto: "MODEL_HASH_MISMATCH"),
-    9999: .same(proto: "UNKNOWN_ERROR"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0NO_ERROR\0\u{2}e\u{1}URI_EXPIRED\0\u{1}NO_NETWORK_CONNECTION\0\u{2}\u{2}DOWNLOAD_FAILED\0\u{1}MODEL_INFO_DOWNLOAD_UNSUCCESSFUL_HTTP_STATUS\0\u{1}MODEL_INFO_DOWNLOAD_NO_HASH\0\u{1}MODEL_INFO_DOWNLOAD_CONNECTION_FAILED\0\u{2}\u{9}MODEL_HASH_MISMATCH\0\u{2}[Z\u{2}UNKNOWN_ERROR\0")
 }
 
 extension SystemInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
   static let protoMessageName: String = "SystemInfo"
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    1: .standard(proto: "app_id"),
-    2: .standard(proto: "app_version"),
-    3: .standard(proto: "firebase_project_id"),
-    4: .standard(proto: "ml_sdk_version"),
-    7: .standard(proto: "api_key"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}app_id\0\u{3}app_version\0\u{3}firebase_project_id\0\u{3}ml_sdk_version\0\u{4}\u{3}api_key\0")
 
   mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
@@ -600,12 +555,7 @@ extension SystemInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio
 
 extension ModelInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
   static let protoMessageName: String = "ModelInfo"
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    1: .same(proto: "name"),
-    2: .same(proto: "version"),
-    5: .same(proto: "hash"),
-    6: .standard(proto: "model_type"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}name\0\u{1}version\0\u{2}\u{3}hash\0\u{3}model_type\0")
 
   mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
@@ -649,18 +599,12 @@ extension ModelInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
 }
 
 extension ModelInfo.ModelType: SwiftProtobuf._ProtoNameProviding {
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    0: .same(proto: "TYPE_UNKNOWN"),
-    1: .same(proto: "CUSTOM"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0TYPE_UNKNOWN\0\u{1}CUSTOM\0")
 }
 
 extension ModelOptions: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
   static let protoMessageName: String = "ModelOptions"
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    1: .standard(proto: "model_info"),
-    4: .standard(proto: "is_model_update_enabled"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}model_info\0\u{4}\u{3}is_model_update_enabled\0")
 
   mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
@@ -676,9 +620,13 @@ extension ModelOptions: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat
   }
 
   func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
-    if let v = self._modelInfo {
+    // The use of inline closures is to circumvent an issue where the compiler
+    // allocates stack space for every if/case branch local when no optimizations
+    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
+    // https://github.com/apple/swift-protobuf/issues/1182
+    try { if let v = self._modelInfo {
       try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
-    }
+    } }()
     if self.isModelUpdateEnabled != false {
       try visitor.visitSingularBoolField(value: self.isModelUpdateEnabled, fieldNumber: 4)
     }
@@ -695,14 +643,7 @@ extension ModelOptions: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat
 
 extension ModelDownloadLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
   static let protoMessageName: String = "ModelDownloadLogEvent"
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    1: .same(proto: "options"),
-    2: .standard(proto: "rough_download_duration_ms"),
-    3: .standard(proto: "error_code"),
-    4: .standard(proto: "exact_download_duration_ms"),
-    5: .standard(proto: "download_status"),
-    6: .standard(proto: "download_failure_status"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}options\0\u{3}rough_download_duration_ms\0\u{3}error_code\0\u{3}exact_download_duration_ms\0\u{3}download_status\0\u{3}download_failure_status\0")
 
   mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
@@ -722,9 +663,13 @@ extension ModelDownloadLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
   }
 
   func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
-    if let v = self._options {
+    // The use of inline closures is to circumvent an issue where the compiler
+    // allocates stack space for every if/case branch local when no optimizations
+    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
+    // https://github.com/apple/swift-protobuf/issues/1182
+    try { if let v = self._options {
       try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
-    }
+    } }()
     if self.roughDownloadDurationMs != 0 {
       try visitor.visitSingularUInt64Field(value: self.roughDownloadDurationMs, fieldNumber: 2)
     }
@@ -756,26 +701,12 @@ extension ModelDownloadLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
 }
 
 extension ModelDownloadLogEvent.DownloadStatus: SwiftProtobuf._ProtoNameProviding {
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    0: .same(proto: "UNKNOWN_STATUS"),
-    1: .same(proto: "EXPLICITLY_REQUESTED"),
-    2: .same(proto: "IMPLICITLY_REQUESTED"),
-    3: .same(proto: "MODEL_INFO_RETRIEVAL_SUCCEEDED"),
-    4: .same(proto: "MODEL_INFO_RETRIEVAL_FAILED"),
-    5: .same(proto: "SCHEDULED"),
-    6: .same(proto: "DOWNLOADING"),
-    7: .same(proto: "SUCCEEDED"),
-    8: .same(proto: "FAILED"),
-    10: .same(proto: "UPDATE_AVAILABLE"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0UNKNOWN_STATUS\0\u{1}EXPLICITLY_REQUESTED\0\u{1}IMPLICITLY_REQUESTED\0\u{1}MODEL_INFO_RETRIEVAL_SUCCEEDED\0\u{1}MODEL_INFO_RETRIEVAL_FAILED\0\u{1}SCHEDULED\0\u{1}DOWNLOADING\0\u{1}SUCCEEDED\0\u{1}FAILED\0\u{2}\u{2}UPDATE_AVAILABLE\0")
 }
 
 extension DeleteModelLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
   static let protoMessageName: String = "DeleteModelLogEvent"
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    1: .standard(proto: "model_type"),
-    2: .standard(proto: "is_successful"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}model_type\0\u{3}is_successful\0")
 
   mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
     while let fieldNumber = try decoder.nextFieldNumber() {
@@ -810,12 +741,7 @@ extension DeleteModelLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImpl
 
 extension FirebaseMlLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
   static let protoMessageName: String = "FirebaseMlLogEvent"
-  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
-    1: .standard(proto: "system_info"),
-    2: .standard(proto: "event_name"),
-    3: .standard(proto: "model_download_log_event"),
-    40: .standard(proto: "delete_model_log_event"),
-  ]
+  static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}system_info\0\u{3}event_name\0\u{3}model_download_log_event\0\u{4}%delete_model_log_event\0")
 
   fileprivate class _StorageClass {
     var _systemInfo: SystemInfo? = nil
@@ -823,7 +749,11 @@ extension FirebaseMlLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImple
     var _modelDownloadLogEvent: ModelDownloadLogEvent? = nil
     var _deleteModelLogEvent: DeleteModelLogEvent? = nil
 
-    static let defaultInstance = _StorageClass()
+      // This property is used as the initial default value for new instances of the type.
+      // The type itself is protecting the reference to its storage via CoW semantics.
+      // This will force a copy to be made of this reference when the first mutation occurs;
+      // hence, it is safe to mark this as `nonisolated(unsafe)`.
+      static nonisolated(unsafe) let defaultInstance = _StorageClass()
 
     private init() {}
 
@@ -862,18 +792,22 @@ extension FirebaseMlLogEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImple
 
   func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
     try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
-      if let v = _storage._systemInfo {
+      // The use of inline closures is to circumvent an issue where the compiler
+      // allocates stack space for every if/case branch local when no optimizations
+      // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
+      // https://github.com/apple/swift-protobuf/issues/1182
+      try { if let v = _storage._systemInfo {
         try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
-      }
+      } }()
       if _storage._eventName != .unknownEvent {
         try visitor.visitSingularEnumField(value: _storage._eventName, fieldNumber: 2)
       }
-      if let v = _storage._modelDownloadLogEvent {
+      try { if let v = _storage._modelDownloadLogEvent {
         try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
-      }
-      if let v = _storage._deleteModelLogEvent {
+      } }()
+      try { if let v = _storage._deleteModelLogEvent {
         try visitor.visitSingularMessageField(value: v, fieldNumber: 40)
-      }
+      } }()
     }
     try unknownFields.traverse(visitor: &visitor)
   }