From 83c04eaf7f8fcc09492d08f277760223b937175c Mon Sep 17 00:00:00 2001 From: zxu123 Date: Wed, 3 Jan 2018 16:52:38 -0500 Subject: [PATCH 01/10] implement C++ assert (stdio, apple) --- .../firebase/firestore/util/CMakeLists.txt | 27 ++++- .../core/src/firebase/firestore/util/assert.h | 98 +++++++++++++++++++ .../firebase/firestore/util/assert_apple.mm | 55 +++++++++++ .../firebase/firestore/util/assert_stdio.cc | 43 ++++++++ .../firebase/firestore/util/CMakeLists.txt | 18 ++++ .../firebase/firestore/util/assert_test.cc | 64 ++++++++++++ 6 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 Firestore/core/src/firebase/firestore/util/assert.h create mode 100644 Firestore/core/src/firebase/firestore/util/assert_apple.mm create mode 100644 Firestore/core/src/firebase/firestore/util/assert_stdio.cc create mode 100644 Firestore/core/test/firebase/firestore/util/assert_test.cc diff --git a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt index d70397d5ca2..d98efd34701 100644 --- a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt +++ b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt @@ -24,22 +24,45 @@ add_library( log_stdio.cc ) -# log_apple can only built and tested on apple plaforms +# assert_stdio can be built and tested everywhere +add_library( + firebase_firestore_util_assert_stdio + assert_stdio.cc +) +target_link_libraries( + firebase_firestore_util_assert_stdio + firebase_firestore_util_log_stdio +) + +# log_apple and assert_apple can only built and tested on apple plaforms if(APPLE) add_library( firebase_firestore_util_log_apple log_apple.mm ) + add_library( + firebase_firestore_util_assert_apple + assert_apple.mm + ) target_compile_options( firebase_firestore_util_log_apple PRIVATE ${OBJC_FLAGS} ) + target_compile_options( + firebase_firestore_util_assert_apple + PRIVATE + ${OBJC_FLAGS} + ) target_link_libraries( firebase_firestore_util_log_apple PUBLIC FirebaseCore ) + target_link_libraries( + firebase_firestore_util_assert_apple + firebase_firestore_util_log_apple + ) endif(APPLE) # Export a dependency on the correct logging library for this platform. All @@ -48,6 +71,7 @@ if(APPLE) target_link_libraries( firebase_firestore_util PUBLIC + firebase_firestore_util_assert_apple firebase_firestore_util_log_apple ) @@ -55,6 +79,7 @@ else(NOT APPLE) target_link_libraries( firebase_firestore_util PUBLIC + firebase_firestore_util_assert_stdio firebase_firestore_util_log_stdio ) diff --git a/Firestore/core/src/firebase/firestore/util/assert.h b/Firestore/core/src/firebase/firestore/util/assert.h new file mode 100644 index 00000000000..9ed32c09b05 --- /dev/null +++ b/Firestore/core/src/firebase/firestore/util/assert.h @@ -0,0 +1,98 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_ASSERT_H_ +#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_ASSERT_H_ + +#include +#include "Firestore/core/src/firebase/firestore/util/log.h" + +#define FIREBASE_EXPAND_STRINGIFY_(X) #X +#define FIREBASE_EXPAND_STRINGIFY(X) FIREBASE_EXPAND_STRINGIFY_(X) + +// FIREBASE_ASSERT_* macros are not compiled out of release builds. They should +// be used for assertions that need to be propagated to end-users of SDKs. +// FIREBASE_DEV_ASSERT_* macros are compiled out of release builds, similar to +// the C assert() macro. They should be used for internal assertions that are +// only shown to SDK developers. + +// Assert condition is true, if it's false log an assert with the specified +// expression as a string. +#define FIREBASE_ASSERT_WITH_EXPRESSION(condition, expression) \ + do { \ + if (!(condition)) { \ + firebase::firestore::util::FailAssert( \ + __FILE__, __PRETTY_FUNCTION__, __LINE__, \ + FIREBASE_EXPAND_STRINGIFY(expression)); \ + } \ + } while(0) + +// Assert condition is true, if it's false log an assert with the specified +// expression as a string. Compiled out of release builds. +#if !defined(NDEBUG) +#define FIREBASE_DEV_ASSERT_WITH_EXPRESSION(condition, expression) \ + FIREBASE_ASSERT_WITH_EXPRESSION(condition, expression) +#else +#define FIREBASE_DEV_ASSERT_WITH_EXPRESSION(condition, expression) \ + { (void)(condition); } +#endif // !defined(NDEBUG) + +// Custom assert() implementation that is not compiled out in release builds. +#define FIREBASE_ASSERT(expression) \ + FIREBASE_ASSERT_WITH_EXPRESSION(expression, expression) + +// Custom assert() implementation that is compiled out in release builds. +// Compiled out of release builds. +#define FIREBASE_DEV_ASSERT(expression) \ + FIREBASE_DEV_ASSERT_WITH_EXPRESSION(expression, expression) + +// Assert condition is true otherwise display the specified expression, +// message and abort. +#define FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, ...) \ + do { \ + if (!(condition)) { \ + firebase::firestore::util::LogError( \ + FIREBASE_EXPAND_STRINGIFY(expression)); \ + firebase::firestore::util::FailAssert( \ + __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__); \ + } \ + } while(0) + +// Assert condition is true otherwise display the specified expression, +// message and abort. Compiled out of release builds. +#if !defined(NDEBUG) +#define FIREBASE_DEV_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, \ + ...) \ + FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, __VA_ARGS__) +#else +#define FIREBASE_DEV_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, \ + ...) \ + { (void)(condition); } +#endif // !defined(NDEBUG) + +namespace firebase { +namespace firestore { +namespace util { + +// A no-return helper function. To raise an assertion, use Macro instead. +void FailAssert(const char* file, const char* func, const int line, + const char* format, ...); + +} // namespace util +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_ASSERT_H_ diff --git a/Firestore/core/src/firebase/firestore/util/assert_apple.mm b/Firestore/core/src/firebase/firestore/util/assert_apple.mm new file mode 100644 index 00000000000..511bf5802e4 --- /dev/null +++ b/Firestore/core/src/firebase/firestore/util/assert_apple.mm @@ -0,0 +1,55 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Firestore/core/src/firebase/firestore/util/assert.h" + +#import + +#include + +namespace firebase { +namespace firestore { +namespace util { + +namespace { + +// Translates a C format string to the equivalent NSString without making a +// copy. +NSString* CStringToNSString(const char* format) { + return [[NSString alloc] initWithBytesNoCopy:(void*)format + length:strlen(format) + encoding:NSUTF8StringEncoding + freeWhenDone:NO]; +} + +} // namespace + +void FailAssert(const char* file, const char* func, const int line, const char* format, ...) { + va_list args; + va_start(args, format); + NSString *description = [[NSString alloc] initWithFormat:CStringToNSString(format) arguments:args]; + va_end(args); + [[NSAssertionHandler currentHandler] + handleFailureInFunction:CStringToNSString(func) + file:CStringToNSString(file) + lineNumber:line + description:@"FIRESTORE INTERNAL ASSERTION FAILED: %@", description]; + abort(); +} + +} // namespace util +} // namespace firestore +} // namespace firebase diff --git a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc new file mode 100644 index 00000000000..cfa4206bc62 --- /dev/null +++ b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc @@ -0,0 +1,43 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Firestore/core/src/firebase/firestore/util/assert.h" + +#include +#include + +#include +#include + +namespace firebase { +namespace firestore { +namespace util { + +void FailAssert(const char* file, const char* func, const int line, + const char* format, ...) { + fprintf(stderr, "ASSERT: %s(%d) %s: ", file, line, func); + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + fprintf(stderr, "\n"); + throw std::exception(); + abort(); +} + +} // namespace util +} // namespace firestore +} // namespace firebase diff --git a/Firestore/core/test/firebase/firestore/util/CMakeLists.txt b/Firestore/core/test/firebase/firestore/util/CMakeLists.txt index 42c4dcce9ab..346c1e59d81 100644 --- a/Firestore/core/test/firebase/firestore/util/CMakeLists.txt +++ b/Firestore/core/test/firebase/firestore/util/CMakeLists.txt @@ -31,6 +31,14 @@ if(APPLE) firebase_firestore_util_log_apple_test firebase_firestore_util_log_apple ) + cc_test( + firebase_firestore_util_assert_apple_test + assert_test.cc + ) + target_link_libraries( + firebase_firestore_util_assert_apple_test + firebase_firestore_util_assert_apple + ) endif(APPLE) cc_test( @@ -41,3 +49,13 @@ target_link_libraries( firebase_firestore_util_log_stdio_test firebase_firestore_util_log_stdio ) + +cc_test( + firebase_firestore_util_assert_stdio_test + assert_test.cc +) +target_link_libraries( + firebase_firestore_util_assert_stdio_test + firebase_firestore_util_assert_stdio +) + diff --git a/Firestore/core/test/firebase/firestore/util/assert_test.cc b/Firestore/core/test/firebase/firestore/util/assert_test.cc new file mode 100644 index 00000000000..0babb759867 --- /dev/null +++ b/Firestore/core/test/firebase/firestore/util/assert_test.cc @@ -0,0 +1,64 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Firestore/core/src/firebase/firestore/util/assert.h" + +#include + +#include "gtest/gtest.h" + +namespace firebase { +namespace firestore { +namespace util { + +namespace { + +void AssertWithExpression(bool condition) { + FIREBASE_ASSERT_WITH_EXPRESSION(condition, 1 + 2 + 3); +} + +void Assert(bool condition) { + FIREBASE_ASSERT(condition == true); +} + +void AssertMessageWithExpression(bool condition) { + FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(condition, 1 + 2 + 3, "connection %s", + condition ? "succeeded" : "failed"); +} + +} // namespace + +TEST(Assert, WithExpression) { + AssertWithExpression(true); + + EXPECT_ANY_THROW(AssertWithExpression(false)); +} + +TEST(Assert, Vanilla) { + Assert(true); + + EXPECT_ANY_THROW(Assert(false)); +} + +TEST(Assert, WithMessageAndExpression) { + AssertMessageWithExpression(true); + + EXPECT_ANY_THROW(AssertMessageWithExpression(false)); +} + +} // namespace util +} // namespace firestore +} // namespace firebase From 07aebfb2faf547463be760272c3093d87cf42146 Mon Sep 17 00:00:00 2001 From: zxu123 Date: Thu, 4 Jan 2018 16:56:04 -0500 Subject: [PATCH 02/10] use use_headermap => no --- FirebaseFirestore.podspec | 9 ++++++++- Firestore/Source/API/FIRCollectionReference+Internal.h | 2 +- Firestore/Source/API/FIRCollectionReference.mm | 3 ++- Firestore/Source/API/FIRDocumentChange+Internal.h | 2 +- Firestore/Source/API/FIRDocumentChange.m | 2 +- Firestore/Source/API/FIRDocumentReference+Internal.h | 2 +- Firestore/Source/API/FIRDocumentReference.m | 6 +++--- Firestore/Source/API/FIRDocumentSnapshot+Internal.h | 2 +- Firestore/Source/API/FIRDocumentSnapshot.m | 2 +- Firestore/Source/API/FIRFieldPath+Internal.h | 2 +- Firestore/Source/API/FIRFieldValue+Internal.h | 2 +- Firestore/Source/API/FIRFirestore+Internal.h | 2 +- Firestore/Source/API/FIRFirestore.m | 4 ++-- Firestore/Source/API/FIRFirestoreSettings.m | 2 +- Firestore/Source/API/FIRGeoPoint+Internal.h | 2 +- Firestore/Source/API/FIRListenerRegistration+Internal.h | 2 +- Firestore/Source/API/FIRQuery+Internal.h | 2 +- Firestore/Source/API/FIRQuery.m | 4 ++-- Firestore/Source/API/FIRQuerySnapshot+Internal.h | 2 +- Firestore/Source/API/FIRQuerySnapshot.m | 2 +- Firestore/Source/API/FIRQuery_Init.h | 2 +- Firestore/Source/API/FIRSetOptions+Internal.h | 2 +- Firestore/Source/API/FIRSnapshotMetadata+Internal.h | 2 +- Firestore/Source/API/FIRSnapshotMetadata.m | 2 +- Firestore/Source/API/FIRTransaction+Internal.h | 2 +- Firestore/Source/API/FIRWriteBatch+Internal.h | 2 +- Firestore/Source/API/FSTUserDataConverter.m | 2 +- Firestore/Source/Auth/FSTCredentialsProvider.m | 2 +- Firestore/Source/Core/FSTSyncEngine.m | 2 +- Firestore/Source/Core/FSTTransaction.m | 4 ++-- Firestore/Source/Local/FSTLevelDB.mm | 2 +- Firestore/Source/Remote/FSTDatastore.m | 2 +- Firestore/Source/Remote/FSTSerializerBeta.m | 4 ++-- Firestore/Source/Remote/FSTStream.m | 2 +- 34 files changed, 48 insertions(+), 40 deletions(-) diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index 5a3a1d639cd..df65fa531bb 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -62,7 +62,14 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'GCC_PREPROCESSOR_DEFINITIONS' => 'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 ', 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}" ' + + '"${PODS_TARGET_SRCROOT}/Firebase/Core/Private" ' + + '"${PODS_TARGET_SRCROOT}/Firebase/Core/Public" ' + + '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc" ' + + '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc/google/api" ' + + '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc/google/rpc" ' + + '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc/google/type" ' + '"${PODS_TARGET_SRCROOT}/Firestore/third_party/abseil-cpp"', - 'OTHER_CFLAGS' => '-DFIRFirestore_VERSION=' + s.version.to_s + 'OTHER_CFLAGS' => '-DFIRFirestore_VERSION=' + s.version.to_s, + 'USE_HEADERMAP' => 'NO' } end diff --git a/Firestore/Source/API/FIRCollectionReference+Internal.h b/Firestore/Source/API/FIRCollectionReference+Internal.h index 1d00cbbadb0..165152ce83d 100644 --- a/Firestore/Source/API/FIRCollectionReference+Internal.h +++ b/Firestore/Source/API/FIRCollectionReference+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRCollectionReference.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRCollectionReference.mm b/Firestore/Source/API/FIRCollectionReference.mm index 92cccc6c860..5a439fa7eff 100644 --- a/Firestore/Source/API/FIRCollectionReference.mm +++ b/Firestore/Source/API/FIRCollectionReference.mm @@ -14,7 +14,8 @@ * limitations under the License. */ -#import "FIRCollectionReference.h" +#import +#import #include "Firestore/core/src/firebase/firestore/util/autoid.h" diff --git a/Firestore/Source/API/FIRDocumentChange+Internal.h b/Firestore/Source/API/FIRDocumentChange+Internal.h index 7e2e5c61d21..3a1bd3b165c 100644 --- a/Firestore/Source/API/FIRDocumentChange+Internal.h +++ b/Firestore/Source/API/FIRDocumentChange+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRDocumentChange.h" +#import @class FSTViewSnapshot; diff --git a/Firestore/Source/API/FIRDocumentChange.m b/Firestore/Source/API/FIRDocumentChange.m index 970dc90b36e..e6d67545816 100644 --- a/Firestore/Source/API/FIRDocumentChange.m +++ b/Firestore/Source/API/FIRDocumentChange.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRDocumentChange.h" +#import #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" #import "Firestore/Source/Core/FSTQuery.h" diff --git a/Firestore/Source/API/FIRDocumentReference+Internal.h b/Firestore/Source/API/FIRDocumentReference+Internal.h index 5e12ddc48d3..e1c2f4104d0 100644 --- a/Firestore/Source/API/FIRDocumentReference+Internal.h +++ b/Firestore/Source/API/FIRDocumentReference+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRDocumentReference.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRDocumentReference.m b/Firestore/Source/API/FIRDocumentReference.m index 1c80ea9ab88..26e89f9d980 100644 --- a/Firestore/Source/API/FIRDocumentReference.m +++ b/Firestore/Source/API/FIRDocumentReference.m @@ -14,12 +14,12 @@ * limitations under the License. */ -#import "FIRDocumentReference.h" +#import #import -#import "FIRFirestoreErrors.h" -#import "FIRSnapshotMetadata.h" +#import +#import #import "Firestore/Source/API/FIRCollectionReference+Internal.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" diff --git a/Firestore/Source/API/FIRDocumentSnapshot+Internal.h b/Firestore/Source/API/FIRDocumentSnapshot+Internal.h index f2776f0b923..5bc8b5fa3f4 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot+Internal.h +++ b/Firestore/Source/API/FIRDocumentSnapshot+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRDocumentSnapshot.h" +#import @class FIRFirestore; @class FSTDocument; diff --git a/Firestore/Source/API/FIRDocumentSnapshot.m b/Firestore/Source/API/FIRDocumentSnapshot.m index b78472e8baf..d7430539437 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot.m +++ b/Firestore/Source/API/FIRDocumentSnapshot.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRDocumentSnapshot.h" +#import #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFieldPath+Internal.h" diff --git a/Firestore/Source/API/FIRFieldPath+Internal.h b/Firestore/Source/API/FIRFieldPath+Internal.h index 227cdad7192..83a42933abb 100644 --- a/Firestore/Source/API/FIRFieldPath+Internal.h +++ b/Firestore/Source/API/FIRFieldPath+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRFieldPath.h" +#import @class FSTFieldPath; diff --git a/Firestore/Source/API/FIRFieldValue+Internal.h b/Firestore/Source/API/FIRFieldValue+Internal.h index 1b4a99cd2a3..e1038304eb1 100644 --- a/Firestore/Source/API/FIRFieldValue+Internal.h +++ b/Firestore/Source/API/FIRFieldValue+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRFieldValue.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRFirestore+Internal.h b/Firestore/Source/API/FIRFirestore+Internal.h index c2e995a9481..18844e26840 100644 --- a/Firestore/Source/API/FIRFirestore+Internal.h +++ b/Firestore/Source/API/FIRFirestore+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRFirestore.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRFirestore.m b/Firestore/Source/API/FIRFirestore.m index 7814ce160c6..d2058b39acc 100644 --- a/Firestore/Source/API/FIRFirestore.m +++ b/Firestore/Source/API/FIRFirestore.m @@ -14,13 +14,13 @@ * limitations under the License. */ -#import "FIRFirestore.h" +#import #import #import #import -#import "FIRFirestoreSettings.h" +#import #import "Firestore/Source/API/FIRCollectionReference+Internal.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFirestore+Internal.h" diff --git a/Firestore/Source/API/FIRFirestoreSettings.m b/Firestore/Source/API/FIRFirestoreSettings.m index 9677ff6b451..1d429f7891f 100644 --- a/Firestore/Source/API/FIRFirestoreSettings.m +++ b/Firestore/Source/API/FIRFirestoreSettings.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRFirestoreSettings.h" +#import #import "Firestore/Source/Util/FSTUsageValidation.h" diff --git a/Firestore/Source/API/FIRGeoPoint+Internal.h b/Firestore/Source/API/FIRGeoPoint+Internal.h index 6eb85483bc1..50e7fac807a 100644 --- a/Firestore/Source/API/FIRGeoPoint+Internal.h +++ b/Firestore/Source/API/FIRGeoPoint+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRGeoPoint.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRListenerRegistration+Internal.h b/Firestore/Source/API/FIRListenerRegistration+Internal.h index 4cd2d579364..6403d0bea32 100644 --- a/Firestore/Source/API/FIRListenerRegistration+Internal.h +++ b/Firestore/Source/API/FIRListenerRegistration+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRListenerRegistration.h" +#import @class FSTAsyncQueryListener; @class FSTFirestoreClient; diff --git a/Firestore/Source/API/FIRQuery+Internal.h b/Firestore/Source/API/FIRQuery+Internal.h index 3c2b2a7331c..7c434efffdf 100644 --- a/Firestore/Source/API/FIRQuery+Internal.h +++ b/Firestore/Source/API/FIRQuery+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRQuery.h" +#import @class FSTQuery; diff --git a/Firestore/Source/API/FIRQuery.m b/Firestore/Source/API/FIRQuery.m index 12e79c57889..14dad7c9142 100644 --- a/Firestore/Source/API/FIRQuery.m +++ b/Firestore/Source/API/FIRQuery.m @@ -14,9 +14,9 @@ * limitations under the License. */ -#import "FIRQuery.h" +#import -#import "FIRDocumentReference.h" +#import #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" #import "Firestore/Source/API/FIRFieldPath+Internal.h" diff --git a/Firestore/Source/API/FIRQuerySnapshot+Internal.h b/Firestore/Source/API/FIRQuerySnapshot+Internal.h index 3a1e9dbf609..f588425d213 100644 --- a/Firestore/Source/API/FIRQuerySnapshot+Internal.h +++ b/Firestore/Source/API/FIRQuerySnapshot+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRQuerySnapshot.h" +#import @class FIRFirestore; @class FIRSnapshotMetadata; diff --git a/Firestore/Source/API/FIRQuerySnapshot.m b/Firestore/Source/API/FIRQuerySnapshot.m index 6bc6761970b..04a597b094d 100644 --- a/Firestore/Source/API/FIRQuerySnapshot.m +++ b/Firestore/Source/API/FIRQuerySnapshot.m @@ -16,7 +16,7 @@ #import "Firestore/Source/API/FIRQuerySnapshot+Internal.h" -#import "FIRSnapshotMetadata.h" +#import #import "Firestore/Source/API/FIRDocumentChange+Internal.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" #import "Firestore/Source/API/FIRQuery+Internal.h" diff --git a/Firestore/Source/API/FIRQuery_Init.h b/Firestore/Source/API/FIRQuery_Init.h index d6b0f37495b..994973850a5 100644 --- a/Firestore/Source/API/FIRQuery_Init.h +++ b/Firestore/Source/API/FIRQuery_Init.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRQuery.h" +#import @class FSTQuery; diff --git a/Firestore/Source/API/FIRSetOptions+Internal.h b/Firestore/Source/API/FIRSetOptions+Internal.h index 91180961d21..d4cf8c14bc7 100644 --- a/Firestore/Source/API/FIRSetOptions+Internal.h +++ b/Firestore/Source/API/FIRSetOptions+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRSetOptions.h" +#import NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRSnapshotMetadata+Internal.h b/Firestore/Source/API/FIRSnapshotMetadata+Internal.h index d3265cd0959..3612eefeb16 100644 --- a/Firestore/Source/API/FIRSnapshotMetadata+Internal.h +++ b/Firestore/Source/API/FIRSnapshotMetadata+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRSnapshotMetadata.h" +#import #import diff --git a/Firestore/Source/API/FIRSnapshotMetadata.m b/Firestore/Source/API/FIRSnapshotMetadata.m index 224015f0a88..85959706da4 100644 --- a/Firestore/Source/API/FIRSnapshotMetadata.m +++ b/Firestore/Source/API/FIRSnapshotMetadata.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRSnapshotMetadata.h" +#import #import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h" diff --git a/Firestore/Source/API/FIRTransaction+Internal.h b/Firestore/Source/API/FIRTransaction+Internal.h index 8fd3f65e333..7bd02068d62 100644 --- a/Firestore/Source/API/FIRTransaction+Internal.h +++ b/Firestore/Source/API/FIRTransaction+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRTransaction.h" +#import @class FIRFirestore; @class FSTTransaction; diff --git a/Firestore/Source/API/FIRWriteBatch+Internal.h b/Firestore/Source/API/FIRWriteBatch+Internal.h index a434e02b4c1..07ffa2b7f5a 100644 --- a/Firestore/Source/API/FIRWriteBatch+Internal.h +++ b/Firestore/Source/API/FIRWriteBatch+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import "FIRWriteBatch.h" +#import @class FIRFirestore; diff --git a/Firestore/Source/API/FSTUserDataConverter.m b/Firestore/Source/API/FSTUserDataConverter.m index 414aadbe3ca..d0d071d27ff 100644 --- a/Firestore/Source/API/FSTUserDataConverter.m +++ b/Firestore/Source/API/FSTUserDataConverter.m @@ -16,7 +16,7 @@ #import "Firestore/Source/API/FSTUserDataConverter.h" -#import "FIRGeoPoint.h" +#import #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFieldPath+Internal.h" #import "Firestore/Source/API/FIRFieldValue+Internal.h" diff --git a/Firestore/Source/Auth/FSTCredentialsProvider.m b/Firestore/Source/Auth/FSTCredentialsProvider.m index 653d7ff2c45..e2ee7f2ee4b 100644 --- a/Firestore/Source/Auth/FSTCredentialsProvider.m +++ b/Firestore/Source/Auth/FSTCredentialsProvider.m @@ -20,7 +20,7 @@ #import #import -#import "FIRFirestoreErrors.h" +#import #import "Firestore/Source/Auth/FSTUser.h" #import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Source/Util/FSTClasses.h" diff --git a/Firestore/Source/Core/FSTSyncEngine.m b/Firestore/Source/Core/FSTSyncEngine.m index 98658e47e6a..8f86016063d 100644 --- a/Firestore/Source/Core/FSTSyncEngine.m +++ b/Firestore/Source/Core/FSTSyncEngine.m @@ -18,7 +18,7 @@ #import -#import "FIRFirestoreErrors.h" +#import #import "Firestore/Source/Auth/FSTUser.h" #import "Firestore/Source/Core/FSTQuery.h" #import "Firestore/Source/Core/FSTSnapshotVersion.h" diff --git a/Firestore/Source/Core/FSTTransaction.m b/Firestore/Source/Core/FSTTransaction.m index c4c5f27846c..2a3faf0c9ec 100644 --- a/Firestore/Source/Core/FSTTransaction.m +++ b/Firestore/Source/Core/FSTTransaction.m @@ -18,8 +18,8 @@ #import -#import "FIRFirestoreErrors.h" -#import "FIRSetOptions.h" +#import +#import #import "Firestore/Source/API/FSTUserDataConverter.h" #import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Model/FSTDocument.h" diff --git a/Firestore/Source/Local/FSTLevelDB.mm b/Firestore/Source/Local/FSTLevelDB.mm index fb1c81a4fd0..eba66bfbe3e 100644 --- a/Firestore/Source/Local/FSTLevelDB.mm +++ b/Firestore/Source/Local/FSTLevelDB.mm @@ -18,7 +18,7 @@ #include -#import "FIRFirestoreErrors.h" +#import #import "Firestore/Source/Core/FSTDatabaseInfo.h" #import "Firestore/Source/Local/FSTLevelDBMutationQueue.h" #import "Firestore/Source/Local/FSTLevelDBQueryCache.h" diff --git a/Firestore/Source/Remote/FSTDatastore.m b/Firestore/Source/Remote/FSTDatastore.m index 02d868c1900..ab8b5c01d96 100644 --- a/Firestore/Source/Remote/FSTDatastore.m +++ b/Firestore/Source/Remote/FSTDatastore.m @@ -19,7 +19,7 @@ #import #import -#import "FIRFirestoreErrors.h" +#import #import "Firestore/Source/API/FIRFirestore+Internal.h" #import "Firestore/Source/API/FIRFirestoreVersion.h" #import "Firestore/Source/Auth/FSTCredentialsProvider.h" diff --git a/Firestore/Source/Remote/FSTSerializerBeta.m b/Firestore/Source/Remote/FSTSerializerBeta.m index 04785c263e9..f464e73ebbe 100644 --- a/Firestore/Source/Remote/FSTSerializerBeta.m +++ b/Firestore/Source/Remote/FSTSerializerBeta.m @@ -26,8 +26,8 @@ #import "Firestore/Protos/objc/google/rpc/Status.pbobjc.h" #import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h" -#import "FIRFirestoreErrors.h" -#import "FIRGeoPoint.h" +#import +#import #import "Firestore/Source/Core/FSTQuery.h" #import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Core/FSTTimestamp.h" diff --git a/Firestore/Source/Remote/FSTStream.m b/Firestore/Source/Remote/FSTStream.m index 2c039be4e40..69444f07063 100644 --- a/Firestore/Source/Remote/FSTStream.m +++ b/Firestore/Source/Remote/FSTStream.m @@ -19,7 +19,7 @@ #import #import -#import "FIRFirestoreErrors.h" +#import #import "Firestore/Source/API/FIRFirestore+Internal.h" #import "Firestore/Source/Auth/FSTCredentialsProvider.h" #import "Firestore/Source/Core/FSTDatabaseInfo.h" From 93751a069bd2ea418381f7a7728163dad27c0520 Mon Sep 17 00:00:00 2001 From: zxu123 Date: Mon, 8 Jan 2018 09:48:13 -0800 Subject: [PATCH 03/10] Revert "use use_headermap => no" This reverts commit 07aebfb2faf547463be760272c3093d87cf42146. --- FirebaseFirestore.podspec | 9 +-------- Firestore/Source/API/FIRCollectionReference+Internal.h | 2 +- Firestore/Source/API/FIRCollectionReference.mm | 3 +-- Firestore/Source/API/FIRDocumentChange+Internal.h | 2 +- Firestore/Source/API/FIRDocumentChange.m | 2 +- Firestore/Source/API/FIRDocumentReference+Internal.h | 2 +- Firestore/Source/API/FIRDocumentReference.m | 6 +++--- Firestore/Source/API/FIRDocumentSnapshot+Internal.h | 2 +- Firestore/Source/API/FIRDocumentSnapshot.m | 2 +- Firestore/Source/API/FIRFieldPath+Internal.h | 2 +- Firestore/Source/API/FIRFieldValue+Internal.h | 2 +- Firestore/Source/API/FIRFirestore+Internal.h | 2 +- Firestore/Source/API/FIRFirestore.m | 4 ++-- Firestore/Source/API/FIRFirestoreSettings.m | 2 +- Firestore/Source/API/FIRGeoPoint+Internal.h | 2 +- Firestore/Source/API/FIRListenerRegistration+Internal.h | 2 +- Firestore/Source/API/FIRQuery+Internal.h | 2 +- Firestore/Source/API/FIRQuery.m | 4 ++-- Firestore/Source/API/FIRQuerySnapshot+Internal.h | 2 +- Firestore/Source/API/FIRQuerySnapshot.m | 2 +- Firestore/Source/API/FIRQuery_Init.h | 2 +- Firestore/Source/API/FIRSetOptions+Internal.h | 2 +- Firestore/Source/API/FIRSnapshotMetadata+Internal.h | 2 +- Firestore/Source/API/FIRSnapshotMetadata.m | 2 +- Firestore/Source/API/FIRTransaction+Internal.h | 2 +- Firestore/Source/API/FIRWriteBatch+Internal.h | 2 +- Firestore/Source/API/FSTUserDataConverter.m | 2 +- Firestore/Source/Auth/FSTCredentialsProvider.m | 2 +- Firestore/Source/Core/FSTSyncEngine.m | 2 +- Firestore/Source/Core/FSTTransaction.m | 4 ++-- Firestore/Source/Local/FSTLevelDB.mm | 2 +- Firestore/Source/Remote/FSTDatastore.m | 2 +- Firestore/Source/Remote/FSTSerializerBeta.m | 4 ++-- Firestore/Source/Remote/FSTStream.m | 2 +- 34 files changed, 40 insertions(+), 48 deletions(-) diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index df65fa531bb..5a3a1d639cd 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -62,14 +62,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'GCC_PREPROCESSOR_DEFINITIONS' => 'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 ', 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}" ' + - '"${PODS_TARGET_SRCROOT}/Firebase/Core/Private" ' + - '"${PODS_TARGET_SRCROOT}/Firebase/Core/Public" ' + - '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc" ' + - '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc/google/api" ' + - '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc/google/rpc" ' + - '"${PODS_TARGET_SRCROOT}/Firestore/Protos/objc/google/type" ' + '"${PODS_TARGET_SRCROOT}/Firestore/third_party/abseil-cpp"', - 'OTHER_CFLAGS' => '-DFIRFirestore_VERSION=' + s.version.to_s, - 'USE_HEADERMAP' => 'NO' + 'OTHER_CFLAGS' => '-DFIRFirestore_VERSION=' + s.version.to_s } end diff --git a/Firestore/Source/API/FIRCollectionReference+Internal.h b/Firestore/Source/API/FIRCollectionReference+Internal.h index 165152ce83d..1d00cbbadb0 100644 --- a/Firestore/Source/API/FIRCollectionReference+Internal.h +++ b/Firestore/Source/API/FIRCollectionReference+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRCollectionReference.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRCollectionReference.mm b/Firestore/Source/API/FIRCollectionReference.mm index 5a439fa7eff..92cccc6c860 100644 --- a/Firestore/Source/API/FIRCollectionReference.mm +++ b/Firestore/Source/API/FIRCollectionReference.mm @@ -14,8 +14,7 @@ * limitations under the License. */ -#import -#import +#import "FIRCollectionReference.h" #include "Firestore/core/src/firebase/firestore/util/autoid.h" diff --git a/Firestore/Source/API/FIRDocumentChange+Internal.h b/Firestore/Source/API/FIRDocumentChange+Internal.h index 3a1bd3b165c..7e2e5c61d21 100644 --- a/Firestore/Source/API/FIRDocumentChange+Internal.h +++ b/Firestore/Source/API/FIRDocumentChange+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRDocumentChange.h" @class FSTViewSnapshot; diff --git a/Firestore/Source/API/FIRDocumentChange.m b/Firestore/Source/API/FIRDocumentChange.m index e6d67545816..970dc90b36e 100644 --- a/Firestore/Source/API/FIRDocumentChange.m +++ b/Firestore/Source/API/FIRDocumentChange.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRDocumentChange.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" #import "Firestore/Source/Core/FSTQuery.h" diff --git a/Firestore/Source/API/FIRDocumentReference+Internal.h b/Firestore/Source/API/FIRDocumentReference+Internal.h index e1c2f4104d0..5e12ddc48d3 100644 --- a/Firestore/Source/API/FIRDocumentReference+Internal.h +++ b/Firestore/Source/API/FIRDocumentReference+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRDocumentReference.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRDocumentReference.m b/Firestore/Source/API/FIRDocumentReference.m index 26e89f9d980..1c80ea9ab88 100644 --- a/Firestore/Source/API/FIRDocumentReference.m +++ b/Firestore/Source/API/FIRDocumentReference.m @@ -14,12 +14,12 @@ * limitations under the License. */ -#import +#import "FIRDocumentReference.h" #import -#import -#import +#import "FIRFirestoreErrors.h" +#import "FIRSnapshotMetadata.h" #import "Firestore/Source/API/FIRCollectionReference+Internal.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" diff --git a/Firestore/Source/API/FIRDocumentSnapshot+Internal.h b/Firestore/Source/API/FIRDocumentSnapshot+Internal.h index 5bc8b5fa3f4..f2776f0b923 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot+Internal.h +++ b/Firestore/Source/API/FIRDocumentSnapshot+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRDocumentSnapshot.h" @class FIRFirestore; @class FSTDocument; diff --git a/Firestore/Source/API/FIRDocumentSnapshot.m b/Firestore/Source/API/FIRDocumentSnapshot.m index d7430539437..b78472e8baf 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot.m +++ b/Firestore/Source/API/FIRDocumentSnapshot.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRDocumentSnapshot.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFieldPath+Internal.h" diff --git a/Firestore/Source/API/FIRFieldPath+Internal.h b/Firestore/Source/API/FIRFieldPath+Internal.h index 83a42933abb..227cdad7192 100644 --- a/Firestore/Source/API/FIRFieldPath+Internal.h +++ b/Firestore/Source/API/FIRFieldPath+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRFieldPath.h" @class FSTFieldPath; diff --git a/Firestore/Source/API/FIRFieldValue+Internal.h b/Firestore/Source/API/FIRFieldValue+Internal.h index e1038304eb1..1b4a99cd2a3 100644 --- a/Firestore/Source/API/FIRFieldValue+Internal.h +++ b/Firestore/Source/API/FIRFieldValue+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRFieldValue.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRFirestore+Internal.h b/Firestore/Source/API/FIRFirestore+Internal.h index 18844e26840..c2e995a9481 100644 --- a/Firestore/Source/API/FIRFirestore+Internal.h +++ b/Firestore/Source/API/FIRFirestore+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRFirestore.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRFirestore.m b/Firestore/Source/API/FIRFirestore.m index d2058b39acc..7814ce160c6 100644 --- a/Firestore/Source/API/FIRFirestore.m +++ b/Firestore/Source/API/FIRFirestore.m @@ -14,13 +14,13 @@ * limitations under the License. */ -#import +#import "FIRFirestore.h" #import #import #import -#import +#import "FIRFirestoreSettings.h" #import "Firestore/Source/API/FIRCollectionReference+Internal.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFirestore+Internal.h" diff --git a/Firestore/Source/API/FIRFirestoreSettings.m b/Firestore/Source/API/FIRFirestoreSettings.m index 1d429f7891f..9677ff6b451 100644 --- a/Firestore/Source/API/FIRFirestoreSettings.m +++ b/Firestore/Source/API/FIRFirestoreSettings.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRFirestoreSettings.h" #import "Firestore/Source/Util/FSTUsageValidation.h" diff --git a/Firestore/Source/API/FIRGeoPoint+Internal.h b/Firestore/Source/API/FIRGeoPoint+Internal.h index 50e7fac807a..6eb85483bc1 100644 --- a/Firestore/Source/API/FIRGeoPoint+Internal.h +++ b/Firestore/Source/API/FIRGeoPoint+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRGeoPoint.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRListenerRegistration+Internal.h b/Firestore/Source/API/FIRListenerRegistration+Internal.h index 6403d0bea32..4cd2d579364 100644 --- a/Firestore/Source/API/FIRListenerRegistration+Internal.h +++ b/Firestore/Source/API/FIRListenerRegistration+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRListenerRegistration.h" @class FSTAsyncQueryListener; @class FSTFirestoreClient; diff --git a/Firestore/Source/API/FIRQuery+Internal.h b/Firestore/Source/API/FIRQuery+Internal.h index 7c434efffdf..3c2b2a7331c 100644 --- a/Firestore/Source/API/FIRQuery+Internal.h +++ b/Firestore/Source/API/FIRQuery+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRQuery.h" @class FSTQuery; diff --git a/Firestore/Source/API/FIRQuery.m b/Firestore/Source/API/FIRQuery.m index 14dad7c9142..12e79c57889 100644 --- a/Firestore/Source/API/FIRQuery.m +++ b/Firestore/Source/API/FIRQuery.m @@ -14,9 +14,9 @@ * limitations under the License. */ -#import +#import "FIRQuery.h" -#import +#import "FIRDocumentReference.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" #import "Firestore/Source/API/FIRFieldPath+Internal.h" diff --git a/Firestore/Source/API/FIRQuerySnapshot+Internal.h b/Firestore/Source/API/FIRQuerySnapshot+Internal.h index f588425d213..3a1e9dbf609 100644 --- a/Firestore/Source/API/FIRQuerySnapshot+Internal.h +++ b/Firestore/Source/API/FIRQuerySnapshot+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRQuerySnapshot.h" @class FIRFirestore; @class FIRSnapshotMetadata; diff --git a/Firestore/Source/API/FIRQuerySnapshot.m b/Firestore/Source/API/FIRQuerySnapshot.m index 04a597b094d..6bc6761970b 100644 --- a/Firestore/Source/API/FIRQuerySnapshot.m +++ b/Firestore/Source/API/FIRQuerySnapshot.m @@ -16,7 +16,7 @@ #import "Firestore/Source/API/FIRQuerySnapshot+Internal.h" -#import +#import "FIRSnapshotMetadata.h" #import "Firestore/Source/API/FIRDocumentChange+Internal.h" #import "Firestore/Source/API/FIRDocumentSnapshot+Internal.h" #import "Firestore/Source/API/FIRQuery+Internal.h" diff --git a/Firestore/Source/API/FIRQuery_Init.h b/Firestore/Source/API/FIRQuery_Init.h index 994973850a5..d6b0f37495b 100644 --- a/Firestore/Source/API/FIRQuery_Init.h +++ b/Firestore/Source/API/FIRQuery_Init.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRQuery.h" @class FSTQuery; diff --git a/Firestore/Source/API/FIRSetOptions+Internal.h b/Firestore/Source/API/FIRSetOptions+Internal.h index d4cf8c14bc7..91180961d21 100644 --- a/Firestore/Source/API/FIRSetOptions+Internal.h +++ b/Firestore/Source/API/FIRSetOptions+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRSetOptions.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Source/API/FIRSnapshotMetadata+Internal.h b/Firestore/Source/API/FIRSnapshotMetadata+Internal.h index 3612eefeb16..d3265cd0959 100644 --- a/Firestore/Source/API/FIRSnapshotMetadata+Internal.h +++ b/Firestore/Source/API/FIRSnapshotMetadata+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRSnapshotMetadata.h" #import diff --git a/Firestore/Source/API/FIRSnapshotMetadata.m b/Firestore/Source/API/FIRSnapshotMetadata.m index 85959706da4..224015f0a88 100644 --- a/Firestore/Source/API/FIRSnapshotMetadata.m +++ b/Firestore/Source/API/FIRSnapshotMetadata.m @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRSnapshotMetadata.h" #import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h" diff --git a/Firestore/Source/API/FIRTransaction+Internal.h b/Firestore/Source/API/FIRTransaction+Internal.h index 7bd02068d62..8fd3f65e333 100644 --- a/Firestore/Source/API/FIRTransaction+Internal.h +++ b/Firestore/Source/API/FIRTransaction+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRTransaction.h" @class FIRFirestore; @class FSTTransaction; diff --git a/Firestore/Source/API/FIRWriteBatch+Internal.h b/Firestore/Source/API/FIRWriteBatch+Internal.h index 07ffa2b7f5a..a434e02b4c1 100644 --- a/Firestore/Source/API/FIRWriteBatch+Internal.h +++ b/Firestore/Source/API/FIRWriteBatch+Internal.h @@ -14,7 +14,7 @@ * limitations under the License. */ -#import +#import "FIRWriteBatch.h" @class FIRFirestore; diff --git a/Firestore/Source/API/FSTUserDataConverter.m b/Firestore/Source/API/FSTUserDataConverter.m index d0d071d27ff..414aadbe3ca 100644 --- a/Firestore/Source/API/FSTUserDataConverter.m +++ b/Firestore/Source/API/FSTUserDataConverter.m @@ -16,7 +16,7 @@ #import "Firestore/Source/API/FSTUserDataConverter.h" -#import +#import "FIRGeoPoint.h" #import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/API/FIRFieldPath+Internal.h" #import "Firestore/Source/API/FIRFieldValue+Internal.h" diff --git a/Firestore/Source/Auth/FSTCredentialsProvider.m b/Firestore/Source/Auth/FSTCredentialsProvider.m index e2ee7f2ee4b..653d7ff2c45 100644 --- a/Firestore/Source/Auth/FSTCredentialsProvider.m +++ b/Firestore/Source/Auth/FSTCredentialsProvider.m @@ -20,7 +20,7 @@ #import #import -#import +#import "FIRFirestoreErrors.h" #import "Firestore/Source/Auth/FSTUser.h" #import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Source/Util/FSTClasses.h" diff --git a/Firestore/Source/Core/FSTSyncEngine.m b/Firestore/Source/Core/FSTSyncEngine.m index 8f86016063d..98658e47e6a 100644 --- a/Firestore/Source/Core/FSTSyncEngine.m +++ b/Firestore/Source/Core/FSTSyncEngine.m @@ -18,7 +18,7 @@ #import -#import +#import "FIRFirestoreErrors.h" #import "Firestore/Source/Auth/FSTUser.h" #import "Firestore/Source/Core/FSTQuery.h" #import "Firestore/Source/Core/FSTSnapshotVersion.h" diff --git a/Firestore/Source/Core/FSTTransaction.m b/Firestore/Source/Core/FSTTransaction.m index 2a3faf0c9ec..c4c5f27846c 100644 --- a/Firestore/Source/Core/FSTTransaction.m +++ b/Firestore/Source/Core/FSTTransaction.m @@ -18,8 +18,8 @@ #import -#import -#import +#import "FIRFirestoreErrors.h" +#import "FIRSetOptions.h" #import "Firestore/Source/API/FSTUserDataConverter.h" #import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Model/FSTDocument.h" diff --git a/Firestore/Source/Local/FSTLevelDB.mm b/Firestore/Source/Local/FSTLevelDB.mm index eba66bfbe3e..fb1c81a4fd0 100644 --- a/Firestore/Source/Local/FSTLevelDB.mm +++ b/Firestore/Source/Local/FSTLevelDB.mm @@ -18,7 +18,7 @@ #include -#import +#import "FIRFirestoreErrors.h" #import "Firestore/Source/Core/FSTDatabaseInfo.h" #import "Firestore/Source/Local/FSTLevelDBMutationQueue.h" #import "Firestore/Source/Local/FSTLevelDBQueryCache.h" diff --git a/Firestore/Source/Remote/FSTDatastore.m b/Firestore/Source/Remote/FSTDatastore.m index ab8b5c01d96..02d868c1900 100644 --- a/Firestore/Source/Remote/FSTDatastore.m +++ b/Firestore/Source/Remote/FSTDatastore.m @@ -19,7 +19,7 @@ #import #import -#import +#import "FIRFirestoreErrors.h" #import "Firestore/Source/API/FIRFirestore+Internal.h" #import "Firestore/Source/API/FIRFirestoreVersion.h" #import "Firestore/Source/Auth/FSTCredentialsProvider.h" diff --git a/Firestore/Source/Remote/FSTSerializerBeta.m b/Firestore/Source/Remote/FSTSerializerBeta.m index f464e73ebbe..04785c263e9 100644 --- a/Firestore/Source/Remote/FSTSerializerBeta.m +++ b/Firestore/Source/Remote/FSTSerializerBeta.m @@ -26,8 +26,8 @@ #import "Firestore/Protos/objc/google/rpc/Status.pbobjc.h" #import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h" -#import -#import +#import "FIRFirestoreErrors.h" +#import "FIRGeoPoint.h" #import "Firestore/Source/Core/FSTQuery.h" #import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Core/FSTTimestamp.h" diff --git a/Firestore/Source/Remote/FSTStream.m b/Firestore/Source/Remote/FSTStream.m index 69444f07063..2c039be4e40 100644 --- a/Firestore/Source/Remote/FSTStream.m +++ b/Firestore/Source/Remote/FSTStream.m @@ -19,7 +19,7 @@ #import #import -#import +#import "FIRFirestoreErrors.h" #import "Firestore/Source/API/FIRFirestore+Internal.h" #import "Firestore/Source/Auth/FSTCredentialsProvider.h" #import "Firestore/Source/Core/FSTDatabaseInfo.h" From 5861a84cd74df929fed86008c7f5188bf3eb0360 Mon Sep 17 00:00:00 2001 From: Marek Gilbert Date: Sat, 6 Jan 2018 12:00:30 -0800 Subject: [PATCH 04/10] Update tests for firebase_firestore_util renames --- .../firebase/firestore/util/CMakeLists.txt | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Firestore/core/test/firebase/firestore/util/CMakeLists.txt b/Firestore/core/test/firebase/firestore/util/CMakeLists.txt index 2126d345919..e51bb51484a 100644 --- a/Firestore/core/test/firebase/firestore/util/CMakeLists.txt +++ b/Firestore/core/test/firebase/firestore/util/CMakeLists.txt @@ -26,37 +26,21 @@ target_link_libraries( if(APPLE) cc_test( firebase_firestore_util_apple_test + assert_test.cc log_test.cc ) target_link_libraries( firebase_firestore_util_apple_test firebase_firestore_util_apple ) - cc_test( - firebase_firestore_util_assert_apple_test - assert_test.cc - ) - target_link_libraries( - firebase_firestore_util_assert_apple_test - firebase_firestore_util_assert_apple - ) endif(APPLE) cc_test( firebase_firestore_util_stdio_test + assert_test.cc log_test.cc ) target_link_libraries( firebase_firestore_util_stdio_test firebase_firestore_util_stdio ) - -cc_test( - firebase_firestore_util_assert_stdio_test - assert_test.cc -) -target_link_libraries( - firebase_firestore_util_assert_stdio_test - firebase_firestore_util_assert_stdio -) - From d1083eddab66facf6569eb9b6356046ee1a016ca Mon Sep 17 00:00:00 2001 From: zxu123 Date: Mon, 8 Jan 2018 10:03:11 -0800 Subject: [PATCH 05/10] renaming `assert.h` to `firebase_assert.h` --- .../core/src/firebase/firestore/util/assert_apple.mm | 2 +- .../core/src/firebase/firestore/util/assert_stdio.cc | 2 +- .../firestore/util/{assert.h => firebase_assert.h} | 9 ++++++--- .../core/test/firebase/firestore/util/assert_test.cc | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) rename Firestore/core/src/firebase/firestore/util/{assert.h => firebase_assert.h} (93%) diff --git a/Firestore/core/src/firebase/firestore/util/assert_apple.mm b/Firestore/core/src/firebase/firestore/util/assert_apple.mm index 511bf5802e4..09b87ba5748 100644 --- a/Firestore/core/src/firebase/firestore/util/assert_apple.mm +++ b/Firestore/core/src/firebase/firestore/util/assert_apple.mm @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "Firestore/core/src/firebase/firestore/util/assert.h" +#include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" #import diff --git a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc index cfa4206bc62..3ec4ed2d889 100644 --- a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc +++ b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "Firestore/core/src/firebase/firestore/util/assert.h" +#include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" #include #include diff --git a/Firestore/core/src/firebase/firestore/util/assert.h b/Firestore/core/src/firebase/firestore/util/firebase_assert.h similarity index 93% rename from Firestore/core/src/firebase/firestore/util/assert.h rename to Firestore/core/src/firebase/firestore/util/firebase_assert.h index 9ed32c09b05..6c25f8fd7f6 100644 --- a/Firestore/core/src/firebase/firestore/util/assert.h +++ b/Firestore/core/src/firebase/firestore/util/firebase_assert.h @@ -14,8 +14,11 @@ * limitations under the License. */ -#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_ASSERT_H_ -#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_ASSERT_H_ +// To avoid naming-collision, this header is called firebase_assert.h instead +// of assert.h. + +#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_FIREBASE_ASSERT_H_ +#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_FIREBASE_ASSERT_H_ #include #include "Firestore/core/src/firebase/firestore/util/log.h" @@ -95,4 +98,4 @@ void FailAssert(const char* file, const char* func, const int line, } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_ASSERT_H_ +#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_FIREBASE_ASSERT_H_ diff --git a/Firestore/core/test/firebase/firestore/util/assert_test.cc b/Firestore/core/test/firebase/firestore/util/assert_test.cc index 0babb759867..7c4946227fd 100644 --- a/Firestore/core/test/firebase/firestore/util/assert_test.cc +++ b/Firestore/core/test/firebase/firestore/util/assert_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "Firestore/core/src/firebase/firestore/util/assert.h" +#include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" #include From a9d169e5c84615d737e903b2a246e1973c569b90 Mon Sep 17 00:00:00 2001 From: zxu123 Date: Mon, 8 Jan 2018 10:40:45 -0800 Subject: [PATCH 06/10] refactoring to a common `WrapNSStringNoCopy()` --- .../firebase/firestore/util/CMakeLists.txt | 1 + .../firebase/firestore/util/assert_apple.mm | 21 +++-------- .../src/firebase/firestore/util/log_apple.mm | 21 ++++------- .../firebase/firestore/util/string_apple.h | 37 +++++++++++++++++++ .../firebase/firestore/util/string_apple.mm | 36 ++++++++++++++++++ 5 files changed, 86 insertions(+), 30 deletions(-) create mode 100644 Firestore/core/src/firebase/firestore/util/string_apple.h create mode 100644 Firestore/core/src/firebase/firestore/util/string_apple.mm diff --git a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt index 3028a956e8b..9990e2fd291 100644 --- a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt +++ b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt @@ -45,6 +45,7 @@ if(APPLE) firebase_firestore_util_apple assert_apple.mm log_apple.mm + string_apple.mm ) target_compile_options( firebase_firestore_util_apple diff --git a/Firestore/core/src/firebase/firestore/util/assert_apple.mm b/Firestore/core/src/firebase/firestore/util/assert_apple.mm index 09b87ba5748..fd973ad9a09 100644 --- a/Firestore/core/src/firebase/firestore/util/assert_apple.mm +++ b/Firestore/core/src/firebase/firestore/util/assert_apple.mm @@ -20,31 +20,20 @@ #include +#include "Firestore/core/src/firebase/firestore/util/string_apple.h" + namespace firebase { namespace firestore { namespace util { -namespace { - -// Translates a C format string to the equivalent NSString without making a -// copy. -NSString* CStringToNSString(const char* format) { - return [[NSString alloc] initWithBytesNoCopy:(void*)format - length:strlen(format) - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; -} - -} // namespace - void FailAssert(const char* file, const char* func, const int line, const char* format, ...) { va_list args; va_start(args, format); - NSString *description = [[NSString alloc] initWithFormat:CStringToNSString(format) arguments:args]; + NSString *description = [[NSString alloc] initWithFormat:WrapNSStringNoCopy(format) arguments:args]; va_end(args); [[NSAssertionHandler currentHandler] - handleFailureInFunction:CStringToNSString(func) - file:CStringToNSString(file) + handleFailureInFunction:WrapNSStringNoCopy(func) + file:WrapNSStringNoCopy(file) lineNumber:line description:@"FIRESTORE INTERNAL ASSERTION FAILED: %@", description]; abort(); diff --git a/Firestore/core/src/firebase/firestore/util/log_apple.mm b/Firestore/core/src/firebase/firestore/util/log_apple.mm index afa087f5981..cb2c58ea581 100644 --- a/Firestore/core/src/firebase/firestore/util/log_apple.mm +++ b/Firestore/core/src/firebase/firestore/util/log_apple.mm @@ -21,21 +21,14 @@ #include +#include "Firestore/core/src/firebase/firestore/util/string_apple.h" + namespace firebase { namespace firestore { namespace util { namespace { -// Translates a C format string to the equivalent NSString without making a -// copy. -NSString* FormatString(const char* format) { - return [[NSString alloc] initWithBytesNoCopy:(void*)format - length:strlen(format) - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; -} - // Translates a C++ LogLevel to the equivalent Objective-C FIRLoggerLevel FIRLoggerLevel ToFIRLoggerLevel(LogLevel level) { switch (level) { @@ -85,7 +78,7 @@ void LogDebug(const char* format, ...) { va_list list; va_start(list, format); FIRLogBasic(FIRLoggerLevelDebug, kFIRLoggerFirestore, @"I-FST000001", - FormatString(format), list); + WrapNSStringNoCopy(format), list); va_end(list); } @@ -93,7 +86,7 @@ void LogInfo(const char* format, ...) { va_list list; va_start(list, format); FIRLogBasic(FIRLoggerLevelInfo, kFIRLoggerFirestore, @"I-FST000001", - FormatString(format), list); + WrapNSStringNoCopy(format), list); va_end(list); } @@ -101,7 +94,7 @@ void LogWarning(const char* format, ...) { va_list list; va_start(list, format); FIRLogBasic(FIRLoggerLevelWarning, kFIRLoggerFirestore, @"I-FST000001", - FormatString(format), list); + WrapNSStringNoCopy(format), list); va_end(list); } @@ -109,13 +102,13 @@ void LogError(const char* format, ...) { va_list list; va_start(list, format); FIRLogBasic(FIRLoggerLevelError, kFIRLoggerFirestore, @"I-FST000001", - FormatString(format), list); + WrapNSStringNoCopy(format), list); va_end(list); } void LogMessageV(LogLevel log_level, const char* format, va_list args) { FIRLogBasic(ToFIRLoggerLevel(log_level), kFIRLoggerFirestore, @"I-FST000001", - FormatString(format), args); + WrapNSStringNoCopy(format), args); } void LogMessage(LogLevel log_level, const char* format, ...) { diff --git a/Firestore/core/src/firebase/firestore/util/string_apple.h b/Firestore/core/src/firebase/firestore/util/string_apple.h new file mode 100644 index 00000000000..ca0705f932c --- /dev/null +++ b/Firestore/core/src/firebase/firestore/util/string_apple.h @@ -0,0 +1,37 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_IOS_UTIL_H_ +#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_IOS_UTIL_H_ + +#import + +#include + +#include + +namespace firebase { +namespace firestore { +namespace util { + +// Translates a C string to the equivalent NSString without making a copy. +NSString* WrapNSStringNoCopy(const char* c_str); + +} // namespace util +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_FORMAT_H_ diff --git a/Firestore/core/src/firebase/firestore/util/string_apple.mm b/Firestore/core/src/firebase/firestore/util/string_apple.mm new file mode 100644 index 00000000000..aa91dddf749 --- /dev/null +++ b/Firestore/core/src/firebase/firestore/util/string_apple.mm @@ -0,0 +1,36 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Firestore/core/src/firebase/firestore/util/string_apple.h" + +#import + +#include + +namespace firebase { +namespace firestore { +namespace util { + +NSString* WrapNSStringNoCopy(const char* c_str) { + return [[NSString alloc] initWithBytesNoCopy:(void*)c_str + length:strlen(c_str) + encoding:NSUTF8StringEncoding + freeWhenDone:NO]; +} + +} // namespace util +} // namespace firestore +} // namespace firebase From 280e38c3ef98ab04ac34425dfef9deee24004fdc Mon Sep 17 00:00:00 2001 From: zxu123 Date: Mon, 8 Jan 2018 10:57:32 -0800 Subject: [PATCH 07/10] address reviewer comments --- .../src/firebase/firestore/util/assert_apple.mm | 2 +- .../src/firebase/firestore/util/assert_stdio.cc | 15 +++++++++++---- .../src/firebase/firestore/util/firebase_assert.h | 15 ++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Firestore/core/src/firebase/firestore/util/assert_apple.mm b/Firestore/core/src/firebase/firestore/util/assert_apple.mm index fd973ad9a09..0447d6c20f5 100644 --- a/Firestore/core/src/firebase/firestore/util/assert_apple.mm +++ b/Firestore/core/src/firebase/firestore/util/assert_apple.mm @@ -18,7 +18,7 @@ #import -#include +#include #include "Firestore/core/src/firebase/firestore/util/string_apple.h" diff --git a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc index 3ec4ed2d889..93cfba70922 100644 --- a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc +++ b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc @@ -22,20 +22,27 @@ #include #include +#include "absl/base/config.h" +#include "Firestore/core/src/firebase/firestore/util/string_printf.h" + namespace firebase { namespace firestore { namespace util { void FailAssert(const char* file, const char* func, const int line, const char* format, ...) { - fprintf(stderr, "ASSERT: %s(%d) %s: ", file, line, func); + std::string message = StringPrintf("ASSERT: %s(%d) %s: ", file, line, func); va_list args; va_start(args, format); - vfprintf(stderr, format, args); + StringAppendV(&message, format, args); va_end(args); - fprintf(stderr, "\n"); - throw std::exception(); + +#if ABSL_HAVE_EXCEPTIONS + throw std::logic_error(message); +#else + fprintf(stderr, "%s\n", message.c_str()); abort(); +#endif } } // namespace util diff --git a/Firestore/core/src/firebase/firestore/util/firebase_assert.h b/Firestore/core/src/firebase/firestore/util/firebase_assert.h index 6c25f8fd7f6..9f1bce8b209 100644 --- a/Firestore/core/src/firebase/firestore/util/firebase_assert.h +++ b/Firestore/core/src/firebase/firestore/util/firebase_assert.h @@ -20,7 +20,8 @@ #ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_FIREBASE_ASSERT_H_ #define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_FIREBASE_ASSERT_H_ -#include +#include + #include "Firestore/core/src/firebase/firestore/util/log.h" #define FIREBASE_EXPAND_STRINGIFY_(X) #X @@ -45,12 +46,12 @@ // Assert condition is true, if it's false log an assert with the specified // expression as a string. Compiled out of release builds. -#if !defined(NDEBUG) +#if defined(NDEBUG) #define FIREBASE_DEV_ASSERT_WITH_EXPRESSION(condition, expression) \ - FIREBASE_ASSERT_WITH_EXPRESSION(condition, expression) + { (void)(condition); } #else #define FIREBASE_DEV_ASSERT_WITH_EXPRESSION(condition, expression) \ - { (void)(condition); } + FIREBASE_ASSERT_WITH_EXPRESSION(condition, expression) #endif // !defined(NDEBUG) // Custom assert() implementation that is not compiled out in release builds. @@ -76,14 +77,14 @@ // Assert condition is true otherwise display the specified expression, // message and abort. Compiled out of release builds. -#if !defined(NDEBUG) +#if defined(NDEBUG) #define FIREBASE_DEV_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, \ ...) \ - FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, __VA_ARGS__) + { (void)(condition); } #else #define FIREBASE_DEV_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, \ ...) \ - { (void)(condition); } + FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(condition, expression, __VA_ARGS__) #endif // !defined(NDEBUG) namespace firebase { From 51116590684beb9bfd547aefd75a1d5f2ca7cfcd Mon Sep 17 00:00:00 2001 From: Gil Date: Mon, 8 Jan 2018 11:22:35 -0800 Subject: [PATCH 08/10] Add assertion text to the thrown exception (#629) --- .../src/firebase/firestore/util/assert_stdio.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc index 93cfba70922..b5d0b7c3abb 100644 --- a/Firestore/core/src/firebase/firestore/util/assert_stdio.cc +++ b/Firestore/core/src/firebase/firestore/util/assert_stdio.cc @@ -16,13 +16,13 @@ #include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" -#include -#include +#include #include #include -#include "absl/base/config.h" +#include + #include "Firestore/core/src/firebase/firestore/util/string_printf.h" namespace firebase { @@ -31,7 +31,9 @@ namespace util { void FailAssert(const char* file, const char* func, const int line, const char* format, ...) { - std::string message = StringPrintf("ASSERT: %s(%d) %s: ", file, line, func); + std::string message; + StringAppendF(&message, "ASSERT: %s(%d) %s: ", file, line, func); + va_list args; va_start(args, format); StringAppendV(&message, format, args); @@ -39,9 +41,10 @@ void FailAssert(const char* file, const char* func, const int line, #if ABSL_HAVE_EXCEPTIONS throw std::logic_error(message); + #else fprintf(stderr, "%s\n", message.c_str()); - abort(); + std::terminate(); #endif } From b9e8c74753dcfc3f233057416983c34a0a278b36 Mon Sep 17 00:00:00 2001 From: zxu123 Date: Mon, 8 Jan 2018 11:39:14 -0800 Subject: [PATCH 09/10] address comment --- .../firebase/firestore/util/CMakeLists.txt | 1 - .../firebase/firestore/util/string_apple.h | 8 ++++- .../firebase/firestore/util/string_apple.mm | 36 ------------------- 3 files changed, 7 insertions(+), 38 deletions(-) delete mode 100644 Firestore/core/src/firebase/firestore/util/string_apple.mm diff --git a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt index 9990e2fd291..3028a956e8b 100644 --- a/Firestore/core/src/firebase/firestore/util/CMakeLists.txt +++ b/Firestore/core/src/firebase/firestore/util/CMakeLists.txt @@ -45,7 +45,6 @@ if(APPLE) firebase_firestore_util_apple assert_apple.mm log_apple.mm - string_apple.mm ) target_compile_options( firebase_firestore_util_apple diff --git a/Firestore/core/src/firebase/firestore/util/string_apple.h b/Firestore/core/src/firebase/firestore/util/string_apple.h index ca0705f932c..c3f9407325f 100644 --- a/Firestore/core/src/firebase/firestore/util/string_apple.h +++ b/Firestore/core/src/firebase/firestore/util/string_apple.h @@ -28,7 +28,13 @@ namespace firestore { namespace util { // Translates a C string to the equivalent NSString without making a copy. -NSString* WrapNSStringNoCopy(const char* c_str); +inline NSString* WrapNSStringNoCopy(const char* c_str) { + return [[NSString alloc] initWithBytesNoCopy:const_cast(static_cast(c_str)) + length:strlen(c_str) + encoding:NSUTF8StringEncoding + freeWhenDone:NO]; +} + } // namespace util } // namespace firestore diff --git a/Firestore/core/src/firebase/firestore/util/string_apple.mm b/Firestore/core/src/firebase/firestore/util/string_apple.mm deleted file mode 100644 index aa91dddf749..00000000000 --- a/Firestore/core/src/firebase/firestore/util/string_apple.mm +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 Google - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Firestore/core/src/firebase/firestore/util/string_apple.h" - -#import - -#include - -namespace firebase { -namespace firestore { -namespace util { - -NSString* WrapNSStringNoCopy(const char* c_str) { - return [[NSString alloc] initWithBytesNoCopy:(void*)c_str - length:strlen(c_str) - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; -} - -} // namespace util -} // namespace firestore -} // namespace firebase From 00b0509d91e64103f16519d49b2907033d15a3db Mon Sep 17 00:00:00 2001 From: zxu123 Date: Mon, 8 Jan 2018 11:43:31 -0800 Subject: [PATCH 10/10] address comment --- .../core/src/firebase/firestore/util/string_apple.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Firestore/core/src/firebase/firestore/util/string_apple.h b/Firestore/core/src/firebase/firestore/util/string_apple.h index c3f9407325f..42b51dd713b 100644 --- a/Firestore/core/src/firebase/firestore/util/string_apple.h +++ b/Firestore/core/src/firebase/firestore/util/string_apple.h @@ -14,15 +14,11 @@ * limitations under the License. */ -#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_IOS_UTIL_H_ -#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_IOS_UTIL_H_ +#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_APPLE_H_ +#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_APPLE_H_ #import -#include - -#include - namespace firebase { namespace firestore { namespace util { @@ -40,4 +36,4 @@ inline NSString* WrapNSStringNoCopy(const char* c_str) { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_FORMAT_H_ +#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_STRING_APPLE_H_