Skip to content

Commit 7a7eced

Browse files
authored
Don't use using statements in Objective-C headers ... (#2827)
use namespace aliases instead. This makes the Objective-C code much more like what it's going to end up being like when translated to C++: headers will include classes declared in a namespace relative to firebase::firestore so everything else will be named relative to firebase::firestore. Meanwhile the using statements in the headers were causing us to miss adding using statements in source files which was moving us away from where we wanted to be.
1 parent 97d4ab1 commit 7a7eced

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+391
-331
lines changed

Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
3636

3737
namespace util = firebase::firestore::util;
38+
using firebase::firestore::api::DocumentChange;
39+
using firebase::firestore::api::DocumentSnapshot;
40+
using firebase::firestore::api::Firestore;
41+
using firebase::firestore::api::SnapshotMetadata;
3842
using firebase::firestore::core::DocumentViewChange;
3943
using firebase::firestore::core::ViewSnapshot;
4044
using firebase::firestore::model::DocumentKeySet;

Firestore/Example/Tests/API/FSTAPIHelpers.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
namespace testutil = firebase::firestore::testutil;
4242
namespace util = firebase::firestore::util;
43+
using firebase::firestore::api::SnapshotMetadata;
4344
using firebase::firestore::core::DocumentViewChange;
4445
using firebase::firestore::core::ViewSnapshot;
4546
using firebase::firestore::model::DocumentKeySet;

Firestore/Example/Tests/Core/FSTEventManagerTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
using firebase::firestore::core::EventListener;
3939
using firebase::firestore::core::ListenOptions;
40+
using firebase::firestore::core::QueryListener;
4041
using firebase::firestore::core::ViewSnapshot;
4142
using firebase::firestore::model::DocumentKeySet;
4243
using firebase::firestore::model::DocumentSet;

Firestore/Example/Tests/Core/FSTQueryListenerTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
using firebase::firestore::core::DocumentViewChange;
4646
using firebase::firestore::core::EventListener;
4747
using firebase::firestore::core::ListenOptions;
48+
using firebase::firestore::core::QueryListener;
4849
using firebase::firestore::core::ViewSnapshot;
4950
using firebase::firestore::model::DocumentKeySet;
5051
using firebase::firestore::model::DocumentSet;

Firestore/Example/Tests/Integration/FSTDatastoreTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
using firebase::firestore::model::DatabaseId;
5656
using firebase::firestore::model::DocumentKey;
5757
using firebase::firestore::model::DocumentKeySet;
58+
using firebase::firestore::model::FieldValue;
5859
using firebase::firestore::model::Precondition;
5960
using firebase::firestore::model::OnlineState;
6061
using firebase::firestore::model::TargetId;

Firestore/Example/Tests/Model/FSTDocumentTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
namespace testutil = firebase::firestore::testutil;
2929
using firebase::firestore::model::DocumentKey;
30+
using firebase::firestore::model::FieldValue;
3031
using firebase::firestore::model::SnapshotVersion;
3132

3233
NS_ASSUME_NONNULL_BEGIN

Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
using firebase::firestore::model::DatabaseId;
6666
using firebase::firestore::model::FieldMask;
6767
using firebase::firestore::model::FieldTransform;
68+
using firebase::firestore::model::FieldValue;
6869
using firebase::firestore::model::Precondition;
6970
using firebase::firestore::model::SnapshotVersion;
7071
using firebase::firestore::remote::DocumentWatchChange;

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
using firebase::firestore::auth::User;
6262
using firebase::firestore::core::DatabaseInfo;
6363
using firebase::firestore::core::ListenOptions;
64+
using firebase::firestore::core::QueryListener;
6465
using firebase::firestore::core::ViewSnapshot;
6566
using firebase::firestore::model::DatabaseId;
6667
using firebase::firestore::model::DocumentKey;

Firestore/Source/API/FIRCollectionReference+Internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
2020

21+
namespace model = firebase::firestore::model;
22+
2123
NS_ASSUME_NONNULL_BEGIN
2224

2325
/** Internal FIRCollectionReference API we don't want exposed in our public header files. */
2426
@interface FIRCollectionReference (Internal)
25-
+ (instancetype)referenceWithPath:(const firebase::firestore::model::ResourcePath &)path
27+
+ (instancetype)referenceWithPath:(const model::ResourcePath &)path
2628
firestore:(FIRFirestore *)firestore;
2729
@end
2830

Firestore/Source/API/FIRDocumentChange+Internal.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020

2121
#include "Firestore/core/src/firebase/firestore/api/document_change.h"
2222

23-
using firebase::firestore::api::DocumentChange;
23+
namespace api = firebase::firestore::api;
2424

2525
NS_ASSUME_NONNULL_BEGIN
2626

2727
@interface FIRDocumentChange (/* Init */)
2828

