aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-07-11 19:21:48 -0700
committerGravatar GitHub <noreply@github.com>2018-07-11 19:21:48 -0700
commit09c75c4fb8269d74ccfdfaccb36ea9f7519efdb5 (patch)
tree529ef668b3bea1870e2f8305e848ef3dda9f5801 /Firestore/core/src/firebase
parent82ef0886bf89339bfe7a1855e697e61959eeb486 (diff)
Fix Firestore when compiled with Xcode 8.3 (#1519)
* Add a travis stage that tests building Firestore with Xcode 8.3. * Simulate on a device available in Xcode 8 * Fix compile errors under Xcode 8.3.3 * Remove Firestore_SwiftTests_iOS from the Firestore_Tests_iOS Scheme I'll create a new target for this but in another PR. * Add an entry to CHANGELOG.md
Diffstat (limited to 'Firestore/core/src/firebase')
-rw-r--r--Firestore/core/src/firebase/firestore/local/local_serializer.cc32
1 files changed, 6 insertions, 26 deletions
diff --git a/Firestore/core/src/firebase/firestore/local/local_serializer.cc b/Firestore/core/src/firebase/firestore/local/local_serializer.cc
index c549604..bdb2792 100644
--- a/Firestore/core/src/firebase/firestore/local/local_serializer.cc
+++ b/Firestore/core/src/firebase/firestore/local/local_serializer.cc
@@ -79,11 +79,7 @@ std::unique_ptr<model::MaybeDocument> LocalSerializer::DecodeMaybeDocument(
Reader* reader) const {
if (!reader->status().ok()) return nullptr;
- // Initialize MaybeDocument fields to their default values. (Due to the
- // 'oneof' in MaybeDocument, only one of 'no_document' or 'document' should
- // ever be set.)
- std::unique_ptr<model::NoDocument> no_document;
- std::unique_ptr<model::Document> document;
+ std::unique_ptr<model::MaybeDocument> result;
while (reader->bytes_left()) {
Tag tag = reader->ReadTag();
@@ -94,33 +90,21 @@ std::unique_ptr<model::MaybeDocument> LocalSerializer::DecodeMaybeDocument(
case firestore_client_MaybeDocument_document_tag:
if (!reader->RequireWireType(PB_WT_STRING, tag)) return nullptr;
- // 'no_document' and 'document' are part of a oneof. The proto docs
- // claim that if both are set on the wire, the last one wins.
- no_document = nullptr;
-
// TODO(rsgowman): If multiple 'document' values are found, we should
// merge them (rather than using the last one.)
- document = reader->ReadNestedMessage<std::unique_ptr<model::Document>>(
+ result = reader->ReadNestedMessage<std::unique_ptr<model::Document>>(
[&](Reader* reader) -> std::unique_ptr<model::Document> {
return rpc_serializer_.DecodeDocument(reader);
});
-
break;
case firestore_client_MaybeDocument_no_document_tag:
if (!reader->RequireWireType(PB_WT_STRING, tag)) return nullptr;
- // 'no_document' and 'document' are part of a oneof. The proto docs
- // claim that if both are set on the wire, the last one wins.
- document = nullptr;
-
// TODO(rsgowman): If multiple 'no_document' values are found, we should
// merge them (rather than using the last one.)
- no_document =
- reader->ReadNestedMessage<std::unique_ptr<model::NoDocument>>(
- [&](Reader* reader) { return DecodeNoDocument(reader); });
- break;
-
+ result = reader->ReadNestedMessage<std::unique_ptr<model::NoDocument>>(
+ [&](Reader* reader) { return DecodeNoDocument(reader); });
break;
default:
@@ -129,16 +113,12 @@ std::unique_ptr<model::MaybeDocument> LocalSerializer::DecodeMaybeDocument(
}
}
- if (no_document) {
- return no_document;
- } else if (document) {
- return document;
- } else {
+ if (!result) {
reader->set_status(Status(FirestoreErrorCode::DataLoss,
"Invalid MaybeDocument message: Neither "
"'no_document' nor 'document' fields set."));
- return nullptr;
}
+ return result;
}
void LocalSerializer::EncodeDocument(Writer* writer,