Skip to content

Bulk move the runtime over to importing FoundationEssentials when pos… #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/AnyMessageStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

private func serializeAnyJSON(
for message: any Message,
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/BinaryDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

internal struct BinaryDecoder: Decoder {
// Current position
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/BinaryDelimited.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
// -----------------------------------------------------------------------------

#if !os(WASI)
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif // !os(WASI)

/// Helper methods for reading/writing messages with a length prefix.
public enum BinaryDelimited {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/BinaryEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Encoder for Binary Protocol Buffer format
internal struct BinaryEncoder {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/BinaryEncodingSizeVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/BinaryEncodingVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Decoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Abstract protocol used by the generated code
/// to deserialize data.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/DoubleParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Support parsing float/double values from UTF-8
internal class DoubleParser {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/FieldTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Google_Protobuf_Any+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Google_Protobuf_Any+Registry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

#if !os(WASI)
#if canImport(Dispatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/HashVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Internal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/JSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

internal struct JSONDecoder: Decoder {
internal var scanner: JSONScanner
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/JSONEncodingVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/JSONMapEncodingVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Visitor that serializes a message into JSON map format.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/JSONScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

private let asciiBell = UInt8(7)
private let asciiBackspace = UInt8(8)
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/MathUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+BinaryAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Binary encoding and decoding methods for messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+BinaryAdditions_Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Binary encoding and decoding methods for messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+FieldMask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension Message {

Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+JSONAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// JSON encoding and decoding methods for messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+JSONAdditions_Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// JSON encoding and decoding methods for messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+JSONArrayAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// JSON encoding and decoding methods for arrays of messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+JSONArrayAdditions_Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// JSON encoding and decoding methods for arrays of messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/Message+TextFormatAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Text format encoding and decoding methods for messages.
extension Message {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/PathDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Describes errors can occure during decoding a proto by path.
public enum PathDecodingError: Error {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/PathVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
///
// -----------------------------------------------------------------------------

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

// Visitor captures all values of message with their paths
struct PathVisitor<T: Message>: Visitor {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftProtobuf/ProtobufMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Loading
Loading