29-
- (instancetype)initWithDocumentChange:(DocumentChange &&)documentChange NS_DESIGNATED_INITIALIZER;
29+
- (instancetype)initWithDocumentChange:(api::DocumentChange &&)documentChange
30+
NS_DESIGNATED_INITIALIZER;
3031

3132
@end
3233

Firestore/Source/API/FIRDocumentReference+Internal.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@
2020
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
2121
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
2222

23+
namespace api = firebase::firestore::api;
24+
namespace model = firebase::firestore::model;
25+
2326
NS_ASSUME_NONNULL_BEGIN
2427

2528
@interface FIRDocumentReference (/* Init */)
2629

27-
- (instancetype)initWithReference:(firebase::firestore::api::DocumentReference &&)reference
28-
NS_DESIGNATED_INITIALIZER;
30+
- (instancetype)initWithReference:(api::DocumentReference &&)reference NS_DESIGNATED_INITIALIZER;
2931

30-
- (instancetype)initWithPath:(firebase::firestore::model::ResourcePath)path
31-
firestore:(firebase::firestore::api::Firestore *)firestore;
32+
- (instancetype)initWithPath:(model::ResourcePath)path firestore:(api::Firestore *)firestore;
3233

33-
- (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
34-
firestore:(firebase::firestore::api::Firestore *)firestore;
34+
- (instancetype)initWithKey:(model::DocumentKey)key firestore:(api::Firestore *)firestore;
3535

3636
@end
3737

3838
/** Internal FIRDocumentReference API we don't want exposed in our public header files. */
3939
@interface FIRDocumentReference (Internal)
4040

41-
- (const firebase::firestore::model::DocumentKey &)key;
41+
- (const model::DocumentKey &)key;
4242

4343
@end
4444

Firestore/Source/API/FIRDocumentReference.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
using firebase::firestore::api::DocumentReference;
5151
using firebase::firestore::api::DocumentSnapshot;
5252
using firebase::firestore::api::Firestore;
53+
using firebase::firestore::api::ListenerRegistration;
5354
using firebase::firestore::api::Source;
5455
using firebase::firestore::api::MakeSource;
5556
using firebase::firestore::api::ThrowInvalidArgument;

Firestore/Source/API/FIRDocumentSnapshot+Internal.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,22 @@
2323
@class FIRFirestore;
2424
@class FSTDocument;
2525

26-
using firebase::firestore::api::DocumentSnapshot;
27-
using firebase::firestore::api::Firestore;
28-
using firebase::firestore::api::SnapshotMetadata;
29-
using firebase::firestore::model::DocumentKey;
26+
namespace api = firebase::firestore::api;
27+
namespace model = firebase::firestore::model;
3028

3129
NS_ASSUME_NONNULL_BEGIN
3230

3331
@interface FIRDocumentSnapshot (/* Init */)
3432

35-
- (instancetype)initWithSnapshot:(DocumentSnapshot &&)snapshot NS_DESIGNATED_INITIALIZER;
33+
- (instancetype)initWithSnapshot:(api::DocumentSnapshot &&)snapshot NS_DESIGNATED_INITIALIZER;
3634

37-
- (instancetype)initWithFirestore:(Firestore *)firestore
38-
documentKey:(DocumentKey)documentKey
35+
- (instancetype)initWithFirestore:(api::Firestore *)firestore
36+
documentKey:(model::DocumentKey)documentKey
3937
document:(nullable FSTDocument *)document
40-
metadata:(SnapshotMetadata)metadata;
38+
metadata:(api::SnapshotMetadata)metadata;
4139

42-
- (instancetype)initWithFirestore:(Firestore *)firestore
43-
documentKey:(DocumentKey)documentKey
40+
- (instancetype)initWithFirestore:(api::Firestore *)firestore
41+
documentKey:(model::DocumentKey)documentKey
4442
document:(nullable FSTDocument *)document
4543
fromCache:(bool)fromCache
4644
hasPendingWrites:(bool)hasPendingWrites;

Firestore/Source/API/FIRDocumentSnapshot.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
namespace util = firebase::firestore::util;
4242
using firebase::firestore::api::DocumentSnapshot;
4343
using firebase::firestore::api::Firestore;
44+
using firebase::firestore::api::SnapshotMetadata;
4445
using firebase::firestore::api::ThrowInvalidArgument;
4546
using firebase::firestore::model::DatabaseId;
4647
using firebase::firestore::model::DocumentKey;

Firestore/Source/API/FIRFieldPath+Internal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818

1919
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
2020

21+
namespace model = firebase::firestore::model;
22+
2123
NS_ASSUME_NONNULL_BEGIN
2224

2325
@interface FIRFieldPath ()
2426

2527
/** Internal field path representation */
26-
- (const firebase::firestore::model::FieldPath &)internalValue;
28+
- (const model::FieldPath &)internalValue;
2729

28-
- (instancetype)initPrivate:(firebase::firestore::model::FieldPath)path NS_DESIGNATED_INITIALIZER;
30+
- (instancetype)initPrivate:(model::FieldPath)path NS_DESIGNATED_INITIALIZER;
2931

3032
@end
3133

Firestore/Source/API/FIRFirestore+Internal.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,29 @@
2323
#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
2424
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
2525

26-
NS_ASSUME_NONNULL_BEGIN
27-
2826
@class FIRApp;
2927
@class FSTFirestoreClient;
3028
@class FSTUserDataConverter;
3129

30+
namespace api = firebase::firestore::api;
31+
namespace auth = firebase::firestore::auth;
32+
namespace model = firebase::firestore::model;
33+
namespace util = firebase::firestore::util;
34+
35+
NS_ASSUME_NONNULL_BEGIN
36+
3237
@interface FIRFirestore (/* Init */)
3338

3439
/**
3540
* Initializes a Firestore object with all the required parameters directly. This exists so that
3641
* tests can create FIRFirestore objects without needing FIRApp.
3742
*/
38-
- (instancetype)
39-
initWithProjectID:(std::string)projectID
40-
database:(std::string)database
41-
persistenceKey:(std::string)persistenceKey
42-
credentialsProvider:
43-
(std::unique_ptr<firebase::firestore::auth::CredentialsProvider>)credentialsProvider
44-
workerQueue:(std::unique_ptr<firebase::firestore::util::AsyncQueue>)workerQueue
45-
firebaseApp:(FIRApp *)app;
43+
- (instancetype)initWithProjectID:(std::string)projectID
44+
database:(std::string)database
45+
persistenceKey:(std::string)persistenceKey
46+
credentialsProvider:(std::unique_ptr<auth::CredentialsProvider>)credentialsProvider
47+
workerQueue:(std::unique_ptr<util::AsyncQueue>)workerQueue
48+
firebaseApp:(FIRApp *)app;
4649
@end
4750

4851
/** Internal FIRFirestore API we don't want exposed in our public header files. */
@@ -51,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
5154
/** Checks to see if logging is is globally enabled for the Firestore client. */
5255
+ (BOOL)isLoggingEnabled;
5356

54-
+ (FIRFirestore *)recoverFromFirestore:(firebase::firestore::api::Firestore *)firestore;
57+
+ (FIRFirestore *)recoverFromFirestore:(api::Firestore *)firestore;
5558

5659
/**
5760
* Shutdown this `FIRFirestore`, releasing all resources (abandoning any outstanding writes,
@@ -62,12 +65,12 @@ NS_ASSUME_NONNULL_BEGIN
6265
- (void)shutdownWithCompletion:(nullable void (^)(NSError *_Nullable error))completion
6366
NS_SWIFT_NAME(shutdown(completion:));
6467

65-
@property(nonatomic, assign, readonly) firebase::firestore::api::Firestore *wrapped;
68+
@property(nonatomic, assign, readonly) api::Firestore *wrapped;
6669

67-
@property(nonatomic, assign, readonly) firebase::firestore::util::AsyncQueue *workerQueue;
70+
@property(nonatomic, assign, readonly) util::AsyncQueue *workerQueue;
6871

6972
// FIRFirestore ownes the DatabaseId instance.
70-
@property(nonatomic, assign, readonly) const firebase::firestore::model::DatabaseId *databaseID;
73+
@property(nonatomic, assign, readonly) const model::DatabaseId *databaseID;
7174
@property(nonatomic, strong, readonly) FSTUserDataConverter *dataConverter;
7275

7376
@end

Firestore/Source/API/FIRListenerRegistration+Internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
#include "Firestore/core/src/firebase/firestore/api/listener_registration.h"
2020

21-
NS_ASSUME_NONNULL_BEGIN
21+
namespace api = firebase::firestore::api;
2222

23-
using firebase::firestore::api::ListenerRegistration;
23+
NS_ASSUME_NONNULL_BEGIN
2424

2525
/** Private implementation of the FIRListenerRegistration protocol. */
2626
@interface FSTListenerRegistration : NSObject <FIRListenerRegistration>
2727

28-
- (instancetype)initWithRegistration:(ListenerRegistration &&)registration;
28+
- (instancetype)initWithRegistration:(api::ListenerRegistration &&)registration;
2929

3030
@end
3131

Firestore/Source/API/FIRListenerRegistration.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
using firebase::firestore::util::DelayedConstructor;
2626

2727
@implementation FSTListenerRegistration {
28-
DelayedConstructor<ListenerRegistration> _registration;
28+
DelayedConstructor<api::ListenerRegistration> _registration;
2929
}
3030

31-
- (instancetype)initWithRegistration:(ListenerRegistration &&)registration {
31+
- (instancetype)initWithRegistration:(api::ListenerRegistration &&)registration {
3232
if (self = [super init]) {
3333
_registration.Init(std::move(registration));
3434
}

Firestore/Source/API/FIRQuery.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@
5151
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
5252

5353
namespace util = firebase::firestore::util;
54-
using firebase::firestore::api::MakeSource;
54+
using firebase::firestore::api::Firestore;
55+
using firebase::firestore::api::ListenerRegistration;
56+
using firebase::firestore::api::SnapshotMetadata;
5557
using firebase::firestore::api::Source;
5658
using firebase::firestore::api::ThrowInvalidArgument;
5759
using firebase::firestore::core::AsyncEventListener;
5860
using firebase::firestore::core::EventListener;
5961
using firebase::firestore::core::Filter;
62+
using firebase::firestore::core::ListenOptions;
63+
using firebase::firestore::core::QueryListener;
6064
using firebase::firestore::core::ViewSnapshot;
6165
using firebase::firestore::model::DocumentKey;
6266
using firebase::firestore::model::FieldPath;
@@ -121,7 +125,7 @@ - (void)getDocumentsWithCompletion:(void (^)(FIRQuerySnapshot *_Nullable snapsho
121125
- (void)getDocumentsWithSource:(FIRFirestoreSource)publicSource
122126
completion:(void (^)(FIRQuerySnapshot *_Nullable snapshot,
123127
NSError *_Nullable error))completion {
124-
Source source = MakeSource(publicSource);
128+
Source source = api::MakeSource(publicSource);
125129
if (source == Source::Cache) {
126130
[self.firestore.wrapped->client() getDocumentsFromLocalCache:self completion:completion];
127131
return;

Firestore/Source/API/FIRQuerySnapshot+Internal.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,20 @@
2525
@class FIRSnapshotMetadata;
2626
@class FSTQuery;
2727

28-
using firebase::firestore::api::Firestore;
29-
using firebase::firestore::api::QuerySnapshot;
30-
using firebase::firestore::api::SnapshotMetadata;
31-
using firebase::firestore::core::ViewSnapshot;
28+
namespace api = firebase::firestore::api;
29+
namespace core = firebase::firestore::core;
3230

3331
NS_ASSUME_NONNULL_BEGIN
3432

3533
/** Internal FIRQuerySnapshot API we don't want exposed in our public header files. */
3634
@interface FIRQuerySnapshot (/* Init */)
3735

38-
- (instancetype)initWithSnapshot:(QuerySnapshot &&)snapshot NS_DESIGNATED_INITIALIZER;
36+
- (instancetype)initWithSnapshot:(api::QuerySnapshot &&)snapshot NS_DESIGNATED_INITIALIZER;
3937

40-
- (instancetype)initWithFirestore:(Firestore *)firestore
38+
- (instancetype)initWithFirestore:(api::Firestore *)firestore
4139
originalQuery:(FSTQuery *)query
42-
snapshot:(ViewSnapshot &&)snapshot
43-
metadata:(SnapshotMetadata)metadata;
40+
snapshot:(core::ViewSnapshot &&)snapshot
41+
metadata:(api::SnapshotMetadata)metadata;
4442

4543
@end
4644

Firestore/Source/API/FIRQuerySnapshot.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@
3232
#include "Firestore/core/src/firebase/firestore/model/document_set.h"
3333
#include "Firestore/core/src/firebase/firestore/util/delayed_constructor.h"
3434

35+
using firebase::firestore::api::DocumentChange;
36+
using firebase::firestore::api::DocumentSnapshot;
3537
using firebase::firestore::api::Firestore;
3638
using firebase::firestore::api::QuerySnapshot;
39+
using firebase::firestore::api::SnapshotMetadata;
3740
using firebase::firestore::api::ThrowInvalidArgument;
3841
using firebase::firestore::core::ViewSnapshot;
3942
using firebase::firestore::util::DelayedConstructor;

Firestore/Source/API/FIRSnapshotMetadata+Internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
#include "Firestore/core/src/firebase/firestore/api/snapshot_metadata.h"
2222

23-
using firebase::firestore::api::SnapshotMetadata;
23+
namespace api = firebase::firestore::api;
2424

2525
NS_ASSUME_NONNULL_BEGIN
2626

2727
@interface FIRSnapshotMetadata (/* Init */)
2828

29-
- (instancetype)initWithMetadata:(SnapshotMetadata)metadata NS_DESIGNATED_INITIALIZER;
29+
- (instancetype)initWithMetadata:(api::SnapshotMetadata)metadata NS_DESIGNATED_INITIALIZER;
3030

3131
- (instancetype)initWithPendingWrites:(bool)pendingWrites fromCache:(bool)fromCache;
3232

0 commit comments

Comments
 (0)