Update to SwiftProtobuf 1.36.1

This commit is contained in:
Max Radermacher 2026-03-17 09:50:14 -05:00
parent b2538b8b7f
commit 8da0e97f58
54 changed files with 618 additions and 417 deletions

View File

@ -44,7 +44,7 @@ PODS:
- SQLCipher/common (4.6.1)
- SQLCipher/standard (4.6.1):
- SQLCipher/common
- SwiftProtobuf (1.35.1)
- SwiftProtobuf (1.36.1)
DEPENDENCIES:
- blurhash (from `./ThirdParty/blurhash.podspec`)
@ -64,7 +64,7 @@ DEPENDENCIES:
- SDWebImageWebPCoder
- SignalRingRTC (from `https://github.com/signalapp/ringrtc`, tag `v2.67.0`)
- SQLCipher (from `https://github.com/signalapp/sqlcipher.git`, tag `v4.6.1-f_barrierfsync`)
- SwiftProtobuf (= 1.35.1)
- SwiftProtobuf (= 1.36.1)
SPEC REPOS:
trunk:
@ -145,8 +145,8 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
SignalRingRTC: 7a3eaaffc8c3d031ccb1b119e950c0b37e464aab
SQLCipher: ff2f045b20d675a73a70f7329395ddd4a2580063
SwiftProtobuf: c268fcf9642d613eb6639fed15842ae25d4b975a
SwiftProtobuf: 9e106a71456f4d3f6a3b0c8fd87ef0be085efc38
PODFILE CHECKSUM: 8482ae9bd0795ad6e60f053ad86c2230309ae36a
PODFILE CHECKSUM: db872f26e6cea91150c00f37864a4886a481f8c4
COCOAPODS: 1.15.2

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private func serializeAnyJSON(
for message: any Message,
@ -414,7 +418,7 @@ extension AnyMessageStorage {
// actually look up the value in their runtime registries, but since we do deferred parsing
// we can't assume the registry is complete, thus just do this minimal validation check.
fileprivate func isTypeURLValid() -> Bool {
_typeURL.contains("/")
_typeURL.contains(where: { $0 == "/" })
}
// Override the traversal-based JSON encoding

View File

@ -15,7 +15,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
internal struct BinaryDecoder: Decoder {
// Current position

View File

@ -12,7 +12,7 @@
///
// -----------------------------------------------------------------------------
#if !os(WASI)
#if !os(WASI) && BinaryDelimitedStreams
import Foundation
#endif
@ -31,7 +31,7 @@ public enum BinaryDelimited {
case truncated
}
#if !os(WASI)
#if !os(WASI) && BinaryDelimitedStreams
/// Serialize a single size-delimited message to the given stream. Delimited
/// format allows a single file or stream to contain multiple messages,
/// whereas normally writing multiple non-delimited messages to the same
@ -212,7 +212,7 @@ public enum BinaryDelimited {
#endif // !os(WASI)
}
#if !os(WASI)
#if !os(WASI) && BinaryDelimitedStreams
// TODO: This should go away when encoding/decoding are more stream based
// as that should provide a more direct way to do this. This is basically
// a rewrite of BinaryDecoder.decodeVarint().

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Encoder for Binary Protocol Buffer format
internal struct BinaryEncoder {

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Visitor that calculates the binary-encoded size of a message so that a
/// properly sized `Data` or `UInt8` array can be pre-allocated before

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Visitor that encodes a message graph in the protobuf binary wire format.
internal struct BinaryEncodingVisitor: Visitor {

View File

@ -14,7 +14,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Abstract protocol used by the generated code
/// to deserialize data.

View File

@ -12,7 +12,19 @@
///
// -----------------------------------------------------------------------------
import Foundation
#if canImport(Glibc)
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#elseif canImport(WASILibc)
import WASILibc
#elseif canImport(Darwin)
import Darwin
#elseif os(Windows)
import CRT
#endif
/// Support parsing float/double values from UTF-8
internal class DoubleParser {

View File

@ -22,7 +22,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// Note: The protobuf- and JSON-specific methods here are defined
// in ProtobufTypeAdditions.swift and JSONTypeAdditions.swift

View File

@ -14,7 +14,11 @@
// Explicit import of Foundation is necessary on Linux,
// don't remove unless obsolete on all platforms
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
public let defaultAnyTypeURLPrefix: String = "type.googleapis.com"

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#if !os(WASI)
#if canImport(Dispatch)

View File

@ -14,7 +14,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let minDurationSeconds: Int64 = -maxDurationSeconds
private let maxDurationSeconds: Int64 = 315_576_000_000

View File

@ -113,6 +113,32 @@ private func parseJSONFieldNames(names: String) -> [String]? {
return split
}
extension Google_Protobuf_FieldMask: _CustomJSONCodable {
mutating func decodeJSON(from decoder: inout JSONDecoder) throws {
let s = try decoder.scanner.nextQuotedString()
if let names = parseJSONFieldNames(names: s) {
paths = names
} else {
throw JSONDecodingError.malformedFieldMask
}
}
func encodedJSONString(options: JSONEncodingOptions) throws -> String {
// Note: Proto requires alphanumeric field names, so there
// cannot be a ',' or '"' character to mess up this formatting.
var jsonPaths = [String]()
for p in paths {
if let jsonPath = ProtoToJSON(name: p) {
jsonPaths.append(jsonPath)
} else {
throw JSONEncodingError.fieldMaskConversion
}
}
return "\"" + jsonPaths.joined(separator: ",") + "\""
}
}
#if FieldMaskUtilities
extension Google_Protobuf_FieldMask {
/// Creates a new `Google_Protobuf_FieldMask` from the given array of paths.
///
@ -154,31 +180,6 @@ extension Google_Protobuf_FieldMask {
// names is not entirely deterministic.
}
extension Google_Protobuf_FieldMask: _CustomJSONCodable {
mutating func decodeJSON(from decoder: inout JSONDecoder) throws {
let s = try decoder.scanner.nextQuotedString()
if let names = parseJSONFieldNames(names: s) {
paths = names
} else {
throw JSONDecodingError.malformedFieldMask
}
}
func encodedJSONString(options: JSONEncodingOptions) throws -> String {
// Note: Proto requires alphanumeric field names, so there
// cannot be a ',' or '"' character to mess up this formatting.
var jsonPaths = [String]()
for p in paths {
if let jsonPath = ProtoToJSON(name: p) {
jsonPaths.append(jsonPath)
} else {
throw JSONEncodingError.fieldMaskConversion
}
}
return "\"" + jsonPaths.joined(separator: ",") + "\""
}
}
extension Google_Protobuf_FieldMask {
/// Initiates a field mask with all fields of the message type.
@ -365,3 +366,5 @@ extension Message where Self: _ProtoNameProviding {
Self._protobuf_nameMap.names.map(\.description)
}
}
#endif

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let minTimestampSeconds: Int64 = -62_135_596_800 // 0001-01-01T00:00:00Z
private let maxTimestampSeconds: Int64 = 253_402_300_799 // 9999-12-31T23:59:59Z

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Internal protocol that minimizes the code duplication across the multiple
/// wrapper types extended below.

View File

@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let i_2166136261 = Int(bitPattern: 2_166_136_261)
private let i_16777619 = Int(16_777_619)

View File

@ -14,7 +14,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Functions that are public only because they are used by generated message implementations.
/// - Important: NOT INTENDED TO BE CALLED BY CLIENTS.

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
internal struct JSONDecoder: Decoder {
internal var scanner: JSONScanner

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let asciiZero = UInt8(ascii: "0")
private let asciiOne = UInt8(ascii: "1")

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Visitor that serializes a message into JSON format.
internal struct JSONEncodingVisitor: Visitor {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Visitor that serializes a message into JSON map format.
///

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let asciiBell = UInt8(7)
private let asciiBackspace = UInt8(8)

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Remainder in standard modular arithmetic (modulo). This coincides with (%)
/// when a > 0.

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Binary encoding and decoding methods for messages.
extension Message {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Binary encoding and decoding methods for messages.
extension Message {

View File

@ -12,7 +12,28 @@
///
// -----------------------------------------------------------------------------
extension Google_Protobuf_FieldMask {
/// Defines available options for merging two messages.
public struct MergeOptions {
public init() {}
/// The default merging behavior will append entries from the source
/// repeated field to the destination repeated field. If you only want
/// to keep the entries from the source repeated field, set this flag
/// to true.
public var replaceRepeatedFields = false
}
}
#if FieldMaskUtilities
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
extension Message {
@ -45,21 +66,6 @@ extension Message {
}
}
extension Google_Protobuf_FieldMask {
/// Defines available options for merging two messages.
public struct MergeOptions {
public init() {}
/// The default merging behavior will append entries from the source
/// repeated field to the destination repeated field. If you only want
/// to keep the entries from the source repeated field, set this flag
/// to true.
public var replaceRepeatedFields = false
}
}
extension Message {
/// Merges fields specified in a FieldMask into another message.
@ -131,3 +137,5 @@ extension Message {
self.unknownFields = message.unknownFields
}
}
#endif

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// JSON encoding and decoding methods for messages.
extension Message {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// JSON encoding and decoding methods for messages.
extension Message {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// JSON encoding and decoding methods for arrays of messages.
extension Message {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// JSON encoding and decoding methods for arrays of messages.
extension Message {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Text format encoding and decoding methods for messages.
extension Message {

View File

@ -12,7 +12,13 @@
///
// -----------------------------------------------------------------------------
#if FieldMaskUtilities
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Describes errors can occure during decoding a proto by path.
public enum PathDecodingError: Error {
@ -441,3 +447,5 @@ extension Message {
try decodeMessage(decoder: &decoder)
}
}
#endif

View File

@ -12,7 +12,13 @@
///
// -----------------------------------------------------------------------------
#if FieldMaskUtilities
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// Visitor captures all values of message with their paths
struct PathVisitor<T: Message>: Visitor {
@ -282,3 +288,5 @@ struct PathVisitor<T: Message>: Visitor {
visit(value, fieldNumber: fieldNumber)
}
}
#endif

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// SwiftProtobuf Internal: Support for Encoding/Decoding.
public struct _ProtobufMap<KeyType: MapKeyType, ValueType: FieldType> {

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// A base for Visitors that only expects a subset of things to called.
internal protocol SelectiveVisitor: Visitor {

View File

@ -18,7 +18,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// Note: Once our minimum support version is at least Swift 5.3, we should
// probably recast the following to use String(unsafeUninitializedCapacity:)

View File

@ -8,7 +8,11 @@
//
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Conformance to this protocol gives users a way to provide their own "bag of bytes" types
/// to be used for serialization and deserialization of protobufs.

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
///
/// Provides a higher-level interface to the token stream coming

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let asciiSpace = UInt8(ascii: " ")
private let asciiColon = UInt8(ascii: ":")

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let mapNameResolver: [Int: StaticString] = [1: "key", 2: "value"]

View File

@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
private let asciiBell = UInt8(7)
private let asciiBackspace = UInt8(8)

View File

@ -14,7 +14,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// Contains any unknown fields in a decoded message; that is, fields that were
/// sent on the wire but were not recognized by the generated message

View File

@ -12,14 +12,18 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// Expose version information about the library.
public struct Version {
/// Major version.
public static let major = 1
/// Minor version.
public static let minor = 35
public static let minor = 36
/// Revision number.
public static let revision = 1

View File

@ -25,7 +25,11 @@
///
// -----------------------------------------------------------------------------
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
/// This is the key interface used by the generated `traverse()` methods
/// used for serialization. It is implemented by each serialization protocol:

View File

@ -38,7 +38,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// 'import SwiftProtobuf' suppressed, this proto file is meant to be bundled in the runtime.
// If the compiler emits an error on this type, it is because this file

View File

@ -46,7 +46,11 @@
// A valid .proto file can be translated directly to a FileDescriptorProto
// without any other information (e.g. without reading its imports).
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// 'import SwiftProtobuf' suppressed, this proto file is meant to be bundled in the runtime.
// If the compiler emits an error on this type, it is because this file

View File

@ -86,14 +86,15 @@ public enum Google_Protobuf_NullValue: Enum, Swift.CaseIterable {
}
/// `Struct` represents a structured data value, consisting of fields
/// which map to dynamically typed values. In some languages, `Struct`
/// might be supported by a native representation. For example, in
/// scripting languages like JS a struct is represented as an
/// object. The details of that representation are described together
/// with the proto support for the language.
/// Represents an unordered key-value map, intending to perfectly
/// capture the semantics of a JSON object. This enables parsing any arbitrary
/// JSON payload as a message field in ProtoJSON format.
///
/// The JSON representation for `Struct` is JSON object.
/// This type cannot represent large Int64 values or `NaN`/`Infinity` numbers,
/// since JSON format generally does not support them in its number type.
///
/// If you do not intend to parse arbitrary JSON into your message, a custom
/// typed message should be preferred instead.
public struct Google_Protobuf_Struct: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
@ -130,7 +131,7 @@ public struct Google_Protobuf_Value: Sendable {
set {kind = .nullValue(newValue)}
}
/// Represents a double value.
/// Represents a double value. Must not be `NaN`, `Infinity` or `-Infinity`.
public var numberValue: Double {
get {
if case .numberValue(let v)? = kind {return v}
@ -181,7 +182,7 @@ public struct Google_Protobuf_Value: Sendable {
public enum OneOf_Kind: Equatable, Sendable {
/// Represents a null value.
case nullValue(Google_Protobuf_NullValue)
/// Represents a double value.
/// Represents a double value. Must not be `NaN`, `Infinity` or `-Infinity`.
case numberValue(Double)
/// Represents a string value.
case stringValue(String)

View File

@ -55,7 +55,11 @@
// These wrappers have no meaningful use within a map or a oneof since
// individual entries of a map or fields of a oneof can already detect presence.
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
// 'import SwiftProtobuf' suppressed, this proto file is meant to be bundled in the runtime.
// If the compiler emits an error on this type, it is because this file

View File

@ -13,7 +13,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.35.1</string>
<string>1.36.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.35.1</string>
<string>1.36.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@ -12,4 +12,5 @@ PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftProtobuf
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) BinaryDelimitedStreams FieldMaskUtilities
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES

View File

@ -12,4 +12,5 @@ PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftProtobuf
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) BinaryDelimitedStreams FieldMaskUtilities
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES