Skip to content

Commit a31212e

Browse files
committed
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.
1 parent 3dec79b commit a31212e

File tree

3 files changed

+6
-42
lines changed

3 files changed

+6
-42
lines changed

Documentation/API.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,6 @@ then the word `Message` is appended to the name.
141141
For example, a `message Int` in the proto file will cause the
142142
generator to emit a `struct IntMessage` to the generated Swift file.
143143

144-
### Overridable Message methods
145-
146-
You can redefine the following in manually-constructed extensions if you
147-
want to override the default generated behavior for any reason:
148-
149-
```swift
150-
// By default, this just calls `serializedText()`
151-
public var debugDescription: String
152-
153-
// By default, this computes a simple hash over all of the
154-
// defined fields and submessages.
155-
public var hashValue: Int
156-
157-
// The == operator is implemented in terms of this method
158-
// so that you can easily override the implementation.
159-
// You may override this method, but you should never call it directly.
160-
// The default generated implementation compares every field for equality.
161-
public func isEqualTo(message: Example) -> Bool
162-
```
163-
164144
## Enum API
165145

166146
Proto enums are translated to Swift enums in a fairly straightforward manner.

Documentation/INTERNALS.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ use an additional type object at this point.
375375

376376
Many other facilities - not just serialization - can be built on
377377
top of this same machinery.
378-
For example, the default `hashValue` implementation uses the same
379-
traversal machinery to iterate over all of the set fields and values
380-
in order to compute the hash.
378+
For example, the `hashValue` implementation uses the same traversal
379+
machinery to iterate over all of the set fields and values in order
380+
to compute the hash.
381381

382382
You can look at the runtime library to see more details about the
383383
`Visitor` protocol and the various implementations in each encoder.
@@ -448,8 +448,6 @@ collected unknown field data onto the resulting message object.
448448

449449
TODO: initializers
450450

451-
TODO: isEqualTo
452-
453451
TODO: _protobuf_generated methods
454452

455453
# Enums

Sources/SwiftProtobuf/Message.swift

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
/// }
3131
///
3232
/// The actual functionality is implemented either in the generated code or in
33-
/// default implementations of the below methods and properties. Some of them,
34-
/// including `hashValue` and `debugDescription`, are designed to let you
35-
/// override the functionality in custom extensions to the generated code.
33+
/// default implementations of the below methods and properties.
3634
public protocol Message: CustomDebugStringConvertible {
3735
/// Creates a new message with all of its fields initialized to their default
3836
/// values.
@@ -108,11 +106,6 @@ public protocol Message: CustomDebugStringConvertible {
108106
/// with the `Hashable` protocol.
109107
var hashValue: Int { get }
110108

111-
/// A textual representation of this message's contents suitable for
112-
/// debugging, for conformance with the `CustomDebugStringConvertible`
113-
/// protocol.
114-
var debugDescription: String { get }
115-
116109
/// Helper to compare `Message`s when not having a specific type to use
117110
/// normal `Equatable`. `Equatable` is provided with specific generated
118111
/// types.
@@ -129,22 +122,15 @@ public extension Message {
129122
return true
130123
}
131124

132-
/// A hash based on the message's full contents. Can be overridden
133-
/// to improve performance and/or remove some values from being used for the
134-
/// hash.
135-
///
136-
/// If you override this, make sure you maintain the property that values
137-
/// which are `==` to each other have identical `hashValues`, providing a
138-
/// custom implementation of `==` if necessary.
125+
/// A hash based on the message's full contents.
139126
var hashValue: Int {
140127
var visitor = HashVisitor()
141128
try? traverse(visitor: &visitor)
142129
return visitor.hashValue
143130
}
144131

145132
/// A description generated by recursively visiting all fields in the message,
146-
/// including messages. May be overridden to improve readability and/or
147-
/// performance.
133+
/// including messages.
148134
var debugDescription: String {
149135
// TODO Ideally there would be something like serializeText() that can
150136
// take a prefix so we could do something like:

0 commit comments

Comments
 (0)