Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/Enum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension Enum {
///
/// Since the text format and JSON names are always identical, we don't need
/// to distinguish them.
internal var name: _NameMap.Name? {
package var name: _NameMap.Name? {
guard let nameProviding = Self.self as? any _ProtoNameProviding.Type else {
return nil
}
Expand Down
16 changes: 8 additions & 8 deletions Sources/SwiftProtobuf/FieldTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
/// improper field number (such as zero) or wire format (such as 6 or 7) to
/// exist. In other words, a `FieldTag`'s properties never need to be tested
/// for validity because they are guaranteed correct at initialization time.
internal struct FieldTag: RawRepresentable {
package struct FieldTag: RawRepresentable {

typealias RawValue = UInt32
package typealias RawValue = UInt32

/// The raw numeric value of the tag, which contains both the field number and
/// wire format.
let rawValue: UInt32
package let rawValue: UInt32

/// The field number component of the tag.
var fieldNumber: Int {
package var fieldNumber: Int {
Int(rawValue >> 3)
}

/// The wire format component of the tag.
var wireFormat: WireFormat {
package var wireFormat: WireFormat {
// This force-unwrap is safe because there are only two initialization
// paths: one that takes a WireFormat directly (and is guaranteed valid at
// compile-time), or one that takes a raw value but which only lets valid
Expand All @@ -43,15 +43,15 @@ internal struct FieldTag: RawRepresentable {

/// A helper property that returns the number of bytes required to
/// varint-encode this tag.
var encodedSize: Int {
package var encodedSize: Int {
Varint.encodedSize(of: rawValue)
}

/// Creates a new tag from its raw numeric representation.
///
/// Note that if the raw value given here is not a valid tag (for example, it
/// has an invalid wire format), this initializer will fail.
init?(rawValue: UInt32) {
package init?(rawValue: UInt32) {
// Verify that the field number and wire format are valid and fail if they
// are not.
guard rawValue & ~0x07 != 0,
Expand All @@ -63,7 +63,7 @@ internal struct FieldTag: RawRepresentable {
}

/// Creates a new tag by composing the given field number and wire format.
init(fieldNumber: Int, wireFormat: WireFormat) {
package init(fieldNumber: Int, wireFormat: WireFormat) {
self.rawValue = UInt32(truncatingIfNeeded: fieldNumber) << 3 | UInt32(wireFormat.rawValue)
}
}
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/NameMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct _NameMap: ExpressibleByDictionaryLiteral {
/// block of UTF-8 data) where possible. In cases where the string
/// has to be computed, it caches the UTF-8 bytes in an
/// unmovable and immutable heap area.
internal struct Name: Hashable, CustomStringConvertible {
package struct Name: Hashable, CustomStringConvertible {
// This should not be used outside of this file, as it requires
// coordinating the lifecycle with the lifecycle of the pool
// where the raw UTF8 gets interned.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/SimpleExtensionMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct SimpleExtensionMap: ExtensionMap, ExpressibleByArrayLiteral {
public typealias Element = AnyMessageExtension

// Since type objects aren't Hashable, we can't do much better than this...
internal var fields = [Int: [any AnyMessageExtension]]()
package var fields = [Int: [any AnyMessageExtension]]()

public init() {}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/SwiftProtobufError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct SwiftProtobufError: Error, @unchecked Sendable {
}

/// A message describing what went wrong and how it may be remedied.
internal var message: String {
package var message: String {
get { self.storage.message }
set {
self.ensureStorageIsUnique()
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/UnknownStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct UnknownStorage: Equatable, Sendable {

public init() {}

internal mutating func append(protobufData: Data) {
package mutating func append(protobufData: Data) {
data.append(protobufData)
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftProtobuf/Varint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
// -----------------------------------------------------------------------------

/// Contains helper methods to varint-encode and decode integers.
internal enum Varint {
package enum Varint {

/// Computes the number of bytes that would be needed to store a 32-bit varint.
///
/// - Parameter value: The number whose varint size should be calculated.
/// - Returns: The size, in bytes, of the 32-bit varint.
static func encodedSize(of value: UInt32) -> Int {
package static func encodedSize(of value: UInt32) -> Int {
if (value & (~0 << 7)) == 0 {
return 1
}
Expand All @@ -40,7 +40,7 @@ internal enum Varint {
///
/// - Parameter value: The number whose varint size should be calculated.
/// - Returns: The size, in bytes, of the 32-bit varint.
static func encodedSize(of value: Int32) -> Int {
package static func encodedSize(of value: Int32) -> Int {
if value >= 0 {
return encodedSize(of: UInt32(bitPattern: value))
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/WireFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// -----------------------------------------------------------------------------

/// Denotes the wire format by which a value is encoded in binary form.
internal enum WireFormat: UInt8 {
package enum WireFormat: UInt8 {
case varint = 0
case fixed64 = 1
case lengthDelimited = 2
Expand Down
3 changes: 1 addition & 2 deletions Tests/SwiftProtobufTests/Data+TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
// -----------------------------------------------------------------------------

import Foundation

@testable import SwiftProtobuf
import SwiftProtobuf

/// Helpers for building up wire encoding in tests.
extension Data {
Expand Down
3 changes: 1 addition & 2 deletions Tests/SwiftProtobufTests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
// -----------------------------------------------------------------------------

import Foundation
import SwiftProtobuf
import XCTest

@testable import SwiftProtobuf

typealias XCTestFileArgType = StaticString

protocol PBTestHelpers {
Expand Down
3 changes: 1 addition & 2 deletions Tests/SwiftProtobufTests/Test_MessageSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
// -----------------------------------------------------------------------------

import Foundation
import SwiftProtobuf
import XCTest

@testable import SwiftProtobuf

extension SwiftProtoTesting_RawMessageSet.Item {
fileprivate init(typeID: Int, message: Data) {
self.init()
Expand Down
3 changes: 1 addition & 2 deletions Tests/SwiftProtobufTests/Test_Reserved.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
// -----------------------------------------------------------------------------

import Foundation
import SwiftProtobuf
import XCTest

@testable import SwiftProtobuf

final class Test_Reserved: XCTestCase {
func testEnumNaming() {
XCTAssertEqual(SwiftProtoTesting_SwiftReservedTest.Enum.double.rawValue, 1)
Expand Down
3 changes: 1 addition & 2 deletions Tests/SwiftProtobufTests/Test_SimpleExtensionMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
// -----------------------------------------------------------------------------

import Foundation
import SwiftProtobuf
import XCTest

@testable import SwiftProtobuf

extension AnyMessageExtension {
// Support equality to simplify testing of getting the correct errors.
func isEqual(_ other: any AnyMessageExtension) -> Bool {
Expand Down
4 changes: 1 addition & 3 deletions Tests/SwiftProtobufTests/Test_TextFormat_Unknown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
// -----------------------------------------------------------------------------

import Foundation
import SwiftProtobuf
import XCTest

@testable import SwiftProtobuf

final class Test_TextFormat_Unknown: XCTestCase, PBTestHelpers {
typealias MessageTestType = SwiftProtoTesting_TestEmptyMessage

Expand Down Expand Up @@ -333,7 +332,6 @@ final class Test_TextFormat_Unknown: XCTestCase, PBTestHelpers {

// If we try to parse `data`, the binary decode recursion budget will
// come into play, instead directly add the data into the unknown fields
// (via the @testable interface).
var msg = MessageTestType()
msg.unknownFields.append(protobufData: bytes)

Expand Down