Commit Graph
27 Commits
Author SHA1 Message Date
Gil 0c23f38397 Migrate Objective-C document types to C++ (#3531)
* Rewrite Document-related classes as a polymorphic value type

* Pass ObjectValue without rvalue references

* Rename HasLocalMutations

* Port C++ users to new Documents

* Port FSTDocumentTests to C++

* Port FSTDocumentSetTests to C++

* Migrate DocumentMap and DocumentSet to C++ Document

* Migrate test helpers

* Delete FSTDocumentSetTests

* Delete FSTDocumentTests

* Mechanical changes to use C++ Document

* Updates to the project file

* Nontrivial test updates

* Remove FSTTestDeletedDoc

* Remove FSTTestUnknownDoc

* Remove FSTDocument

* Convert usage of FSTDocument to C++ Document

* Fix Serializer usage of Documents
2019-08-13 13:59:00 -07:00
Hui-Wu 902d9fe4c5 Port public shutdown (#3467)
* async_queue shutdown ready

* shutdown feature complete. need to fix shared_ptr for credprovider and stop executor leakage.

* stop executor leakage.

* Improved comments without shared_from_this

* shared_ptr everywhere!

* undo scheme change

* addressing comments #1

* addressing comments

* addressing comments #3
2019-08-06 20:33:08 -04:00
Gil 13a1b33913 Migrate from FSTQuery to C++ Query (#3484) 2019-08-02 11:35:33 -07:00
Hui-Wu d723fc49f2 FieldValue and DocumentReference codable support. (#3231)
* working serverTimestamp

* working FieldValue. Still need: document ref and ability to Eq of FieldValue

* DocumentReference implemented and testing works

* clean up header search path

* improving FieldValue enum comments

* run through formatting

* addressing comments

* formatted with swiftformat 0.35.7

* add missing bool->BOOL change

* undo unintended swift version change

* remove unwanted proj file change
2019-06-24 16:18:30 -04:00
Gil ffdc328732 Migrate FSTDocumentState to C++ DocumentState (#3225) 2019-06-20 09:39:19 -07:00
Gil 220589d9bc Port FIRCollectionReference to C++ (#3126)
Also fix up DocumentReference to use it.
2019-06-04 18:10:17 -07:00
Gil 8770828dd8 Refactor usages of DatabaseId to avoid raw pointers (#3041)
* Remove stale references to DatabaseId
* Have Firestore take the DatabaseId directly
* Allow tests to default the database implicitly
* Have FSTSerializerBeta take DatabaseId by value
* Have FSTUserDataConverter take DatabaseId by value
* Make FIRFirestore.databaseID a const reference
* Make FSTFirestoreClient.databaseID a const reference
* Have FSTReferenceValue take DatabaseId by value
* Have DatabaseInfo take DatabaseId by value
* Have Serializer take DatabaseId by value
* Fix C++ ReferenceValue
  * Take DatabaseId by value
  * Reverse order to match Android
  * Rename `reference` to `key`
2019-05-21 20:28:51 -07:00
Gil d53558c4c4 Use C++ three-way comparison in FSTQuery (#2885) 2019-04-25 11:11:38 -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 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
Gil 7babc0a7f6 Port FIRQuerySnapshot to C++ (#2581) 2019-03-20 08:04:57 -07:00
Gil fd8947ce74 Port FIRSnapshotMetadata to C++ (#2580) 2019-03-19 12:55:24 -07:00
Konstantin Varlamov 0643b36aef C++ migration: make FIRFirestore implementation delegate to core API (#2492) 2019-03-15 16:10:32 -07:00
Gil 9c95d61304 Update project and fix warnings (#2531)
* Update Firestore project to Xcode 10.1 defaults

* Fix NSUInteger in format strings warning

* Fix implicit conversion warning in FSTLevelDB

* Fix BOOL/bool mismatch

* Fix erroneous comparison

This failure shows up on 32-bit targets. I have no idea why this
succeeds on 64-bit targets.

* Fix incorrect type inference with explicit cast

clang is inferring the type of the key in these maps is `NSString *` and
then complaining that `FIRFieldValue *` doesn't match that type, despite
the underlying method taking `NSDictionary<id, id>`. Explicitly casting
to `id` prevents the warning.

* Remove reliance on representation in FSTFieldValue tests

On *some* platforms [NSNumber numberWithChar:1] ends up with a "c"
(signed char) objcType, but apparently on 32-bit platforms this ends up
as "i" (signed int). Rather than relying on this working properly just
test that [NSNumber numberWithBool:] does the right thing.

* Fix field_value_test on 32-bit targets

When sizeof(void*) is 4 the test failed :-(.

* Rephrase testWritesWithLargeNumbersFail in terms of fixed size types

The prior definition only worked on LP64. Switching to LLONG_MAX would
have also fixed this, but Firestore's data model is independent of C's
data model, so rewriting this in terms of fixed size types more closely
models what's actually an invalid value.

* Fix implicit retain self warnings
2019-03-12 15:58:52 -07: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 19fa24cecd C++ migration: port FSTDocumentViewChange (#2388) 2019-02-19 18:30:12 -05:00
Konstantin Varlamov 0a58581bda C++ migration: make DocumentViewChangeType a C++ enum (#2307) 2019-01-24 14:09:42 -05:00
Konstantin Varlamov 673b08592a C++: replace FSTMaybeDocumentDictionary with a C++ equivalent (#2139)
Also eliminate most usages of `FSTDocumentKey`, remove most methods from the Objective-C class and make it just a wrapper over `DocumentKey`. The only usage that cannot be directly replaced by C++ `DocumentKey` is in `FSTFieldValue`.
2018-12-10 11:57:08 -08:00
Konstantin Varlamov e0d797515c C++: eliminate FSTDispatchQueue and replace it with AsyncQueue (#2062)
* replace all references to `FSTDispatchQueue` and `FSTTimerID` with their C++ equivalents;
* remove `FSTDispatchQueue` class and related tests;
* in method argument names, replace `workerDispatchQueue` with just `workerQueue`, more similar to other platforms;
* move `Executor` and derived classes out of `internal` namespace.
2018-11-18 17:49:32 -05:00
Konstantin Varlamov 5038e26b20 Fix string_view referring to an out-of-scope string (#2074) 2018-11-13 20:04:14 -05:00
Sebastian Schmidt 4aaf9081a3 Porting Multi-Tab Structural Changes (#2049) 2018-11-07 11:22:01 -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 15ef78f090 Replace uses of absl::string_view in constructor parameters with std::string (#1676)
* Add a MakeStringView benchmark

Turns out this is worse than just creating a std::string:

BM_MakeString             29 ns         29 ns  189065849
BM_MakeStringView         59 ns         59 ns   93013367

* Convert database_id to take std::string

* Convert DatabaseInfo to take std::string

* Convert User to take std::string

* Convert Token to take std::string

* Convert MakeStringView([NSString stringWithFormat:]) to StringFormat
2018-08-13 11:02:28 -07:00
zxu 4e7296b080 port DocumentKey to non-container types of Model/* (#930)
* 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

* add converter function between two DocumentKey implementations

* add unit test

* address changes

* fix lint

* using DocumentKey in model except for the container types `FSTDocumentDictionary`, `FSTDocumentKeySet`, and  `FSTDocumentVersionDictionary`

* change other place w.r.t. the use of `DocumentKey` in model

* update parameter of test helpers from NSString to string_view

* revert a temporary change used in debug

* address changes
2018-03-16 15:42:05 -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
Gil 935f3ca7d7 Avoid wrapping and rewrapping NSStrings when constructing DatabaseId (#833)
* Avoid wrapping and rewrapping NSStrings when constructing DatabaseId

* Shorten DatabaseId::kDefaultDatabaseId
2018-02-22 08:12:54 -08: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