Skip to content

Commit

Permalink
Split SwiftProtobuf into SwiftProtobufCore & SwiftProtobufFoundationC…
Browse files Browse the repository at this point in the history
…ompat
  • Loading branch information
gjcairo committed Oct 31, 2022
1 parent f80c750 commit 56e4e5f
Show file tree
Hide file tree
Showing 165 changed files with 15,569 additions and 15,545 deletions.
2 changes: 1 addition & 1 deletion DevTools/LibraryVersions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

_PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_PODSPEC_PATH = os.path.join(_PROJECT_ROOT, 'SwiftProtobuf.podspec')
_VERSION_SWIFT_PATH = os.path.join(_PROJECT_ROOT, 'Sources/SwiftProtobuf/Version.swift')
_VERSION_SWIFT_PATH = os.path.join(_PROJECT_ROOT, 'Sources/SwiftProtobufCore/Version.swift')

def Fail(message):
sys.stderr.write('Error: %s\n' % message)
Expand Down
1,088 changes: 544 additions & 544 deletions FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ regenerate-library-protos: build ${PROTOC_GEN_SWIFT}
${GENERATE_SRCS} \
--tfiws_opt=FileNaming=DropPath \
--tfiws_opt=Visibility=Public \
--tfiws_out=Sources/SwiftProtobuf \
--tfiws_out=Sources/SwiftProtobufCore \
${LIBRARY_PROTOS}

