Commit Graph
156 Commits
Author SHA1 Message Date
Gil df06ad9a5c Clean up GeoPoint port to C++ (#3153)
... based on things learned porting Timestamps.

There's no good way to include conversions equivalent to toGeoPoint in
FIRTimestamp, so pull out separate conversion functions that match other
similar things.
2019-06-09 21:19:14 -07:00
Gil 04d1d41a16 Migrate FSTBlobValue to FSTDelegateValue (#3130)
* Rename nanopb::String to nanopb::ByteString

... and flesh it out.

* Remove const pb_bytes_array* constructor

* Use std:: prefixes

* Pull forward CopyVector

* Simplify nanopb::Reader/Writer construction

* Reuse ByteString construction in serializer

* Add nanopb_testing.h

* Make QueryData.resume_token a ByteString

* Use ByteString as FieldValue::blob_value

* Migrate FSTBlobValue to FSTDelegateValue

* Rework the ByteString API

  * Make data(), begin(), and end() never return nullptr
  * Make copies of pb_bytes_array_t* more obvious (also avoids ambiguity
    with the private constructor).

* Remove constructors that duplicate absl::string_view

* Make ByteString::Copy just a constructor

* Remove EncodeBytes/DecodeBytes

These duplicate ByteString constructors

* Overhaul ByteString and users

  * Remove most conversions from ByteString
  * Put remaining conversions in nanopb_util as free functions
  * Make ByteStringWriter accumulate in a pb_bytes_array_t*
  * Have ProtobufSerialize use ByteStringWriter

* Avoid reserving/writing if we're not asked to append data

* Ensure ByteStringWriter initializes/frees

* Make copies explicit

* Make Reserve match std::vector::reserve

* Add comments, assertions, and tests
2019-06-07 11:29:30 -07:00
Brian Chen 840ab65a69 Expose clearPersistence() publicly (#3026) 2019-06-05 16:25:09 -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 9703caec5c Fix -[FIRGeoPoint compare:] analysis warning (#3121) 2019-05-31 17:49:04 -07:00
Gil dd94ab677f Change limit to an int32 to match the backend (#3120) 2019-05-31 14:10:02 -07:00
Gil 8428d4a8e2 Migrate null, numbers, and GeoPoints to FSTDelegateValue (#3044)
* Migrate FSTNullValue to FSTDelegateValue
* Migrate FSTIntegerValue to FSTDelegateValue
* Migrate FSTDoubleValue to FSTDelegateValue
* Migrate FSTGeoPointValue to FSTDelegateValue
2019-05-26 10:02:21 -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
Brian Chen afe63ccff5 Add clearPersistence() to Firestore client(#2993) 2019-05-17 11:29:20 -07:00
Brian Chen 570f4465de Use shared_ptr for AsyncQueue and Executor (#2996) 2019-05-15 09:55:18 -07:00
Gil 2a263eac83 Port FIRQuery to C++ (#2986) 2019-05-14 14:04:35 -07:00
Gil 7ae2af4e6f Port FSTFieldValueOptions to C++ (#2989) 2019-05-14 07:43:51 -07:00
Gil 03c2e728b3 Flesh out C++ FieldValue (#2990)
* Add GeoPoint::ToString

* Add FieldValue::ToString

* Fix description of FIRTimestamp

* ServerTimestamp's previous_value is a FieldValue

* Implement FieldValue::Hash
2019-05-13 15:30:48 -07:00
Gil fc1ebb808a Remove unused FIRFirestore instances dictionary (#2937)
This was copied into FSTFirestoreComponent but never removed.
2019-05-06 09:00:47 -07:00
Gil bef0dfb69e use portable util/log.h instead of FIRLogger (#2915) 2019-05-01 11:03:28 -07:00
Gil 9a3ba6e66d Make disabling GC prevent even scheduling it (#2862)
* Make disabling GC prevent even scheduling it

Make the linkage of kFIRFirestoreCacheSizeUnlimited explicitly
extern "C". This previously had no fixed linkage in the header and must
have accidentally worked because the implementation had C++ linkage.

Move internal CacheSizeUnlimited to api::Settings and the
definition of kFIRFirestoreCacheSizeUnlimited into the Objective-C
language binding.

Migrate settings defaults to C++ settings

Ensure that all defaults are compiler initialized to ensure there are no
initialization order problems.
2019-04-18 18:17:34 -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
Michael Lehenbauer 6dca5e601c Port FirestoreSettings to C++. (#2804)
* Creates a C++ api::Settings class as a container for the settings we pass
  into the core client.
* Adds [FIRFirestoreSettings internalSettings] to convert from public API
  settings to api::Settings.

Input validation, etc. still happens in FIRFirestoreSettings.
2019-04-14 12:28:22 -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 58205aa513 Tunnel underlying NSErrors through C++ Status (#2808)
* Tunnel underlying NSErrors through Status

* Make FIRFirestoreErrorDomain available to CMake builds

The prior state was actually semi-broken. The
firebase_credentials_provider_apple definition wasn't extern "C" so it
was defining the value in addition to whatever FIRFirestore was doing.

FIRFirestore's value isn't available to straight C++ though, so this
change pushes the definition down into error_apple.mm so that it can be
shared by the Objective-C API and MakeNSError.

Pushing MakeNSError up into the API layer isn't practical yet so this
change is a compromise that makes things work
2019-04-12 12:47:56 -07:00
Michael Lehenbauer db2701b480 Take 2: Move input validation logic from FIRFieldPath to model::FieldPath. (#2727) (#2790)
* Move input validation logic from FIRFieldPath to model::FieldPath. (#2727)
2019-04-11 14:44:11 -07:00
Gil 2a97c2ea5f Port FSTRelationFilterOperator to Filter::Operator (#2812)
Note:
  * This includes a partial port of array-contains for Filters because
    this silenced a warning about an unhandled case
  * There's some sensitivity to the order of the cases that I didn't
    bother to figure out; instead I just made it match what came before.
2019-04-11 13:35:09 -07:00
Michael Lehenbauer 09010cfba0 Fix a couple small issues I tripped over today. (#2806)
* Fix a couple small issues I tripped over today.

1. Fix primeBackend so it uses an isolated FIRFirestore* instance. I ran into
   an issue where tests that try to change .settings would fail if they were the
   very first test run, since primeBackend had already configured the client and
   so settings could no longer be changed.
2. Remove FIRFirestore.client and make api::Firestore.client() assert client is configured.
2019-04-11 10:40:56 -07:00
Gil 47bd60a7d0 Move collectionGroup method out of the Internal category (#2802)
This prevents a warning for end users.
2019-04-10 17:32:49 -07:00
Michael Lehenbauer 754d5c07d4 Expose Collection Group queries. (#2786) 2019-04-09 20:50:58 -07:00
Michael Lehenbauer 7e6cc0ddd5 Revert "Move input validation logic from FIRFieldPath to model::FieldPath. (#2727)" (#2789)
This reverts commit 384ccd81a9 due to broken integration tests.
2019-04-09 15:59:06 -07:00
Michael Lehenbauer 384ccd81a9 Move input validation logic from FIRFieldPath to model::FieldPath. (#2727)
This will allow it to be shared with the (eventual) C++ FieldPath Public API.
2019-04-09 13:27:00 -07:00
Gil edd4bd719c Port FIRFirestoreSource to C++ Source (#2749) 2019-04-09 07:07:20 -07:00
rsgowman 58e36e15cb Migrate FSTStringValue to FSTDelegateValue (#2719) 2019-04-08 16:16:04 -04:00
rsgowman 82ced2d8c1 Add FSTDelegateValue which delegates to model::FieldValue (#2681)
* Fix FSTFieldValue instanceof check to use FSTFieldValue.type

Missed in the previous PR because this gets the class via [value class]
rather than [value isKindOfClass].

* Add FSTDelegateValue which delegates to model::FieldValue

Also migrates FSTBooleanValue to FSTDelegateValue as a proof-of-concept.
Other FSTXValues still TODO.
2019-04-04 14:47:59 -04:00
Michael Lehenbauer c65ecf55c8 Port FIRDocumentChange to C++. (#2687)
* Create C++ api::DocumentChange class.
* Make FIRDocumentChange a wrapper over api::DocumentChange.
* Moved documentChangesForSnapshot helper from FIRDocumentChange to
  where it's used in QuerySnapshot. I think this is cleaner.
2019-04-03 11:52: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
rsgowman 6e5221ba41 Eliminate 'instanceof' checks for FSTFieldValue (#2651)
Previously, we checked for FSTFieldValue subtypes via:
`[value isKindOfClass:[FSTStringValue class]]`

Now, we check via a new type parameter on FSTFieldValue, i.e.:
`value.type == firebase::firestore::model::FieldValue::Type::String`

Or with the appropriate using declaration:
`value.type == FieldValue::Type::String`

This should enable easier transition to C++.
2019-03-27 12:26:23 -04: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
Gil 38496c450c Add DelayedConstructor<T> (#2579)
* Add util::DelayedConstructor

* Run sync_project on any Firestore change since start

* Use DelayedConstructor in a few places to show how it works
2019-03-20 10:29:02 -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
Michael Lehenbauer bd0b8e9449 Collection Group Query Internals (#2378)
Includes the new index and all internals for collection group queries, but the public API will not be exposed until backend support is ready.
2019-03-08 13:37:00 -08:00
Sebastian Schmidt 657f53a9b8 Adding FieldValue.increment() (#2075) 2019-03-06 14:51:30 -08:00
Konstantin Varlamov e04f5d2b85 C++ migration: make FIRDocumentReference implementation delegate to core API (#2469) 2019-03-06 14:17:52 -05:00
Konstantin Varlamov 213e427667 C++: make internal Objective-C API wrap DocumentSnapshot from core API (#2456) 2019-03-04 15:12:56 -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