Commit Graph
11 Commits
Author SHA1 Message Date
Gil 60e37f32e2 Use three-way comparisons in C++ (#2884)
* Remove last traces of Objective-C from document_key.h

* Generalize empty base optimization into CompressedMember

Remove ComparatorHolder.

* Add Comparator<T>.Compare

This makes C++ more like the other platforms, where three-way comparison
is the default.

For now, don't remove the less-than definition of operator()--this
allows these comparators to be used in both circumstances.

* Remove KeyComparator

With the transition between less-than and three-way comparison adapting
this class isn't worth it.

While technically this is losing use of std::lower_bound, the
performance cost is negligible because these arrays are guaranteed to be
always small. This also makes ArraySortedMap work more like it does in
the other ports.

* Add Compare to the remaining Comparators

* Migrate remaining comparator usage in immuntable to three-way

* Use absl::bit_cast in comparison

* Make Comparable depend upon CompareTo.

* Use Comparable in more places

* Remove Comparator::operator()

* Move things around in comparison.h

Move:
  * Objective-C ComparisonResult functions nearer to others
  * DefaultComparator to above the first specializations

* Make Comparison on by default, delegating to CompareTo if available

* Move NSString Comparator into comparison.h

* Remove no longer required Comparator classes

* Make FieldValue support Comparable
2019-04-25 09:27:02 -07: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
Gil 16f7be5864 Migrate nearly all usages of MakeStringView to MakeString (#1679) 2018-08-13 15:23:58 -07:00
Konstantin Varlamov 0f0a1dab2d Eliminate unnecessary DocumentKey->FSTDocumentKey conversions (#1507) 2018-07-10 16:08:18 -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
Gil 04a28fce81 Make BasePath hash directly as a range (#1232)
Remove BasePath.Hash() Objective-C compatibility method
Make DocumentKey's hasher use BasePath's segment-based hash code.
2018-05-06 14:12:20 -07:00
Gil 0a66187053 Add lint checking for Objective-C++ sources (#1048)
* lint.sh now lints Objective-C++ too

* cpplint checks system-style includes that should be user-style

This prevents it from recognizing project sources as if they were C
system headers and then complaining that they're in the wrong place.

* cpplint checks #imports and #includes

* cpplint checks that C++ system headers aren't #imported

* cpplint checks for C system headers that could be C++ system headers

* cpplint checks that Objective-C sources include their headers
2018-04-09 11:54:39 -07:00
Bryan Klimt e78f9d41d3 Fix some formatting issues. 2018-03-27 16:50:32 -07:00
zxu 2d9d3a868c adding converters between DocumentKey (#900)
* 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
2018-03-15 11:31:16 -04:00
zxu 8311c6432e port paths to FSTDocumentKey (#877)
* replace path with C++ implementation in FSTDocumentKey.{h,mm} only

* address changes

* address changes
2018-03-06 14:28:04 -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