# Rebuild just the protos used by the plugin
Expand Down Expand Up @@ -411,7 +411,7 @@ Tests/protoc-gen-swiftTests/DescriptorTestData.swift: build ${PROTOC_GEN_SWIFT}
# public protocol, struct, enum, or class name, as well as every
# method or property defined in a public protocol, struct, or class.
# It also gives us a large collection of Swift names.
Protos/mined_words.txt: Sources/SwiftProtobuf/*.swift
Protos/mined_words.txt: Sources/SwiftProtobufCore/*.swift
@echo Building $@
@cat $^ | \
grep -E '\b(public|func|var)\b' | \
Expand Down
12 changes: 10 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ let package = Package(
],
targets: [
.target(
name: "SwiftProtobuf",
name: "SwiftProtobufCore",
exclude: ["CMakeLists.txt"]
),
.target(
name: "SwiftProtobufFoundationCompat",
dependencies: ["SwiftProtobufCore"]
),
.target(
name: "SwiftProtobuf",
dependencies: ["SwiftProtobufCore", "SwiftProtobufFoundationCompat"]
),
.target(
name: "SwiftProtobufPluginLibrary",
dependencies: ["SwiftProtobuf"],
Expand Down Expand Up @@ -67,7 +75,7 @@ let package = Package(
),
.testTarget(
name: "SwiftProtobufTests",
dependencies: ["SwiftProtobuf"]
dependencies: ["SwiftProtobufCore"]
),
.testTarget(
name: "SwiftProtobufPluginLibraryTests",
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_enum_cases.proto
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ enum GeneratedSwiftReservedEnum {
subVisitor = 735;
Swift = 736;
swiftPrefix = 737;
SwiftProtobuf = 738;
SwiftProtobufCore = 738;
syntax = 739;
T = 740;
tag = 741;
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ message GeneratedSwiftReservedEnums {
enum subVisitor { NONE_subVisitor = 0; }
enum Swift { NONE_Swift = 0; }
enum swiftPrefix { NONE_swiftPrefix = 0; }
enum SwiftProtobuf { NONE_SwiftProtobuf = 0; }
enum SwiftProtobufCore { NONE_SwiftProtobufCore = 0; }
enum syntax { NONE_syntax = 0; }
enum T { NONE_T = 0; }
enum tag { NONE_tag = 0; }
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_fields.proto
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ message GeneratedSwiftReservedFields {
int32 subVisitor = 735;
int32 Swift = 736;
int32 swiftPrefix = 737;
int32 SwiftProtobuf = 738;
int32 SwiftProtobufCore = 738;
int32 syntax = 739;
int32 T = 740;
int32 tag = 741;
Expand Down
2 changes: 1 addition & 1 deletion Protos/generated_swift_names_messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ message GeneratedSwiftReservedMessages {
message subVisitor { int32 subVisitor = 1; }
message Swift { int32 Swift = 1; }
message swiftPrefix { int32 swiftPrefix = 1; }
message SwiftProtobuf { int32 SwiftProtobuf = 1; }
message SwiftProtobufCore { int32 SwiftProtobufCore = 1; }
message syntax { int32 syntax = 1; }
message T { int32 T = 1; }
message tag { int32 tag = 1; }
Expand Down
66 changes: 33 additions & 33 deletions Sources/Conformance/conformance.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import Foundation
import SwiftProtobuf
import SwiftProtobufCore

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _3: SwiftProtobuf.ProtobufAPIVersion_3 {}
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobufCore.ProtobufAPIVersionCheck {
struct _3: SwiftProtobufCore.ProtobufAPIVersion_3 {}
typealias Version = _3
}

enum Conformance_WireFormat: SwiftProtobuf.Enum {
enum Conformance_WireFormat: SwiftProtobufCore.Enum {
typealias RawValue = Int
case unspecified // = 0
case protobuf // = 1
Expand Down Expand Up @@ -98,7 +98,7 @@ enum Conformance_WireFormat: SwiftProtobuf.Enum {

}

enum Conformance_TestCategory: SwiftProtobuf.Enum {
enum Conformance_TestCategory: SwiftProtobufCore.Enum {
typealias RawValue = Int
case unspecifiedTest // = 0

Expand Down Expand Up @@ -168,13 +168,13 @@ enum Conformance_TestCategory: SwiftProtobuf.Enum {
/// This will be known by message_type == "conformance.FailureSet", a conformance
/// test should return a serialized FailureSet in protobuf_payload.
struct Conformance_FailureSet {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// SwiftProtobufCore.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.

var failure: [String] = []

var unknownFields = SwiftProtobuf.UnknownStorage()
var unknownFields = SwiftProtobufCore.UnknownStorage()

init() {}
}
Expand All @@ -185,7 +185,7 @@ struct Conformance_FailureSet {
/// 2. parse the protobuf or JSON payload in "payload" (which may fail)
/// 3. if the parse succeeded, serialize the message in the requested format.
struct Conformance_ConformanceRequest {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// SwiftProtobufCore.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.

Expand Down Expand Up @@ -254,7 +254,7 @@ struct Conformance_ConformanceRequest {
/// unknown fields instead of ignore. This feature is optional.
var printUnknownFields: Bool = false

var unknownFields = SwiftProtobuf.UnknownStorage()
var unknownFields = SwiftProtobufCore.UnknownStorage()

/// The payload (whether protobuf of JSON) is always for a
/// protobuf_test_messages.proto3.TestAllTypes proto (as defined in
Expand All @@ -275,7 +275,7 @@ struct Conformance_ConformanceRequest {

/// Represents a single test case's output.
struct Conformance_ConformanceResponse {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// SwiftProtobufCore.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.

Expand Down Expand Up @@ -378,7 +378,7 @@ struct Conformance_ConformanceResponse {
set {result = .textPayload(newValue)}
}

var unknownFields = SwiftProtobuf.UnknownStorage()
var unknownFields = SwiftProtobufCore.UnknownStorage()

enum OneOf_Result: Equatable {
/// This string should be set to indicate parsing failed. The string can
Expand Down Expand Up @@ -423,14 +423,14 @@ struct Conformance_ConformanceResponse {

/// Encoding options for jspb format.
struct Conformance_JspbEncodingConfig {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// SwiftProtobufCore.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.

/// Encode the value field of Any as jspb array if true, otherwise binary.
var useJspbArrayAnyFormat: Bool = false

var unknownFields = SwiftProtobuf.UnknownStorage()
var unknownFields = SwiftProtobufCore.UnknownStorage()

init() {}
}
Expand All @@ -448,8 +448,8 @@ extension Conformance_JspbEncodingConfig: @unchecked Sendable {}

fileprivate let _protobuf_package = "conformance"

extension Conformance_WireFormat: SwiftProtobuf._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
extension Conformance_WireFormat: SwiftProtobufCore._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
0: .same(proto: "UNSPECIFIED"),
1: .same(proto: "PROTOBUF"),
2: .same(proto: "JSON"),
Expand All @@ -458,8 +458,8 @@ extension Conformance_WireFormat: SwiftProtobuf._ProtoNameProviding {
]
}

extension Conformance_TestCategory: SwiftProtobuf._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
extension Conformance_TestCategory: SwiftProtobufCore._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
0: .same(proto: "UNSPECIFIED_TEST"),
1: .same(proto: "BINARY_TEST"),
2: .same(proto: "JSON_TEST"),
Expand All @@ -469,13 +469,13 @@ extension Conformance_TestCategory: SwiftProtobuf._ProtoNameProviding {
]
}

extension Conformance_FailureSet: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Conformance_FailureSet: SwiftProtobufCore.Message, SwiftProtobufCore._MessageImplementationBase, SwiftProtobufCore._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".FailureSet"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
1: .same(proto: "failure"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
mutating func decodeMessage<D: SwiftProtobufCore.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
Expand All @@ -487,7 +487,7 @@ extension Conformance_FailureSet: SwiftProtobuf.Message, SwiftProtobuf._MessageI
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
func traverse<V: SwiftProtobufCore.Visitor>(visitor: inout V) throws {
if !self.failure.isEmpty {
try visitor.visitRepeatedStringField(value: self.failure, fieldNumber: 1)
}
Expand All @@ -501,9 +501,9 @@ extension Conformance_FailureSet: SwiftProtobuf.Message, SwiftProtobuf._MessageI
}
}

extension Conformance_ConformanceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Conformance_ConformanceRequest: SwiftProtobufCore.Message, SwiftProtobufCore._MessageImplementationBase, SwiftProtobufCore._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ConformanceRequest"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
1: .standard(proto: "protobuf_payload"),
2: .standard(proto: "json_payload"),
7: .standard(proto: "jspb_payload"),
Expand All @@ -515,7 +515,7 @@ extension Conformance_ConformanceRequest: SwiftProtobuf.Message, SwiftProtobuf._
9: .standard(proto: "print_unknown_fields"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
mutating func decodeMessage<D: SwiftProtobufCore.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
Expand Down Expand Up @@ -563,7 +563,7 @@ extension Conformance_ConformanceRequest: SwiftProtobuf.Message, SwiftProtobuf._
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
func traverse<V: SwiftProtobufCore.Visitor>(visitor: inout V) throws {
// 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
Expand Down Expand Up @@ -620,9 +620,9 @@ extension Conformance_ConformanceRequest: SwiftProtobuf.Message, SwiftProtobuf._
}
}

extension Conformance_ConformanceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Conformance_ConformanceResponse: SwiftProtobufCore.Message, SwiftProtobufCore._MessageImplementationBase, SwiftProtobufCore._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ConformanceResponse"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
1: .standard(proto: "parse_error"),
6: .standard(proto: "serialize_error"),
9: .standard(proto: "timeout_error"),
Expand All @@ -634,7 +634,7 @@ extension Conformance_ConformanceResponse: SwiftProtobuf.Message, SwiftProtobuf.
8: .standard(proto: "text_payload"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
mutating func decodeMessage<D: SwiftProtobufCore.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
Expand Down Expand Up @@ -717,7 +717,7 @@ extension Conformance_ConformanceResponse: SwiftProtobuf.Message, SwiftProtobuf.
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
func traverse<V: SwiftProtobufCore.Visitor>(visitor: inout V) throws {
// 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
Expand Down Expand Up @@ -771,13 +771,13 @@ extension Conformance_ConformanceResponse: SwiftProtobuf.Message, SwiftProtobuf.
}
}

extension Conformance_JspbEncodingConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Conformance_JspbEncodingConfig: SwiftProtobufCore.Message, SwiftProtobufCore._MessageImplementationBase, SwiftProtobufCore._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".JspbEncodingConfig"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
static let _protobuf_nameMap: SwiftProtobufCore._NameMap = [
1: .standard(proto: "use_jspb_array_any_format"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
mutating func decodeMessage<D: SwiftProtobufCore.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
Expand All @@ -789,7 +789,7 @@ extension Conformance_JspbEncodingConfig: SwiftProtobuf.Message, SwiftProtobuf._
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
func traverse<V: SwiftProtobufCore.Visitor>(visitor: inout V) throws {
if self.useJspbArrayAnyFormat != false {
try visitor.visitSingularBoolField(value: self.useJspbArrayAnyFormat, fieldNumber: 1)
}
Expand Down
Loading

0 comments on commit 56e4e5f

Please sign in to comment.