Commit Graph
43 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
Gil 22b9c9006b Convert TransformOperations to polymorphic value types (#3567)
* Rename transform_operation{s,}

* Convert TransformOperation to a polymorphic value class

* fixup! Convert TransformOperation to a polymorphic value class

* Remove ServerTimestampTransform::Get
2019-08-16 07:23:57 -07:00
Gil 9c35050270 Migrate FSTMutation to C++ Mutations (#3564)
* Nontrivial edits

* Mostly mechanical edits

* Remove FSTMutation
2019-08-14 23:18:47 -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 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 7f1050ae27 Use C++ Timestamp internally instead of FIRTimestamp (#3156)
This is yet another preparatory step to migrating FIRTimetsampValue to
C++.
2019-06-11 10:56:28 -07:00
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
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 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
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
Gil 2e8b9181fa Port FSTUsageValidation to C++ (#2670)
* Port FSTUsageValidation to C++

* Add an error log level
2019-03-28 13:19:28 -07:00
Sebastian Schmidt 657f53a9b8 Adding FieldValue.increment() (#2075) 2019-03-06 14:51:30 -08: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
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
rsgowman 074de008b4 Rework FieldMask to use a (ordered) set of FieldPaths (#2136)
Rather than a vector.

Port of firebase/firebase-android-sdk#137
2019-01-02 12:02:16 -05:00
Sebastian Schmidt 08dede03ba Don't drop empty object during merge (#1851) 2018-09-19 14:43:08 -07: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 2813ac30da Fix analyze issues in Firestore (#1763)
* Fix analyzer errors in Firestore

* Add testutil to IntegrationTests
2018-08-29 12:09:52 -07:00
Gil 16f7be5864 Migrate nearly all usages of MakeStringView to MakeString (#1679) 2018-08-13 15:23:58 -07:00
Sebastian Schmidt d13a51abac Allowing field deletes using merge fields (#1389) 2018-06-07 13:57:01 -07:00
Gil 03d26a76a0 Remove nearly all usages of WrapNSStringNoCopy (#1351) 2018-05-30 10:24:40 -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
Gil fb0ba40c00 Remove extraneous braces (#1315) 2018-05-22 16:39:45 -07:00
Sebastian Schmidt 542d81ac68 Adding mergeFields support (#1141) 2018-05-02 11:10:19 -07:00
Michael Lehenbauer e36cc9610b Integration tests, changelog, and minor fixes for array transforms. (#1108) 2018-04-17 15:55:29 -07:00
Michael Lehenbauer f2ec9e11fb Serialize array transform mutations. (#1107)
* Serialize array transform mutations.
* Improve ArrayTransform constructor to avoid extra copying.
2018-04-17 15:07:25 -07: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
Michael Lehenbauer 60d43d7b09 Array Transforms public API and parsing
This includes the new FIRFieldValue sentinels, the FSTUserDataConverter code to parse them into internal ArrayTransform operations for use in an FSTTransformMutation, and some sanity testing in FSTMutationTests.

I still need to implement FSTTransformMutation support for local application and serialization (and then integration tests).
2018-04-13 14:22:41 -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
Michael Lehenbauer c2d4d3a9cf Small cleanup to UserDataConverter / FieldValue sentinel code to make adding more FieldValue sentinels easier. (#1077)
Port of https://github.com/firebase/firebase-js-sdk/commit/b14678002bf6e8cc9ebd7561efbafe29315ceb8e and https://github.com/firebase/firebase-js-sdk/commit/b14678002bf6e8cc9ebd7561efbafe29315ceb8e.
2018-04-12 13:50:02 -07:00
zxu 2ac778f312 Port FieldTransform to C++ (#1033)
* 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`

* address changes

* fix lint

* address changes
2018-04-10 16:28:22 -04:00
zxu db717bf670 Port transform operations to C++ (#1020)
* 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

* address change
2018-04-05 11:52:07 -04:00
zxu 5fa10a9143 port FieldMask to C++ (#998)
* port FieldMask to C++

* address changes

* address changes

* fix test

* address change

* fix lint

* address changes

* Revert "address changes"

This reverts commit c75bb42851.
2018-04-04 12:40:46 -04: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
Konstantin Varlamov 50f9df9240 Accept FIRTimestamp where NSDate is currently accepted as a parameter (#823) 2018-02-21 15:36:23 -05:00
Konstantin Varlamov 14ea068f5f Make FSTTimestamp into a public Firestore class (#698)
- FSTTimestamp is now FIRTimestamp, under Firestore/Source/{Public,API}. This is a temporary solution; eventually, FIRTimestamp is supposed to live somewhere under Firebase;
- move most internal Timestamp methods to the public header (the only exception is ISOString).
2018-02-20 17:33:57 -05:00
zxu a441190635 Implement Firestore DatabaseInfo and port both Database{Id,Info} C++ to the iOS code (#738)
* implement Firestore DatabaseInfo in C++

* temporary stash changes; blocking on the massive renaming of .m to .mm

* add database_info_test to project

* finish port DatabaseId and fix style, modular fixing DatabaseInfo

* port DatabaseInfo

* remove FSTDatabase{ID,Info} and their tests from project

* fix unit test

* use namespace alias

* use namespace alias, leftover

* address more changes

* refactoring to use raw pointer instead of value for property

* address changes

* remove self->

* fix style

* remove the name suffix Alloc

* fix a bug
2018-02-06 13:51:11 -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