diff --git a/Documentation/API.md b/Documentation/API.md index bf76665d6..03b42b183 100644 --- a/Documentation/API.md +++ b/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. diff --git a/Documentation/INTERNALS.md b/Documentation/INTERNALS.md index dbf68e127..a2c9289ad 100644 --- a/Documentation/INTERNALS.md +++ b/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 diff --git a/Sources/SwiftProtobuf/Message.swift b/Sources/SwiftProtobuf/Message.swift index 74d488cfd..70c2b9a20 100644 --- a/Sources/SwiftProtobuf/Message.swift +++ b/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: