Commit Graph
67 Commits
Author SHA1 Message Date
Morgan ChenandPaul Beusterien 90d3600c56 Implement unified emulator settings API proposal (#5916)
* Add header for API proposal

* Fix some bugs and add implmentation

* Fix header import

* Fix umbrella header

* Add ways to modify settings object

* Remove unnecessary nodoc

* Update with new API

* Add implementations for Firestore and RTDB

* Revert emulator settings class

* fix style

* Remove bad import and assertion on override

* Prevent database emu from being set after repo init

* Add unified emu to functions

* Add tests

* update header comment

* fix test failures

* remove unused variable

* fix database test

* cast NSInteger to long

* fix style

* Fix functions test in travis

* Remove valueForKeyPath in tests

* fix style

* update comments and remove explicit scheme

* save progress

* Implement reference validation for RTDB

* Add tests

* Add changelog entries

* Remove test logs

* Fix line lengths

* remove underlyingHost

* fix functions tests

* fix integration warnings in functions test

* fix functions test

* Fix infinite loop exposed in integration tests (#6912)

Co-authored-by: Paul Beusterien <paulbeusterien@google.com>
2020-11-06 10:37:06 -08:00
Konstantin Varlamov 2311c36dbc Integrate Firestore with Firebase platform logging (#6507)
The sample user agent string I'm getting in XCode is `apple-platform/ios apple-sdk/17E8258 fire-fst/1.17.1 fire-ios/6.10.2 swift/true xcode/11E503a`.
2020-09-25 15:47:20 -04:00
Paul Beusterien d4621a636f Use preserve_paths instead of CocoaPods private (#5758) 2020-06-09 05:21:28 -07: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 74f4ceb4c9 Fix unused variable warnings (#5389)
* Fix unused variable warnings

These are now exposed because libprotobuf is no longer polluting the
compiler command-line with -Wno-unused-parameter.

* Convert (void)var to __unused where possible
2020-04-20 14:23:36 -07:00
Gil 314f137bd5 Shorten CMake Objective-C targets (#5323)
* Shorten firebase_firestore_example_app

... and:
  * Migrate to firebase_ios_add_executable
  * Use globs for specifying sources

* Migrate Example/Tests/API to new CMake primitives

* Migrate Example/Tests/Integration to new CMake primitives

* Migrate Example/Tests/SpecTests to new CMake primitives

* Migrate Example/Tests/Util to new CMake primitives

Rename firebase_firestore_objc_test_util to firestore_objc_testing.

* Migrate fuzzing to new CMake primitives

Rewrite firebase_ios_cc_fuzz_test to match the other primitives.

* Add firebase_ios_add_objc_test

* Migrate Example/Benchmarks to new CMake primitives
2020-04-20 10:28:36 -07:00
Gil e404054a9f Refactor and clean up the CMake build ahead of CMake/iOS support (#5051)
* Use early exit in objc_framework CMakeLists.txt

* Clean up objc_framework CMakeLists.txt

  * Use `version` consistently
  * Use `firebase_ios_version` for the repo-level version
  * Remove INCLUDE directories that are no longer needed
  * Sort dependencies

* Simplify Example/App/CMakeLists.txt

  * Add `OBJC_FLAGS` directly, avoiding a separate `sources` variable.
  * Add resources directly

* Rename test host app to firebase_firestore_example_app

* Add a firebase_ios prefix to functions and variables

This reduces the chance of collision with other projects.

* Simplify compiler_setup

Now that compiler_setup.cmake no longer has side-effects, fold
compiler_id.cmake and archive_options.cmake into it and move
the include of compiler_setup up to the top of the main build.
2020-03-10 20:50:13 -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 16447a5e2b Restrict use of Abseil types in public C++ accessible APIs (#4503)
* Change string parameters from absl::string_view to std::string

No abseil types can be used as parameters in this package.

This fixes an issue where Unity builds fail due to missing symbols.

The underlying issue is that Abseil in CocoaPods is an LTS release and
LTS releases contain an inline namespace, making types like
absl::string_view link as absl::lts_2019_08_08::string_view. When
compiling Firestore in google3 it uses the abseil in //third_party/absl,
which is not an LTS release and does not include the inline namespace.
This disagreement causes issues for the public C++ API which is compiled
in google3 and consumes code in the API package.

* Avoid absl::any in interfaces shared with public C++

* Make resource-related methods class members

This gives them access to private methods of friends of Serializer.

* Access control FieldPath/ResourcePath construction

* Access control Document construction

* Access control FieldValue construction

* Access control TransformOperation methods

* Remove DocumentSnapshot constructor that takes metadata pieces individually

* Restrict access to DocumentSnapshot from optional<Document>

* Add comments indicating how Abseil types are restricted

* Make DocumentKey::FromPathString take std::string
2019-12-17 11:32:48 -08:00
Gil 85365cb089 Get the remainder of Objective-C tests running under CMake (#4430)
* Add Objective-C API tests to the CMake build

* Fix signedness warnings under the CMake build

* Get the remainder of Objective-C tests running under CMake

Also:
  * Add a Path::HasExtension check
  * Change spec tests to pick up json without NSBundle
2019-12-06 10:11:05 -08:00
Gil 971445ce35 Add cross-platform support for creating Executors (#3897)
* Add Executor::CreateSerial

... a standard way to create an Executor for most cases where we don't
care about the implementation.

* Add ExecutorForTesting/AsyncQueueForTesting

Uses Executor::CreateSerial to do the heavy lifting.

* Use AsyncQueueForTesting

* Avoid direct references to ExecutorLibdispatch in prod code

* Rewrite time_testing in terms of absl::Time

* Migrate async_test_util's now to time_testing

* Fix AddressSanitizer stack-buffer-underflow error

This was reading random data off the stack until it hit a negative
integer's worth of data. The test passed because this was generating the
input and expected values, which were much longer than expected given
the input.
2019-09-26 10:41:36 -07:00
Gil 5cdff78f2b Migrate FSTView to C++ View (#3684)
* Add C++ ViewChange

* Migrate FSTViewChange to C++ ViewChange

* Add C++ View

* Migrate FSTView to C++ View
2019-08-26 19:39:54 -07:00
Gil dd7fbf885e Migrate FSTMutationTests to C++ (#3571)
* Tidy up mutation_test.cc ahead of filling it out

* Move FSTUserDataConverter tests out of FSTMutationTests

* Add operator<< for Document

The compiler won't apply the one for MaybeDocument.

* Port FSTMutationTests to C++

* Delete FSTMutationTests
2019-08-19 08:21:43 -07: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
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
Gil b673b2a82a Reimplement FSTFilter classes in terms of C++ Filter classes (#3348)
* Reimplement FSTNullFilter with core::NullFilter

* Reimplement FSTRelationFilter with model::RelationFilter

* Implement Filter equality
2019-07-15 08:09:22 -07:00
Gil 37affc1eb4 Have Firestore integration tests run all tests (#3342)
* Rename FIRQueryTests to FIRQueryUnitTests

* Make IntegrationTests targets run everything

The incremental cost of running all tests is an extra two seconds of run
time, but not starting the simulator three times during a build cuts
build times by ~25%.

* sync_project.rb generated changes

* sync_project.rb generated changes

* Remove AllTests_iOS aggregate target

* Add unit test deps to Firestore_IntegrationTests_*

* Fix BasicCompileTests on macOS and tvOS

* Run Firestore IntegrationTests only on Travis

This cuts build time for the job by about 25%, primarily due to not
having to start/deploy to the simulator repeatedly.
2019-07-12 15:57:03 -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
Konstantin Varlamov b645037a2e Fix small compilation and linter issues (#3222)
* remove C++11 library feature from `Timestamp` (which is supposed to be "portable");
* fix return type mismatch (`bool` vs `BOOL`);
* removed unused `using` declaration;
* fix typo in function name.
2019-06-19 20:13:27 -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 34fcd5af6b Migrate FSTTimestampValue to FSTDelegateValue (#3170) 2019-06-11 13:41:53 -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
Gil 220589d9bc Port FIRCollectionReference to C++ (#3126)
Also fix up DocumentReference to use it.
2019-06-04 18:10:17 -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
Gil 7d656705af Rewrite FieldValue tests to match the Android port (#3025)
* Split data conversion tests into FSTUserDataConverterTests

* Add TestUtil Value/Object to match Java

* Port Java FieldValue tests

* FieldValue::Map -> ObjectValue (#3047)
2019-05-21 17:56:42 -07:00
Gil 2a263eac83 Port FIRQuery to C++ (#2986) 2019-05-14 14:04:35 -07:00
Gil d53558c4c4 Use C++ three-way comparison in FSTQuery (#2885) 2019-04-25 11:11: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
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 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
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 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
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 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