Skip to content

Commit b8a3726

Browse files
authored
SWIFT-779 Funnel all bson_t access through helper methods (#453)
1 parent d026dd9 commit b8a3726

29 files changed

+554
-364
lines changed

Sources/MongoSwift/BSON/BSONEncoder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ private class MutableArray: BSONValue {
754754

755755
/// methods required by the BSONValue protocol that we don't actually need/use. MutableArray
756756
/// is just a BSONValue to simplify usage alongside true BSONValues within the encoder.
757-
fileprivate func encode(to _: DocumentStorage, forKey _: String) throws {
758-
fatalError("`MutableArray` is not meant to be encoded to a `DocumentStorage`")
757+
fileprivate func encode(to _: inout Document, forKey _: String) throws {
758+
fatalError("`MutableArray` is not meant to be encoded to a `Document`")
759759
}
760760

761761
internal static func from(iterator _: DocumentIterator) -> BSON {
@@ -818,8 +818,8 @@ private class MutableDictionary: BSONValue {
818818

819819
/// methods required by the BSONValue protocol that we don't actually need/use. MutableDictionary
820820
/// is just a BSONValue to simplify usage alongside true BSONValues within the encoder.
821-
fileprivate func encode(to _: DocumentStorage, forKey _: String) throws {
822-
fatalError("`MutableDictionary` is not meant to be encoded to a `DocumentStorage`")
821+
fileprivate func encode(to _: inout Document, forKey _: String) throws {
822+
fatalError("`MutableDictionary` is not meant to be encoded to a `Document`")
823823
}
824824

825825
internal static func from(iterator _: DocumentIterator) -> BSON {

Sources/MongoSwift/BSON/BSONValue.swift

Lines changed: 114 additions & 71 deletions
Large diffs are not rendered by default.

Sources/MongoSwift/BSON/Document+Collection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extension Document: Collection {
3838
// criticism also applies to key-based subscripting via `String`.
3939
// See SWIFT-250.
4040
self.failIndexCheck(position)
41-
guard let iter = DocumentIterator(forDocument: self) else {
41+
guard let iter = DocumentIterator(over: self) else {
4242
fatalError("Failed to initialize an iterator over document \(self)")
4343
}
4444

Sources/MongoSwift/BSON/Document+Sequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension Document: Sequence {
2323

2424
/// Returns a `DocumentIterator` over the values in this `Document`.
2525
public func makeIterator() -> DocumentIterator {
26-
guard let iter = DocumentIterator(forDocument: self) else {
26+
guard let iter = DocumentIterator(over: self) else {
2727
fatalError("Failed to initialize an iterator over document \(self)")
2828
}
2929
return iter

0 commit comments

Comments
 (0)