Skip to content

Commit

Permalink
remove the unnecessary code which can be figured out using git diff
Browse files Browse the repository at this point in the history
  • Loading branch information
RishavG96 committed May 25, 2023
1 parent 2288e3a commit 814b866
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 72 deletions.
19 changes: 0 additions & 19 deletions Sources/protoc-gen-swift/FileGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ class FileGenerator {
}
}

p.print()
// generateVersionCheck(printer: &p)

let extensionSet =
ExtensionSetGenerator(fileDescriptor: fileDescriptor,
generatorOptions: generatorOptions,
Expand Down Expand Up @@ -202,20 +199,4 @@ class FileGenerator {
}
}
}

private func generateVersionCheck(printer p: inout CodePrinter) {
let v = Version.compatibilityVersion
p.print("""
// 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: \(namer.swiftProtobufModulePrefix)ProtobufAPIVersionCheck {
""")
p.printIndented(
"struct _\(v): \(namer.swiftProtobufModulePrefix)ProtobufAPIVersion_\(v) {}",
"typealias Version = _\(v)")
p.print("}")
}
}
12 changes: 0 additions & 12 deletions Sources/protoc-gen-swift/MessageFieldGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,6 @@ class MessageFieldGenerator: FieldGeneratorBase, FieldGenerator {
p.print("\(comments)\(visibility)var \(swiftName): \(swiftStorageType) = \(swiftDefaultValue)")
}
}
return
guard hasFieldPresence else { return }

let immutableStoragePrefix = usesHeapStorage ? "_storage." : "self."
p.print(
"/// Returns true if `\(swiftName)` has been explicitly set.",
"\(visibility)var \(swiftHasName): Bool {return \(immutableStoragePrefix)\(underscoreSwiftName) != nil}")

let mutableStoragePrefix = usesHeapStorage ? "_uniqueStorage()." : "self."
p.print(
"/// Clears the value of `\(swiftName)`. Subsequent reads from it will return its default value.",
"\(visibility)mutating func \(swiftClearName)() {\(mutableStoragePrefix)\(underscoreSwiftName) = nil}")
}

func generateStorageClassClone(printer p: inout CodePrinter) {
Expand Down
41 changes: 0 additions & 41 deletions Sources/protoc-gen-swift/MessageGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ class MessageGenerator {
generateDecodeMessage(printer: &p)
p.print()
generateTraverse(printer: &p)
p.print()
// generateMessageEquality(printer: &p)
}
p.print("}")

Expand Down Expand Up @@ -371,45 +369,6 @@ class MessageGenerator {
p.print("}")
}

private func generateMessageEquality(printer p: inout CodePrinter) {
p.print("\(visibility)static func ==(lhs: \(swiftFullName), rhs: \(swiftFullName)) -> Bool {")
p.withIndentation { p in
var compareFields = true
if let storage = storage {
p.print("if lhs._storage !== rhs._storage {")
p.indent()
p.print("let storagesAreEqual: Bool = ", newlines: false)
if storage.storageProvidesEqualTo {
p.print("lhs._storage.isEqualTo(other: rhs._storage)")
compareFields = false
}
}
if compareFields {
generateWithLifetimeExtension(printer: &p,
alsoCapturing: "rhs",
selfQualifier: "lhs") { p in
for f in fields {
f.generateFieldComparison(printer: &p)
}
if storage != nil {
p.print("return true")
}
}
}
if storage != nil {
p.print("if !storagesAreEqual {return false}")
p.outdent()
p.print("}")
}
p.print("if lhs.unknownFields != rhs.unknownFields {return false}")
if isExtensible {
p.print("if lhs._protobuf_extensionFieldValues != rhs._protobuf_extensionFieldValues {return false}")
}
p.print("return true")
}
p.print("}")
}

/// Generates the `isInitialized` property for the message, if needed.
///
/// This may generate nothing, if the `isInitialized` property is not
Expand Down

0 comments on commit 814b866

Please sign in to comment.