Commit Graph
58 Commits
Author SHA1 Message Date
Brian Chen 21921e9851 Add != and notIn support (#6418) 2020-09-15 16:12:44 -05:00
Gil 7a58eba2e5 Remove firebase/firestore from paths in Firestore/core (#5374)
* Manual Xcode project fixups

* Remove `firebase/firestore` from paths in Firestore/core

This renames all Firestore files under `Firestore/core` to remove the
interior `firebase/firestore` directory structure. This is motivated by
build failures under Windows where the filenames of intermediates were
too long.

Concretely:

  * `Firebase/core/src/firebase/firestore` becomes `Firebase/core/src`
  * `Firebase/core/test/firebase/firestore` becomes
    `Firebase/core/test/unit`

Moving the tests into a `unit` subdirectory aligns Firestore with the
directory structure in
[AddNewPod](https://github.com/firebase/firebase-ios-sdk/blob/master/AddNewPod.md),
modified for C++ (see discussion in #3224).
2020-04-20 14:57:34 -07:00
Gil 77f92cd2c6 Stop using built-in CMake Framework support (#5316)
* Fix previously unknown warnings

These become visible once flags are handled uniformly across all
Firestore targets in an upcoming build change.

* Stop using built-in CMake Framework support

CMake has built-in support for building Framework bundles (briefly:
bundles of libraries, associated headers, and resources) but this
doesn't work well for our needs.

1. In CMake 3.5.1 (our earliest supported CMake version) it doesn't copy
headers properly at build time.

2. Even up to CMake 3.15.5, CMake doesn't handle link-line multiplicity
correctly. CMake passes the static library location within the framework
and this seems to cause the linker to mishandle Objective-C metaclass
information resulting in duplicate symbols. Building with `-framework`
flags works correctly.

Previously we partially worked around the latter problem by building
some frameworks as shared instead of static frameworks, but this is
problematic because this mode of operation isn't actually intended and
is unsupported as far as the rest of Firebase is concerned. This turned
out to be fragile though and while refactoring libraries this workaround
broke.

Rather than piling on additional workarounds, this change converts the
frameworks to simple library targets and emulates framework imports
through include paths.

Additionally, this starts refactoring our cmake helper functions to make
them more like built-in functions. This makes it possible to freely use
different CMake features that were made difficult by trying to wrap
everything up in a single CMake command.

* style.sh generated changes

* Review feedback

* More review feedback
2020-04-14 08:40:33 -07:00
Gil d9b7a33f0c Use forward declarations instead of IWYU (#4868)
* Remove rarely used template argumnets from SortedMap/SortedSet

* Remove unused STATUS_CHECK_OK

* Rename QuerySnapshot::Listener to QuerySnapshotListener

This makes the type something that can be forward declared.

* Rename DocumentSnapshot::Listener to DocumentSnapshotListener

This makes the type something that can be forward declared.

* Rename ViewSnapshot::Listener to ViewSnapshotListener

This makes the type something that can be forward declared.

* Put most QueryListener implementation in .cc

* Actually use sync_engine_callback.h

* Add forward declaration headers for api, core, and model

These centralize forward declarations, including declarations for some
hard-to-forward-declare types.

* Move includes of hard_assert.h out of other headers

* Make testutil definitions out of line

* Move definitions out-of-line

* Move DocumentKey definitions out-of-line

* Move definitions out-of-line

* Shorten unnecessarily long namespace usages

* Use default destructors where possible

* Delete unused MutationBatch::kUnknown constant

* Use forward declarations instead of IWYU

* Misc fixups from Linux/GCC 9.2.1

* Fix testutil under VS 2017

Forward declarations of functions local to a function body end up
generating unresolved externals. Reduce most of these back to just
calling FieldValue::FromX methods.
2020-02-15 14:34:38 -08:00
Gil 904c1835a5 Prep for forward declarations (#4859)
* Remove rarely used template argumnets from SortedMap/SortedSet

* Remove unused STATUS_CHECK_OK

* Rename QuerySnapshot::Listener to QuerySnapshotListener

This makes the type something that can be forward declared.

* Rename DocumentSnapshot::Listener to DocumentSnapshotListener

This makes the type something that can be forward declared.

* Rename ViewSnapshot::Listener to ViewSnapshotListener

This makes the type something that can be forward declared.

* Put most QueryListener implementation in .cc

* Actually use sync_engine_callback.h
2020-02-10 14:44:10 -08:00
wu-hui 14e28121e2 Release LimitToLast (#4616)
* [1/4] Split Query and Target, and make LocalStore/RemoteStore work with Target. (#4413)

* [2/4]LimitToLast: Make SyncEngine work with Target (#4491)

* [3/4] Implement LimitToLast (#4505)
2020-01-08 09:04:28 -08:00
Gil 9a4f4e73c7 Miscellaneous fixes (#4584)
* Fix use after move in LevelDbPersistenceForTesting

* Fix size-related errors when compiling in 32-bit mode

* Fix test-only memory leaks

* Fix test-only memory leaks

* Prevent spec tests from appearing to leak

The spec tests aren't actually leaking, but they accumulate enough
garbage without clearing the autorelease pool that Instruments
complains.

* Avoid temporaries in methods that @throw

ARC does not release temporaries when an Objective-C exception is
thrown. Use C++ equivalents directly to avoid leaks as detected by
Instruments.

* Fix memory leak in acknowledge mutation

Any previous value must be freed before the next one is assigned.

* Manually implement assignment operators in ByteString

The single by-value implementation wasn't preventing the compiler
generated standard versions from being generated which was causing
leaks.

* Prevent leaking GrpcCompletions that complete after Shutdown

After shutdown, the AsyncQueue silently drops Enqueue requests which
prevents these blocks from being deleted.

* Avoid racing with enqueued operations

It's possible for the Executor to immediately execute the given block,
at which point the block might observe the async queue in a
not-shutting-down state.
2020-01-08 07:11:05 -08:00
Brian Chen 0170957544 Allow querying for arrays in IN queries (#4285) 2019-11-12 13:07:58 -08:00
Morgan Chen 9a611a859d Update header docs based on feedback in cr/278458897 (#4235)
* Update header docs based on feedback in cr/278458897

* Change param names in .mm to match header file
2019-11-05 13:01:45 -08:00
Brian Chen 251a70f26a Make IN queries publicly available (#4174) 2019-10-29 14:13:02 -07:00
Brian Chen 441d7eda8b Change id to NSArray<id> for IN queries (#4182) 2019-10-28 22:22:37 -07:00
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
wu-hui 7870c73b7c Port FSTFirestoreClient to C++ 2/2 (#3657)
* firestore_client + FSTFirestoreClient becomes delegate.

* fix comment

* addressing comment

* use new instead make_shared

* reformat

* Update references to firestore client

* Addressing comments#2

* addressing comments #3

* add std::move

* remove deleted header.

* fix cmake build error.
2019-08-26 15:48:18 -04:00
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
Brian Chen 86b09fa469 Add IN and ARRAY_CONTAINS_ANY (not publicly exposed) (#3492) 2019-08-05 11:47:06 -07:00
Gil 13a1b33913 Migrate from FSTQuery to C++ Query (#3484) 2019-08-02 11:35:33 -07:00
Gil 2f22dce569 Reimplement C++ Query with AppendOnlyList (#3483)
* Reimplement C++ Query with AppendOnlyList

* Fix missing assignment to last_document (!!!)

* Refer to filters as std::shared_ptr<const Filter>
2019-08-02 09:14:10 -07:00
Gil bef89668f0 Migrate FSTBound to C++ Bound (#3478)
* Port FSTBound to C++ Bound

* Add limit and Bound to Query

* Migrate FSTBound to C++ Bound, also limits
2019-08-01 12:58:53 -07:00
Gil 561325300b Port FSTSortOrder to C++ OrderBy (#3468)
* Port FSTSortOrder to C++ OrderBy

* Finish port of C++ Direction from Android

* Reimplement FSTSortOrder with C++ OrderBy

* Migrate FSTSortOrder to C++ OrderBy

* Remove FSTSortOrder

* Compare OrderBy equality in C++ Query
2019-07-31 15:39:38 -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 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 64d8a40a70 Migrate FSTReferenceValue to FSTDelegateValue (#3177)
* Add FieldValue::Reference

* Migrate FSTReferenceValue to FSTDelegateValue

* Build Objective-C components with CMake

Build only the things required for FSTFieldValue
2019-06-14 07:14:18 -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 dd94ab677f Change limit to an int32 to match the backend (#3120) 2019-05-31 14:10:02 -07:00
Gil 2a263eac83 Port FIRQuery to C++ (#2986) 2019-05-14 14:04:35 -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 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 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
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 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
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
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 5efbb08f3b Add a ToString function to create human-readable debug descriptions (#2384)
The motivation is to avoid writing lots of boilerplate for containers.
2019-02-15 14:49:27 -05:00
rsgowman 0f32878009 Forbid queries endAt an uncommitted server timestamp. (#2382)
Without this, it still fails, but:
a) not until serializing the query, and
b) the error is an internal error, and
c) the error message is quite cryptic and has nothing to do with the problem.

Port of https://github.com/firebase/firebase-android-sdk/pull/138
2019-02-13 12:12:42 -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
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
rsgowman 82ef0886bf Move creation of FSTFilter objects to static create method on FSTFilter. (#1512)
Rather than previously inlining it in the calling code. This is to unify
filter creation across platforms.

(This change involves altering FSTFilter from a protocol to an abstract
class.)
2018-07-11 21:59:49 -04: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
Michael Lehenbauer 0ec836f9ca b/79432277: Limit Queries to only a single array-contains clause. (#1286) 2018-05-16 17:05:33 -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
Michael Lehenbauer 8409f21830 Backport array contains / transform improvements from Web. (#1242) 2018-05-08 15:33:10 -07:00