Преглед изворни кода

Remove reference to api that are "hookable".

These fall down in the face of modules. What's worse, is they
don't fail to build, the fail to apply in some cases, and to
understand it, a developer has to really understand how protocols
work/are resolved/etc.

We also were documenting the wrong method as a hook point.

So, rather than try to document all the things that do/don't work,
just stop documenting it, and allow future changes to not be
required to support it.

Issue #773 is open to look at provide better apis in the future for
customizing comparisons.
Thomas Van Lenten пре 7 година
родитељ
комит
a31212e1df
3 измењених фајлова са 6 додато и 42 уклоњено
  1. 0 20
      Documentation/API.md
  2. 3 5
      Documentation/INTERNALS.md
  3. 3 17
      Sources/SwiftProtobuf/Message.swift

+ 0 - 20
Documentation/API.md

@@ -141,26 +141,6 @@ then the word `Message` is appended to the name.
 For example, a `message Int` in the proto file will cause the
 generator to emit a `struct IntMessage` to the generated Swift file.
 
-### Overridable Message methods
-
-You can redefine the following in manually-constructed extensions if you
-want to override the default generated behavior for any reason:
-
-```swift
-  // By default, this just calls `serializedText()`
-  public var debugDescription: String
-
-  // By default, this computes a simple hash over all of the
-  // defined fields and submessages.
-  public var hashValue: Int
-
-  // The == operator is implemented in terms of this method
-  // so that you can easily override the implementation.
-  // You may override this method, but you should never call it directly.
-  // The default generated implementation compares every field for equality.
-  public func isEqualTo(message: Example) -> Bool
-```
-
 ## Enum API
 
 Proto enums are translated to Swift enums in a fairly straightforward manner.

+ 3 - 5
Documentation/INTERNALS.md

@@ -375,9 +375,9 @@ use an additional type object at this point.
 
 Many other facilities - not just serialization - can be built on
 top of this same machinery.
-For example, the default `hashValue` implementation uses the same
-traversal machinery to iterate over all of the set fields and values
-in order to compute the hash.
+For example, the `hashValue` implementation uses the same traversal
+machinery to iterate over all of the set fields and values in order
+to compute the hash.
 
 You can look at the runtime library to see more details about the
 `Visitor` protocol and the various implementations in each encoder.
@@ -448,8 +448,6 @@ collected unknown field data onto the resulting message object.
 
 TODO: initializers
 
-TODO: isEqualTo
-
 TODO: _protobuf_generated methods
 
 # Enums

+ 3 - 17
Sources/SwiftProtobuf/Message.swift

@@ -30,9 +30,7 @@
 ///     }
 ///
 /// The actual functionality is implemented either in the generated code or in
-/// default implementations of the below methods and properties. Some of them,
-/// including `hashValue` and `debugDescription`, are designed to let you
-/// override the functionality in custom extensions to the generated code.
+/// default implementations of the below methods and properties.
 public protocol Message: CustomDebugStringConvertible {
   /// Creates a new message with all of its fields initialized to their default
   /// values.
@@ -108,11 +106,6 @@ public protocol Message: CustomDebugStringConvertible {
   /// with the `Hashable` protocol.
   var hashValue: Int { get }
 
-  /// A textual representation of this message's contents suitable for
-  /// debugging, for conformance with the `CustomDebugStringConvertible`
-  /// protocol.
-  var debugDescription: String { get }
-
   /// Helper to compare `Message`s when not having a specific type to use
   /// normal `Equatable`. `Equatable` is provided with specific generated
   /// types.
@@ -129,13 +122,7 @@ public extension Message {
     return true
   }
 
-  /// A hash based on the message's full contents. Can be overridden
-  /// to improve performance and/or remove some values from being used for the
-  /// hash.
-  ///
-  /// If you override this, make sure you maintain the property that values
-  /// which are `==` to each other have identical `hashValues`, providing a
-  /// custom implementation of `==` if necessary.
+  /// A hash based on the message's full contents.
   var hashValue: Int {
     var visitor = HashVisitor()
     try? traverse(visitor: &visitor)
@@ -143,8 +130,7 @@ public extension Message {
   }
 
   /// A description generated by recursively visiting all fields in the message,
-  /// including messages. May be overridden to improve readability and/or
-  /// performance.
+  /// including messages.
   var debugDescription: String {
     // TODO Ideally there would be something like serializeText() that can
     // take a prefix so we could do something like: