diff options
Diffstat (limited to 'Firestore/Source/Model')
-rw-r--r-- | Firestore/Source/Model/FSTDocument.mm | 2 | ||||
-rw-r--r-- | Firestore/Source/Model/FSTDocumentKey.mm | 6 | ||||
-rw-r--r-- | Firestore/Source/Model/FSTFieldValue.mm | 19 | ||||
-rw-r--r-- | Firestore/Source/Model/FSTMutation.mm | 45 | ||||
-rw-r--r-- | Firestore/Source/Model/FSTMutationBatch.mm | 22 |
5 files changed, 48 insertions, 46 deletions
diff --git a/Firestore/Source/Model/FSTDocument.mm b/Firestore/Source/Model/FSTDocument.mm index 8c4c801..376075e 100644 --- a/Firestore/Source/Model/FSTDocument.mm +++ b/Firestore/Source/Model/FSTDocument.mm @@ -19,10 +19,10 @@ #include <utility> #import "Firestore/Source/Model/FSTFieldValue.h" -#import "Firestore/Source/Util/FSTAssert.h" #include "Firestore/core/src/firebase/firestore/model/document_key.h" #include "Firestore/core/src/firebase/firestore/model/field_path.h" +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" #include "Firestore/core/src/firebase/firestore/util/hashing.h" #include "Firestore/core/src/firebase/firestore/util/string_apple.h" diff --git a/Firestore/Source/Model/FSTDocumentKey.mm b/Firestore/Source/Model/FSTDocumentKey.mm index d29df86..ad3968e 100644 --- a/Firestore/Source/Model/FSTDocumentKey.mm +++ b/Firestore/Source/Model/FSTDocumentKey.mm @@ -20,9 +20,9 @@ #include <utility> #import "Firestore/Source/Core/FSTFirestoreClient.h" -#import "Firestore/Source/Util/FSTAssert.h" #include "Firestore/core/src/firebase/firestore/model/resource_path.h" +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" #include "Firestore/core/src/firebase/firestore/util/hashing.h" #include "Firestore/core/src/firebase/firestore/util/string_apple.h" @@ -53,8 +53,8 @@ NS_ASSUME_NONNULL_BEGIN /** Designated initializer. */ - (instancetype)initWithPath:(ResourcePath)path { - FSTAssert([FSTDocumentKey isDocumentKey:path], @"invalid document key path: %s", - path.CanonicalString().c_str()); + HARD_ASSERT([FSTDocumentKey isDocumentKey:path], "invalid document key path: %s", + path.CanonicalString()); if (self = [super init]) { _path = path; diff --git a/Firestore/Source/Model/FSTFieldValue.mm b/Firestore/Source/Model/FSTFieldValue.mm index 9e77d39..6a13511 100644 --- a/Firestore/Source/Model/FSTFieldValue.mm +++ b/Firestore/Source/Model/FSTFieldValue.mm @@ -21,12 +21,12 @@ #import "Firestore/Source/API/FIRGeoPoint+Internal.h" #import "Firestore/Source/Model/FSTDocumentKey.h" -#import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Source/Util/FSTClasses.h" #include "Firestore/core/src/firebase/firestore/model/database_id.h" #include "Firestore/core/src/firebase/firestore/model/field_path.h" #include "Firestore/core/src/firebase/firestore/util/comparison.h" +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" #include "Firestore/core/src/firebase/firestore/util/string_apple.h" namespace util = firebase::firestore::util; @@ -99,8 +99,8 @@ NS_ASSUME_NONNULL_BEGIN if (self.typeOrder > other.typeOrder) { return NSOrderedDescending; } else { - FSTAssert(self.typeOrder < other.typeOrder, - @"defaultCompare should not be used for values of same type."); + HARD_ASSERT(self.typeOrder < other.typeOrder, + "defaultCompare should not be used for values of same type."); return NSOrderedAscending; } } @@ -231,8 +231,8 @@ NS_ASSUME_NONNULL_BEGIN if ([other isKindOfClass:[FSTDoubleValue class]]) { return WrapCompare(thisDouble, ((FSTDoubleValue *)other).internalValue); } else { - FSTAssert([other isKindOfClass:[FSTIntegerValue class]], @"Unknown number value: %@", - other); + HARD_ASSERT([other isKindOfClass:[FSTIntegerValue class]], "Unknown number value: %s", + other); auto result = CompareMixedNumber(thisDouble, ((FSTIntegerValue *)other).internalValue); return static_cast<NSComparisonResult>(result); } @@ -241,7 +241,8 @@ NS_ASSUME_NONNULL_BEGIN if ([other isKindOfClass:[FSTIntegerValue class]]) { return WrapCompare(thisInt, ((FSTIntegerValue *)other).internalValue); } else { - FSTAssert([other isKindOfClass:[FSTDoubleValue class]], @"Unknown number value: %@", other); + HARD_ASSERT([other isKindOfClass:[FSTDoubleValue class]], "Unknown number value: %s", + other); double otherDouble = ((FSTDoubleValue *)other).internalValue; auto result = ReverseOrder(CompareMixedNumber(otherDouble, thisInt)); return static_cast<NSComparisonResult>(result); @@ -499,7 +500,7 @@ struct Comparator<NSString *> { case FSTServerTimestampBehaviorPrevious: return self.previousValue ? [self.previousValue valueWithOptions:options] : [NSNull null]; default: - FSTFail(@"Unexpected server timestamp option: %ld", (long)options.serverTimestampBehavior); + HARD_FAIL("Unexpected server timestamp option: %s", options.serverTimestampBehavior); } } @@ -825,7 +826,7 @@ static const NSComparator StringComparator = ^NSComparisonResult(NSString *left, - (FSTObjectValue *)objectBySettingValue:(FSTFieldValue *)value forPath:(const FieldPath &)fieldPath { - FSTAssert(fieldPath.size() > 0, @"Cannot set value with an empty path"); + HARD_ASSERT(fieldPath.size() > 0, "Cannot set value with an empty path"); NSString *childName = util::WrapNSString(fieldPath.first_segment()); if (fieldPath.size() == 1) { @@ -849,7 +850,7 @@ static const NSComparator StringComparator = ^NSComparisonResult(NSString *left, } - (FSTObjectValue *)objectByDeletingPath:(const FieldPath &)fieldPath { - FSTAssert(fieldPath.size() > 0, @"Cannot delete an empty path"); + HARD_ASSERT(fieldPath.size() > 0, "Cannot delete an empty path"); NSString *childName = util::WrapNSString(fieldPath.first_segment()); if (fieldPath.size() == 1) { return [[FSTObjectValue alloc] diff --git a/Firestore/Source/Model/FSTMutation.mm b/Firestore/Source/Model/FSTMutation.mm index 82a535e..d124c78 100644 --- a/Firestore/Source/Model/FSTMutation.mm +++ b/Firestore/Source/Model/FSTMutation.mm @@ -25,7 +25,6 @@ #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTFieldValue.h" -#import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Source/Util/FSTClasses.h" #include "Firestore/core/src/firebase/firestore/model/document_key.h" @@ -34,6 +33,7 @@ #include "Firestore/core/src/firebase/firestore/model/field_transform.h" #include "Firestore/core/src/firebase/firestore/model/precondition.h" #include "Firestore/core/src/firebase/firestore/model/transform_operations.h" +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" #include "absl/types/optional.h" @@ -153,7 +153,7 @@ NS_ASSUME_NONNULL_BEGIN localWriteTime:(FIRTimestamp *)localWriteTime mutationResult:(nullable FSTMutationResult *)mutationResult { if (mutationResult) { - FSTAssert(!mutationResult.transformResults, @"Transform results received by FSTSetMutation."); + HARD_ASSERT(!mutationResult.transformResults, "Transform results received by FSTSetMutation."); } if (!self.precondition.IsValidFor(maybeDoc)) { @@ -169,11 +169,11 @@ NS_ASSUME_NONNULL_BEGIN hasLocalMutations:hasLocalMutations]; } - FSTAssert([maybeDoc isMemberOfClass:[FSTDocument class]], @"Unknown MaybeDocument type %@", - [maybeDoc class]); + HARD_ASSERT([maybeDoc isMemberOfClass:[FSTDocument class]], "Unknown MaybeDocument type %s", + [maybeDoc class]); FSTDocument *doc = (FSTDocument *)maybeDoc; - FSTAssert([doc.key isEqual:self.key], @"Can only set a document with the same key"); + HARD_ASSERT([doc.key isEqual:self.key], "Can only set a document with the same key"); return [FSTDocument documentWithData:self.value key:doc.key version:doc.version @@ -236,7 +236,8 @@ NS_ASSUME_NONNULL_BEGIN localWriteTime:(FIRTimestamp *)localWriteTime mutationResult:(nullable FSTMutationResult *)mutationResult { if (mutationResult) { - FSTAssert(!mutationResult.transformResults, @"Transform results received by FSTPatchMutation."); + HARD_ASSERT(!mutationResult.transformResults, + "Transform results received by FSTPatchMutation."); } if (!self.precondition.IsValidFor(maybeDoc)) { @@ -254,11 +255,11 @@ NS_ASSUME_NONNULL_BEGIN hasLocalMutations:hasLocalMutations]; } - FSTAssert([maybeDoc isMemberOfClass:[FSTDocument class]], @"Unknown MaybeDocument type %@", - [maybeDoc class]); + HARD_ASSERT([maybeDoc isMemberOfClass:[FSTDocument class]], "Unknown MaybeDocument type %s", + [maybeDoc class]); FSTDocument *doc = (FSTDocument *)maybeDoc; - FSTAssert([doc.key isEqual:self.key], @"Can only patch a document with the same key"); + HARD_ASSERT([doc.key isEqual:self.key], "Can only patch a document with the same key"); FSTObjectValue *newData = [self patchObjectValue:doc.data]; return [FSTDocument documentWithData:newData @@ -340,8 +341,8 @@ NS_ASSUME_NONNULL_BEGIN localWriteTime:(FIRTimestamp *)localWriteTime mutationResult:(nullable FSTMutationResult *)mutationResult { if (mutationResult) { - FSTAssert(mutationResult.transformResults, - @"Transform results missing for FSTTransformMutation."); + HARD_ASSERT(mutationResult.transformResults, + "Transform results missing for FSTTransformMutation."); } if (!self.precondition.IsValidFor(maybeDoc)) { @@ -350,11 +351,11 @@ NS_ASSUME_NONNULL_BEGIN // We only support transforms with precondition exists, so we can only apply it to an existing // document - FSTAssert([maybeDoc isMemberOfClass:[FSTDocument class]], @"Unknown MaybeDocument type %@", - [maybeDoc class]); + HARD_ASSERT([maybeDoc isMemberOfClass:[FSTDocument class]], "Unknown MaybeDocument type %s", + [maybeDoc class]); FSTDocument *doc = (FSTDocument *)maybeDoc; - FSTAssert([doc.key isEqual:self.key], @"Can only transform a document with the same key"); + HARD_ASSERT([doc.key isEqual:self.key], "Can only transform a document with the same key"); BOOL hasLocalMutations = (mutationResult == nil); NSArray<FSTFieldValue *> *transformResults; @@ -386,9 +387,9 @@ NS_ASSUME_NONNULL_BEGIN serverTransformResultsWithBaseDocument:(nullable FSTMaybeDocument *)baseDocument serverTransformResults:(NSArray<FSTFieldValue *> *)serverTransformResults { NSMutableArray<FSTFieldValue *> *transformResults = [NSMutableArray array]; - FSTAssert(self.fieldTransforms.size() == serverTransformResults.count, - @"server transform result count (%lu) should match field transforms count (%zu)", - (unsigned long)serverTransformResults.count, self.fieldTransforms.size()); + HARD_ASSERT(self.fieldTransforms.size() == serverTransformResults.count, + "server transform result count (%s) should match field transforms count (%s)", + (unsigned long)serverTransformResults.count, self.fieldTransforms.size()); for (NSUInteger i = 0; i < serverTransformResults.count; i++) { const FieldTransform &fieldTransform = self.fieldTransforms[i]; @@ -433,8 +434,8 @@ serverTransformResultsWithBaseDocument:(nullable FSTMaybeDocument *)baseDocument - (FSTObjectValue *)transformObject:(FSTObjectValue *)objectValue transformResults:(NSArray<FSTFieldValue *> *)transformResults { - FSTAssert(transformResults.count == self.fieldTransforms.size(), - @"Transform results length mismatch."); + HARD_ASSERT(transformResults.count == self.fieldTransforms.size(), + "Transform results length mismatch."); for (size_t i = 0; i < self.fieldTransforms.size(); i++) { const FieldTransform &fieldTransform = self.fieldTransforms[i]; @@ -478,8 +479,8 @@ serverTransformResultsWithBaseDocument:(nullable FSTMaybeDocument *)baseDocument localWriteTime:(FIRTimestamp *)localWriteTime mutationResult:(nullable FSTMutationResult *)mutationResult { if (mutationResult) { - FSTAssert(!mutationResult.transformResults, - @"Transform results received by FSTDeleteMutation."); + HARD_ASSERT(!mutationResult.transformResults, + "Transform results received by FSTDeleteMutation."); } if (!self.precondition.IsValidFor(maybeDoc)) { @@ -487,7 +488,7 @@ serverTransformResultsWithBaseDocument:(nullable FSTMaybeDocument *)baseDocument } if (maybeDoc) { - FSTAssert([maybeDoc.key isEqual:self.key], @"Can only delete a document with the same key"); + HARD_ASSERT([maybeDoc.key isEqual:self.key], "Can only delete a document with the same key"); } return [FSTDeletedDocument documentWithKey:self.key version:SnapshotVersion::None()]; diff --git a/Firestore/Source/Model/FSTMutationBatch.mm b/Firestore/Source/Model/FSTMutationBatch.mm index 1e9189c..b3f4dde 100644 --- a/Firestore/Source/Model/FSTMutationBatch.mm +++ b/Firestore/Source/Model/FSTMutationBatch.mm @@ -22,7 +22,8 @@ #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTMutation.h" -#import "Firestore/Source/Util/FSTAssert.h" + +#include "Firestore/core/src/firebase/firestore/util/hard_assert.h" using firebase::firestore::model::DocumentKey; using firebase::firestore::model::DocumentKeyHash; @@ -76,15 +77,14 @@ const FSTBatchID kFSTBatchIDUnknown = -1; - (FSTMaybeDocument *_Nullable)applyTo:(FSTMaybeDocument *_Nullable)maybeDoc documentKey:(const DocumentKey &)documentKey mutationBatchResult:(FSTMutationBatchResult *_Nullable)mutationBatchResult { - FSTAssert(!maybeDoc || [maybeDoc.key isEqualToKey:documentKey], - @"applyTo: key %s doesn't match maybeDoc key %s", documentKey.ToString().c_str(), - maybeDoc.key.ToString().c_str()); + HARD_ASSERT(!maybeDoc || [maybeDoc.key isEqualToKey:documentKey], + "applyTo: key %s doesn't match maybeDoc key %s", documentKey.ToString(), + maybeDoc.key.ToString()); FSTMaybeDocument *baseDoc = maybeDoc; if (mutationBatchResult) { - FSTAssert(mutationBatchResult.mutationResults.count == self.mutations.count, - @"Mismatch between mutations length (%lu) and results length (%lu)", - (unsigned long)self.mutations.count, - (unsigned long)mutationBatchResult.mutationResults.count); + HARD_ASSERT(mutationBatchResult.mutationResults.count == self.mutations.count, + "Mismatch between mutations length (%s) and results length (%s)", + self.mutations.count, mutationBatchResult.mutationResults.count); } for (NSUInteger i = 0; i < self.mutations.count; i++) { @@ -168,9 +168,9 @@ const FSTBatchID kFSTBatchIDUnknown = -1; commitVersion:(SnapshotVersion)commitVersion mutationResults:(NSArray<FSTMutationResult *> *)mutationResults streamToken:(nullable NSData *)streamToken { - FSTAssert(batch.mutations.count == mutationResults.count, - @"Mutations sent %lu must equal results received %lu", - (unsigned long)batch.mutations.count, (unsigned long)mutationResults.count); + HARD_ASSERT(batch.mutations.count == mutationResults.count, + "Mutations sent %s must equal results received %s", batch.mutations.count, + mutationResults.count); DocumentVersionMap docVersions; NSArray<FSTMutation *> *mutations = batch.mutations; |