Commit Graph
45 Commits
Author SHA1 Message Date
Gil cd460eca2d Rationalize input validation exceptions and assertion failures (#4107)
* Rationalize input validation exceptions and assertions

... under a single ThrowHandler concept. This makes it possible to set
an alternative ThrowHandler in our C# bindings that properly translates
input validation exceptions to the correct .NET exception types.

* Rename api/input_validation.h to util/exception.h

* Reimplement util/hard_assert.h in terms of util/exception.h
2019-10-18 12:58:45 -07:00
Brian Chen f7028988b1 Split ListenerRegistration into QueryListenerRegistration (#3832) 2019-09-12 16:44:14 -07:00
Gil 6ad473ae04 Merge persistence-master to master (#3829)
* Port FSTMemoryPersistence to C++ (#3754)

* Add local::Persistence

* Add MemoryPersistence

* Add MemoryEagerReferenceDelegate

* Make LruDelegate extend ReferenceDelegate

This enables downcasting to LruDelegate in tests that need to do so.

* Add MemoryLruReferenceDelegate

* Don't double-count document key size.

* Port FSTLevelDB to C++ (#3755)

* Add LevelDbPersistence

Note that Apple-specific initialization has been partitioned off in
anticipation of being able to run this code on non-Apple platforms.

* Add LevelDbLruReferenceDelegate

* Migrate to C++ Persistence (1/2) (#3756)

* Use C++ Persistence classes in FSTLocalStore

* Remove ReferenceDelegateBridge

* Cut src over to C++ persistence types

* Remove Objective-C requirement from some classes

... that no longer require it.

* Migrate to C++ Persistence (2/2) (#3757)

* Remove LruDelegateBridge

* Update test initialization of persistence components

In particular, ensure that there's always an owner for the Persistence
instance, which wasn't always handled explicitly in the Objective-C
version of the tests.

* Largely mechanical changes to tests

* Remove Objective-C persistence classes

* Forward declare util::Status when possible (#3761)

* Add a header dedicated to forward declarations for util::Status

* Use status_fwd.h wherever possible
2019-09-12 14:28:10 -07:00
Gil 13a1b33913 Migrate from FSTQuery to C++ Query (#3484) 2019-08-02 11:35:33 -07:00
Konstantin Varlamov a294e8c112 Remove extraneous imports (#3402)
Remove several imports that appear to be unused.
2019-07-21 17:16:04 -04:00
Gil 07b5eadf5a Rename WrapNSString to MakeNSString (#3274)
This makes it match the convention we've established for other
converters of this type. WrapNSString was perhaps the earliest of these
that we wrote and the convention hadn't yet been established.
2019-06-27 17:31:17 -07:00
Gil 10752cd68c Finish migration of FSTFieldValue to C++ FieldValue (#3178)
* Split transform_operations

* Revert "Make ServerTimestamp use FSTFieldValue for previous value"

* Finish FieldValue migration

* Delete FSTFieldValue
2019-06-18 16:21:17 -07:00
Gil 220589d9bc Port FIRCollectionReference to C++ (#3126)
Also fix up DocumentReference to use it.
2019-06-04 18:10:17 -07:00
Michael Lehenbauer 27b2f0a19c Port FIRWriteBatch. (#2844)
* Create api::WriteBatch "port" of FIRWriteBatch.
* Make FIRWriteBatch a wrapper around an api::WriteBatch (and a FSTUserDataConverter for parsing input).
2019-04-18 10:34:53 -07:00
Michael Lehenbauer c293f8b317 Make api::DocumentReference accept ParsedSetData / ParsedUserData. (#2854)
I think the intention was that the user_data.h types should be used as the representation of parsed user data that can be passed down from the public API to the api:: layer, so this PR "fixes" api::DocumentReference to accept ParsedSetData and ParsedUserData in SetData() / UpdateData() instead of taking the list of mutations. This is consistent with the approach I took in the api::WriteBatch port.

Side note: Prior to this change, SetData() / UpdateData() were actually identical methods just with different names.
2019-04-17 14:50:33 -07:00
Gil cad35b18d8 Migrate api::Firestore completions to C++ (#2831)
* Make error_apple definitions out-of-line

* Add util::MakeCallback

Translates between API completion handlers that take just an NSError and
the equivalent std::function that accepts util::Status.

* Port DocumentReference::Completion to a std::function callback

* Port Firestore::ErrorCompletions to StatusCallback

* Port transaction-related completions to C++

* Remove now-unused FSTVoidIDErrorBlock

* Fix tunneling of Firestore-generated NSErrors.

Remove MakeStatus(NSError*) because it has different results from
Status::FromNSError. Ensure that user-supplied errors created in
transactions tunnel through correctly.
2019-04-16 17:37:38 -07:00
Michael Lehenbauer a3c5064797 Use shared_ptr<Firestore> instead of Firestore* for api:: classes. (#2830)
This is safer and better matches our design (and the other platforms), since
classes like api::DocumentReference will have references to api::Firsetore but
the lifetime is controlled by the developer, not us.
2019-04-15 09:06:10 -07:00
Gil 7a7eced747 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.
2019-04-12 17:03:26 -07:00
Gil edd4bd719c Port FIRFirestoreSource to C++ Source (#2749) 2019-04-09 07:07:20 -07:00
Gil 2e8b9181fa Port FSTUsageValidation to C++ (#2670)
* Port FSTUsageValidation to C++

* Add an error log level
2019-03-28 13:19:28 -07:00
Gil ba332be794 Port FSTAsyncQueryListener to C++ (#2620)
* Test that shows a leak.

* Add EventListener to match Android.

* Use AsyncEventListener in FSTQueryListenerTests

* Remove FSTAsyncQueryListener

* Use EventListener throughout
2019-03-26 11:54:03 -07:00
Gil f28e76802d Port FSTListenerRegistration to C++ (#2619)
* Replace FSTQueryListener with C++ QueryListener

* objc::unordered_map

* Add a lint check for Objective-C banned words
2019-03-26 08:29:17 -07:00
Gil 315effec4a Port FSTQueryListener to C++ (#2618) 2019-03-26 07:11:02 -07:00
Gil ce07f8d0c3 Port FSTListenOptions to C++ (#2617) 2019-03-25 20:01:20 -07:00
Gil c2a3d04e6d Port FSTDocumentSet to C++ (#2608)
* Replace FSTDocumentSet's guts with immutable::SortedSet.

* Port FSTDocumentSet to C++ DocumentSet.

* Replace implementation of FSTDocumentSet with C++ DocumentSet

* Update all usages of FSTDocumentSet

* Remove FSTDocumentSet

* Add Objective-C++ guard

* Use absl::c_equal instead of hand-rolling it.

* Split SortedContainer out of SortedMapBase

... and use it

* Fix NSNotFound -> npos

* Remove = default constructors that aren't true.

These are implicitly deleted because DocumentSet is a member and isn't
default constructible.

* Fix usage of FSTQuery.limit
2019-03-25 11:04:21 -07:00
Konstantin Varlamov 0643b36aef C++ migration: make FIRFirestore implementation delegate to core API (#2492) 2019-03-15 16:10:32 -07:00
Konstantin Varlamov e04f5d2b85 C++ migration: make FIRDocumentReference implementation delegate to core API (#2469) 2019-03-06 14:17:52 -05:00
Konstantin Varlamov 48009aaf7d C++ migration: port FSTViewSnapshot (#2441)
Also add a version of `ToString` taking an `absl::optional`
2019-03-01 14:16:41 -05:00
Konstantin Varlamov a22b4cd08e Pass FSTMutations using a vector (#2357) 2019-02-07 22:03:17 -05:00
Paul Beusterien 7c53489e03 Travis to Xcode 10.1 and clang-format to 8.0.0 (tags/google/stable/2018-08-24) (#2222)
* Travis to Xcode 10.1
* Update to clang-format 8
* Update clang-format homebrew link
* Work around space in filename style.sh issue
2019-01-02 09:27:31 -08:00
Konstantin Varlamov 8b1efabd82 gRPC: replace Objective-C implementation with the new C++ implementation (#2068)
* Revert "Revert "gRPC: replace Objective-C implementation with the new C++ implementation (#1968)" (#2030)"

This reverts commit ea567dca47.

* gRPC: fix bugs found during testing (#2039)

All in `GrpcStream`:
* make sure there are no pending completions when "finish" operation is enqueued;
* always finish gRPC calls;
* when connectivity changes, reset not just the calls, but the underlying channel as well.

* Revert "Partially revert "Update CHANGELOG for Firestore v0.14.0 (#2025)" (#2031)"

This reverts commit b2437b80f6.

* Update changelog for v0.15.0.

* gRPC: add gRPC wrapper classes to CMake build (#2015)

* add a C++ equivalent of `FIRFirestoreVersionString`. This eliminates the only Objective-C dependency of `grpc_connection.mm` and allows making it a pure C++ file;
* open-source `binary_to_array.py` script and use it in the build to embed `roots.pem` certificate file from gRPC into the Firestore binary. The embedded char array is then used to load certificate at runtime.

* Revert local change -- do not enable sanitizers by default
2018-11-13 11:51:06 -08:00
Sebastian Schmidt 5bc4cc55a6 Remove Held Write Acks (#2029)
* Drop acknowledged mutations in schema migration (#1818)

Drop acknowledged mutations in schema migration as part of removing held write acks.

Port of firebase/firebase-js-sdk#1149

* Change removeMutationBatch to remove a single batch (#1955)

* Update Firestore Generated Protos

*  Adding UnknownDocument and hasCommittedMutations (#1971)

* Removing held write batch handling from LocalStore (#1997)

* View changes for held write acks (#2004)

* Held Write Acks Unit Test Fixes (#2008)

* Held Write Ack Removal Spec Tests (#2018)

* Fix integration test
2018-11-01 09:44:30 -07:00
Gil ea567dca47 Revert "gRPC: replace Objective-C implementation with the new C++ implementation (#1968)" (#2030)
This reverts commit a514bd957a.
2018-11-01 08:37:32 -07:00
Konstantin Varlamov a514bd957a gRPC: replace Objective-C implementation with the new C++ implementation (#1968)
* add support for SSL disabled to `GrpcConnection` (unfortunately, there
  currently is no way to verify this change actually works);
* make gRPC calls using the C++ implementation:
* make `FSTRemoteStore` create C++ streams instead of their Objective-C
  counterparts;
* port https://github.com/firebase/firebase-js-sdk/pull/1041: streams
  are now never recreated, only restarted;
* make `FSTDatastore` delegate server calls to the C++ implementation;
* port `MockWatchStream` and `MockWriteStream` to C++ (`FSTMockDatastore` is
  still in place, because `Datastore` is not fully ported yet);
* no longer generate Objective-C gRPC service definitions from protos;
* remove all references to Objective-C gRPC client;
* check in gRPC root certificates file and load it at runtime (the check-in part
  is temporary until gRPC-C++.podspec provides the certificate). This makes SSL
  work.
2018-10-25 20:13:03 -04:00
Gil a40a43c058 Port user data handling to C++ (#1823)
Extract useful bits of FSTUserDataConverter for use in C++:
  * Migrate FSTParsedSetData to core::ParsedSetData
  * Migrate FSTParsedUpdateData to core::ParsedUpdateData
  * Migrate FSTParseContext to core::ParseContext
  * Split ParseAccumulator out of ParseContext to make ownership easier

Also:
  * Remove dead code (handled in parseSentinelFieldValue)
  * Flatten App/iOS/Supporting Files into the parent
2018-09-18 09:19:11 -07:00
Gil 16f7be5864 Migrate nearly all usages of MakeStringView to MakeString (#1679) 2018-08-13 15:23:58 -07:00
Michael Lehenbauer b88f95c44f Reformat using 'clang-format version 7.0.0 (tags/google/stable/2018-04-24)' (#1681)
This is the version of clang-format that travis is currently using.
2018-08-13 14:18:02 -07:00
Gil 8037a4bf79 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
2018-05-24 11:00:23 -07:00
Konstantin Varlamov edd6f60a73 Firestore: use C++ Executor for user queue. (#1238)
FSTDispatchQueue enforces serial execution, which is inappropriate for
user queue, because a user may configure usage of a concurrent queue in
settings, breaking FSTDispatchQueue invariants. Instead, use C++
ExecutorLibdispatch directly.
2018-05-10 20:16:50 -04:00
Sebastian Schmidt 542d81ac68 Adding mergeFields support (#1141) 2018-05-02 11:10:19 -07:00
rsgowman a5b3185ed3 Add GetOptions for controlling offline get behaviour (#655)
Add option to allow the user to control where DocumentReference.getDocument() and CollectionReference.getDocuments() fetches from. By default, it fetches from the server (if possible) and falls back to the local cache. It's now possible to alternatively fetch from the local cache only, or to fetch from the server only (though in the server only case, latency compensation is still enabled).
2018-04-18 10:30:37 -04:00
Gil 5368c9e22f Replace the SetOptions object with a simple boolean. (#1098)
Instead of calling

  `setData(["a": "b"], options: SetOptions.merge())`

call

  `setData(["a": "b"], merge: true)`
2018-04-15 13:06:06 -07:00
Gil 33b12f6c70 Replace DocumentListenOptions with a simple boolean. (#1099)
* Replace `DocumentListenOptions` with a simple boolean.

Instead of calling

  `addSnapshotListener(options: DocumentListenOptions.includeMetadataChanges(true))`

call

  `addSnapshotListener(includeMetadataChanges:true)`

* Style
2018-04-14 17:19:06 -07:00
zxu 2ceea9b66e Port Precondition to C++ (#1040)
* port FieldMask to C++

* address changes

* address changes

* fix test

* address change

* Port transform operations (FSTTransformOperation, FSTServerTimestampTransform) to C++

* address changes

* address changes

* address changes

* implement `FieldTransform` in C++

* port `FieldTransform`

* make `fieldTransforms` shared inside `context`

* Implement Precondition in C++ w/o test yet

* add unit test for `Precondition`

* port `Precondition`

* address changes

* address changes

* fix bugs for integration test

* address changes

* fix lint

* address changes

* address changes
2018-04-12 21:32:19 -04:00
Gil 0a66187053 Add lint checking for Objective-C++ sources (#1048)
* lint.sh now lints Objective-C++ too

* cpplint checks system-style includes that should be user-style

This prevents it from recognizing project sources as if they were C
system headers and then complaining that they're in the wrong place.

* cpplint checks #imports and #includes

* cpplint checks that C++ system headers aren't #imported

* cpplint checks for C system headers that could be C++ system headers

* cpplint checks that Objective-C sources include their headers
2018-04-09 11:54:39 -07:00
zxu cb8c4b6b1f port C++ DocumentKey to the rest of Firestore code (#977)
* port C++ DocumentKey to API's and Core's

* address changes

* address changes

* fix Hash return types
2018-03-27 14:33:39 -04:00
zxu 9e815620e9 grand PR to port the remaining paths (FieldPath and ResourcePath). (#865)
* naively remove FSTPath import and source/test files.

* port FieldPath, part I

* port FieldPath, part II

* port ResourcePath, part I

* port ResourcePath, part II

* the grand commit to fix build errors

* use testutil:: helper instead of those from FSTHelpers

* fix test and lint

* use c_str in errmsg directly

* fix

* fix

* make code clean

* fix integration test I missed

* fix to avoid naming collision in preprocessor

* address changes

* address changes

* address changes

* fix: fieldMask are actually shared with different context.

* address changes

* address changes
2018-03-14 08:57:31 -04:00
zxu 8311c6432e port paths to FSTDocumentKey (#877)
* replace path with C++ implementation in FSTDocumentKey.{h,mm} only

* address changes

* address changes
2018-03-06 14:28:04 -05:00
zxu 1c40e7aada add converters and port paths to FSTQuery (#869)
* add converters and fix FSTQuery.{h,m} only

* address changes

* a change forget to address

* add a dummy function to make inline-only-library buildable
2018-03-05 11:30:59 -05:00
Gil 729b8d176c Move all Firestore Objective-C to Objective-C++ (#734)
* Move all Firestore files to Objective-C++
* Update project file references
* Don't use module imports from Objective-C++
* Use extern "C" for C-accessible globals
* Work around more stringent type checking in Objective-C++
  * NSMutableDictionary ivars aren't implicitly casted to NSDictionary
  * FSTMaybeDocument callback can't be passed a function that accepts
    FSTDocument
  * NSComparisonResult can't be multiplied by -1 without casting
* Add a #include <inttypes.h> where needed
* Avoid using C++ keywords as variables
* Remove #if __cplusplus guards
2018-01-31 11:23:55 -08:00