aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-05-24 11:00:23 -0700
committerGravatar GitHub <noreply@github.com>2018-05-24 11:00:23 -0700
commit8037a4bf79b8ae49162c2b6f099d62ec17a7f283 (patch)
tree5a15df8664abbcf3e63479fa3e7560fd8c2fbe9e /Firestore
parentde4fe203525072babcdec444a06e42e77f0aa714 (diff)
Replace Objective-C assertions with C++ assertions (#1327)
* Migrate FSTFail to HARD_FAIL * FSTCFail -> HARD_FAIL * FSTCAssert -> HARD_ASSERT * FSTAssert -> HARD_ASSERT * Replace FSTAssert with NSAssert in dead Objective-C code * Remove FSTAssert.h
Diffstat (limited to 'Firestore')
-rw-r--r--Firestore/Example/Firestore.xcodeproj/project.pbxproj6
-rw-r--r--Firestore/Example/Tests/Integration/FSTDatastoreTests.mm6
-rw-r--r--Firestore/Example/Tests/Integration/FSTStreamTests.mm4
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm19
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTSpecTests.mm20
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm18
-rw-r--r--Firestore/Example/Tests/Util/FSTAssertTests.mm105
-rw-r--r--Firestore/Example/Tests/Util/FSTEventAccumulator.mm8
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.mm15
-rw-r--r--Firestore/Source/API/FIRCollectionReference.mm3
-rw-r--r--Firestore/Source/API/FIRDocumentChange.mm17
-rw-r--r--Firestore/Source/API/FIRDocumentReference.mm4
-rw-r--r--Firestore/Source/API/FIRDocumentSnapshot.mm6
-rw-r--r--Firestore/Source/API/FIRFirestore.mm8
-rw-r--r--Firestore/Source/API/FIRQuery.mm2
-rw-r--r--Firestore/Source/API/FIRQuerySnapshot.mm3
-rw-r--r--Firestore/Source/API/FIRTransaction.mm7
-rw-r--r--Firestore/Source/API/FSTUserDataConverter.mm24
-rw-r--r--Firestore/Source/Core/FSTEventManager.mm17
-rw-r--r--Firestore/Source/Core/FSTFirestoreClient.mm6
-rw-r--r--Firestore/Source/Core/FSTQuery.mm46
-rw-r--r--Firestore/Source/Core/FSTSyncEngine.mm26
-rw-r--r--Firestore/Source/Core/FSTTransaction.mm6
-rw-r--r--Firestore/Source/Core/FSTView.mm14
-rw-r--r--Firestore/Source/Core/FSTViewSnapshot.mm5
-rw-r--r--Firestore/Source/Local/FSTLevelDB.mm12
-rw-r--r--Firestore/Source/Local/FSTLevelDBMigrations.mm6
-rw-r--r--Firestore/Source/Local/FSTLevelDBMutationQueue.mm55
-rw-r--r--Firestore/Source/Local/FSTLevelDBQueryCache.mm26
-rw-r--r--Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm14
-rw-r--r--Firestore/Source/Local/FSTLocalDocumentsView.mm4
-rw-r--r--Firestore/Source/Local/FSTLocalSerializer.mm14
-rw-r--r--Firestore/Source/Local/FSTLocalStore.mm31
-rw-r--r--Firestore/Source/Local/FSTMemoryMutationQueue.mm39
-rw-r--r--Firestore/Source/Local/FSTMemoryPersistence.mm6
-rw-r--r--Firestore/Source/Local/FSTPersistence.h7
-rw-r--r--Firestore/Source/Model/FSTDocument.mm2
-rw-r--r--Firestore/Source/Model/FSTDocumentKey.mm6
-rw-r--r--Firestore/Source/Model/FSTFieldValue.mm19
-rw-r--r--Firestore/Source/Model/FSTMutation.mm45
-rw-r--r--Firestore/Source/Model/FSTMutationBatch.mm22
-rw-r--r--Firestore/Source/Remote/FSTDatastore.mm16
-rw-r--r--Firestore/Source/Remote/FSTOnlineStateTracker.mm12
-rw-r--r--Firestore/Source/Remote/FSTRemoteEvent.mm10
-rw-r--r--Firestore/Source/Remote/FSTRemoteStore.mm42
-rw-r--r--Firestore/Source/Remote/FSTSerializerBeta.mm106
-rw-r--r--Firestore/Source/Remote/FSTStream.mm44
-rw-r--r--Firestore/Source/Util/FSTAssert.h77
-rw-r--r--Firestore/Source/Util/FSTDispatchQueue.mm4
-rw-r--r--Firestore/Source/Util/FSTUsageValidation.h2
-rw-r--r--Firestore/core/test/firebase/firestore/FSTGoogleTestTests.mm2
-rw-r--r--Firestore/third_party/Immutable/FSTArraySortedDictionary.m5
-rw-r--r--Firestore/third_party/Immutable/FSTLLRBValueNode.m3
-rw-r--r--Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m4
-rw-r--r--Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m3
55 files changed, 418 insertions, 615 deletions
diff --git a/Firestore/Example/Firestore.xcodeproj/project.pbxproj b/Firestore/Example/Firestore.xcodeproj/project.pbxproj
index 836017b..ca8b598 100644
--- a/Firestore/Example/Firestore.xcodeproj/project.pbxproj
+++ b/Firestore/Example/Firestore.xcodeproj/project.pbxproj
@@ -43,7 +43,6 @@
5492E03420213FFC00B64F25 /* FSTMemorySpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E02F20213FFC00B64F25 /* FSTMemorySpecTests.mm */; };
5492E03520213FFC00B64F25 /* FSTSpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E03020213FFC00B64F25 /* FSTSpecTests.mm */; };
5492E03C2021401F00B64F25 /* XCTestCase+Await.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0372021401E00B64F25 /* XCTestCase+Await.mm */; };
- 5492E03D2021401F00B64F25 /* FSTAssertTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0382021401E00B64F25 /* FSTAssertTests.mm */; };
5492E03E2021401F00B64F25 /* FSTEventAccumulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */; };
5492E03F2021401F00B64F25 /* FSTHelpers.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E03A2021401F00B64F25 /* FSTHelpers.mm */; };
5492E041202143E700B64F25 /* FSTEventAccumulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */; };
@@ -257,7 +256,7 @@
3B843E4A1F3930A400548890 /* remote_store_spec_test.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = remote_store_spec_test.json; sourceTree = "<group>"; };
3C81DE3772628FE297055662 /* Pods-Firestore_Example_iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_iOS/Pods-Firestore_Example_iOS.debug.xcconfig"; sourceTree = "<group>"; };
3F0992A4B83C60841C52E960 /* Pods-Firestore_Example_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_iOS/Pods-Firestore_Example_iOS.release.xcconfig"; sourceTree = "<group>"; };
- 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = hard_assert_test.cc; sourceTree = "<group>"; };
+ 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = hard_assert_test.cc; sourceTree = "<group>"; };
54131E9620ADE678001DF3FF /* string_format_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_format_test.cc; sourceTree = "<group>"; };
54511E8D209805F8005BD28F /* hashing_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hashing_test.cc; sourceTree = "<group>"; };
5467FAFF203E56F8009C9584 /* FIRFirestoreTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRFirestoreTests.mm; sourceTree = "<group>"; };
@@ -275,7 +274,6 @@
5492E02F20213FFC00B64F25 /* FSTMemorySpecTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FSTMemorySpecTests.mm; sourceTree = "<group>"; };
5492E03020213FFC00B64F25 /* FSTSpecTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FSTSpecTests.mm; sourceTree = "<group>"; };
5492E0372021401E00B64F25 /* XCTestCase+Await.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "XCTestCase+Await.mm"; sourceTree = "<group>"; };
- 5492E0382021401E00B64F25 /* FSTAssertTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FSTAssertTests.mm; sourceTree = "<group>"; };
5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FSTEventAccumulator.mm; sourceTree = "<group>"; };
5492E03A2021401F00B64F25 /* FSTHelpers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FSTHelpers.mm; sourceTree = "<group>"; };
5492E045202154AA00B64F25 /* FIRCollectionReferenceTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FIRCollectionReferenceTests.mm; sourceTree = "<group>"; };
@@ -874,7 +872,6 @@
DE51B1851F0D48AC0013853F /* Util */ = {
isa = PBXGroup;
children = (
- 5492E0382021401E00B64F25 /* FSTAssertTests.mm */,
7346E61C20325C6900FD6CEF /* FSTDispatchQueueTests.mm */,
54E9281C1F33950B00C1953E /* FSTEventAccumulator.h */,
5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */,
@@ -1471,7 +1468,6 @@
B65D34A9203C995B0076A5E1 /* FIRTimestampTest.m in Sources */,
5492E058202154AB00B64F25 /* FSTAPIHelpers.mm in Sources */,
DE2EF0851F3D0B6E003D0CDC /* FSTArraySortedDictionaryTests.m in Sources */,
- 5492E03D2021401F00B64F25 /* FSTAssertTests.mm in Sources */,
5492E0C82021557E00B64F25 /* FSTDatastoreTests.mm in Sources */,
7346E61D20325C6900FD6CEF /* FSTDispatchQueueTests.mm in Sources */,
5492E0B92021555100B64F25 /* FSTDocumentKeyTests.mm in Sources */,
diff --git a/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm b/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
index 920e3c5..e6e1a19 100644
--- a/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
+++ b/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
@@ -33,7 +33,6 @@
#import "Firestore/Source/Remote/FSTDatastore.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
@@ -42,6 +41,7 @@
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/precondition.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;
@@ -118,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)rejectFailedWriteWithBatchID:(FSTBatchID)batchID error:(NSError *)error {
- FSTFail(@"Not implemented");
+ HARD_FAIL("Not implemented");
}
- (void)applyRemoteEvent:(FSTRemoteEvent *)remoteEvent {
@@ -129,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)rejectListenWithTargetID:(const TargetId)targetID error:(NSError *)error {
- FSTFail(@"Not implemented");
+ HARD_FAIL("Not implemented");
}
@end
diff --git a/Firestore/Example/Tests/Integration/FSTStreamTests.mm b/Firestore/Example/Tests/Integration/FSTStreamTests.mm
index 2e5c9b6..b944a93 100644
--- a/Firestore/Example/Tests/Integration/FSTStreamTests.mm
+++ b/Firestore/Example/Tests/Integration/FSTStreamTests.mm
@@ -24,12 +24,12 @@
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
#import "Firestore/Source/Remote/FSTDatastore.h"
#import "Firestore/Source/Remote/FSTStream.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.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;
@@ -121,7 +121,7 @@ using firebase::firestore::model::SnapshotVersion;
* to be called.
*/
- (void)awaitNotificationFromBlock:(void (^)(void))block {
- FSTAssert(_expectation == nil, @"Previous expectation still active");
+ HARD_ASSERT(_expectation == nil, "Previous expectation still active");
XCTestExpectation *expectation =
[self.testCase expectationWithDescription:@"awaitCallbackInBlock"];
_expectation = expectation;
diff --git a/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm b/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm
index 3c7f46a..63c3d72 100644
--- a/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm
+++ b/Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm
@@ -21,7 +21,6 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
#import "Firestore/Source/Remote/FSTStream.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Example/Tests/Remote/FSTWatchChange+Testing.h"
@@ -80,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
credentials:credentials
serializer:serializer];
if (self) {
- FSTAssert(datastore, @"Datastore must not be nil");
+ HARD_ASSERT(datastore, "Datastore must not be nil");
_datastore = datastore;
_activeTargets = [NSMutableDictionary dictionary];
}
@@ -90,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Overridden FSTWatchStream methods.
- (void)startWithDelegate:(id<FSTWatchStreamDelegate>)delegate {
- FSTAssert(!self.open, @"Trying to start already started watch stream");
+ HARD_ASSERT(!self.open, "Trying to start already started watch stream");
self.open = YES;
self.delegate = delegate;
[self notifyStreamOpen];
@@ -148,7 +147,7 @@ NS_ASSUME_NONNULL_BEGIN
// Technically removing an unknown target is valid (e.g. it could race with a
// server-side removal), but we want to pay extra careful attention in tests
// that we only remove targets we listened too.
- FSTFail(@"Removing a non-active target");
+ HARD_FAIL("Removing a non-active target");
}
[self.activeTargets removeObjectForKey:targetID];
}
@@ -204,7 +203,7 @@ NS_ASSUME_NONNULL_BEGIN
credentials:credentials
serializer:serializer];
if (self) {
- FSTAssert(datastore, @"Datastore must not be nil");
+ HARD_ASSERT(datastore, "Datastore must not be nil");
_datastore = datastore;
_sentMutations = [NSMutableArray array];
}
@@ -214,7 +213,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Overridden FSTWriteStream methods.
- (void)startWithDelegate:(id<FSTWriteStreamDelegate>)delegate {
- FSTAssert(!self.open, @"Trying to start already started write stream");
+ HARD_ASSERT(!self.open, "Trying to start already started write stream");
self.open = YES;
[self.sentMutations removeAllObjects];
self.delegate = delegate;
@@ -258,8 +257,8 @@ NS_ASSUME_NONNULL_BEGIN
* Returns the next write that was "sent to the backend", failing if there are no queued sent
*/
- (NSArray<FSTMutation *> *)nextSentWrite {
- FSTAssert(self.sentMutations.count > 0,
- @"Writes need to happen before you can call nextSentWrite.");
+ HARD_ASSERT(self.sentMutations.count > 0,
+ "Writes need to happen before you can call nextSentWrite.");
NSArray<FSTMutation *> *result = [self.sentMutations objectAtIndex:0];
[self.sentMutations removeObjectAtIndex:0];
return result;
@@ -292,7 +291,6 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Overridden FSTDatastore methods.
- (FSTWatchStream *)createWatchStream {
- // FSTAssert(self.databaseInfo, @"DatabaseInfo must not be nil");
self.watchStream = [[FSTMockWatchStream alloc]
initWithDatastore:self
workerDispatchQueue:self.workerDispatchQueue
@@ -303,7 +301,6 @@ NS_ASSUME_NONNULL_BEGIN
}
- (FSTWriteStream *)createWriteStream {
- // FSTAssert(self.databaseInfo, @"DatabaseInfo must not be nil");
self.writeStream = [[FSTMockWriteStream alloc]
initWithDatastore:self
workerDispatchQueue:self.workerDispatchQueue
@@ -314,7 +311,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)authorizeAndStartRPC:(GRPCProtoCall *)rpc completion:(FSTVoidErrorBlock)completion {
- FSTFail(@"FSTMockDatastore shouldn't be starting any RPCs.");
+ HARD_FAIL("FSTMockDatastore shouldn't be starting any RPCs.");
}
#pragma mark - Method exposed for tests to call.
diff --git a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
index 7b10bd4..77010e5 100644
--- a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
+++ b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
@@ -34,7 +34,6 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTExistenceFilter.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTClasses.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
@@ -45,6 +44,7 @@
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
@@ -233,7 +233,7 @@ static NSString *const kNoIOSTag = @"no-ios";
- (void)doWatchEntity:(NSDictionary *)watchEntity snapshot:(NSNumber *_Nullable)watchSnapshot {
if (watchEntity[@"docs"]) {
- FSTAssert(!watchEntity[@"doc"], @"Exactly one of |doc| or |docs| needs to be set.");
+ HARD_ASSERT(!watchEntity[@"doc"], "Exactly one of |doc| or |docs| needs to be set.");
int count = 0;
NSArray *docs = watchEntity[@"docs"];
for (NSDictionary *doc in docs) {
@@ -277,13 +277,13 @@ static NSString *const kNoIOSTag = @"no-ios";
document:nil];
[self.driver receiveWatchChange:change snapshotVersion:[self parseVersion:watchSnapshot]];
} else {
- FSTFail(@"Either key, doc or docs must be set.");
+ HARD_FAIL("Either key, doc or docs must be set.");
}
}
- (void)doWatchFilter:(NSArray *)watchFilter snapshot:(NSNumber *_Nullable)watchSnapshot {
NSArray<NSNumber *> *targets = watchFilter[0];
- FSTAssert(targets.count == 1, @"ExistenceFilters currently support exactly one target only.");
+ HARD_ASSERT(targets.count == 1, "ExistenceFilters currently support exactly one target only.");
int keyCount = watchFilter.count == 0 ? 0 : (int)watchFilter.count - 1;
@@ -308,7 +308,7 @@ static NSString *const kNoIOSTag = @"no-ios";
NSNumber *runBackoffTimer = closeSpec[@"runBackoffTimer"];
// TODO(b/72313632): Incorporate backoff in iOS Spec Tests.
- FSTAssert(runBackoffTimer.boolValue, @"iOS Spec Tests don't support backoff.");
+ HARD_ASSERT(runBackoffTimer.boolValue, "iOS Spec Tests don't support backoff.");
[self.driver receiveWatchStreamError:code userInfo:errorSpec];
}
@@ -323,8 +323,8 @@ static NSString *const kNoIOSTag = @"no-ios";
[self.driver receiveWriteAckWithVersion:version mutationResults:@[ mutationResult ]];
if (expectUserCallback.boolValue) {
- FSTAssert(write.done, @"Write should be done");
- FSTAssert(!write.error, @"Ack should not fail");
+ HARD_ASSERT(write.done, "Write should be done");
+ HARD_ASSERT(!write.error, "Ack should not fail");
}
}
@@ -336,7 +336,7 @@ static NSString *const kNoIOSTag = @"no-ios";
FSTOutstandingWrite *write = [self.driver receiveWriteError:code userInfo:errorSpec];
if (expectUserCallback.boolValue) {
- FSTAssert(write.done, @"Write should be done");
+ HARD_ASSERT(write.done, "Write should be done");
XCTAssertNotNil(write.error, @"Write should have failed");
XCTAssertEqualObjects(write.error.domain, FIRFirestoreErrorDomain);
XCTAssertEqual(write.error.code, code);
@@ -358,7 +358,7 @@ static NSString *const kNoIOSTag = @"no-ios";
} else if ([timer isEqualToString:@"online_state_timeout"]) {
timerID = FSTTimerIDOnlineStateTimeout;
} else {
- FSTFail(@"runTimer spec step specified unknown timer: %@", timer);
+ HARD_FAIL("runTimer spec step specified unknown timer: %s", timer);
}
[self.driver runTimer:timerID];
@@ -427,7 +427,7 @@ static NSString *const kNoIOSTag = @"no-ios";
[self doWatchStreamClose:step[@"watchStreamClose"]];
} else if (step[@"watchProto"]) {
// watchProto isn't yet used, and it's unclear how to create arbitrary protos from JSON.
- FSTFail(@"watchProto is not yet supported.");
+ HARD_FAIL("watchProto is not yet supported.");
} else if (step[@"writeAck"]) {
[self doWriteAck:step[@"writeAck"]];
} else if (step[@"failWrite"]) {
diff --git a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
index 40ebfb9..d346197 100644
--- a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
+++ b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
@@ -30,7 +30,6 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTDatastore.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h"
#import "Firestore/Example/Tests/SpecTests/FSTMockDatastore.h"
@@ -40,6 +39,7 @@
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
using firebase::firestore::auth::EmptyCredentialsProvider;
@@ -183,9 +183,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)validateUsage {
// We could relax this if we found a reason to.
- FSTAssert(self.events.count == 0,
- @"You must clear all pending events by calling"
- " capturedEventsSinceLastCall before calling shutdown.");
+ HARD_ASSERT(self.events.count == 0,
+ "You must clear all pending events by calling"
+ " capturedEventsSinceLastCall before calling shutdown.");
}
- (void)shutdown {
@@ -197,11 +197,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)validateNextWriteSent:(FSTMutation *)expectedWrite {
NSArray<FSTMutation *> *request = [self.datastore nextSentWrite];
// Make sure the write went through the pipe like we expected it to.
- FSTAssert(request.count == 1, @"Only single mutation requests are supported at the moment");
+ HARD_ASSERT(request.count == 1, "Only single mutation requests are supported at the moment");
FSTMutation *actualWrite = request[0];
- FSTAssert([actualWrite isEqual:expectedWrite],
- @"Mock datastore received write %@ but first outstanding mutation was %@", actualWrite,
- expectedWrite);
+ HARD_ASSERT([actualWrite isEqual:expectedWrite],
+ "Mock datastore received write %s but first outstanding mutation was %s", actualWrite,
+ expectedWrite);
LOG_DEBUG("A write was sent: %s", actualWrite);
}
@@ -347,7 +347,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.datastore failWatchStreamWithError:error];
// Unlike web, stream should re-open synchronously (if we have any listeners)
if (self.queryListeners.count > 0) {
- FSTAssert(self.datastore.isWatchStreamOpen, @"Watch stream is open");
+ HARD_ASSERT(self.datastore.isWatchStreamOpen, "Watch stream is open");
}
}];
}
diff --git a/Firestore/Example/Tests/Util/FSTAssertTests.mm b/Firestore/Example/Tests/Util/FSTAssertTests.mm
deleted file mode 100644
index 0cba03f..0000000
--- a/Firestore/Example/Tests/Util/FSTAssertTests.mm
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2017 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import "Firestore/Source/Util/FSTAssert.h"
-
-#import <XCTest/XCTest.h>
-
-@interface FSTAssertTests : XCTestCase
-@end
-
-@implementation FSTAssertTests
-
-- (void)testFail {
- @try {
- [self failingMethod];
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: 0:foo:bar");
- }
-}
-
-// A method guaranteed to fail. Note that the return type is intentionally something that is
-// not actually returned in the body to ensure that the function attribute declarations in the
-// macro properly mark this macro invocation as never returning.
-- (int)failingMethod {
- FSTFail(@"%d:%s:%@", 0, "foo", @"bar");
-}
-
-- (void)testCFail {
- @try {
- failingFunction();
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: 0:foo:bar");
- }
-}
-
-// A function guaranteed to fail. Note that the return type is intentionally something that is
-// not actually returned in the body to ensure that the function attribute declarations in the
-// macro properly mark this macro invocation as never returning.
-int failingFunction() {
- FSTCFail(@"%d:%s:%@", 0, "foo", @"bar");
-}
-
-- (void)testAssertNonFailing {
- @try {
- FSTAssert(YES, @"shouldn't fail");
- } @catch (NSException *ex) {
- XCTFail("Should not have failed, but got %@", ex);
- }
-}
-
-- (void)testAssertFailing {
- @try {
- FSTAssert(NO, @"should fail");
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: should fail");
- }
-}
-
-- (void)testCAssertNonFailing {
- @try {
- nonAssertingFunction();
- } @catch (NSException *ex) {
- XCTFail("Should not have failed, but got %@", ex);
- }
-}
-
-int nonAssertingFunction() {
- FSTCAssert(YES, @"shouldn't fail");
- return 0;
-}
-
-- (void)testCAssertFailing {
- @try {
- assertingFunction();
- XCTFail("Should not have succeeded");
- } @catch (NSException *ex) {
- XCTAssertEqualObjects(ex.name, NSInternalInconsistencyException);
- XCTAssertEqualObjects(ex.reason, @"FIRESTORE INTERNAL ASSERTION FAILED: should fail");
- }
-}
-
-int assertingFunction() {
- FSTCAssert(NO, @"should fail");
-}
-
-@end
diff --git a/Firestore/Example/Tests/Util/FSTEventAccumulator.mm b/Firestore/Example/Tests/Util/FSTEventAccumulator.mm
index 3ab6035..835dc68 100644
--- a/Firestore/Example/Tests/Util/FSTEventAccumulator.mm
+++ b/Firestore/Example/Tests/Util/FSTEventAccumulator.mm
@@ -18,12 +18,12 @@
#import <XCTest/XCTest.h>
+#import "Firestore/Example/Tests/Util/XCTestCase+Await.h"
#import "Firestore/Source/Public/FIRDocumentSnapshot.h"
#import "Firestore/Source/Public/FIRQuerySnapshot.h"
#import "Firestore/Source/Public/FIRSnapshotMetadata.h"
-#import "Firestore/Source/Util/FSTAssert.h"
-#import "Firestore/Example/Tests/Util/XCTestCase+Await.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
NS_ASSUME_NONNULL_BEGIN
@@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<id> *)awaitEvents:(NSUInteger)events name:(NSString *)name {
@synchronized(self) {
- FSTAssert(!self.expectation, @"Existing expectation still pending?");
+ HARD_ASSERT(!self.expectation, "Existing expectation still pending?");
self.expectation = [self.testCase expectationWithDescription:name];
self.maxEvents = self.maxEvents + events;
[self checkFulfilled];
@@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
if ([event isKindOfClass:[FIRDocumentSnapshot class]]) {
return ((FIRDocumentSnapshot *)event).metadata.hasPendingWrites;
} else {
- FSTAssert([event isKindOfClass:[FIRQuerySnapshot class]], @"Unexpected event: %@", event);
+ HARD_ASSERT([event isKindOfClass:[FIRQuerySnapshot class]], "Unexpected event: %s", event);
return ((FIRQuerySnapshot *)event).metadata.hasPendingWrites;
}
}
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm
index bc2f005..5ed4fd5 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.mm
+++ b/Firestore/Example/Tests/Util/FSTHelpers.mm
@@ -40,7 +40,6 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
@@ -140,7 +139,7 @@ FSTFieldValue *FSTTestFieldValue(id _Nullable value) {
FSTObjectValue *FSTTestObjectValue(NSDictionary<NSString *, id> *data) {
FSTFieldValue *wrapped = FSTTestFieldValue(data);
- FSTCAssert([wrapped isKindOfClass:[FSTObjectValue class]], @"Unsupported value: %@", data);
+ HARD_ASSERT([wrapped isKindOfClass:[FSTObjectValue class]], "Unsupported value: %s", data);
return (FSTObjectValue *)wrapped;
}
@@ -195,15 +194,15 @@ id<FSTFilter> FSTTestFilter(const absl::string_view field, NSString *opString, i
} else if ([opString isEqualToString:@"array_contains"]) {
op = FSTRelationFilterOperatorArrayContains;
} else {
- FSTCFail(@"Unsupported operator type: %@", opString);
+ HARD_FAIL("Unsupported operator type: %s", opString);
}
FSTFieldValue *data = FSTTestFieldValue(value);
if ([data isEqual:[FSTDoubleValue nanValue]]) {
- FSTCAssert(op == FSTRelationFilterOperatorEqual, @"Must use == with NAN.");
+ HARD_ASSERT(op == FSTRelationFilterOperatorEqual, "Must use == with NAN.");
return [[FSTNanFilter alloc] initWithField:path];
} else if ([data isEqual:[FSTNullValue nullValue]]) {
- FSTCAssert(op == FSTRelationFilterOperatorEqual, @"Must use == with Null.");
+ HARD_ASSERT(op == FSTRelationFilterOperatorEqual, "Must use == with Null.");
return [[FSTNullFilter alloc] initWithField:path];
} else {
return [FSTRelationFilter filterWithField:path filterOperator:op value:data];
@@ -218,7 +217,7 @@ FSTSortOrder *FSTTestOrderBy(const absl::string_view field, NSString *direction)
} else if ([direction isEqualToString:@"desc"]) {
ascending = NO;
} else {
- FSTCFail(@"Unsupported direction: %@", direction);
+ HARD_FAIL("Unsupported direction: %s", direction);
}
return [FSTSortOrder sortOrderWithFieldPath:path ascending:ascending];
}
@@ -272,8 +271,8 @@ FSTTransformMutation *FSTTestTransformMutation(NSString *path, NSDictionary<NSSt
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:testutil::Resource(util::MakeStringView(path))];
FSTUserDataConverter *converter = FSTTestUserDataConverter();
FSTParsedUpdateData *result = [converter parsedUpdateData:data];
- FSTCAssert(result.data.value.count == 0,
- @"FSTTestTransformMutation() only expects transforms; no other data");
+ HARD_ASSERT(result.data.value.count == 0,
+ "FSTTestTransformMutation() only expects transforms; no other data");
return [[FSTTransformMutation alloc] initWithKey:key
fieldTransforms:std::move(result.fieldTransforms)];
}
diff --git a/Firestore/Source/API/FIRCollectionReference.mm b/Firestore/Source/API/FIRCollectionReference.mm
index 3f1559e..dc157ed 100644
--- a/Firestore/Source/API/FIRCollectionReference.mm
+++ b/Firestore/Source/API/FIRCollectionReference.mm
@@ -23,7 +23,6 @@
#import "Firestore/Source/API/FIRQuery+Internal.h"
#import "Firestore/Source/API/FIRQuery_Init.h"
#import "Firestore/Source/Core/FSTQuery.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
@@ -68,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
// Override the designated initializer from the super class.
- (instancetype)initWithQuery:(FSTQuery *)query firestore:(FIRFirestore *)firestore {
- FSTFail(@"Use FIRCollectionReference initWithPath: initializer.");
+ HARD_FAIL("Use FIRCollectionReference initWithPath: initializer.");
}
// NSObject Methods
diff --git a/Firestore/Source/API/FIRDocumentChange.mm b/Firestore/Source/API/FIRDocumentChange.mm
index 7bb24d2..0b1413f 100644
--- a/Firestore/Source/API/FIRDocumentChange.mm
+++ b/Firestore/Source/API/FIRDocumentChange.mm
@@ -21,7 +21,8 @@
#import "Firestore/Source/Core/FSTViewSnapshot.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
-#import "Firestore/Source/Util/FSTAssert.h"
+
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
NS_ASSUME_NONNULL_BEGIN
@@ -45,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if (change.type == FSTDocumentViewChangeTypeRemoved) {
return FIRDocumentChangeTypeRemoved;
} else {
- FSTFail(@"Unknown FSTDocumentViewChange: %ld", (long)change.type);
+ HARD_FAIL("Unknown FSTDocumentViewChange: %s", change.type);
}
}
@@ -64,11 +65,11 @@ NS_ASSUME_NONNULL_BEGIN
documentKey:change.document.key
document:change.document
fromCache:snapshot.isFromCache];
- FSTAssert(change.type == FSTDocumentViewChangeTypeAdded,
- @"Invalid event type for first snapshot");
- FSTAssert(!lastDocument ||
- snapshot.query.comparator(lastDocument, change.document) == NSOrderedAscending,
- @"Got added events in wrong order");
+ HARD_ASSERT(change.type == FSTDocumentViewChangeTypeAdded,
+ "Invalid event type for first snapshot");
+ HARD_ASSERT(!lastDocument || snapshot.query.comparator(lastDocument, change.document) ==
+ NSOrderedAscending,
+ "Got added events in wrong order");
[changes addObject:[[FIRDocumentChange alloc] initWithType:FIRDocumentChangeTypeAdded
document:document
oldIndex:NSNotFound
@@ -95,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
NSUInteger newIndex = NSNotFound;
if (change.type != FSTDocumentViewChangeTypeAdded) {
oldIndex = [indexTracker indexOfKey:change.document.key];
- FSTAssert(oldIndex != NSNotFound, @"Index for document not found");
+ HARD_ASSERT(oldIndex != NSNotFound, "Index for document not found");
indexTracker = [indexTracker documentSetByRemovingKey:change.document.key];
}
if (change.type != FSTDocumentViewChangeTypeRemoved) {
diff --git a/Firestore/Source/API/FIRDocumentReference.mm b/Firestore/Source/API/FIRDocumentReference.mm
index 5ad606c..b83f3cb 100644
--- a/Firestore/Source/API/FIRDocumentReference.mm
+++ b/Firestore/Source/API/FIRDocumentReference.mm
@@ -36,13 +36,13 @@
#import "Firestore/Source/Model/FSTDocumentSet.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Model/FSTMutation.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTAsyncQueryListener.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/precondition.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/string_apple.h"
namespace util = firebase::firestore::util;
@@ -269,7 +269,7 @@ addSnapshotListenerInternalWithOptions:(FSTListenOptions *)internalOptions
return;
}
- FSTAssert(snapshot.documents.count <= 1, @"Too many document returned on a document query");
+ HARD_ASSERT(snapshot.documents.count <= 1, "Too many document returned on a document query");
FSTDocument *document = [snapshot.documents documentForKey:key];
FIRDocumentSnapshot *result = [FIRDocumentSnapshot snapshotWithFirestore:firestore
diff --git a/Firestore/Source/API/FIRDocumentSnapshot.mm b/Firestore/Source/API/FIRDocumentSnapshot.mm
index 388b3b3..dff5b7f 100644
--- a/Firestore/Source/API/FIRDocumentSnapshot.mm
+++ b/Firestore/Source/API/FIRDocumentSnapshot.mm
@@ -26,11 +26,11 @@
#import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.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;
@@ -275,7 +275,7 @@ static FSTServerTimestampBehavior InternalServerTimestampBehavor(
- (NSDictionary<NSString *, id> *)data {
NSDictionary<NSString *, id> *data = [super data];
- FSTAssert(data, @"Document in a QueryDocumentSnapshot should exist");
+ HARD_ASSERT(data, "Document in a QueryDocumentSnapshot should exist");
return data;
}
@@ -283,7 +283,7 @@ static FSTServerTimestampBehavior InternalServerTimestampBehavor(
(FIRServerTimestampBehavior)serverTimestampBehavior {
NSDictionary<NSString *, id> *data =
[super dataWithServerTimestampBehavior:serverTimestampBehavior];
- FSTAssert(data, @"Document in a QueryDocumentSnapshot should exist");
+ HARD_ASSERT(data, "Document in a QueryDocumentSnapshot should exist");
return data;
}
diff --git a/Firestore/Source/API/FIRFirestore.mm b/Firestore/Source/API/FIRFirestore.mm
index 0ed9082..3671b51 100644
--- a/Firestore/Source/API/FIRFirestore.mm
+++ b/Firestore/Source/API/FIRFirestore.mm
@@ -32,7 +32,6 @@
#import "Firestore/Source/API/FIRWriteBatch+Internal.h"
#import "Firestore/Source/API/FSTUserDataConverter.h"
#import "Firestore/Source/Core/FSTFirestoreClient.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
@@ -41,6 +40,7 @@
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.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/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"
@@ -158,7 +158,7 @@ extern "C" NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain";
FIRFirestore *firestore = instances[key];
if (!firestore) {
NSString *projectID = app.options.projectID;
- FSTAssert(projectID, @"FirebaseOptions.projectID cannot be nil.");
+ HARD_ASSERT(projectID, "FirebaseOptions.projectID cannot be nil.");
FSTDispatchQueue *workerDispatchQueue = [FSTDispatchQueue
queueWith:dispatch_queue_create("com.google.firebase.firestore", DISPATCH_QUEUE_SERIAL)];
@@ -242,8 +242,8 @@ extern "C" NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain";
@synchronized(self) {
if (!_client) {
// These values are validated elsewhere; this is just double-checking:
- FSTAssert(_settings.host, @"FirestoreSettings.host cannot be nil.");
- FSTAssert(_settings.dispatchQueue, @"FirestoreSettings.dispatchQueue cannot be nil.");
+ HARD_ASSERT(_settings.host, "FirestoreSettings.host cannot be nil.");
+ HARD_ASSERT(_settings.dispatchQueue, "FirestoreSettings.dispatchQueue cannot be nil.");
if (!_settings.timestampsInSnapshotsEnabled) {
LOG_WARN(
diff --git a/Firestore/Source/API/FIRQuery.mm b/Firestore/Source/API/FIRQuery.mm
index ad4d2aa..08c912d 100644
--- a/Firestore/Source/API/FIRQuery.mm
+++ b/Firestore/Source/API/FIRQuery.mm
@@ -34,13 +34,13 @@
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTAsyncQueryListener.h"
#import "Firestore/Source/Util/FSTUsageValidation.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/model/resource_path.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;
diff --git a/Firestore/Source/API/FIRQuerySnapshot.mm b/Firestore/Source/API/FIRQuerySnapshot.mm
index fb7a849..7a6018b 100644
--- a/Firestore/Source/API/FIRQuerySnapshot.mm
+++ b/Firestore/Source/API/FIRQuerySnapshot.mm
@@ -25,7 +25,8 @@
#import "Firestore/Source/Core/FSTViewSnapshot.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
-#import "Firestore/Source/Util/FSTAssert.h"
+
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
NS_ASSUME_NONNULL_BEGIN
diff --git a/Firestore/Source/API/FIRTransaction.mm b/Firestore/Source/API/FIRTransaction.mm
index b5bdefa..8eb82bb 100644
--- a/Firestore/Source/API/FIRTransaction.mm
+++ b/Firestore/Source/API/FIRTransaction.mm
@@ -22,9 +22,10 @@
#import "Firestore/Source/API/FSTUserDataConverter.h"
#import "Firestore/Source/Core/FSTTransaction.h"
#import "Firestore/Source/Model/FSTDocument.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
+
NS_ASSUME_NONNULL_BEGIN
#pragma mark - FIRTransaction
@@ -111,8 +112,8 @@ NS_ASSUME_NONNULL_BEGIN
completion(nil, error);
return;
}
- FSTAssert(documents.count == 1,
- @"Mismatch in docs returned from document lookup.");
+ HARD_ASSERT(documents.count == 1,
+ "Mismatch in docs returned from document lookup.");
FSTMaybeDocument *internalDoc = documents.firstObject;
if ([internalDoc isKindOfClass:[FSTDeletedDocument class]]) {
completion(nil, nil);
diff --git a/Firestore/Source/API/FSTUserDataConverter.mm b/Firestore/Source/API/FSTUserDataConverter.mm
index 3484539..44e46da 100644
--- a/Firestore/Source/API/FSTUserDataConverter.mm
+++ b/Firestore/Source/API/FSTUserDataConverter.mm
@@ -29,7 +29,6 @@
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Model/FSTMutation.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
@@ -39,6 +38,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 "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"
@@ -532,8 +532,8 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
[FSTParseContext contextWithSource:FSTUserDataSourceArgument
path:absl::make_unique<FieldPath>(FieldPath::EmptyPath())];
FSTFieldValue *_Nullable parsed = [self parseData:input context:context];
- FSTAssert(parsed, @"Parsed data should not be nil.");
- FSTAssert(context.fieldTransforms->empty(), @"Field transforms should have been disallowed.");
+ HARD_ASSERT(parsed, "Parsed data should not be nil.");
+ HARD_ASSERT(context.fieldTransforms->empty(), "Field transforms should have been disallowed.");
return parsed;
}
@@ -626,8 +626,8 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
// deleted.
[context appendToFieldMaskWithFieldPath:*context.path];
} else if (context.dataSource == FSTUserDataSourceUpdate) {
- FSTAssert(context.path->size() > 0,
- @"FieldValue.delete() at the top level should have already been handled.");
+ HARD_ASSERT(context.path->size() > 0,
+ "FieldValue.delete() at the top level should have already been handled.");
FSTThrowInvalidArgument(
@"FieldValue.delete() can only appear at the top level of your "
"update data%@",
@@ -662,7 +662,7 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
transformOperation:std::move(array_remove)];
} else {
- FSTFail(@"Unknown FIRFieldValue type: %@", NSStringFromClass([fieldValue class]));
+ HARD_FAIL("Unknown FIRFieldValue type: %s", NSStringFromClass([fieldValue class]));
}
}
@@ -741,7 +741,7 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
default:
// All documented codes should be handled above, so this shouldn't happen.
- FSTCFail(@"Unknown NSNumber objCType %s on %@", cType, input);
+ HARD_FAIL("Unknown NSNumber objCType %s on %s", cType, input);
}
} else if ([input isKindOfClass:[NSString class]]) {
@@ -780,8 +780,8 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
if (context.dataSource == FSTUserDataSourceMergeSet) {
return nil;
} else if (context.dataSource == FSTUserDataSourceUpdate) {
- FSTAssert(context.path->size() > 0,
- @"FieldValue.delete() at the top level should have already been handled.");
+ HARD_ASSERT(context.path->size() > 0,
+ "FieldValue.delete() at the top level should have already been handled.");
FSTThrowInvalidArgument(
@"FieldValue.delete() can only appear at the top level of your update data%@",
[context fieldDescription]);
@@ -808,7 +808,7 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
// Return nil so this value is omitted from the parsed result.
return nil;
} else {
- FSTFail(@"Unknown FIRFieldValue type: %@", NSStringFromClass([input class]));
+ HARD_FAIL("Unknown FIRFieldValue type: %s", NSStringFromClass([input class]));
}
} else {
@@ -828,8 +828,8 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
path:absl::make_unique<FieldPath>(FieldPath::EmptyPath())];
FSTFieldValue *parsedElement =
[self parseData:element context:[context contextForArrayIndex:i]];
- FSTAssert(parsedElement && context.fieldTransforms->size() == 0,
- @"Failed to properly parse array transform element: %@", element);
+ HARD_ASSERT(parsedElement && context.fieldTransforms->size() == 0,
+ "Failed to properly parse array transform element: %s", element);
results.push_back(parsedElement);
}
return results;
diff --git a/Firestore/Source/Core/FSTEventManager.mm b/Firestore/Source/Core/FSTEventManager.mm
index b02fc5f..69d5ef1 100644
--- a/Firestore/Source/Core/FSTEventManager.mm
+++ b/Firestore/Source/Core/FSTEventManager.mm
@@ -19,7 +19,8 @@
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSyncEngine.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
-#import "Firestore/Source/Util/FSTAssert.h"
+
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
NS_ASSUME_NONNULL_BEGIN
@@ -50,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (instancetype)init {
- FSTFail(@"FSTListenOptions init not supported");
+ HARD_FAIL("FSTListenOptions init not supported");
return nil;
}
@@ -116,8 +117,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)queryDidChangeViewSnapshot:(FSTViewSnapshot *)snapshot {
- FSTAssert(snapshot.documentChanges.count > 0 || snapshot.syncStateChanged,
- @"We got a new snapshot with no changes?");
+ HARD_ASSERT(snapshot.documentChanges.count > 0 || snapshot.syncStateChanged,
+ "We got a new snapshot with no changes?");
if (!self.options.includeDocumentMetadataChanges) {
// Remove the metadata-only changes.
@@ -161,8 +162,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)shouldRaiseInitialEventForSnapshot:(FSTViewSnapshot *)snapshot
onlineState:(FSTOnlineState)onlineState {
- FSTAssert(!self.raisedInitialEvent,
- @"Determining whether to raise initial event, but already had first event.");
+ HARD_ASSERT(!self.raisedInitialEvent,
+ "Determining whether to raise initial event, but already had first event.");
// Always raise the first event when we're synced
if (!snapshot.fromCache) {
@@ -175,7 +176,7 @@ NS_ASSUME_NONNULL_BEGIN
// Don't raise the event if we're online, aren't synced yet (checked
// above) and are waiting for a sync.
if (self.options.waitForSyncWhenOnline && maybeOnline) {
- FSTAssert(snapshot.fromCache, @"Waiting for sync, but snapshot is not from cache.");
+ HARD_ASSERT(snapshot.fromCache, "Waiting for sync, but snapshot is not from cache.");
return NO;
}
@@ -203,7 +204,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)raiseInitialEventForSnapshot:(FSTViewSnapshot *)snapshot {
- FSTAssert(!self.raisedInitialEvent, @"Trying to raise initial events for second time");
+ HARD_ASSERT(!self.raisedInitialEvent, "Trying to raise initial events for second time");
snapshot = [[FSTViewSnapshot alloc]
initWithQuery:snapshot.query
documents:snapshot.documents
diff --git a/Firestore/Source/Core/FSTFirestoreClient.mm b/Firestore/Source/Core/FSTFirestoreClient.mm
index da19960..dc918d0 100644
--- a/Firestore/Source/Core/FSTFirestoreClient.mm
+++ b/Firestore/Source/Core/FSTFirestoreClient.mm
@@ -42,13 +42,13 @@
#import "Firestore/Source/Remote/FSTDatastore.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTClasses.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
@@ -320,8 +320,8 @@ NS_ASSUME_NONNULL_BEGIN
FSTView *view = [[FSTView alloc] initWithQuery:query.query remoteDocuments:DocumentKeySet{}];
FSTViewDocumentChanges *viewDocChanges = [view computeChangesWithDocuments:docs];
FSTViewChange *viewChange = [view applyChangesToDocuments:viewDocChanges];
- FSTAssert(viewChange.limboChanges.count == 0,
- @"View returned limbo documents during local-only query execution.");
+ HARD_ASSERT(viewChange.limboChanges.count == 0,
+ "View returned limbo documents during local-only query execution.");
FSTViewSnapshot *snapshot = viewChange.snapshot;
FIRSnapshotMetadata *metadata =
diff --git a/Firestore/Source/Core/FSTQuery.mm b/Firestore/Source/Core/FSTQuery.mm
index 13ebadb..eb6d087 100644
--- a/Firestore/Source/Core/FSTQuery.mm
+++ b/Firestore/Source/Core/FSTQuery.mm
@@ -23,11 +23,11 @@
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/Model/FSTDocument.h"
#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/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"
@@ -62,7 +62,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
case FSTRelationFilterOperatorArrayContains:
return @"array_contains";
default:
- FSTCFail(@"Unknown FSTRelationFilterOperator %lu", (unsigned long)filterOperator);
+ HARD_FAIL("Unknown FSTRelationFilterOperator %s", filterOperator);
}
}
@@ -152,10 +152,10 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
- (BOOL)matchesDocument:(FSTDocument *)document {
if (_field.IsKeyFieldPath()) {
- FSTAssert([self.value isKindOfClass:[FSTReferenceValue class]],
- @"Comparing on key, but filter value not a FSTReferenceValue.");
- FSTAssert(self.filterOperator != FSTRelationFilterOperatorArrayContains,
- @"arrayContains queries don't make sense on document keys.");
+ HARD_ASSERT([self.value isKindOfClass:[FSTReferenceValue class]],
+ "Comparing on key, but filter value not a FSTReferenceValue.");
+ HARD_ASSERT(self.filterOperator != FSTRelationFilterOperatorArrayContains,
+ "arrayContains queries don't make sense on document keys.");
FSTReferenceValue *refValue = (FSTReferenceValue *)self.value;
NSComparisonResult comparison = FSTDocumentKeyComparator(document.key, refValue.value);
return [self matchesComparison:comparison];
@@ -214,7 +214,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
case FSTRelationFilterOperatorGreaterThan:
return comparison == NSOrderedDescending;
default:
- FSTFail(@"Unknown operator: %ld", (long)self.filterOperator);
+ HARD_FAIL("Unknown operator: %s", self.filterOperator);
}
}
@@ -354,8 +354,8 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
} else {
FSTFieldValue *value1 = [document1 fieldForPath:self.field];
FSTFieldValue *value2 = [document2 fieldForPath:self.field];
- FSTAssert(value1 != nil && value2 != nil,
- @"Trying to compare documents on fields that don't exist.");
+ HARD_ASSERT(value1 != nil && value2 != nil,
+ "Trying to compare documents on fields that don't exist.");
result = [value1 compare:value2];
}
if (!self.isAscending) {
@@ -433,21 +433,22 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
- (BOOL)sortsBeforeDocument:(FSTDocument *)document
usingSortOrder:(NSArray<FSTSortOrder *> *)sortOrder {
- FSTAssert(self.position.count <= sortOrder.count,
- @"FSTIndexPosition has more components than provided sort order.");
+ HARD_ASSERT(self.position.count <= sortOrder.count,
+ "FSTIndexPosition has more components than provided sort order.");
__block NSComparisonResult result = NSOrderedSame;
[self.position enumerateObjectsUsingBlock:^(FSTFieldValue *fieldValue, NSUInteger idx,
BOOL *stop) {
FSTSortOrder *sortOrderComponent = sortOrder[idx];
NSComparisonResult comparison;
if (sortOrderComponent.field == FieldPath::KeyFieldPath()) {
- FSTAssert([fieldValue isKindOfClass:[FSTReferenceValue class]],
- @"FSTBound has a non-key value where the key path is being used %@", fieldValue);
+ HARD_ASSERT([fieldValue isKindOfClass:[FSTReferenceValue class]],
+ "FSTBound has a non-key value where the key path is being used %s", fieldValue);
FSTReferenceValue *refValue = (FSTReferenceValue *)fieldValue;
comparison = [refValue.value compare:document.key];
} else {
FSTFieldValue *docValue = [document fieldForPath:sortOrderComponent.field];
- FSTAssert(docValue != nil, @"Field should exist since document matched the orderBy already.");
+ HARD_ASSERT(docValue != nil,
+ "Field should exist since document matched the orderBy already.");
comparison = [fieldValue compare:docValue];
}
@@ -600,10 +601,9 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
];
}
} else {
- FSTAssert(!inequalityField || *inequalityField == *firstSortOrderField,
- @"First orderBy %s should match inequality field %s.",
- firstSortOrderField->CanonicalString().c_str(),
- inequalityField->CanonicalString().c_str());
+ HARD_ASSERT(!inequalityField || *inequalityField == *firstSortOrderField,
+ "First orderBy %s should match inequality field %s.",
+ firstSortOrderField->CanonicalString(), inequalityField->CanonicalString());
__block BOOL foundKeyOrder = NO;
@@ -631,7 +631,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
}
- (instancetype)queryByAddingFilter:(id<FSTFilter>)filter {
- FSTAssert(!DocumentKey::IsDocumentKey(_path), @"No filtering allowed for document query");
+ HARD_ASSERT(!DocumentKey::IsDocumentKey(_path), "No filtering allowed for document query");
const FieldPath *newInequalityField = nullptr;
if ([filter isKindOfClass:[FSTRelationFilter class]] &&
@@ -639,9 +639,9 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
newInequalityField = &filter.field;
}
const FieldPath *queryInequalityField = [self inequalityFilterField];
- FSTAssert(
+ HARD_ASSERT(
!queryInequalityField || !newInequalityField || *queryInequalityField == *newInequalityField,
- @"Query must only have one inequality field.");
+ "Query must only have one inequality field.");
return [[FSTQuery alloc] initWithPath:self.path
filterBy:[self.filters arrayByAddingObject:filter]
@@ -652,7 +652,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
}
- (instancetype)queryByAddingSortOrder:(FSTSortOrder *)sortOrder {
- FSTAssert(!DocumentKey::IsDocumentKey(_path), @"No ordering is allowed for a document query.");
+ HARD_ASSERT(!DocumentKey::IsDocumentKey(_path), "No ordering is allowed for a document query.");
// TODO(klimt): Validate that the same key isn't added twice.
return [[FSTQuery alloc] initWithPath:self.path
@@ -709,7 +709,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe
}
didCompareOnKeyField = didCompareOnKeyField || orderBy.field == FieldPath::KeyFieldPath();
}
- FSTAssert(didCompareOnKeyField, @"sortOrder of query did not include key ordering");
+ HARD_ASSERT(didCompareOnKeyField, "sortOrder of query did not include key ordering");
return NSOrderedSame;
};
}
diff --git a/Firestore/Source/Core/FSTSyncEngine.mm b/Firestore/Source/Core/FSTSyncEngine.mm
index 9d9e526..7d0c1a3 100644
--- a/Firestore/Source/Core/FSTSyncEngine.mm
+++ b/Firestore/Source/Core/FSTSyncEngine.mm
@@ -38,13 +38,13 @@
#import "Firestore/Source/Model/FSTDocumentSet.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/core/target_id_generator.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
using firebase::firestore::auth::HashUser;
@@ -183,7 +183,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
- (FSTTargetID)listenToQuery:(FSTQuery *)query {
[self assertDelegateExistsForSelector:_cmd];
- FSTAssert(self.queryViewsByQuery[query] == nil, @"We already listen to query: %@", query);
+ HARD_ASSERT(self.queryViewsByQuery[query] == nil, "We already listen to query: %s", query);
FSTQueryData *queryData = [self.localStore allocateQuery:query];
FSTDocumentDictionary *docs = [self.localStore executeQuery:query];
@@ -192,8 +192,8 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:std::move(remoteKeys)];
FSTViewDocumentChanges *viewDocChanges = [view computeChangesWithDocuments:docs];
FSTViewChange *viewChange = [view applyChangesToDocuments:viewDocChanges];
- FSTAssert(viewChange.limboChanges.count == 0,
- @"View returned limbo docs before target ack from the server.");
+ HARD_ASSERT(viewChange.limboChanges.count == 0,
+ "View returned limbo docs before target ack from the server.");
FSTQueryView *queryView = [[FSTQueryView alloc] initWithQuery:query
targetID:queryData.targetID
@@ -211,7 +211,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
[self assertDelegateExistsForSelector:_cmd];
FSTQueryView *queryView = self.queryViewsByQuery[query];
- FSTAssert(queryView, @"Trying to stop listening to a query not found");
+ HARD_ASSERT(queryView, "Trying to stop listening to a query not found");
[self.localStore releaseQuery:query];
[self.remoteStore stopListeningToTargetID:queryView.targetID];
@@ -257,7 +257,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
updateBlock:(FSTTransactionBlock)updateBlock
completion:(FSTVoidIDErrorBlock)completion {
[workerDispatchQueue verifyIsCurrentQueue];
- FSTAssert(retries >= 0, @"Got negative number of retries for transaction");
+ HARD_ASSERT(retries >= 0, "Got negative number of retries for transaction");
FSTTransaction *transaction = [self.remoteStore transaction];
updateBlock(transaction, ^(id _Nullable result, NSError *_Nullable error) {
[workerDispatchQueue dispatchAsync:^{
@@ -303,7 +303,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
const auto iter = self->_limboKeysByTarget.find([targetID intValue]);
if (iter == self->_limboKeysByTarget.end()) {
FSTQueryView *qv = self.queryViewsByTarget[targetID];
- FSTAssert(qv, @"Missing queryview for non-limbo query: %i", [targetID intValue]);
+ HARD_ASSERT(qv, "Missing queryview for non-limbo query: %s", [targetID intValue]);
[targetChange.mapping filterUpdatesUsingExistingKeys:qv.view.syncedDocuments];
} else {
[remoteEvent synthesizeDeleteForLimboTargetChange:targetChange key:iter->second];
@@ -319,8 +319,8 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
[self.queryViewsByQuery
enumerateKeysAndObjectsUsingBlock:^(FSTQuery *query, FSTQueryView *queryView, BOOL *stop) {
FSTViewChange *viewChange = [queryView.view applyChangedOnlineState:onlineState];
- FSTAssert(viewChange.limboChanges.count == 0,
- @"OnlineState should not affect limbo documents.");
+ HARD_ASSERT(viewChange.limboChanges.count == 0,
+ "OnlineState should not affect limbo documents.");
if (viewChange.snapshot) {
[newViewSnapshots addObject:viewChange.snapshot];
}
@@ -360,7 +360,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
[self applyRemoteEvent:event];
} else {
FSTQueryView *queryView = self.queryViewsByTarget[@(targetID)];
- FSTAssert(queryView, @"Unknown targetId: %d", targetID);
+ HARD_ASSERT(queryView, "Unknown targetId: %s", targetID);
[self.localStore releaseQuery:queryView.query];
[self removeAndCleanupQuery:queryView];
[self.delegate handleError:error forQuery:queryView.query];
@@ -408,8 +408,8 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
}
- (void)assertDelegateExistsForSelector:(SEL)methodSelector {
- FSTAssert(self.delegate, @"Tried to call '%@' before delegate was registered.",
- NSStringFromSelector(methodSelector));
+ HARD_ASSERT(self.delegate, "Tried to call '%s' before delegate was registered.",
+ NSStringFromSelector(methodSelector));
}
- (void)removeAndCleanupQuery:(FSTQueryView *)queryView {
@@ -475,7 +475,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1;
break;
default:
- FSTFail(@"Unknown limbo change type: %ld", (long)limboChange.type);
+ HARD_FAIL("Unknown limbo change type: %s", limboChange.type);
}
}
[self garbageCollectLimboDocuments];
diff --git a/Firestore/Source/Core/FSTTransaction.mm b/Firestore/Source/Core/FSTTransaction.mm
index 5c36b20..da5cf71 100644
--- a/Firestore/Source/Core/FSTTransaction.mm
+++ b/Firestore/Source/Core/FSTTransaction.mm
@@ -26,13 +26,13 @@
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTDatastore.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::model::DocumentKey;
using firebase::firestore::model::Precondition;
@@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
* writes sent to the backend.
*/
- (BOOL)recordVersionForDocument:(FSTMaybeDocument *)doc error:(NSError **)error {
- FSTAssert(error != nil, @"nil error parameter");
+ HARD_ASSERT(error != nil, "nil error parameter");
*error = nil;
SnapshotVersion docVersion = doc.version;
if ([doc isKindOfClass:[FSTDeletedDocument class]]) {
@@ -189,7 +189,7 @@ NS_ASSUME_NONNULL_BEGIN
NSError *error = nil;
const Precondition precondition = [self preconditionForUpdateWithDocumentKey:key error:&error];
if (precondition.IsNone()) {
- FSTAssert(error, @"Got nil precondition, but error was not set");
+ HARD_ASSERT(error, "Got nil precondition, but error was not set");
self.lastWriteError = error;
} else {
[self writeMutations:[data mutationsWithKey:key precondition:precondition]];
diff --git a/Firestore/Source/Core/FSTView.mm b/Firestore/Source/Core/FSTView.mm
index d254a82..63efd4e 100644
--- a/Firestore/Source/Core/FSTView.mm
+++ b/Firestore/Source/Core/FSTView.mm
@@ -24,9 +24,9 @@
#import "Firestore/Source/Model/FSTDocumentSet.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::model::DocumentKey;
using firebase::firestore::model::DocumentKeySet;
@@ -235,8 +235,8 @@ static NSComparisonResult FSTCompareDocumentViewChangeTypes(FSTDocumentViewChang
newDoc = (FSTDocument *)maybeNewDoc;
}
if (newDoc) {
- FSTAssert([key isEqual:newDoc.key], @"Mismatching key in document changes: %@ != %s", key,
- newDoc.key.ToString().c_str());
+ HARD_ASSERT([key isEqual:newDoc.key], "Mismatching key in document changes: %s != %s", key,
+ newDoc.key.ToString());
if (![self.query matchesDocument:newDoc]) {
newDoc = nil;
}
@@ -300,8 +300,8 @@ static NSComparisonResult FSTCompareDocumentViewChangeTypes(FSTDocumentViewChang
}
}
- FSTAssert(!needsRefill || !previousChanges,
- @"View was refilled using docs that themselves needed refilling.");
+ HARD_ASSERT(!needsRefill || !previousChanges,
+ "View was refilled using docs that themselves needed refilling.");
return [[FSTViewDocumentChanges alloc] initWithDocumentSet:newDocumentSet
changeSet:changeSet
@@ -315,7 +315,7 @@ static NSComparisonResult FSTCompareDocumentViewChangeTypes(FSTDocumentViewChang
- (FSTViewChange *)applyChangesToDocuments:(FSTViewDocumentChanges *)docChanges
targetChange:(nullable FSTTargetChange *)targetChange {
- FSTAssert(!docChanges.needsRefill, @"Cannot apply changes that need a refill");
+ HARD_ASSERT(!docChanges.needsRefill, "Cannot apply changes that need a refill");
FSTDocumentSet *oldDocuments = self.documentSet;
self.documentSet = docChanges.documentSet;
@@ -476,7 +476,7 @@ static inline int DocumentViewChangeTypePosition(FSTDocumentViewChangeType chang
// equivalently.
return 2;
default:
- FSTCFail(@"Unknown FSTDocumentViewChangeType %lu", (unsigned long)changeType);
+ HARD_FAIL("Unknown FSTDocumentViewChangeType %s", changeType);
}
}
diff --git a/Firestore/Source/Core/FSTViewSnapshot.mm b/Firestore/Source/Core/FSTViewSnapshot.mm
index ae366fb..ac5b376 100644
--- a/Firestore/Source/Core/FSTViewSnapshot.mm
+++ b/Firestore/Source/Core/FSTViewSnapshot.mm
@@ -19,10 +19,10 @@
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/third_party/Immutable/FSTImmutableSortedDictionary.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::model::DocumentKey;
@@ -154,8 +154,7 @@ NS_ASSUME_NONNULL_BEGIN
// Removed -> Modified
// Metadata -> Added
// Removed -> Metadata
- FSTFail(@"Unsupported combination of changes: %ld after %ld", (long)change.type,
- (long)oldChange.type);
+ HARD_FAIL("Unsupported combination of changes: %s after %s", change.type, oldChange.type);
}
}
diff --git a/Firestore/Source/Local/FSTLevelDB.mm b/Firestore/Source/Local/FSTLevelDB.mm
index 6d0f8af..321d47a 100644
--- a/Firestore/Source/Local/FSTLevelDB.mm
+++ b/Firestore/Source/Local/FSTLevelDB.mm
@@ -24,12 +24,12 @@
#import "Firestore/Source/Local/FSTLevelDBQueryCache.h"
#import "Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_transaction.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"
#include "leveldb/db.h"
@@ -132,7 +132,7 @@ using leveldb::WriteOptions;
#pragma mark - Startup
- (BOOL)start:(NSError **)error {
- FSTAssert(!self.isStarted, @"FSTLevelDB double-started!");
+ HARD_ASSERT(!self.isStarted, "FSTLevelDB double-started!");
self.started = YES;
NSString *directory = self.directory;
if (![self ensureDirectory:directory error:error]) {
@@ -207,7 +207,7 @@ using leveldb::WriteOptions;
}
- (LevelDbTransaction *)currentTransaction {
- FSTAssert(_transaction != nullptr, @"Attempting to access transaction before one has started");
+ HARD_ASSERT(_transaction != nullptr, "Attempting to access transaction before one has started");
return _transaction.get();
}
@@ -226,18 +226,18 @@ using leveldb::WriteOptions;
}
- (void)startTransaction:(absl::string_view)label {
- FSTAssert(_transaction == nullptr, @"Starting a transaction while one is already outstanding");
+ HARD_ASSERT(_transaction == nullptr, "Starting a transaction while one is already outstanding");
_transaction = absl::make_unique<LevelDbTransaction>(_ptr.get(), label);
}
- (void)commitTransaction {
- FSTAssert(_transaction != nullptr, @"Committing a transaction before one is started");
+ HARD_ASSERT(_transaction != nullptr, "Committing a transaction before one is started");
_transaction->Commit();
_transaction.reset();
}
- (void)shutdown {
- FSTAssert(self.isStarted, @"FSTLevelDB shutdown without start!");
+ HARD_ASSERT(self.isStarted, "FSTLevelDB shutdown without start!");
self.started = NO;
_ptr.reset();
}
diff --git a/Firestore/Source/Local/FSTLevelDBMigrations.mm b/Firestore/Source/Local/FSTLevelDBMigrations.mm
index fefd0f7..bd72c97 100644
--- a/Firestore/Source/Local/FSTLevelDBMigrations.mm
+++ b/Firestore/Source/Local/FSTLevelDBMigrations.mm
@@ -21,8 +21,8 @@
#import "Firestore/Protos/objc/firestore/local/Target.pbobjc.h"
#import "Firestore/Source/Local/FSTLevelDBKey.h"
#import "Firestore/Source/Local/FSTLevelDBQueryCache.h"
-#import "Firestore/Source/Util/FSTAssert.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "absl/strings/match.h"
#include "leveldb/write_batch.h"
@@ -80,8 +80,8 @@ static void AddTargetCount(LevelDbTransaction *transaction) {
FSTPBTargetGlobal *targetGlobal =
[FSTLevelDBQueryCache readTargetMetadataWithTransaction:transaction];
- FSTCAssert(targetGlobal != nil,
- @"We should have a metadata row as it was added in an earlier migration");
+ HARD_ASSERT(targetGlobal != nil,
+ "We should have a metadata row as it was added in an earlier migration");
targetGlobal.targetCount = count;
transaction->Put([FSTLevelDBTargetGlobalKey key], targetGlobal);
}
diff --git a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm
index 2c9f68d..3b4687c 100644
--- a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm
+++ b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm
@@ -27,12 +27,12 @@
#import "Firestore/Source/Local/FSTLocalSerializer.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_transaction.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.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/string_apple.h"
#include "Firestore/core/src/firebase/firestore/util/string_util.h"
#include "absl/strings/match.h"
@@ -120,7 +120,7 @@ using leveldb::WriteOptions;
} else {
FSTBatchID lastAcked = metadata.lastAcknowledgedBatchId;
if (lastAcked >= nextBatchID) {
- FSTAssert([self isEmpty], @"Reset nextBatchID is only possible when the queue is empty");
+ HARD_ASSERT([self isEmpty], "Reset nextBatchID is only possible when the queue is empty");
lastAcked = kFSTBatchIDUnknown;
metadata.lastAcknowledgedBatchId = lastAcked;
@@ -184,7 +184,7 @@ using leveldb::WriteOptions;
// In all the cases above there was at least one row for the current user and each case has
// set things up such that iterator points to it.
if (![rowKey decodeKey:it->key()]) {
- FSTFail(@"There should have been a key previous to %s", userEnd.c_str());
+ HARD_FAIL("There should have been a key previous to %s", userEnd);
}
if (rowKey.batchID > maxBatchID) {
@@ -215,8 +215,8 @@ using leveldb::WriteOptions;
- (void)acknowledgeBatch:(FSTMutationBatch *)batch streamToken:(nullable NSData *)streamToken {
FSTBatchID batchID = batch.batchID;
- FSTAssert(batchID > self.highestAcknowledgedBatchID,
- @"Mutation batchIDs must be acknowledged in order");
+ HARD_ASSERT(batchID > self.highestAcknowledgedBatchID,
+ "Mutation batchIDs must be acknowledged in order");
FSTPBMutationQueue *metadata = self.metadata;
metadata.lastAcknowledgedBatchId = batchID;
@@ -248,8 +248,7 @@ using leveldb::WriteOptions;
} else if (status.IsNotFound()) {
return nil;
} else {
- FSTFail(@"metadataForKey: failed loading key %s with status: %s", key.c_str(),
- status.ToString().c_str());
+ HARD_FAIL("metadataForKey: failed loading key %s with status: %s", key, status.ToString());
}
}
@@ -290,8 +289,8 @@ using leveldb::WriteOptions;
if (status.IsNotFound()) {
return nil;
}
- FSTFail(@"Lookup mutation batch (%@, %d) failed with status: %s", self.userID, batchID,
- status.ToString().c_str());
+ HARD_FAIL("Lookup mutation batch (%s, %s) failed with status: %s", self.userID, batchID,
+ status.ToString());
}
return [self decodedMutationBatch:value];
@@ -318,7 +317,7 @@ using leveldb::WriteOptions;
return nil;
}
- FSTAssert(rowKey.batchID >= nextBatchID, @"Should have found mutation after %d", nextBatchID);
+ HARD_ASSERT(rowKey.batchID >= nextBatchID, "Should have found mutation after %s", nextBatchID);
return [self decodedMutationBatch:it->value()];
}
@@ -385,9 +384,9 @@ using leveldb::WriteOptions;
if (mutationIterator->Valid()) {
foundKeyDescription = [FSTLevelDBKey descriptionForKey:mutationIterator->key()];
}
- FSTFail(
- @"Dangling document-mutation reference found: "
- @"%@ points to %@; seeking there found %@",
+ HARD_FAIL(
+ "Dangling document-mutation reference found: "
+ "%s points to %s; seeking there found %s",
[FSTLevelDBKey descriptionForKey:indexIterator->key()],
[FSTLevelDBKey descriptionForKey:mutationKey], foundKeyDescription);
}
@@ -398,7 +397,7 @@ using leveldb::WriteOptions;
}
- (NSArray<FSTMutationBatch *> *)allMutationBatchesAffectingQuery:(FSTQuery *)query {
- FSTAssert(![query isDocumentQuery], @"Document queries shouldn't go down this path");
+ HARD_ASSERT(![query isDocumentQuery], "Document queries shouldn't go down this path");
NSString *userID = self.userID;
const ResourcePath &queryPath = query.path;
@@ -460,9 +459,9 @@ using leveldb::WriteOptions;
if (mutationIterator->Valid()) {
foundKeyDescription = [FSTLevelDBKey descriptionForKey:mutationIterator->key()];
}
- FSTFail(
- @"Dangling document-mutation reference found: "
- @"Missing batch %@; seeking there found %@",
+ HARD_FAIL(
+ "Dangling document-mutation reference found: "
+ "Missing batch %s; seeking there found %s",
[FSTLevelDBKey descriptionForKey:mutationKey], foundKeyDescription);
}
@@ -497,12 +496,12 @@ using leveldb::WriteOptions;
// As a sanity check, verify that the mutation batch exists before deleting it.
checkIterator->Seek(key);
- FSTAssert(checkIterator->Valid(), @"Mutation batch %@ did not exist",
- [FSTLevelDBKey descriptionForKey:key]);
+ HARD_ASSERT(checkIterator->Valid(), "Mutation batch %s did not exist",
+ [FSTLevelDBKey descriptionForKey:key]);
- FSTAssert(key == checkIterator->key(), @"Mutation batch %@ not found; found %@",
- [FSTLevelDBKey descriptionForKey:key],
- [FSTLevelDBKey descriptionForKey:checkIterator->key()]);
+ HARD_ASSERT(key == checkIterator->key(), "Mutation batch %s not found; found %s",
+ [FSTLevelDBKey descriptionForKey:key],
+ [FSTLevelDBKey descriptionForKey:checkIterator->key()]);
_db.currentTransaction->Delete(key);
@@ -538,10 +537,10 @@ using leveldb::WriteOptions;
[danglingMutationReferences addObject:[FSTLevelDBKey descriptionForKey:indexIterator->key()]];
}
- FSTAssert(danglingMutationReferences.count == 0,
- @"Document leak -- detected dangling mutation references when queue "
- @"is empty. Dangling keys: %@",
- danglingMutationReferences);
+ HARD_ASSERT(danglingMutationReferences.count == 0,
+ "Document leak -- detected dangling mutation references when queue "
+ "is empty. Dangling keys: %s",
+ danglingMutationReferences);
}
- (std::string)mutationKeyForBatch:(FSTMutationBatch *)batch {
@@ -560,7 +559,7 @@ using leveldb::WriteOptions;
NSError *error;
FSTPBMutationQueue *proto = [FSTPBMutationQueue parseFromData:data error:&error];
if (!proto) {
- FSTFail(@"FSTPBMutationQueue failed to parse: %@", error);
+ HARD_FAIL("FSTPBMutationQueue failed to parse: %s", error);
}
return proto;
@@ -574,7 +573,7 @@ using leveldb::WriteOptions;
NSError *error;
FSTPBWriteBatch *proto = [FSTPBWriteBatch parseFromData:data error:&error];
if (!proto) {
- FSTFail(@"FSTPBMutationBatch failed to parse: %@", error);
+ HARD_FAIL("FSTPBMutationBatch failed to parse: %s", error);
}
return [self.serializer decodedMutationBatch:proto];
diff --git a/Firestore/Source/Local/FSTLevelDBQueryCache.mm b/Firestore/Source/Local/FSTLevelDBQueryCache.mm
index 68b6f98..f28370a 100644
--- a/Firestore/Source/Local/FSTLevelDBQueryCache.mm
+++ b/Firestore/Source/Local/FSTLevelDBQueryCache.mm
@@ -26,10 +26,10 @@
#import "Firestore/Source/Local/FSTLevelDBKey.h"
#import "Firestore/Source/Local/FSTLocalSerializer.h"
#import "Firestore/Source/Local/FSTQueryData.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "absl/strings/match.h"
NS_ASSUME_NONNULL_BEGIN
@@ -70,8 +70,7 @@ using firebase::firestore::model::DocumentKeySet;
if (status.IsNotFound()) {
return nil;
} else if (!status.ok()) {
- FSTFail(@"metadataForKey: failed loading key %s with status: %s", key.c_str(),
- status.ToString().c_str());
+ HARD_FAIL("metadataForKey: failed loading key %s with status: %s", key, status.ToString());
}
NSData *data =
@@ -80,7 +79,7 @@ using firebase::firestore::model::DocumentKeySet;
NSError *error;
FSTPBTargetGlobal *proto = [FSTPBTargetGlobal parseFromData:data error:&error];
if (!proto) {
- FSTFail(@"FSTPBTargetGlobal failed to parse: %@", error);
+ HARD_FAIL("FSTPBTargetGlobal failed to parse: %s", error);
}
return proto;
@@ -93,8 +92,7 @@ using firebase::firestore::model::DocumentKeySet;
if (status.IsNotFound()) {
return nil;
} else if (!status.ok()) {
- FSTFail(@"metadataForKey: failed loading key %s with status: %s", key.c_str(),
- status.ToString().c_str());
+ HARD_FAIL("metadataForKey: failed loading key %s with status: %s", key, status.ToString());
}
NSData *data =
@@ -103,7 +101,7 @@ using firebase::firestore::model::DocumentKeySet;
NSError *error;
FSTPBTargetGlobal *proto = [FSTPBTargetGlobal parseFromData:data error:&error];
if (!proto) {
- FSTFail(@"FSTPBTargetGlobal failed to parse: %@", error);
+ HARD_FAIL("FSTPBTargetGlobal failed to parse: %s", error);
}
return proto;
@@ -111,7 +109,7 @@ using firebase::firestore::model::DocumentKeySet;
- (instancetype)initWithDB:(FSTLevelDB *)db serializer:(FSTLocalSerializer *)serializer {
if (self = [super init]) {
- FSTAssert(db, @"db must not be NULL");
+ HARD_ASSERT(db, "db must not be NULL");
_db = db;
_serializer = serializer;
}
@@ -121,9 +119,9 @@ using firebase::firestore::model::DocumentKeySet;
- (void)start {
// TODO(gsoltis): switch this usage of ptr to currentTransaction
FSTPBTargetGlobal *metadata = [FSTLevelDBQueryCache readTargetMetadataFromDB:_db.ptr];
- FSTAssert(
+ HARD_ASSERT(
metadata != nil,
- @"Found nil metadata, expected schema to be at version 0 which ensures metadata existence");
+ "Found nil metadata, expected schema to be at version 0 which ensures metadata existence");
_lastRemoteSnapshotVersion = [self.serializer decodedVersion:metadata.lastRemoteSnapshotVersion];
self.metadata = metadata;
@@ -224,7 +222,7 @@ using firebase::firestore::model::DocumentKeySet;
NSError *error;
FSTPBTarget *proto = [FSTPBTarget parseFromData:data error:&error];
if (!proto) {
- FSTFail(@"FSTPBTarget failed to parse: %@", error);
+ HARD_FAIL("FSTPBTarget failed to parse: %s", error);
}
return [self.serializer decodedQueryData:proto];
@@ -263,9 +261,9 @@ using firebase::firestore::model::DocumentKeySet;
if (targetIterator->Valid()) {
foundKeyDescription = [FSTLevelDBKey descriptionForKey:targetIterator->key()];
}
- FSTFail(
- @"Dangling query-target reference found: "
- @"%@ points to %@; seeking there found %@",
+ HARD_FAIL(
+ "Dangling query-target reference found: "
+ "%s points to %s; seeking there found %s",
[FSTLevelDBKey descriptionForKey:indexItererator->key()],
[FSTLevelDBKey descriptionForKey:targetKey], foundKeyDescription);
}
diff --git a/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm b/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm
index f655e3a..534d2a4 100644
--- a/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm
+++ b/Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm
@@ -26,10 +26,10 @@
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentDictionary.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_transaction.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
@@ -77,8 +77,8 @@ using leveldb::Status;
} else if (status.ok()) {
return [self decodeMaybeDocument:value withKey:documentKey];
} else {
- FSTFail(@"Fetch document for key (%s) failed with status: %s", documentKey.ToString().c_str(),
- status.ToString().c_str());
+ HARD_FAIL("Fetch document for key (%s) failed with status: %s", documentKey.ToString(),
+ status.ToString());
}
}
@@ -118,13 +118,13 @@ using leveldb::Status;
NSError *error;
FSTPBMaybeDocument *proto = [FSTPBMaybeDocument parseFromData:data error:&error];
if (!proto) {
- FSTFail(@"FSTPBMaybeDocument failed to parse: %@", error);
+ HARD_FAIL("FSTPBMaybeDocument failed to parse: %s", error);
}
FSTMaybeDocument *maybeDocument = [self.serializer decodedMaybeDocument:proto];
- FSTAssert([maybeDocument.key isEqualToKey:documentKey],
- @"Read document has key (%s) instead of expected key (%s).",
- maybeDocument.key.ToString().c_str(), documentKey.ToString().c_str());
+ HARD_ASSERT([maybeDocument.key isEqualToKey:documentKey],
+ "Read document has key (%s) instead of expected key (%s).",
+ maybeDocument.key.ToString(), documentKey.ToString());
return maybeDocument;
}
diff --git a/Firestore/Source/Local/FSTLocalDocumentsView.mm b/Firestore/Source/Local/FSTLocalDocumentsView.mm
index 471840a..48c963e 100644
--- a/Firestore/Source/Local/FSTLocalDocumentsView.mm
+++ b/Firestore/Source/Local/FSTLocalDocumentsView.mm
@@ -23,11 +23,11 @@
#import "Firestore/Source/Model/FSTDocumentDictionary.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::model::DocumentKey;
using firebase::firestore::model::ResourcePath;
@@ -178,7 +178,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if ([mutatedDoc isKindOfClass:[FSTDocument class]]) {
result = [result dictionaryBySettingObject:(FSTDocument *)mutatedDoc forKey:key];
} else {
- FSTFail(@"Unknown document: %@", mutatedDoc);
+ HARD_FAIL("Unknown document: %s", mutatedDoc);
}
}];
return result;
diff --git a/Firestore/Source/Local/FSTLocalSerializer.mm b/Firestore/Source/Local/FSTLocalSerializer.mm
index 2c5ab4d..662419a 100644
--- a/Firestore/Source/Local/FSTLocalSerializer.mm
+++ b/Firestore/Source/Local/FSTLocalSerializer.mm
@@ -29,11 +29,11 @@
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/include/firebase/firestore/timestamp.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::Timestamp;
using firebase::firestore::model::DocumentKey;
@@ -64,7 +64,7 @@ using firebase::firestore::model::SnapshotVersion;
} else if ([document isKindOfClass:[FSTDocument class]]) {
proto.document = [self encodedDocument:(FSTDocument *)document];
} else {
- FSTFail(@"Unknown document type %@", NSStringFromClass([document class]));
+ HARD_FAIL("Unknown document type %s", NSStringFromClass([document class]));
}
return proto;
@@ -79,7 +79,7 @@ using firebase::firestore::model::SnapshotVersion;
return [self decodedDeletedDocument:proto.noDocument];
default:
- FSTFail(@"Unknown MaybeDocument %@", proto);
+ HARD_FAIL("Unknown MaybeDocument %s", proto);
}
}
@@ -164,9 +164,9 @@ using firebase::firestore::model::SnapshotVersion;
- (FSTPBTarget *)encodedQueryData:(FSTQueryData *)queryData {
FSTSerializerBeta *remoteSerializer = self.remoteSerializer;
- FSTAssert(queryData.purpose == FSTQueryPurposeListen,
- @"only queries with purpose %lu may be stored, got %lu",
- (unsigned long)FSTQueryPurposeListen, (unsigned long)queryData.purpose);
+ HARD_ASSERT(queryData.purpose == FSTQueryPurposeListen,
+ "only queries with purpose %s may be stored, got %s", FSTQueryPurposeListen,
+ queryData.purpose);
FSTPBTarget *proto = [FSTPBTarget message];
proto.targetId = queryData.targetID;
@@ -203,7 +203,7 @@ using firebase::firestore::model::SnapshotVersion;
break;
default:
- FSTFail(@"Unknown Target.targetType %" PRId32, target.targetTypeOneOfCase);
+ HARD_FAIL("Unknown Target.targetType %s", target.targetTypeOneOfCase);
}
return [[FSTQueryData alloc] initWithQuery:query
diff --git a/Firestore/Source/Local/FSTLocalStore.mm b/Firestore/Source/Local/FSTLocalStore.mm
index 245dd62..7469c71 100644
--- a/Firestore/Source/Local/FSTLocalStore.mm
+++ b/Firestore/Source/Local/FSTLocalStore.mm
@@ -36,12 +36,12 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/core/target_id_generator.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
using firebase::firestore::auth::User;
@@ -236,10 +236,10 @@ NS_ASSUME_NONNULL_BEGIN
- (FSTMaybeDocumentDictionary *)rejectBatchID:(FSTBatchID)batchID {
return self.persistence.run("Reject batch", [&]() -> FSTMaybeDocumentDictionary * {
FSTMutationBatch *toReject = [self.mutationQueue lookupMutationBatch:batchID];
- FSTAssert(toReject, @"Attempt to reject nonexistent batch!");
+ HARD_ASSERT(toReject, "Attempt to reject nonexistent batch!");
FSTBatchID lastAcked = [self.mutationQueue highestAcknowledgedBatchID];
- FSTAssert(batchID > lastAcked, @"Acknowledged batches can't be rejected.");
+ HARD_ASSERT(batchID > lastAcked, "Acknowledged batches can't be rejected.");
DocumentKeySet affected = [self removeMutationBatch:toReject];
@@ -304,7 +304,7 @@ NS_ASSUME_NONNULL_BEGIN
[queryCache addMatchingKeys:update.addedDocuments forTargetID:targetID];
} else {
- FSTFail(@"Unknown mapping type: %@", mapping);
+ HARD_FAIL("Unknown mapping type: %s", mapping);
}
}
}];
@@ -345,10 +345,9 @@ NS_ASSUME_NONNULL_BEGIN
const SnapshotVersion &lastRemoteVersion = [self.queryCache lastRemoteSnapshotVersion];
const SnapshotVersion &remoteVersion = remoteEvent.snapshotVersion;
if (remoteVersion != SnapshotVersion::None()) {
- FSTAssert(remoteVersion >= lastRemoteVersion,
- @"Watch stream reverted to previous snapshot?? (%s < %s)",
- remoteVersion.timestamp().ToString().c_str(),
- lastRemoteVersion.timestamp().ToString().c_str());
+ HARD_ASSERT(remoteVersion >= lastRemoteVersion,
+ "Watch stream reverted to previous snapshot?? (%s < %s)",
+ remoteVersion.timestamp().ToString(), lastRemoteVersion.timestamp().ToString());
[self.queryCache setLastRemoteSnapshotVersion:remoteVersion];
}
@@ -369,7 +368,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTReferenceSet *localViewReferences = self.localViewReferences;
for (FSTLocalViewChanges *view in viewChanges) {
FSTQueryData *queryData = [self.queryCache queryDataForQuery:view.query];
- FSTAssert(queryData, @"Local view changes contain unallocated query.");
+ HARD_ASSERT(queryData, "Local view changes contain unallocated query.");
FSTTargetID targetID = queryData.targetID;
for (const DocumentKey &key : view.removedKeys) {
[self->_persistence.referenceDelegate removeReference:key target:targetID];
@@ -409,8 +408,8 @@ NS_ASSUME_NONNULL_BEGIN
});
// Sanity check to ensure that even when resuming a query it's not currently active.
FSTBoxedTargetID *boxedTargetID = @(queryData.targetID);
- FSTAssert(!self.targetIDs[boxedTargetID], @"Tried to allocate an already allocated query: %@",
- query);
+ HARD_ASSERT(!self.targetIDs[boxedTargetID], "Tried to allocate an already allocated query: %s",
+ query);
self.targetIDs[boxedTargetID] = queryData;
return queryData;
}
@@ -418,7 +417,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)releaseQuery:(FSTQuery *)query {
self.persistence.run("Release query", [&]() {
FSTQueryData *queryData = [self.queryCache queryDataForQuery:query];
- FSTAssert(queryData, @"Tried to release nonexistent query: %@", query);
+ HARD_ASSERT(queryData, "Tried to release nonexistent query: %s", query);
[self.localViewReferences removeReferencesForID:queryData.targetID];
if (self.garbageCollector.isEager) {
@@ -530,14 +529,14 @@ NS_ASSUME_NONNULL_BEGIN
FSTMaybeDocument *_Nullable doc = remoteDoc;
auto ackVersionIter = versions.find(docKey);
- FSTAssert(ackVersionIter != versions.end(),
- @"docVersions should contain every doc in the write.");
+ HARD_ASSERT(ackVersionIter != versions.end(),
+ "docVersions should contain every doc in the write.");
const SnapshotVersion &ackVersion = ackVersionIter->second;
if (!doc || doc.version < ackVersion) {
doc = [batch applyTo:doc documentKey:docKey mutationBatchResult:batchResult];
if (!doc) {
- FSTAssert(!remoteDoc, @"Mutation batch %@ applied to document %@ resulted in nil.", batch,
- remoteDoc);
+ HARD_ASSERT(!remoteDoc, "Mutation batch %s applied to document %s resulted in nil.", batch,
+ remoteDoc);
} else {
[self.remoteDocumentCache addEntry:doc];
}
diff --git a/Firestore/Source/Local/FSTMemoryMutationQueue.mm b/Firestore/Source/Local/FSTMemoryMutationQueue.mm
index e05ee64..8faf893 100644
--- a/Firestore/Source/Local/FSTMemoryMutationQueue.mm
+++ b/Firestore/Source/Local/FSTMemoryMutationQueue.mm
@@ -21,11 +21,11 @@
#import "Firestore/Source/Local/FSTMemoryPersistence.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/third_party/Immutable/FSTImmutableSortedSet.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::model::DocumentKey;
using firebase::firestore::model::ResourcePath;
@@ -102,8 +102,8 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
self.nextBatchID = 1;
self.highestAcknowledgedBatchID = kFSTBatchIDUnknown;
}
- FSTAssert(self.highestAcknowledgedBatchID < self.nextBatchID,
- @"highestAcknowledgedBatchID must be less than the nextBatchID");
+ HARD_ASSERT(self.highestAcknowledgedBatchID < self.nextBatchID,
+ "highestAcknowledgedBatchID must be less than the nextBatchID");
}
- (BOOL)isEmpty {
@@ -120,16 +120,16 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
NSMutableArray<FSTMutationBatch *> *queue = self.queue;
FSTBatchID batchID = batch.batchID;
- FSTAssert(batchID > self.highestAcknowledgedBatchID,
- @"Mutation batchIDs must be acknowledged in order");
+ HARD_ASSERT(batchID > self.highestAcknowledgedBatchID,
+ "Mutation batchIDs must be acknowledged in order");
NSInteger batchIndex = [self indexOfExistingBatchID:batchID action:@"acknowledged"];
// Verify that the batch in the queue is the one to be acknowledged.
FSTMutationBatch *check = queue[(NSUInteger)batchIndex];
- FSTAssert(batchID == check.batchID, @"Queue ordering failure: expected batch %d, got batch %d",
- batchID, check.batchID);
- FSTAssert(![check isTombstone], @"Can't acknowledge a previously removed batch");
+ HARD_ASSERT(batchID == check.batchID, "Queue ordering failure: expected batch %s, got batch %s",
+ batchID, check.batchID);
+ HARD_ASSERT(![check isTombstone], "Can't acknowledge a previously removed batch");
self.highestAcknowledgedBatchID = batchID;
self.lastStreamToken = streamToken;
@@ -137,7 +137,7 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
- (FSTMutationBatch *)addMutationBatchWithWriteTime:(FIRTimestamp *)localWriteTime
mutations:(NSArray<FSTMutation *> *)mutations {
- FSTAssert(mutations.count > 0, @"Mutation batches should not be empty");
+ HARD_ASSERT(mutations.count > 0, "Mutation batches should not be empty");
FSTBatchID batchID = self.nextBatchID;
self.nextBatchID += 1;
@@ -145,7 +145,8 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
NSMutableArray<FSTMutationBatch *> *queue = self.queue;
if (queue.count > 0) {
FSTMutationBatch *prior = queue[queue.count - 1];
- FSTAssert(prior.batchID < batchID, @"Mutation batchIDs must be monotonically increasing order");
+ HARD_ASSERT(prior.batchID < batchID,
+ "Mutation batchIDs must be monotonically increasing order");
}
FSTMutationBatch *batch = [[FSTMutationBatch alloc] initWithBatchID:batchID
@@ -173,7 +174,7 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
}
FSTMutationBatch *batch = queue[(NSUInteger)index];
- FSTAssert(batch.batchID == batchID, @"If found batch must match");
+ HARD_ASSERT(batch.batchID == batchID, "If found batch must match");
return [batch isTombstone] ? nil : batch;
}
@@ -233,7 +234,7 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
}
FSTMutationBatch *batch = [self lookupMutationBatch:reference.ID];
- FSTAssert(batch, @"Batches in the index must exist in the main table");
+ HARD_ASSERT(batch, "Batches in the index must exist in the main table");
[result addObject:batch];
};
@@ -292,7 +293,7 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
- (void)removeMutationBatches:(NSArray<FSTMutationBatch *> *)batches {
NSUInteger batchCount = batches.count;
- FSTAssert(batchCount > 0, @"Should not remove mutations when none exist.");
+ HARD_ASSERT(batchCount > 0, "Should not remove mutations when none exist.");
FSTBatchID firstBatchID = batches[0].batchID;
@@ -302,7 +303,7 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
// Find the position of the first batch for removal. This need not be the first entry in the
// queue.
NSUInteger startIndex = [self indexOfExistingBatchID:firstBatchID action:@"removed"];
- FSTAssert(queue[startIndex].batchID == firstBatchID, @"Removed batches must exist in the queue");
+ HARD_ASSERT(queue[startIndex].batchID == firstBatchID, "Removed batches must exist in the queue");
// Check that removed batches are contiguous (while excluding tombstones).
NSUInteger batchIndex = 1;
@@ -314,8 +315,8 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
continue;
}
- FSTAssert(batch.batchID == batches[batchIndex].batchID,
- @"Removed batches must be contiguous in the queue");
+ HARD_ASSERT(batch.batchID == batches[batchIndex].batchID,
+ "Removed batches must be contiguous in the queue");
batchIndex++;
queueIndex++;
}
@@ -359,8 +360,8 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
- (void)performConsistencyCheck {
if (self.queue.count == 0) {
- FSTAssert([self.batchesByDocumentKey isEmpty],
- @"Document leak -- detected dangling mutation references when queue is empty.");
+ HARD_ASSERT([self.batchesByDocumentKey isEmpty],
+ "Document leak -- detected dangling mutation references when queue is empty.");
}
}
@@ -431,7 +432,7 @@ static const NSComparator NumberComparator = ^NSComparisonResult(NSNumber *left,
*/
- (NSUInteger)indexOfExistingBatchID:(FSTBatchID)batchID action:(NSString *)action {
NSInteger index = [self indexOfBatchID:batchID];
- FSTAssert(index >= 0 && index < self.queue.count, @"Batches must exist to be %@", action);
+ HARD_ASSERT(index >= 0 && index < self.queue.count, "Batches must exist to be %s", action);
return (NSUInteger)index;
}
diff --git a/Firestore/Source/Local/FSTMemoryPersistence.mm b/Firestore/Source/Local/FSTMemoryPersistence.mm
index 3466f3e..5e35aa4 100644
--- a/Firestore/Source/Local/FSTMemoryPersistence.mm
+++ b/Firestore/Source/Local/FSTMemoryPersistence.mm
@@ -21,9 +21,9 @@
#import "Firestore/Source/Local/FSTMemoryMutationQueue.h"
#import "Firestore/Source/Local/FSTMemoryQueryCache.h"
#import "Firestore/Source/Local/FSTMemoryRemoteDocumentCache.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::auth::HashUser;
using firebase::firestore::auth::User;
@@ -67,14 +67,14 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)start:(NSError **)error {
// No durable state to read on startup.
- FSTAssert(!self.isStarted, @"FSTMemoryPersistence double-started!");
+ HARD_ASSERT(!self.isStarted, "FSTMemoryPersistence double-started!");
self.started = YES;
return YES;
}
- (void)shutdown {
// No durable state to ensure is closed on shutdown.
- FSTAssert(self.isStarted, @"FSTMemoryPersistence shutdown without start!");
+ HARD_ASSERT(self.isStarted, "FSTMemoryPersistence shutdown without start!");
self.started = NO;
}
diff --git a/Firestore/Source/Local/FSTPersistence.h b/Firestore/Source/Local/FSTPersistence.h
index 417ff3f..a2ce76f 100644
--- a/Firestore/Source/Local/FSTPersistence.h
+++ b/Firestore/Source/Local/FSTPersistence.h
@@ -17,8 +17,9 @@
#import <Foundation/Foundation.h>
#import "Firestore/Source/Core/FSTTypes.h"
-#import "Firestore/Source/Util/FSTAssert.h"
+
#include "Firestore/core/src/firebase/firestore/auth/user.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
@class FSTDocumentKey;
@protocol FSTMutationQueue;
@@ -181,7 +182,7 @@ struct FSTTransactionRunner {
typename std::enable_if<std::is_void<decltype(block())>::value, void>::type {
__strong id<FSTTransactional> strongDb = _db;
if (!strongDb && _expect_db) {
- FSTCFail(@"Transaction runner accessed without underlying db when it expected one");
+ HARD_FAIL("Transaction runner accessed without underlying db when it expected one");
}
if (strongDb) {
[strongDb startTransaction:label];
@@ -198,7 +199,7 @@ struct FSTTransactionRunner {
using ReturnT = decltype(block());
__strong id<FSTTransactional> strongDb = _db;
if (!strongDb && _expect_db) {
- FSTCFail(@"Transaction runner accessed without underlying db when it expected one");
+ HARD_FAIL("Transaction runner accessed without underlying db when it expected one");
}
if (strongDb) {
[strongDb startTransaction:label];
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;
diff --git a/Firestore/Source/Remote/FSTDatastore.mm b/Firestore/Source/Remote/FSTDatastore.mm
index d45af6b..5f79122 100644
--- a/Firestore/Source/Remote/FSTDatastore.mm
+++ b/Firestore/Source/Remote/FSTDatastore.mm
@@ -31,7 +31,6 @@
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
#import "Firestore/Source/Remote/FSTStream.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbrpc.h"
@@ -42,6 +41,7 @@
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/util/error_apple.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
@@ -130,8 +130,8 @@ typedef GRPCProtoCall * (^RPCFactory)(void);
} else if ([error.domain isEqualToString:FIRFirestoreErrorDomain]) {
return error;
} else if ([error.domain isEqualToString:kGRPCErrorDomain]) {
- FSTAssert(error.code >= GRPCErrorCodeCancelled && error.code <= GRPCErrorCodeUnauthenticated,
- @"Unknown GRPC error code: %ld", (long)error.code);
+ HARD_ASSERT(error.code >= GRPCErrorCodeCancelled && error.code <= GRPCErrorCodeUnauthenticated,
+ "Unknown GRPC error code: %s", error.code);
return
[NSError errorWithDomain:FIRFirestoreErrorDomain code:error.code userInfo:error.userInfo];
} else {
@@ -142,14 +142,14 @@ typedef GRPCProtoCall * (^RPCFactory)(void);
}
+ (BOOL)isAbortedError:(NSError *)error {
- FSTAssert([error.domain isEqualToString:FIRFirestoreErrorDomain],
- @"isAbortedError: only works with errors emitted by FSTDatastore.");
+ HARD_ASSERT([error.domain isEqualToString:FIRFirestoreErrorDomain],
+ "isAbortedError: only works with errors emitted by FSTDatastore.");
return error.code == FIRFirestoreErrorCodeAborted;
}
+ (BOOL)isPermanentWriteError:(NSError *)error {
- FSTAssert([error.domain isEqualToString:FIRFirestoreErrorDomain],
- @"isPerminanteWriteError: only works with errors emitted by FSTDatastore.");
+ HARD_ASSERT([error.domain isEqualToString:FIRFirestoreErrorDomain],
+ "isPerminanteWriteError: only works with errors emitted by FSTDatastore.");
switch (error.code) {
case FIRFirestoreErrorCodeCancelled:
case FIRFirestoreErrorCodeUnknown:
@@ -287,7 +287,7 @@ typedef GRPCProtoCall * (^RPCFactory)(void);
// Streaming response is done, call completion
LOG_DEBUG("RPC BatchGetDocuments completed successfully.");
[FSTDatastore logHeadersForRPC:rpc RPCName:@"BatchGetDocuments"];
- FSTAssert(!response, @"Got response after done.");
+ HARD_ASSERT(!response, "Got response after done.");
NSMutableArray<FSTMaybeDocument *> *docs =
[NSMutableArray arrayWithCapacity:closure->results.size()];
for (auto &&entry : closure->results) {
diff --git a/Firestore/Source/Remote/FSTOnlineStateTracker.mm b/Firestore/Source/Remote/FSTOnlineStateTracker.mm
index e512a3c..fb993e5 100644
--- a/Firestore/Source/Remote/FSTOnlineStateTracker.mm
+++ b/Firestore/Source/Remote/FSTOnlineStateTracker.mm
@@ -16,9 +16,9 @@
#import "Firestore/Source/Remote/FSTOnlineStateTracker.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
NS_ASSUME_NONNULL_BEGIN
@@ -75,15 +75,15 @@ static const NSTimeInterval kOnlineStateTimeout = 10;
if (self.watchStreamFailures == 0) {
[self setAndBroadcastState:FSTOnlineStateUnknown];
- FSTAssert(!self.onlineStateTimer, @"onlineStateTimer shouldn't be started yet");
+ HARD_ASSERT(!self.onlineStateTimer, "onlineStateTimer shouldn't be started yet");
self.onlineStateTimer = [self.queue
dispatchAfterDelay:kOnlineStateTimeout
timerID:FSTTimerIDOnlineStateTimeout
block:^{
self.onlineStateTimer = nil;
- FSTAssert(
+ HARD_ASSERT(
self.state == FSTOnlineStateUnknown,
- @"Timer should be canceled if we transitioned to a different state.");
+ "Timer should be canceled if we transitioned to a different state.");
LOG_DEBUG(
"Watch stream didn't reach Online or Offline within %s seconds. "
"Considering client offline.",
@@ -104,8 +104,8 @@ static const NSTimeInterval kOnlineStateTimeout = 10;
// To get to FSTOnlineStateOnline, updateState: must have been called which would have reset
// our heuristics.
- FSTAssert(self.watchStreamFailures == 0, @"watchStreamFailures must be 0");
- FSTAssert(!self.onlineStateTimer, @"onlineStateTimer must be nil");
+ HARD_ASSERT(self.watchStreamFailures == 0, "watchStreamFailures must be 0");
+ HARD_ASSERT(!self.onlineStateTimer, "onlineStateTimer must be nil");
} else {
self.watchStreamFailures++;
if (self.watchStreamFailures >= kMaxWatchStreamFailures) {
diff --git a/Firestore/Source/Remote/FSTRemoteEvent.mm b/Firestore/Source/Remote/FSTRemoteEvent.mm
index ebd9b93..67af650 100644
--- a/Firestore/Source/Remote/FSTRemoteEvent.mm
+++ b/Firestore/Source/Remote/FSTRemoteEvent.mm
@@ -22,10 +22,10 @@
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTClasses.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.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/log.h"
@@ -444,14 +444,14 @@ initWithSnapshotVersion:(SnapshotVersion)snapshotVersion
}
- (void)addWatchChanges:(NSArray<FSTWatchChange *> *)watchChanges {
- FSTAssert(!self.frozen, @"Trying to modify frozen FSTWatchChangeAggregator");
+ HARD_ASSERT(!self.frozen, "Trying to modify frozen FSTWatchChangeAggregator");
for (FSTWatchChange *watchChange in watchChanges) {
[self addWatchChange:watchChange];
}
}
- (void)addWatchChange:(FSTWatchChange *)watchChange {
- FSTAssert(!self.frozen, @"Trying to modify frozen FSTWatchChangeAggregator");
+ HARD_ASSERT(!self.frozen, "Trying to modify frozen FSTWatchChangeAggregator");
if ([watchChange isKindOfClass:[FSTDocumentWatchChange class]]) {
[self addDocumentChange:(FSTDocumentWatchChange *)watchChange];
} else if ([watchChange isKindOfClass:[FSTWatchTargetChange class]]) {
@@ -459,7 +459,7 @@ initWithSnapshotVersion:(SnapshotVersion)snapshotVersion
} else if ([watchChange isKindOfClass:[FSTExistenceFilterWatchChange class]]) {
[self addExistenceFilterChange:(FSTExistenceFilterWatchChange *)watchChange];
} else {
- FSTFail(@"Unknown watch change: %@", watchChange);
+ HARD_FAIL("Unknown watch change: %s", watchChange);
}
}
@@ -561,7 +561,7 @@ initWithSnapshotVersion:(SnapshotVersion)snapshotVersion
// We need to keep track of removed targets to we can post-filter and remove any target
// changes.
[self recordResponseForTargetID:targetID];
- FSTAssert(!targetChange.cause, @"WatchChangeAggregator does not handle errored targets.");
+ HARD_ASSERT(!targetChange.cause, "WatchChangeAggregator does not handle errored targets.");
break;
case FSTWatchTargetChangeStateCurrent:
if ([self isActiveTarget:targetID]) {
diff --git a/Firestore/Source/Remote/FSTRemoteStore.mm b/Firestore/Source/Remote/FSTRemoteStore.mm
index e0adb4e..7338ffb 100644
--- a/Firestore/Source/Remote/FSTRemoteStore.mm
+++ b/Firestore/Source/Remote/FSTRemoteStore.mm
@@ -31,11 +31,11 @@
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
#import "Firestore/Source/Remote/FSTStream.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
@@ -154,8 +154,8 @@ static const int kMaxPendingWrites = 10;
#pragma mark Online/Offline state
- (BOOL)isNetworkEnabled {
- FSTAssert((self.watchStream == nil) == (self.writeStream == nil),
- @"WatchStream and WriteStream should both be null or non-null");
+ HARD_ASSERT((self.watchStream == nil) == (self.writeStream == nil),
+ "WatchStream and WriteStream should both be null or non-null");
return self.watchStream != nil;
}
@@ -227,16 +227,16 @@ static const int kMaxPendingWrites = 10;
#pragma mark Watch Stream
- (void)startWatchStream {
- FSTAssert([self shouldStartWatchStream],
- @"startWatchStream: called when shouldStartWatchStream: is false.");
+ HARD_ASSERT([self shouldStartWatchStream],
+ "startWatchStream: called when shouldStartWatchStream: is false.");
[self.watchStream startWithDelegate:self];
[self.onlineStateTracker handleWatchStreamStart];
}
- (void)listenToTargetWithQueryData:(FSTQueryData *)queryData {
NSNumber *targetKey = @(queryData.targetID);
- FSTAssert(!self.listenTargets[targetKey], @"listenToQuery called with duplicate target id: %@",
- targetKey);
+ HARD_ASSERT(!self.listenTargets[targetKey], "listenToQuery called with duplicate target id: %s",
+ targetKey);
self.listenTargets[targetKey] = queryData;
@@ -255,7 +255,7 @@ static const int kMaxPendingWrites = 10;
- (void)stopListeningToTargetID:(FSTTargetID)targetID {
FSTBoxedTargetID *targetKey = @(targetID);
FSTQueryData *queryData = self.listenTargets[targetKey];
- FSTAssert(queryData, @"unlistenToTarget: target not currently watched: %@", targetKey);
+ HARD_ASSERT(queryData, "unlistenToTarget: target not currently watched: %s", targetKey);
[self.listenTargets removeObjectForKey:targetKey];
if ([self isNetworkEnabled] && [self.watchStream isOpen]) {
@@ -331,9 +331,9 @@ static const int kMaxPendingWrites = 10;
}
- (void)watchStreamWasInterruptedWithError:(nullable NSError *)error {
- FSTAssert([self isNetworkEnabled],
- @"watchStreamWasInterruptedWithError: should only be called when the network is "
- "enabled");
+ HARD_ASSERT([self isNetworkEnabled],
+ "watchStreamWasInterruptedWithError: should only be called when the network is "
+ "enabled");
[self cleanUpWatchStreamState];
[self.onlineStateTracker handleWatchStreamFailure];
@@ -388,8 +388,8 @@ static const int kMaxPendingWrites = 10;
[FSTDeletedDocument documentWithKey:key version:snapshotVersion];
[remoteEvent addDocumentUpdate:deletedDoc];
} else {
- FSTAssert(filter.count == 1, @"Single document existence filter with count: %" PRId32,
- filter.count);
+ HARD_ASSERT(filter.count == 1, "Single document existence filter with count: %s",
+ filter.count);
}
} else {
@@ -401,8 +401,8 @@ static const int kMaxPendingWrites = 10;
FSTUpdateMapping *update = (FSTUpdateMapping *)mapping;
trackedRemote = [update applyTo:trackedRemote];
} else {
- FSTAssert([mapping isKindOfClass:[FSTResetMapping class]],
- @"Expected either reset or update mapping but got something else %@", mapping);
+ HARD_ASSERT([mapping isKindOfClass:[FSTResetMapping class]],
+ "Expected either reset or update mapping but got something else %s", mapping);
trackedRemote = ((FSTResetMapping *)mapping).documents;
}
}
@@ -461,7 +461,7 @@ static const int kMaxPendingWrites = 10;
/** Process a target error and passes the error along to SyncEngine. */
- (void)processTargetErrorForWatchChange:(FSTWatchTargetChange *)change {
- FSTAssert(change.cause, @"Handling target error without a cause");
+ HARD_ASSERT(change.cause, "Handling target error without a cause");
// Ignore targets that have been removed already.
for (FSTBoxedTargetID *targetID in change.targetIDs) {
if (self.listenTargets[targetID]) {
@@ -482,8 +482,8 @@ static const int kMaxPendingWrites = 10;
}
- (void)startWriteStream {
- FSTAssert([self shouldStartWriteStream],
- @"startWriteStream: called when shouldStartWriteStream: is false.");
+ HARD_ASSERT([self shouldStartWriteStream],
+ "startWriteStream: called when shouldStartWriteStream: is false.");
[self.writeStream startWithDelegate:self];
}
@@ -526,7 +526,7 @@ static const int kMaxPendingWrites = 10;
/** Given mutations to commit, actually commits them to the backend. */
- (void)commitBatch:(FSTMutationBatch *)batch {
- FSTAssert([self canWriteMutations], @"commitBatch called when mutations can't be written");
+ HARD_ASSERT([self canWriteMutations], "commitBatch called when mutations can't be written");
self.lastBatchSeen = batch.batchID;
[self.pendingWrites addObject:batch];
@@ -590,8 +590,8 @@ static const int kMaxPendingWrites = 10;
* has been terminated by the client or the server.
*/
- (void)writeStreamWasInterruptedWithError:(nullable NSError *)error {
- FSTAssert([self isNetworkEnabled],
- @"writeStreamDidClose: should only be called when the network is enabled");
+ HARD_ASSERT([self isNetworkEnabled],
+ "writeStreamDidClose: should only be called when the network is enabled");
// If the write stream closed due to an error, invoke the error callbacks if there are pending
// writes.
diff --git a/Firestore/Source/Remote/FSTSerializerBeta.mm b/Firestore/Source/Remote/FSTSerializerBeta.mm
index f862ec3..ab40dd6 100644
--- a/Firestore/Source/Remote/FSTSerializerBeta.mm
+++ b/Firestore/Source/Remote/FSTSerializerBeta.mm
@@ -41,7 +41,6 @@
#import "Firestore/Source/Model/FSTMutationBatch.h"
#import "Firestore/Source/Remote/FSTExistenceFilter.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
@@ -51,6 +50,7 @@
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
#include "Firestore/core/src/firebase/firestore/model/transform_operations.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
@@ -128,10 +128,10 @@ NS_ASSUME_NONNULL_BEGIN
- (DocumentKey)decodedDocumentKey:(NSString *)name {
const ResourcePath path = [self decodedResourcePathWithDatabaseID:name];
- FSTAssert(path[1] == self.databaseID->project_id(),
- @"Tried to deserialize key from different project.");
- FSTAssert(path[3] == self.databaseID->database_id(),
- @"Tried to deserialize key from different datbase.");
+ HARD_ASSERT(path[1] == self.databaseID->project_id(),
+ "Tried to deserialize key from different project.");
+ HARD_ASSERT(path[3] == self.databaseID->database_id(),
+ "Tried to deserialize key from different datbase.");
return DocumentKey{[self localResourcePathForQualifiedResourcePath:path]};
}
@@ -145,8 +145,8 @@ NS_ASSUME_NONNULL_BEGIN
- (ResourcePath)decodedResourcePathWithDatabaseID:(NSString *)name {
const ResourcePath path = ResourcePath::FromString(util::MakeStringView(name));
- FSTAssert([self validQualifiedResourcePath:path], @"Tried to deserialize invalid key %s",
- path.CanonicalString().c_str());
+ HARD_ASSERT([self validQualifiedResourcePath:path], "Tried to deserialize invalid key %s",
+ path.CanonicalString());
return path;
}
@@ -172,8 +172,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (ResourcePath)localResourcePathForQualifiedResourcePath:(const ResourcePath &)resourceName {
- FSTAssert(resourceName.size() > 4 && resourceName[4] == "documents",
- @"Tried to deserialize invalid key %s", resourceName.CanonicalString().c_str());
+ HARD_ASSERT(resourceName.size() > 4 && resourceName[4] == "documents",
+ "Tried to deserialize invalid key %s", resourceName.CanonicalString());
return resourceName.PopFirst(5);
}
@@ -229,7 +229,7 @@ NS_ASSUME_NONNULL_BEGIN
return result;
} else {
- FSTFail(@"Unhandled type %@ on %@", NSStringFromClass([fieldValue class]), fieldValue);
+ HARD_FAIL("Unhandled type %s on %s", NSStringFromClass([fieldValue class]), fieldValue);
}
}
@@ -273,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self decodedMapValue:valueProto.mapValue];
default:
- FSTFail(@"Unhandled type %d on %@", valueProto.valueTypeOneOfCase, valueProto);
+ HARD_FAIL("Unhandled type %s on %s", valueProto.valueTypeOneOfCase, valueProto);
}
}
@@ -327,9 +327,9 @@ NS_ASSUME_NONNULL_BEGIN
- (GCFSValue *)encodedReferenceValueForDatabaseID:(const DatabaseId *)databaseID
key:(const DocumentKey &)key {
- FSTAssert(*databaseID == *self.databaseID, @"Database %s:%s cannot encode reference from %s:%s",
- self.databaseID->project_id().c_str(), self.databaseID->database_id().c_str(),
- databaseID->project_id().c_str(), databaseID->database_id().c_str());
+ HARD_ASSERT(*databaseID == *self.databaseID, "Database %s:%s cannot encode reference from %s:%s",
+ self.databaseID->project_id(), self.databaseID->database_id(),
+ databaseID->project_id(), databaseID->database_id());
GCFSValue *result = [GCFSValue message];
result.referenceValue = [self encodedResourcePathForDatabaseID:databaseID path:key.path()];
return result;
@@ -342,9 +342,9 @@ NS_ASSUME_NONNULL_BEGIN
const DocumentKey key{[self localResourcePathForQualifiedResourcePath:path]};
const DatabaseId database_id(project, database);
- FSTAssert(database_id == *self.databaseID, @"Database %s:%s cannot encode reference from %s:%s",
- self.databaseID->project_id().c_str(), self.databaseID->database_id().c_str(),
- database_id.project_id().c_str(), database_id.database_id().c_str());
+ HARD_ASSERT(database_id == *self.databaseID, "Database %s:%s cannot encode reference from %s:%s",
+ self.databaseID->project_id(), self.databaseID->database_id(),
+ database_id.project_id(), database_id.database_id());
return [FSTReferenceValue referenceValue:key databaseID:self.databaseID];
}
@@ -425,27 +425,27 @@ NS_ASSUME_NONNULL_BEGIN
case GCFSBatchGetDocumentsResponse_Result_OneOfCase_Missing:
return [self decodedDeletedDocument:response];
default:
- FSTFail(@"Unknown document type: %@", response);
+ HARD_FAIL("Unknown document type: %s", response);
}
}
- (FSTDocument *)decodedFoundDocument:(GCFSBatchGetDocumentsResponse *)response {
- FSTAssert(!!response.found, @"Tried to deserialize a found document from a deleted document.");
+ HARD_ASSERT(!!response.found, "Tried to deserialize a found document from a deleted document.");
const DocumentKey key = [self decodedDocumentKey:response.found.name];
FSTObjectValue *value = [self decodedFields:response.found.fields];
SnapshotVersion version = [self decodedVersion:response.found.updateTime];
- FSTAssert(version != SnapshotVersion::None(),
- @"Got a document response with no snapshot version");
+ HARD_ASSERT(version != SnapshotVersion::None(),
+ "Got a document response with no snapshot version");
return [FSTDocument documentWithData:value key:key version:version hasLocalMutations:NO];
}
- (FSTDeletedDocument *)decodedDeletedDocument:(GCFSBatchGetDocumentsResponse *)response {
- FSTAssert(!!response.missing, @"Tried to deserialize a deleted document from a found document.");
+ HARD_ASSERT(!!response.missing, "Tried to deserialize a deleted document from a found document.");
const DocumentKey key = [self decodedDocumentKey:response.missing];
SnapshotVersion version = [self decodedVersion:response.readTime];
- FSTAssert(version != SnapshotVersion::None(),
- @"Got a no document response with no snapshot version");
+ HARD_ASSERT(version != SnapshotVersion::None(),
+ "Got a no document response with no snapshot version");
return [FSTDeletedDocument documentWithKey:key version:version];
}
@@ -480,7 +480,7 @@ NS_ASSUME_NONNULL_BEGIN
proto.delete_p = [self encodedDocumentKey:deleteMutation.key];
} else {
- FSTFail(@"Unknown mutation type %@", NSStringFromClass(mutationClass));
+ HARD_FAIL("Unknown mutation type %s", NSStringFromClass(mutationClass));
}
if (!mutation.precondition.IsNone()) {
@@ -513,8 +513,8 @@ NS_ASSUME_NONNULL_BEGIN
precondition:precondition];
case GCFSWrite_Operation_OneOfCase_Transform: {
- FSTAssert(precondition == Precondition::Exists(true),
- @"Transforms must have precondition \"exists == true\"");
+ HARD_ASSERT(precondition == Precondition::Exists(true),
+ "Transforms must have precondition \"exists == true\"");
return [[FSTTransformMutation alloc]
initWithKey:[self decodedDocumentKey:mutation.transform.document]
@@ -523,19 +523,19 @@ NS_ASSUME_NONNULL_BEGIN
default:
// Note that insert is intentionally unhandled, since we don't ever deal in them.
- FSTFail(@"Unknown mutation operation: %d", mutation.operationOneOfCase);
+ HARD_FAIL("Unknown mutation operation: %s", mutation.operationOneOfCase);
}
}
- (GCFSPrecondition *)encodedPrecondition:(const Precondition &)precondition {
- FSTAssert(!precondition.IsNone(), @"Can't serialize an empty precondition");
+ HARD_ASSERT(!precondition.IsNone(), "Can't serialize an empty precondition");
GCFSPrecondition *message = [GCFSPrecondition message];
if (precondition.type() == Precondition::Type::UpdateTime) {
message.updateTime = [self encodedVersion:precondition.update_time()];
} else if (precondition.type() == Precondition::Type::Exists) {
message.exists = precondition == Precondition::Exists(true);
} else {
- FSTFail(@"Unknown precondition: %@", precondition.description());
+ HARD_FAIL("Unknown precondition: %s", precondition.description());
}
return message;
}
@@ -552,7 +552,7 @@ NS_ASSUME_NONNULL_BEGIN
return Precondition::UpdateTime([self decodedVersion:precondition.updateTime]);
default:
- FSTFail(@"Unrecognized Precondition one-of case %@", precondition);
+ HARD_FAIL("Unrecognized Precondition one-of case %s", precondition);
}
}
@@ -599,7 +599,7 @@ NS_ASSUME_NONNULL_BEGIN
encodedArrayTransformElements:ArrayTransform::Elements(fieldTransform.transformation())];
} else {
- FSTFail(@"Unknown transform: %d type", fieldTransform.transformation().type());
+ HARD_FAIL("Unknown transform: %s type", fieldTransform.transformation().type());
}
return proto;
}
@@ -623,9 +623,9 @@ NS_ASSUME_NONNULL_BEGIN
for (GCFSDocumentTransform_FieldTransform *proto in protos) {
switch (proto.transformTypeOneOfCase) {
case GCFSDocumentTransform_FieldTransform_TransformType_OneOfCase_SetToServerValue: {
- FSTAssert(
+ HARD_ASSERT(
proto.setToServerValue == GCFSDocumentTransform_FieldTransform_ServerValue_RequestTime,
- @"Unknown transform setToServerValue: %d", proto.setToServerValue);
+ "Unknown transform setToServerValue: %s", proto.setToServerValue);
fieldTransforms.emplace_back(
FieldPath::FromServerFormat(util::MakeStringView(proto.fieldPath)),
absl::make_unique<ServerTimestampTransform>(ServerTimestampTransform::Get()));
@@ -653,7 +653,7 @@ NS_ASSUME_NONNULL_BEGIN
}
default:
- FSTFail(@"Unknown transform: %@", proto);
+ HARD_FAIL("Unknown transform: %s", proto);
}
}
@@ -711,7 +711,7 @@ NS_ASSUME_NONNULL_BEGIN
case FSTQueryPurposeLimboResolution:
return @"limbo-document";
default:
- FSTFail(@"Unrecognized query purpose: %lu", (unsigned long)purpose);
+ HARD_FAIL("Unrecognized query purpose: %s", purpose);
}
}
@@ -742,8 +742,8 @@ NS_ASSUME_NONNULL_BEGIN
- (FSTQuery *)decodedQueryFromDocumentsTarget:(GCFSTarget_DocumentsTarget *)target {
NSArray<NSString *> *documents = target.documentsArray;
- FSTAssert(documents.count == 1, @"DocumentsTarget contained other than 1 document %lu",
- (unsigned long)documents.count);
+ HARD_ASSERT(documents.count == 1, "DocumentsTarget contained other than 1 document %s",
+ (unsigned long)documents.count);
NSString *name = documents[0];
return [FSTQuery queryWithPath:[self decodedQueryPath:name]];
@@ -756,7 +756,7 @@ NS_ASSUME_NONNULL_BEGIN
queryTarget.parent = [self encodedQueryPath:query.path];
} else {
const ResourcePath &path = query.path;
- FSTAssert(path.size() % 2 != 0, @"Document queries with filters are not supported.");
+ HARD_ASSERT(path.size() % 2 != 0, "Document queries with filters are not supported.");
queryTarget.parent = [self encodedQueryPath:path.PopLast()];
GCFSStructuredQuery_CollectionSelector *from = [GCFSStructuredQuery_CollectionSelector message];
from.collectionId = util::WrapNSString(path.last_segment());
@@ -795,8 +795,8 @@ NS_ASSUME_NONNULL_BEGIN
GCFSStructuredQuery *query = target.structuredQuery;
NSUInteger fromCount = query.fromArray_Count;
if (fromCount > 0) {
- FSTAssert(fromCount == 1,
- @"StructuredQuery.from with more than one collection is not supported.");
+ HARD_ASSERT(fromCount == 1,
+ "StructuredQuery.from with more than one collection is not supported.");
GCFSStructuredQuery_CollectionSelector *from = query.fromArray[0];
path = path.Append(util::MakeString(from.collectionId));
@@ -870,8 +870,8 @@ NS_ASSUME_NONNULL_BEGIN
NSArray<GCFSStructuredQuery_Filter *> *filters;
if (proto.filterTypeOneOfCase ==
GCFSStructuredQuery_Filter_FilterType_OneOfCase_CompositeFilter) {
- FSTAssert(proto.compositeFilter.op == GCFSStructuredQuery_CompositeFilter_Operator_And,
- @"Only AND-type composite filters are supported, got %d", proto.compositeFilter.op);
+ HARD_ASSERT(proto.compositeFilter.op == GCFSStructuredQuery_CompositeFilter_Operator_And,
+ "Only AND-type composite filters are supported, got %s", proto.compositeFilter.op);
filters = proto.compositeFilter.filtersArray;
} else {
filters = @[ proto ];
@@ -880,7 +880,7 @@ NS_ASSUME_NONNULL_BEGIN
for (GCFSStructuredQuery_Filter *filter in filters) {
switch (filter.filterTypeOneOfCase) {
case GCFSStructuredQuery_Filter_FilterType_OneOfCase_CompositeFilter:
- FSTFail(@"Nested composite filters are not supported");
+ HARD_FAIL("Nested composite filters are not supported");
case GCFSStructuredQuery_Filter_FilterType_OneOfCase_FieldFilter:
[result addObject:[self decodedRelationFilter:filter.fieldFilter]];
@@ -891,7 +891,7 @@ NS_ASSUME_NONNULL_BEGIN
break;
default:
- FSTFail(@"Unrecognized Filter.filterType %d", filter.filterTypeOneOfCase);
+ HARD_FAIL("Unrecognized Filter.filterType %s", filter.filterTypeOneOfCase);
}
}
return result;
@@ -921,7 +921,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if ([filter isKindOfClass:[FSTNullFilter class]]) {
proto.unaryFilter.op = GCFSStructuredQuery_UnaryFilter_Operator_IsNull;
} else {
- FSTFail(@"Unrecognized filter: %@", filter);
+ HARD_FAIL("Unrecognized filter: %s", static_cast<id>(filter));
}
return proto;
}
@@ -936,7 +936,7 @@ NS_ASSUME_NONNULL_BEGIN
return [[FSTNullFilter alloc] initWithField:field];
default:
- FSTFail(@"Unrecognized UnaryFilter.operator %d", proto.op);
+ HARD_FAIL("Unrecognized UnaryFilter.operator %s", proto.op);
}
}
@@ -962,7 +962,7 @@ NS_ASSUME_NONNULL_BEGIN
case FSTRelationFilterOperatorArrayContains:
return GCFSStructuredQuery_FieldFilter_Operator_ArrayContains;
default:
- FSTFail(@"Unhandled FSTRelationFilterOperator: %ld", (long)filterOperator);
+ HARD_FAIL("Unhandled FSTRelationFilterOperator: %s", filterOperator);
}
}
@@ -982,7 +982,7 @@ NS_ASSUME_NONNULL_BEGIN
case GCFSStructuredQuery_FieldFilter_Operator_ArrayContains:
return FSTRelationFilterOperatorArrayContains;
default:
- FSTFail(@"Unhandled FieldFilter.operator: %d", filterOperator);
+ HARD_FAIL("Unhandled FieldFilter.operator: %s", filterOperator);
}
}
@@ -1026,7 +1026,7 @@ NS_ASSUME_NONNULL_BEGIN
ascending = NO;
break;
default:
- FSTFail(@"Unrecognized GCFSStructuredQuery_Direction %d", proto.direction);
+ HARD_FAIL("Unrecognized GCFSStructuredQuery_Direction %s", proto.direction);
}
return [FSTSortOrder sortOrderWithFieldPath:fieldPath ascending:ascending];
}
@@ -1074,7 +1074,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self decodedExistenceFilterWatchChange:watchChange.filter];
default:
- FSTFail(@"Unknown WatchChange.changeType %" PRId32, watchChange.responseTypeOneOfCase);
+ HARD_FAIL("Unknown WatchChange.changeType %s", watchChange.responseTypeOneOfCase);
}
}
@@ -1127,7 +1127,7 @@ NS_ASSUME_NONNULL_BEGIN
case GCFSTargetChange_TargetChangeType_Reset:
return FSTWatchTargetChangeStateReset;
default:
- FSTFail(@"Unexpected TargetChange.state: %" PRId32, state);
+ HARD_FAIL("Unexpected TargetChange.state: %s", state);
}
}
@@ -1143,7 +1143,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTObjectValue *value = [self decodedFields:change.document.fields];
const DocumentKey key = [self decodedDocumentKey:change.document.name];
SnapshotVersion version = [self decodedVersion:change.document.updateTime];
- FSTAssert(version != SnapshotVersion::None(), @"Got a document change with no snapshot version");
+ HARD_ASSERT(version != SnapshotVersion::None(), "Got a document change with no snapshot version");
FSTMaybeDocument *document =
[FSTDocument documentWithData:value key:key version:version hasLocalMutations:NO];
diff --git a/Firestore/Source/Remote/FSTStream.mm b/Firestore/Source/Remote/FSTStream.mm
index 0e45418..3a6c035 100644
--- a/Firestore/Source/Remote/FSTStream.mm
+++ b/Firestore/Source/Remote/FSTStream.mm
@@ -26,7 +26,6 @@
#import "Firestore/Source/Remote/FSTExponentialBackoff.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
#import "Firestore/Source/Remote/FSTStream.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTClasses.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
@@ -37,6 +36,7 @@
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
#include "Firestore/core/src/firebase/firestore/util/error_apple.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
@@ -259,10 +259,10 @@ static const NSTimeInterval kIdleTimeout = 60.0;
}
LOG_DEBUG("%s %s start", NSStringFromClass([self class]), (__bridge void *)self);
- FSTAssert(self.state == FSTStreamStateInitial, @"Already started");
+ HARD_ASSERT(self.state == FSTStreamStateInitial, "Already started");
self.state = FSTStreamStateAuth;
- FSTAssert(_delegate == nil, @"Delegate must be nil");
+ HARD_ASSERT(_delegate == nil, "Delegate must be nil");
_delegate = delegate;
_credentials->GetToken(
@@ -281,8 +281,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
// Streams can be stopped while waiting for authorization.
return;
}
- FSTAssert(self.state == FSTStreamStateAuth, @"State should still be auth (was %ld)",
- (long)self.state);
+ HARD_ASSERT(self.state == FSTStreamStateAuth, "State should still be auth (was %s)", self.state);
// TODO(mikelehen): We should force a refresh if the previous RPC failed due to an expired token,
// but I'm not sure how to detect that right now. http://b/32762461
@@ -301,7 +300,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
prepareHeadersForRPC:_rpc
databaseID:&self.databaseInfo->database_id()
token:(token.user().is_authenticated() ? token.token() : absl::string_view())];
- FSTAssert(_callbackFilter == nil, @"GRX Filter must be nil");
+ HARD_ASSERT(_callbackFilter == nil, "GRX Filter must be nil");
_callbackFilter = [[FSTCallbackFilter alloc] initWithStream:self];
[_rpc startWithWriteable:_callbackFilter];
@@ -314,7 +313,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
LOG_DEBUG("%s %s backoff", NSStringFromClass([self class]), (__bridge void *)self);
[self.workerDispatchQueue verifyIsCurrentQueue];
- FSTAssert(self.state == FSTStreamStateError, @"Should only perform backoff in an error case");
+ HARD_ASSERT(self.state == FSTStreamStateError, "Should only perform backoff in an error case");
self.state = FSTStreamStateBackoff;
FSTWeakify(self);
@@ -334,13 +333,13 @@ static const NSTimeInterval kIdleTimeout = 60.0;
// In order to have performed a backoff the stream must have been in an error state just prior
// to entering the backoff state. If we weren't stopped we must be in the backoff state.
- FSTAssert(self.state == FSTStreamStateBackoff, @"State should still be backoff (was %ld)",
- (long)self.state);
+ HARD_ASSERT(self.state == FSTStreamStateBackoff, "State should still be backoff (was %s)",
+ self.state);
// Momentarily set state to FSTStreamStateInitial as `start` expects it.
self.state = FSTStreamStateInitial;
[self startWithDelegate:delegate];
- FSTAssert([self isStarted], @"Stream should have started.");
+ HARD_ASSERT([self isStarted], "Stream should have started.");
}
/**
@@ -365,8 +364,8 @@ static const NSTimeInterval kIdleTimeout = 60.0;
* @param error the NSError the connection was closed with.
*/
- (void)closeWithFinalState:(FSTStreamState)finalState error:(nullable NSError *)error {
- FSTAssert(finalState == FSTStreamStateError || error == nil,
- @"Can't provide an error when not in an error state.");
+ HARD_ASSERT(finalState == FSTStreamStateError || error == nil,
+ "Can't provide an error when not in an error state.");
[self.workerDispatchQueue verifyIsCurrentQueue];
@@ -433,8 +432,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
}
- (void)inhibitBackoff {
- FSTAssert(![self isStarted], @"Can only inhibit backoff after an error (was %ld)",
- (long)self.state);
+ HARD_ASSERT(![self isStarted], "Can only inhibit backoff after an error (was %s)", self.state);
[self.workerDispatchQueue verifyIsCurrentQueue];
// Clear the error condition.
@@ -551,7 +549,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
*/
- (void)handleStreamClose:(nullable NSError *)error {
LOG_DEBUG("%s %s close: %s", NSStringFromClass([self class]), (__bridge void *)self, error);
- FSTAssert([self isStarted], @"handleStreamClose: called for non-started stream.");
+ HARD_ASSERT([self isStarted], "handleStreamClose: called for non-started stream.");
// In theory the stream could close cleanly, however, in our current model we never expect this
// to happen because if we stop a stream ourselves, this callback will never be called. To
@@ -572,7 +570,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
*/
- (void)writeValue:(id)value {
[self.workerDispatchQueue enterCheckedOperation:^{
- FSTAssert([self isStarted], @"writeValue: called for stopped stream.");
+ HARD_ASSERT([self isStarted], "writeValue: called for stopped stream.");
if (!self.messageReceived) {
self.messageReceived = YES;
@@ -606,7 +604,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
- (void)writesFinishedWithError:(nullable NSError *)error __used {
error = [FSTDatastore firestoreErrorForError:error];
[self.workerDispatchQueue enterCheckedOperation:^{
- FSTAssert([self isStarted], @"writesFinishedWithError: called for stopped stream.");
+ HARD_ASSERT([self isStarted], "writesFinishedWithError: called for stopped stream.");
[self handleStreamClose:error];
}];
@@ -657,7 +655,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
}
- (void)watchQuery:(FSTQueryData *)query {
- FSTAssert([self isOpen], @"Not yet open");
+ HARD_ASSERT([self isOpen], "Not yet open");
[self.workerDispatchQueue verifyIsCurrentQueue];
GCFSListenRequest *request = [GCFSListenRequest message];
@@ -670,7 +668,7 @@ static const NSTimeInterval kIdleTimeout = 60.0;
}
- (void)unwatchTargetID:(FSTTargetID)targetID {
- FSTAssert([self isOpen], @"Not yet open");
+ HARD_ASSERT([self isOpen], "Not yet open");
[self.workerDispatchQueue verifyIsCurrentQueue];
GCFSListenRequest *request = [GCFSListenRequest message];
@@ -756,8 +754,8 @@ static const NSTimeInterval kIdleTimeout = 60.0;
- (void)writeHandshake {
// The initial request cannot contain mutations, but must contain a projectID.
- FSTAssert([self isOpen], @"Not yet open");
- FSTAssert(!self.handshakeComplete, @"Handshake sent out of turn");
+ HARD_ASSERT([self isOpen], "Not yet open");
+ HARD_ASSERT(!self.handshakeComplete, "Handshake sent out of turn");
[self.workerDispatchQueue verifyIsCurrentQueue];
GCFSWriteRequest *request = [GCFSWriteRequest message];
@@ -770,8 +768,8 @@ static const NSTimeInterval kIdleTimeout = 60.0;
}
- (void)writeMutations:(NSArray<FSTMutation *> *)mutations {
- FSTAssert([self isOpen], @"Not yet open");
- FSTAssert(self.handshakeComplete, @"Mutations sent out of turn");
+ HARD_ASSERT([self isOpen], "Not yet open");
+ HARD_ASSERT(self.handshakeComplete, "Mutations sent out of turn");
[self.workerDispatchQueue verifyIsCurrentQueue];
NSMutableArray<GCFSWrite *> *protos = [NSMutableArray arrayWithCapacity:mutations.count];
diff --git a/Firestore/Source/Util/FSTAssert.h b/Firestore/Source/Util/FSTAssert.h
deleted file mode 100644
index 610d306..0000000
--- a/Firestore/Source/Util/FSTAssert.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2017 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-// Fails the current Objective-C method if the given condition is false.
-//
-// Unlike NSAssert, this macro is never compiled out if assertions are disabled.
-#define FSTAssert(condition, format, ...) \
- do { \
- if (!(condition)) { \
- FSTFail((format), ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Fails the current C function if the given condition is false.
-//
-// Unlike NSCAssert, this macro is never compiled out if assertions are disabled.
-#define FSTCAssert(condition, format, ...) \
- do { \
- if (!(condition)) { \
- FSTCFail((format), ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Unconditionally fails the current Objective-C method.
-//
-// This macro fails by calling [[NSAssertionHandler currentHandler] handleFailureInMethod]. It
-// also calls abort(3) in order to make this macro appear to never return, even though the call
-// to handleFailureInMethod itself never returns.
-#define FSTFail(format, ...) \
- do { \
- NSString *_file = [NSString stringWithUTF8String:__FILE__]; \
- NSString *_description = [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd \
- object:self \
- file:_file \
- lineNumber:__LINE__ \
- description:@"FIRESTORE INTERNAL ASSERTION FAILED: %@", _description]; \
- abort(); \
- } while (0)
-
-// Unconditionally fails the current C function.
-//
-// This macro fails by calling [[NSAssertionHandler currentHandler] handleFailureInFunction]. It
-// also calls abort(3) in order to make this macro appear to never return, even though the call
-// to handleFailureInFunction itself never returns.
-#define FSTCFail(format, ...) \
- do { \
- NSString *_file = [NSString stringWithUTF8String:__FILE__]; \
- NSString *_function = [NSString stringWithUTF8String:__PRETTY_FUNCTION__]; \
- NSString *_description = [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction:_function \
- file:_file \
- lineNumber:__LINE__ \
- description:@"FIRESTORE INTERNAL ASSERTION FAILED: %@", _description]; \
- abort(); \
- } while (0)
-
-NS_ASSUME_NONNULL_END
diff --git a/Firestore/Source/Util/FSTDispatchQueue.mm b/Firestore/Source/Util/FSTDispatchQueue.mm
index 01b2732..b921484 100644
--- a/Firestore/Source/Util/FSTDispatchQueue.mm
+++ b/Firestore/Source/Util/FSTDispatchQueue.mm
@@ -19,11 +19,11 @@
#include <memory>
#include <utility>
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
#include "Firestore/core/src/firebase/firestore/util/executor_libdispatch.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "absl/memory/memory.h"
using firebase::firestore::util::AsyncQueue;
@@ -74,7 +74,7 @@ NS_ASSUME_NONNULL_BEGIN
case TimerId::OnlineStateTimeout:
return converted;
default:
- FSTAssert(false, @"Unknown value of enum FSTTimerID.");
+ HARD_FAIL("Unknown value of enum FSTTimerID.");
}
}
diff --git a/Firestore/Source/Util/FSTUsageValidation.h b/Firestore/Source/Util/FSTUsageValidation.h
index 05933ea..afc5412 100644
--- a/Firestore/Source/Util/FSTUsageValidation.h
+++ b/Firestore/Source/Util/FSTUsageValidation.h
@@ -30,7 +30,7 @@ NSException *FSTInvalidUsage(NSString *exceptionName, NSString *format, ...);
* invalid method arguments.
*
* For recoverable runtime errors, use NSError**.
- * For internal programming errors, use FSTFail().
+ * For internal programming errors, use HARD_FAIL().
*/
#define FSTThrowInvalidUsage(exceptionName, format, ...) \
do { \
diff --git a/Firestore/core/test/firebase/firestore/FSTGoogleTestTests.mm b/Firestore/core/test/firebase/firestore/FSTGoogleTestTests.mm
index c87949a..bb2f836 100644
--- a/Firestore/core/test/firebase/firestore/FSTGoogleTestTests.mm
+++ b/Firestore/core/test/firebase/firestore/FSTGoogleTestTests.mm
@@ -17,8 +17,6 @@
#import <XCTest/XCTest.h>
#import <objc/runtime.h>
-#import "Firestore/Source/Util/FSTAssert.h"
-
#include "gtest/gtest.h"
/**
diff --git a/Firestore/third_party/Immutable/FSTArraySortedDictionary.m b/Firestore/third_party/Immutable/FSTArraySortedDictionary.m
index e9325a7..985b514 100644
--- a/Firestore/third_party/Immutable/FSTArraySortedDictionary.m
+++ b/Firestore/third_party/Immutable/FSTArraySortedDictionary.m
@@ -1,7 +1,6 @@
#import "Firestore/third_party/Immutable/FSTArraySortedDictionary.h"
#import "Firestore/third_party/Immutable/FSTArraySortedDictionaryEnumerator.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/third_party/Immutable/FSTTreeSortedDictionary.h"
NS_ASSUME_NONNULL_BEGIN
@@ -38,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
for (id key in keys) {
values[pos++] = dictionary[key];
}
- FSTAssert(values.count == keys.count, @"We added as many keys as values");
+ NSAssert(values.count == keys.count, @"We added as many keys as values");
return [[FSTArraySortedDictionary alloc] initWithComparator:comparator keys:keys values:values];
}
@@ -50,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
- (id)initWithComparator:(NSComparator)comparator keys:(NSArray *)keys values:(NSArray *)values {
self = [super init];
if (self != nil) {
- FSTAssert(keys.count == values.count, @"keys and values must have the same count");
+ NSAssert(keys.count == values.count, @"keys and values must have the same count");
_comparator = comparator;
_keys = keys;
_values = values;
diff --git a/Firestore/third_party/Immutable/FSTLLRBValueNode.m b/Firestore/third_party/Immutable/FSTLLRBValueNode.m
index 194a393..e2590a1 100644
--- a/Firestore/third_party/Immutable/FSTLLRBValueNode.m
+++ b/Firestore/third_party/Immutable/FSTLLRBValueNode.m
@@ -1,6 +1,5 @@
#import "Firestore/third_party/Immutable/FSTLLRBValueNode.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/third_party/Immutable/FSTLLRBEmptyNode.h"
NS_ASSUME_NONNULL_BEGIN
@@ -64,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setLeft:(nullable id<FSTLLRBNode>)left {
// Setting the left node should be only done by the builder, so doing it after someone has
// memoized count is an error.
- FSTAssert(_count == NSNotFound, @"Can't update left node after using count");
+ NSAssert(_count == NSNotFound, @"Can't update left node after using count");
_left = left;
}
diff --git a/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m b/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m
index bf17496..a220a3c 100644
--- a/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m
+++ b/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m
@@ -2,8 +2,6 @@
#import <XCTest/XCTest.h>
-#import "Firestore/Source/Util/FSTAssert.h"
-
@interface FSTArraySortedDictionary (Test)
// Override methods to return subtype.
- (FSTArraySortedDictionary *)dictionaryBySettingObject:(id)aValue forKey:(id)aKey;
@@ -17,7 +15,7 @@
- (NSComparator)defaultComparator {
return ^(id obj1, id obj2) {
- FSTAssert([obj1 respondsToSelector:@selector(compare:)] &&
+ NSAssert([obj1 respondsToSelector:@selector(compare:)] &&
[obj2 respondsToSelector:@selector(compare:)],
@"Objects must support compare: %@ %@", obj1, obj2);
return [obj1 compare:obj2];
diff --git a/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m b/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m
index 3e06b30..c6e522c 100644
--- a/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m
+++ b/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m
@@ -4,7 +4,6 @@
#import "Firestore/third_party/Immutable/FSTLLRBNode.h"
#import "Firestore/third_party/Immutable/FSTLLRBValueNode.h"
#import "Firestore/third_party/Immutable/FSTTreeSortedDictionary.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/third_party/Immutable/Tests/FSTLLRBValueNode+Test.h"
@@ -21,7 +20,7 @@
- (NSComparator)defaultComparator {
return ^(id obj1, id obj2) {
- FSTAssert([obj1 respondsToSelector:@selector(compare:)] &&
+ NSAssert([obj1 respondsToSelector:@selector(compare:)] &&
[obj2 respondsToSelector:@selector(compare:)],
@"Objects must support compare: %@ %@", obj1, obj2);
return [obj1 compare:obj2];