From 09c75c4fb8269d74ccfdfaccb36ea9f7519efdb5 Mon Sep 17 00:00:00 2001 From: Gil Date: Wed, 11 Jul 2018 19:21:48 -0700 Subject: 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 --- .../firebase/firestore/local/local_serializer.cc | 32 ++++------------------ 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'Firestore/core/src/firebase') 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 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 no_document; - std::unique_ptr document; + std::unique_ptr result; while (reader->bytes_left()) { Tag tag = reader->ReadTag(); @@ -94,33 +90,21 @@ std::unique_ptr 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>( + result = reader->ReadNestedMessage>( [&](Reader* reader) -> std::unique_ptr { 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>( - [&](Reader* reader) { return DecodeNoDocument(reader); }); - break; - + result = reader->ReadNestedMessage>( + [&](Reader* reader) { return DecodeNoDocument(reader); }); break; default: @@ -129,16 +113,12 @@ std::unique_ptr 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, -- cgit v1.2.3