From edd300fef207527bc05e128592b93edec55e8c4d Mon Sep 17 00:00:00 2001 From: austinbenoit Date: Thu, 26 Nov 2026 19:05:12 +0000 Subject: [PATCH 1/2] chore: remove always-defined FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION macros - Remove FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION definitions and follow-up TODO from app/src/include/firebase/internal/common.h (following #1958). - Unwrap all 90 #if/#ifdef guards across 72 files in app, auth, database, functions, and storage, keeping #ifndef SWIG on SWIG-parsed public headers so Unity SWIG output is unchanged. - Fix include ordering for unwrapped / headers and add missing #include in intrusive_list.h, intrusive_list_test.cc, jobject_reference.cc, and callable_result.h. - Fix newly Doxygen-exposed move-assignment comments in future.h and mutable_data.h. - Fix newly activated intrusive_list/intrusive_list_node move-assignment safety (self-move guard, clear() before overwrite, direct move-ctor member initialization) with regression tests. --- app/rest/controller_curl.cc | 2 - app/rest/controller_curl.h | 2 - app/src/callback.h | 7 +-- app/src/include/firebase/future.h | 34 +++++------ app/src/include/firebase/internal/common.h | 5 -- .../include/firebase/internal/future_impl.h | 17 +----- app/src/include/firebase/variant.h | 3 - app/src/intrusive_list.h | 21 ++++--- app/src/jobject_reference.cc | 5 +- app/src/jobject_reference.h | 4 -- app/src/reference_counted_future_impl.cc | 6 -- app/src/reference_counted_future_impl.h | 2 - app/src/scheduler.cc | 2 - app/src/scheduler.h | 2 - app/src/variant.cc | 4 -- app/tests/intrusive_list_test.cc | 58 ++++++++++++++++++- app/tests/scheduler_test.cc | 2 - app/tests/variant_test.cc | 2 - auth/tests/desktop/auth_desktop_test.cc | 2 - database/src/android/data_snapshot_android.cc | 2 - database/src/android/data_snapshot_android.h | 2 - .../src/android/database_reference_android.cc | 2 - .../src/android/database_reference_android.h | 2 - database/src/android/query_android.cc | 2 - database/src/android/query_android.h | 2 - database/src/common/data_snapshot.cc | 2 - database/src/common/database_reference.cc | 2 - database/src/common/mutable_data.cc | 2 - database/src/common/query.cc | 2 - database/src/desktop/data_snapshot_desktop.cc | 2 - database/src/desktop/data_snapshot_desktop.h | 2 - .../src/desktop/database_reference_desktop.cc | 2 - .../src/desktop/database_reference_desktop.h | 2 - database/src/desktop/query_desktop.cc | 2 - database/src/desktop/query_desktop.h | 2 - .../include/firebase/database/data_snapshot.h | 4 +- .../firebase/database/database_reference.h | 8 +-- .../include/firebase/database/mutable_data.h | 9 +-- .../src/include/firebase/database/query.h | 4 +- .../include/firebase/database/transaction.h | 10 ++-- database/src/ios/data_snapshot_ios.h | 2 - database/src/ios/data_snapshot_ios.mm | 2 - database/src/ios/database_reference_ios.h | 2 - database/src/ios/database_reference_ios.mm | 2 - database/src/ios/query_ios.h | 2 - database/src/ios/query_ios.mm | 2 - .../src/android/callable_reference_android.cc | 2 - .../src/android/callable_reference_android.h | 2 - functions/src/common/callable_reference.cc | 2 - .../src/desktop/callable_reference_desktop.cc | 2 - .../src/desktop/callable_reference_desktop.h | 2 - .../firebase/functions/callable_reference.h | 2 - .../firebase/functions/callable_result.h | 7 +-- functions/src/ios/callable_reference_ios.h | 2 - functions/src/ios/callable_reference_ios.mm | 2 - storage/src/android/metadata_android.cc | 2 - storage/src/android/metadata_android.h | 2 - .../src/android/storage_reference_android.cc | 2 - .../src/android/storage_reference_android.h | 2 - storage/src/common/controller.cc | 2 - storage/src/common/list_result.cc | 2 - storage/src/common/metadata.cc | 2 - storage/src/common/storage_reference.cc | 2 - storage/src/desktop/metadata_desktop.cc | 2 - storage/src/desktop/metadata_desktop.h | 2 - .../src/include/firebase/storage/controller.h | 4 +- .../include/firebase/storage/list_result.h | 4 +- .../src/include/firebase/storage/metadata.h | 4 +- .../firebase/storage/storage_reference.h | 4 +- storage/src/ios/metadata_ios.h | 2 - storage/src/ios/metadata_ios.mm | 2 - storage/src/ios/storage_reference_ios.h | 2 - storage/src/ios/storage_reference_ios.mm | 2 - 73 files changed, 115 insertions(+), 211 deletions(-) diff --git a/app/rest/controller_curl.cc b/app/rest/controller_curl.cc index bc7c14b4e1..9a2fbcebe9 100644 --- a/app/rest/controller_curl.cc +++ b/app/rest/controller_curl.cc @@ -46,7 +46,6 @@ ControllerCurl::~ControllerCurl() { } } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ControllerCurl::ControllerCurl(ControllerCurl&& other) noexcept { *this = std::move(other); } @@ -69,7 +68,6 @@ ControllerCurl& ControllerCurl::operator=(ControllerCurl&& other) noexcept { other.transport_ = nullptr; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) bool ControllerCurl::Pause() { if (this_handle_mutex_) { diff --git a/app/rest/controller_curl.h b/app/rest/controller_curl.h index c13d8288cb..e6d13d8419 100644 --- a/app/rest/controller_curl.h +++ b/app/rest/controller_curl.h @@ -53,11 +53,9 @@ class ControllerCurl : public Controller { ~ControllerCurl() override; -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ControllerCurl(ControllerCurl&& other) noexcept; ControllerCurl& operator=(ControllerCurl&& other) noexcept; -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Pauses whatever the handle is doing. bool Pause() override; diff --git a/app/src/callback.h b/app/src/callback.h index 5bf53f8b1f..9caa980d6d 100644 --- a/app/src/callback.h +++ b/app/src/callback.h @@ -17,15 +17,12 @@ #ifndef FIREBASE_APP_SRC_CALLBACK_H_ #define FIREBASE_APP_SRC_CALLBACK_H_ +#include #include #include #include "firebase/internal/common.h" -#ifdef FIREBASE_USE_STD_FUNCTION -#include -#endif - /// @cond FIREBASE_APP_INTERNAL /// This file is intended for use with the C# interfaces, to allow registration @@ -276,7 +273,6 @@ class CallbackMoveValue1 : public Callback { UserCallback user_callback_; }; -#ifdef FIREBASE_USE_STD_FUNCTION /// Callback implementation that wraps std::function class CallbackStdFunction : public Callback { public: @@ -288,7 +284,6 @@ class CallbackStdFunction : public Callback { private: std::function func_; }; -#endif template struct IntegerSequence {}; diff --git a/app/src/include/firebase/future.h b/app/src/include/firebase/future.h index 7e2d2a695b..8f8bdbc6d2 100644 --- a/app/src/include/firebase/future.h +++ b/app/src/include/firebase/future.h @@ -20,15 +20,12 @@ #include #include +#include #include #include "firebase/internal/common.h" #include "firebase/internal/mutex.h" -#ifdef FIREBASE_USE_STD_FUNCTION -#include -#endif - namespace firebase { // Predeclarations. @@ -70,11 +67,11 @@ class FutureHandle { FutureHandle(const FutureHandle& rhs); FutureHandle& operator=(const FutureHandle& rhs); -#if defined(FIREBASE_USE_MOVE_OPERATORS) +#ifndef SWIG // Move constructor and assignment operator. FutureHandle(FutureHandle&& rhs) noexcept; FutureHandle& operator=(FutureHandle&& rhs) noexcept; -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) +#endif // SWIG // Comparison operators. bool operator!=(const FutureHandle& rhs) const { return !(*this == rhs); } @@ -159,15 +156,15 @@ class FutureBase { /// Copy an untyped future. FutureBase& operator=(const FutureBase& rhs); -#if defined(FIREBASE_USE_MOVE_OPERATORS) - /// Move constructor and operator. +#ifndef SWIG + /// Move constructor. /// Move is more efficient than copy and delete because we don't touch the /// reference counting in the API. FutureBase(FutureBase&& rhs) noexcept; - /// Copy an untyped future. + /// Move an untyped future. FutureBase& operator=(FutureBase&& rhs) noexcept; -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) +#endif // SWIG /// Explicitly release the internal resources for a future. /// Future will become invalid. @@ -236,7 +233,7 @@ class FutureBase { /// callback. void OnCompletion(CompletionCallback callback, void* user_data) const; -#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#ifndef SWIG /// Register a single callback that will be called at most once, when the /// future is completed. /// @@ -254,7 +251,7 @@ class FutureBase { /// /// @param[in] callback Function or lambda to call. void OnCompletion(std::function callback) const; -#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#endif // SWIG #if defined(INTERNAL_EXPERIMENTAL) /// Like OnCompletion, but allows adding multiple callbacks. @@ -275,7 +272,7 @@ class FutureBase { CompletionCallbackHandle AddOnCompletion(CompletionCallback callback, void* user_data) const; -#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#ifndef SWIG /// Like OnCompletion, but allows adding multiple callbacks. /// /// If you call AddCompletion() more than once, all of the completions that @@ -291,8 +288,7 @@ class FutureBase { /// @return A handle that can be passed to RemoveOnCompletion. CompletionCallbackHandle AddOnCompletion( std::function callback) const; - -#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#endif // SWIG /// Unregisters a callback that was previously registered with /// AddOnCompletion. @@ -458,7 +454,7 @@ class Future : public FutureBase { inline void OnCompletion(TypedCompletionCallback callback, void* user_data) const; -#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#ifndef SWIG /// Register a single callback that will be called at most once, when the /// future is completed. /// @@ -472,7 +468,7 @@ class Future : public FutureBase { /// registered one will run. inline void OnCompletion( std::function&)> callback) const; -#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#endif // SWIG #if defined(INTERNAL_EXPERIMENTAL) /// Like OnCompletion, but allows adding multiple callbacks. @@ -493,7 +489,7 @@ class Future : public FutureBase { inline CompletionCallbackHandle AddOnCompletion( TypedCompletionCallback callback, void* user_data) const; -#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#ifndef SWIG /// Like OnCompletion, but allows adding multiple callbacks. /// /// If you call AddCompletion() more than once, all of the completions that @@ -509,7 +505,7 @@ class Future : public FutureBase { /// @return A handle that can be passed to RemoveOnCompletion. inline CompletionCallbackHandle AddOnCompletion( std::function&)> callback) const; -#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#endif // SWIG #endif // defined(INTERNAL_EXPERIMENTAL) }; diff --git a/app/src/include/firebase/internal/common.h b/app/src/include/firebase/internal/common.h index adc8e45e79..9e81a7f263 100644 --- a/app/src/include/firebase/internal/common.h +++ b/app/src/include/firebase/internal/common.h @@ -21,11 +21,6 @@ #include -// TODO(b/582384770): Remove these always-defined macros and unwrap their -// remaining #if/#ifdef guards across the codebase in a follow-up cleanup. -#define FIREBASE_USE_MOVE_OPERATORS -#define FIREBASE_USE_STD_FUNCTION - #if !defined(DOXYGEN) && !defined(SWIG) #if !defined(_WIN32) && !defined(__CYGWIN__) // Prevent GCC & Clang from stripping a symbol. diff --git a/app/src/include/firebase/internal/future_impl.h b/app/src/include/firebase/internal/future_impl.h index a328aaf094..168f84876a 100644 --- a/app/src/include/firebase/internal/future_impl.h +++ b/app/src/include/firebase/internal/future_impl.h @@ -19,14 +19,12 @@ /// @cond FIREBASE_APP_INTERNAL +#include + // You shouldn't include future_impl.h directly, since its just the inline // implementation of the functions in future.h. Include future.h instead. #include "firebase/future.h" -#if defined(FIREBASE_USE_MOVE_OPERATORS) -#include -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) - namespace firebase { class ReferenceCountedFutureImpl; @@ -93,7 +91,6 @@ class FutureApiInterface { virtual void RemoveCompletionCallback( const FutureHandle& handle, CompletionCallbackHandle callback_handle) = 0; -#if defined(FIREBASE_USE_STD_FUNCTION) /// Register a callback that will be called when this future's status is set /// to Complete. /// @@ -109,7 +106,6 @@ class FutureApiInterface { const FutureHandle& handle, std::function callback, bool clear_existing_callbacks) = 0; -#endif // defined(FIREBASE_USE_STD_FUNCTION) /// Register this Future instance to be cleaned up. virtual void RegisterFutureForCleanup(FutureBase* future) = 0; @@ -194,7 +190,6 @@ void Future::OnCompletion(TypedCompletionCallback callback, } } -#if defined(FIREBASE_USE_STD_FUNCTION) template inline void Future::OnCompletion( std::function&)> callback) const { @@ -206,7 +201,6 @@ inline void Future::OnCompletion( }); } } -#endif // defined(FIREBASE_USE_STD_FUNCTION) #if defined(INTERNAL_EXPERIMENTAL) template @@ -227,7 +221,6 @@ FutureBase::CompletionCallbackHandle Future::AddOnCompletion( return CompletionCallbackHandle(); } -#if defined(FIREBASE_USE_STD_FUNCTION) template inline FutureBase::CompletionCallbackHandle Future::AddOnCompletion( std::function&)> callback) const { @@ -238,7 +231,6 @@ inline FutureBase::CompletionCallbackHandle Future::AddOnCompletion( callback(static_cast&>(future)); }); } -#endif // defined(FIREBASE_USE_STD_FUNCTION) #endif // defined(INTERNAL_EXPERIMENTAL) @@ -290,7 +282,6 @@ inline FutureBase& FutureBase::operator=(const FutureBase& rhs) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) inline FutureBase::FutureBase(FutureBase&& rhs) noexcept : mutex_(Mutex::Mode::kModeNonRecursive), api_(NULL) // NOLINT @@ -317,7 +308,6 @@ inline FutureBase& FutureBase::operator=(FutureBase&& rhs) noexcept { detail::RegisterForCleanup(api_, this); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) inline void FutureBase::Release() { MutexLock lock(mutex_); @@ -379,7 +369,6 @@ inline void FutureBase::RemoveOnCompletion( } #endif // defined(INTERNAL_EXPERIMENTAL) -#if defined(FIREBASE_USE_STD_FUNCTION) inline void FutureBase::OnCompletion( std::function callback) const { MutexLock lock(mutex_); @@ -402,8 +391,6 @@ inline FutureBase::CompletionCallbackHandle FutureBase::AddOnCompletion( } #endif // defined(INTERNAL__EXPERIMENTAL) -#endif // defined(FIREBASE_USE_STD_FUNCTION) - // NOLINTNEXTLINE - allow namespace overridden } // namespace firebase diff --git a/app/src/include/firebase/variant.h b/app/src/include/firebase/variant.h index ef1d552dff..0c352e9e81 100644 --- a/app/src/include/firebase/variant.h +++ b/app/src/include/firebase/variant.h @@ -229,8 +229,6 @@ class Variant { /// @param[in] other Source Variant to copy from. Variant& operator=(const Variant& other); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) - /// @brief Move constructor. Efficiently moves the more complex data types by /// simply reassigning pointer ownership. /// @@ -245,7 +243,6 @@ class Variant { /// @param[in] other Source Variant to move from. Variant& operator=(Variant&& other) noexcept; -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) #endif // SWIG /// Destructor. Frees the memory that this Variant owns. diff --git a/app/src/intrusive_list.h b/app/src/intrusive_list.h index e600d9c937..af714949c3 100644 --- a/app/src/intrusive_list.h +++ b/app/src/intrusive_list.h @@ -23,6 +23,7 @@ #include #include #include +#include #if defined(_MSC_FULL_VER) #pragma warning(push) @@ -130,9 +131,11 @@ class intrusive_list_node { // Move assignment operator. intrusive_list_node& operator=(intrusive_list_node&& other) FIREBASE_NOEXCEPT { - next_->previous_ = previous_; - previous_->next_ = next_; - move(other); + if (this != &other) { + next_->previous_ = previous_; + previous_->next_ = next_; + move(other); + } return *this; } @@ -246,15 +249,17 @@ class intrusive_list { explicit intrusive_list(intrusive_list_node T::*node_member) : data_(&data_, &data_), node_offset_(offset_of_node(node_member)) {} -#if defined(FIREBASE_USE_MOVE_OPERATORS) - intrusive_list(this_type&& other) noexcept { *this = std::move(other); } + intrusive_list(this_type&& other) noexcept + : data_(std::move(other.data_)), node_offset_(other.node_offset_) {} intrusive_list& operator=(this_type&& other) noexcept { - data_ = std::move(other.data_); - node_offset_ = std::move(other.node_offset_); + if (this != &other) { + clear(); + data_ = std::move(other.data_); + node_offset_ = other.node_offset_; + } return *this; } -#endif #if defined(_MSC_VER) // Normally we need to disallow copying. Ideally we'd put this in the diff --git a/app/src/jobject_reference.cc b/app/src/jobject_reference.cc index 9dbbc15ee8..dd2bfc6ed2 100644 --- a/app/src/jobject_reference.cc +++ b/app/src/jobject_reference.cc @@ -19,6 +19,7 @@ #include #include +#include #include "app/src/assert.h" // util_android.h is included for GetThreadsafeJNIEnv() @@ -40,11 +41,9 @@ JObjectReference::JObjectReference(const JObjectReference& reference) { Initialize(reference.java_vm_, reference.GetJNIEnv(), reference.object()); } -#ifdef FIREBASE_USE_MOVE_OPERATORS JObjectReference::JObjectReference(JObjectReference&& reference) noexcept { operator=(std::move(reference)); } -#endif // FIREBASE_USE_MOVE_OPERATORS JObjectReference::~JObjectReference() { Set(nullptr); } @@ -54,7 +53,6 @@ JObjectReference& JObjectReference::operator=( return *this; } -#ifdef FIREBASE_USE_MOVE_OPERATORS JObjectReference& JObjectReference::operator=( JObjectReference&& reference) noexcept { java_vm_ = reference.java_vm_; @@ -63,7 +61,6 @@ JObjectReference& JObjectReference::operator=( reference.object_ = nullptr; return *this; } -#endif // FIREBASE_USE_MOVE_OPERATORS void JObjectReference::Set(jobject jobject_reference) { JNIEnv* env = GetJNIEnv(); diff --git a/app/src/jobject_reference.h b/app/src/jobject_reference.h index 63ea63ca62..bc3161f955 100644 --- a/app/src/jobject_reference.h +++ b/app/src/jobject_reference.h @@ -57,17 +57,13 @@ class JObjectReference { // Copy JObjectReference(const JObjectReference& reference); // Move -#ifdef FIREBASE_USE_MOVE_OPERATORS JObjectReference(JObjectReference&& reference) noexcept; -#endif // FIREBASE_USE_MOVE_OPERATORS // Delete the reference to the java object. ~JObjectReference(); // Copy this reference. JObjectReference& operator=(const JObjectReference& reference); // Move this reference. -#ifdef FIREBASE_USE_MOVE_OPERATORS JObjectReference& operator=(JObjectReference&& reference) noexcept; -#endif // FIREBASE_USE_MOVE_OPERATORS // Add a global reference to the specified object, removing the reference // to the object currently referenced by this class. If jobject_reference diff --git a/app/src/reference_counted_future_impl.cc b/app/src/reference_counted_future_impl.cc index 96026fcfef..de820018c6 100644 --- a/app/src/reference_counted_future_impl.cc +++ b/app/src/reference_counted_future_impl.cc @@ -635,8 +635,6 @@ void ReferenceCountedFutureImpl::RemoveCompletionCallback( } } -#ifdef FIREBASE_USE_STD_FUNCTION - static void CallStdFunction(const FutureBase& future, void* function_void) { if (function_void) { std::function* function = @@ -700,8 +698,6 @@ ReferenceCountedFutureImpl::AddCompletionCallbackLambda( } } -#endif // FIREBASE_USE_STD_FUNCTION - bool ReferenceCountedFutureImpl::IsSafeToDelete() const { MutexLock lock(mutex_); // Check if any Futures we have are still pending. @@ -861,7 +857,6 @@ FutureHandle& FutureHandle::operator=(const FutureHandle& rhs) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) FutureHandle::FutureHandle(FutureHandle&& rhs) noexcept { this->id_ = rhs.id_; this->api_ = rhs.api_; @@ -890,7 +885,6 @@ FutureHandle& FutureHandle::operator=(FutureHandle&& rhs) noexcept { rhs.api_ = nullptr; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) void FutureHandle::Detach() { if (api_ != nullptr) { diff --git a/app/src/reference_counted_future_impl.h b/app/src/reference_counted_future_impl.h index 0ca87712d7..a0165e50c2 100644 --- a/app/src/reference_counted_future_impl.h +++ b/app/src/reference_counted_future_impl.h @@ -139,14 +139,12 @@ class ReferenceCountedFutureImpl : public detail::FutureApiInterface { void RemoveCompletionCallback( const FutureHandle& handle, detail::CompletionCallbackHandle callback_handle) override; -#ifdef FIREBASE_USE_STD_FUNCTION // std::function version of AddCompletionCallback, which supports lambda // capture. detail::CompletionCallbackHandle AddCompletionCallbackLambda( const FutureHandle& handle, std::function callback, bool single_completion) override; -#endif // FIREBASE_USE_STD_FUNCTION // When a Future instance is created, register it with the cleanup manager so // it will be properly invalidated upon destruction of // ReferenceCountedFutureImpl. diff --git a/app/src/scheduler.cc b/app/src/scheduler.cc index c76ee70c3d..8bb93facd6 100644 --- a/app/src/scheduler.cc +++ b/app/src/scheduler.cc @@ -113,13 +113,11 @@ RequestHandle Scheduler::Schedule(callback::Callback* callback, return handler; } -#ifdef FIREBASE_USE_STD_FUNCTION RequestHandle Scheduler::Schedule(const std::function& callback, ScheduleTimeMs delay /* = 0 */, ScheduleTimeMs repeat /* = 0 */) { return Schedule(new callback::CallbackStdFunction(callback), delay, repeat); } -#endif void Scheduler::WorkerThreadRoutine(void* data) { Scheduler* scheduler = static_cast(data); diff --git a/app/src/scheduler.h b/app/src/scheduler.h index d23ec72704..b177cd801a 100644 --- a/app/src/scheduler.h +++ b/app/src/scheduler.h @@ -114,11 +114,9 @@ class Scheduler { RequestHandle Schedule(callback::Callback* callback, ScheduleTimeMs delay = 0, ScheduleTimeMs repeat = 0); -#ifdef FIREBASE_USE_STD_FUNCTION // std::function version of Schedule(callback, delay, repeat) RequestHandle Schedule(const std::function& callback, ScheduleTimeMs delay = 0, ScheduleTimeMs repeat = 0); -#endif // FIREBASE_USE_STD_FUNCTION // Cancel all scheduled callbacks and shut down the worker thread. void CancelAllAndShutdownWorkerThread(); diff --git a/app/src/variant.cc b/app/src/variant.cc index 9b5a0e3756..482430c76e 100644 --- a/app/src/variant.cc +++ b/app/src/variant.cc @@ -87,8 +87,6 @@ Variant& Variant::operator=(const Variant& other) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) - Variant& Variant::operator=(Variant&& other) noexcept { if (this != &other) { Clear(); @@ -156,8 +154,6 @@ Variant& Variant::operator=(Variant&& other) noexcept { return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) - bool Variant::operator==(const Variant& other) const { // If types don't match and we aren't both strings or blobs, fail. if (type_ != other.type_ && !(is_string() && other.is_string()) && diff --git a/app/tests/intrusive_list_test.cc b/app/tests/intrusive_list_test.cc index db43bf5add..a998aaf81e 100644 --- a/app/tests/intrusive_list_test.cc +++ b/app/tests/intrusive_list_test.cc @@ -16,6 +16,7 @@ #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -1024,7 +1025,6 @@ TEST_F(intrusive_list_test, merge_other_this) { EXPECT_EQ(other_list.end(), iter); } -#if defined(FIREBASE_USE_MOVE_OPERATORS) TEST_F(intrusive_list_test, move_constructor) { list_.push_back(one_); list_.push_back(two_); @@ -1083,7 +1083,61 @@ TEST_F(intrusive_list_test, move_assignment) { ++iter; EXPECT_EQ(other.end(), iter); } -#endif + +TEST_F(intrusive_list_test, move_assignment_non_empty_destination) { + list_.push_back(one_); + list_.push_back(two_); + + firebase::intrusive_list other(&IntegerListNode::node); + other.push_back(three_); + other.push_back(four_); + other.push_back(five_); + + other = std::move(list_); + + EXPECT_TRUE(list_.empty()); + EXPECT_TRUE(one_.node.in_list()); + EXPECT_TRUE(two_.node.in_list()); + EXPECT_FALSE(three_.node.in_list()); + EXPECT_FALSE(four_.node.in_list()); + EXPECT_FALSE(five_.node.in_list()); + + auto iter = other.begin(); + EXPECT_EQ(1, iter->value()); + ++iter; + EXPECT_EQ(2, iter->value()); + ++iter; + EXPECT_EQ(other.end(), iter); + + // Previously evicted elements must be safe to re-insert. + list_.push_back(three_); + list_.push_back(four_); + EXPECT_TRUE(three_.node.in_list()); + EXPECT_TRUE(four_.node.in_list()); +} + +TEST_F(intrusive_list_test, move_assignment_self) { + list_.push_back(one_); + list_.push_back(two_); + list_.push_back(three_); + + firebase::intrusive_list& self_ref = list_; + list_ = std::move(self_ref); + + EXPECT_FALSE(list_.empty()); + EXPECT_TRUE(one_.node.in_list()); + EXPECT_TRUE(two_.node.in_list()); + EXPECT_TRUE(three_.node.in_list()); + + auto iter = list_.begin(); + EXPECT_EQ(1, iter->value()); + ++iter; + EXPECT_EQ(2, iter->value()); + ++iter; + EXPECT_EQ(3, iter->value()); + ++iter; + EXPECT_EQ(list_.end(), iter); +} TEST_F(intrusive_list_test, swap) { list_.push_back(one_); diff --git a/app/tests/scheduler_test.cc b/app/tests/scheduler_test.cc index 9692710f75..971734d439 100644 --- a/app/tests/scheduler_test.cc +++ b/app/tests/scheduler_test.cc @@ -94,7 +94,6 @@ TEST_F(SchedulerTest, Basic) { EXPECT_TRUE(callback_sem1_.TimedWait(1000)); } -#ifdef FIREBASE_USE_STD_FUNCTION TEST_F(SchedulerTest, BasicStdFunction) { std::function func = [this]() { callback_sem1_.Post(); }; @@ -104,7 +103,6 @@ TEST_F(SchedulerTest, BasicStdFunction) { scheduler_.Schedule(func, 1); EXPECT_TRUE(callback_sem1_.TimedWait(1000)); } -#endif TEST_F(SchedulerTest, TriggerOrderNoDelay) { std::vector expected; diff --git a/app/tests/variant_test.cc b/app/tests/variant_test.cc index 28d9d6f483..12eef9dce0 100644 --- a/app/tests/variant_test.cc +++ b/app/tests/variant_test.cc @@ -278,14 +278,12 @@ TEST_F(VariantTest, TestSmallString) { Eq(VariantInternal::kInternalTypeSmallString)); EXPECT_THAT(v1c.string_value(), StrEq(small_str.c_str())); -#ifdef FIREBASE_USE_MOVE_OPERATORS // Test move constructor Variant temp(small_str); Variant v2(std::move(temp)); EXPECT_THAT(VariantInternal::type(v2), Eq(VariantInternal::kInternalTypeSmallString)); EXPECT_THAT(v2.string_value(), StrEq(small_str.c_str())); -#endif // Test construction of string bigger than max Variant v3(max_small_str); diff --git a/auth/tests/desktop/auth_desktop_test.cc b/auth/tests/desktop/auth_desktop_test.cc index 090678d358..dbf69ec0d2 100644 --- a/auth/tests/desktop/auth_desktop_test.cc +++ b/auth/tests/desktop/auth_desktop_test.cc @@ -917,7 +917,6 @@ TEST(UserViewTest, TestCopyUserView) { EXPECT_EQ("dangerm", view3.user_data().uid); } -#if defined(FIREBASE_USE_MOVE_OPERATORS) TEST(UserViewTest, TestMoveUserView) { UserData user1; user1.uid = "mrsspoon"; @@ -933,7 +932,6 @@ TEST(UserViewTest, TestMoveUserView) { view2 = std::move(view1); EXPECT_EQ("mrsspoon", view2.user_data().uid); } -#endif // defined(defined(FIREBASE_USE_MOVE_OPERATORS) } // namespace auth } // namespace firebase diff --git a/database/src/android/data_snapshot_android.cc b/database/src/android/data_snapshot_android.cc index af4d0603cc..ea324f1c62 100644 --- a/database/src/android/data_snapshot_android.cc +++ b/database/src/android/data_snapshot_android.cc @@ -66,7 +66,6 @@ DataSnapshotInternal& DataSnapshotInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal::DataSnapshotInternal(DataSnapshotInternal&& src) : db_(src.db_) { obj_ = src.obj_; @@ -80,7 +79,6 @@ DataSnapshotInternal& DataSnapshotInternal::operator=( src.obj_ = nullptr; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal::~DataSnapshotInternal() { if (obj_ != nullptr) { diff --git a/database/src/android/data_snapshot_android.h b/database/src/android/data_snapshot_android.h index cf8912cb4f..098aebb7a5 100644 --- a/database/src/android/data_snapshot_android.h +++ b/database/src/android/data_snapshot_android.h @@ -44,11 +44,9 @@ class DataSnapshotInternal { DataSnapshotInternal& operator=(const DataSnapshotInternal& snapshot); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal(DataSnapshotInternal&& snapshot); DataSnapshotInternal& operator=(DataSnapshotInternal&& snapshot); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~DataSnapshotInternal(); diff --git a/database/src/android/database_reference_android.cc b/database/src/android/database_reference_android.cc index d3d3947068..bca543eee3 100644 --- a/database/src/android/database_reference_android.cc +++ b/database/src/android/database_reference_android.cc @@ -90,7 +90,6 @@ DatabaseReferenceInternal& DatabaseReferenceInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal::DatabaseReferenceInternal( DatabaseReferenceInternal&& src) : QueryInternal(std::move(src)), cached_disconnection_handler_(nullptr) { @@ -103,7 +102,6 @@ DatabaseReferenceInternal& DatabaseReferenceInternal::operator=( db_->future_manager().MoveFutureApi(&src.future_api_id_, &future_api_id_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal::~DatabaseReferenceInternal() { if (cached_disconnection_handler_ != nullptr) { diff --git a/database/src/android/database_reference_android.h b/database/src/android/database_reference_android.h index a2a78ef33c..85cd733bbe 100644 --- a/database/src/android/database_reference_android.h +++ b/database/src/android/database_reference_android.h @@ -47,11 +47,9 @@ class DatabaseReferenceInternal : public QueryInternal { DatabaseReferenceInternal& operator=( const DatabaseReferenceInternal& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal(DatabaseReferenceInternal&& reference); DatabaseReferenceInternal& operator=(DatabaseReferenceInternal&& reference); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Database* GetDatabase() const; diff --git a/database/src/android/query_android.cc b/database/src/android/query_android.cc index 23ec28c43b..2dcd014a3d 100644 --- a/database/src/android/query_android.cc +++ b/database/src/android/query_android.cc @@ -119,7 +119,6 @@ QueryInternal& QueryInternal::operator=(const QueryInternal& src) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal::QueryInternal(QueryInternal&& src) : db_(src.db_) { obj_ = src.obj_; src.obj_ = nullptr; @@ -134,7 +133,6 @@ QueryInternal& QueryInternal::operator=(QueryInternal&& src) { query_spec_ = src.query_spec_; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal::~QueryInternal() { if (obj_ != nullptr) { diff --git a/database/src/android/query_android.h b/database/src/android/query_android.h index 585a66acda..72de19be8d 100644 --- a/database/src/android/query_android.h +++ b/database/src/android/query_android.h @@ -43,11 +43,9 @@ class QueryInternal { QueryInternal& operator=(const QueryInternal& query); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal(QueryInternal&& query); QueryInternal& operator=(QueryInternal&& query); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) virtual ~QueryInternal(); diff --git a/database/src/common/data_snapshot.cc b/database/src/common/data_snapshot.cc index 900baec185..e6d2d38de1 100644 --- a/database/src/common/data_snapshot.cc +++ b/database/src/common/data_snapshot.cc @@ -71,7 +71,6 @@ DataSnapshot& DataSnapshot::operator=(const DataSnapshot& src) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshot::DataSnapshot(DataSnapshot&& snapshot) { CleanupFnDataSnapshot::Unregister(&snapshot, snapshot.internal_); internal_ = snapshot.internal_; @@ -88,7 +87,6 @@ DataSnapshot& DataSnapshot::operator=(DataSnapshot&& snapshot) { CleanupFnDataSnapshot::Register(this, internal_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshot::~DataSnapshot() { CleanupFnDataSnapshot::Unregister(this, internal_); diff --git a/database/src/common/database_reference.cc b/database/src/common/database_reference.cc index dce0de7481..f7d531013b 100644 --- a/database/src/common/database_reference.cc +++ b/database/src/common/database_reference.cc @@ -109,7 +109,6 @@ DatabaseReference& DatabaseReference::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReference::DatabaseReference(DatabaseReference&& reference) : Query(), internal_(reference.internal_) { MutexLock lock(internal::g_database_reference_constructor_mutex); @@ -129,7 +128,6 @@ DatabaseReference& DatabaseReference::operator=(DatabaseReference&& reference) { return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReference::~DatabaseReference() { SwitchCleanupRegistrationBackToQuery(); diff --git a/database/src/common/mutable_data.cc b/database/src/common/mutable_data.cc index eabc17ad7a..3695d6fc38 100644 --- a/database/src/common/mutable_data.cc +++ b/database/src/common/mutable_data.cc @@ -54,7 +54,6 @@ MutableData::MutableData(MutableDataInternal* internal) : internal_(internal) { CleanupFnMutableData::Register(this, internal_); } -#if defined(FIREBASE_USE_MOVE_OPERATORS) MutableData::MutableData(MutableData&& rhs) : internal_(rhs.internal_) { rhs.internal_ = nullptr; CleanupFnMutableData::Unregister(&rhs, internal_); @@ -70,7 +69,6 @@ MutableData& MutableData::operator=(MutableData&& rhs) { CleanupFnMutableData::Register(this, internal_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) MutableData::~MutableData() { CleanupFnMutableData::Unregister(this, internal_); diff --git a/database/src/common/query.cc b/database/src/common/query.cc index 670bf42840..b964537eab 100644 --- a/database/src/common/query.cc +++ b/database/src/common/query.cc @@ -81,7 +81,6 @@ Query& Query::operator=(const Query& src) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Query::Query(Query&& query) : internal_(query.internal_) { query.UnregisterCleanup(); query.internal_ = nullptr; @@ -95,7 +94,6 @@ Query& Query::operator=(Query&& query) { SetInternal(internal); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) bool operator==(const Query& lhs, const Query& rhs) { if (!lhs.is_valid() && !rhs.is_valid()) return true; // both invalid diff --git a/database/src/desktop/data_snapshot_desktop.cc b/database/src/desktop/data_snapshot_desktop.cc index 4fa5bca7b2..e8406b7ad7 100644 --- a/database/src/desktop/data_snapshot_desktop.cc +++ b/database/src/desktop/data_snapshot_desktop.cc @@ -52,7 +52,6 @@ DataSnapshotInternal& DataSnapshotInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal::DataSnapshotInternal(DataSnapshotInternal&& internal) { database_ = internal.database_; data_ = std::move(internal.data_); @@ -66,7 +65,6 @@ DataSnapshotInternal& DataSnapshotInternal::operator=( query_spec_ = std::move(internal.query_spec_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal::~DataSnapshotInternal() {} diff --git a/database/src/desktop/data_snapshot_desktop.h b/database/src/desktop/data_snapshot_desktop.h index a0c91fc42f..b9499b22da 100644 --- a/database/src/desktop/data_snapshot_desktop.h +++ b/database/src/desktop/data_snapshot_desktop.h @@ -45,11 +45,9 @@ class DataSnapshotInternal { DataSnapshotInternal& operator=(const DataSnapshotInternal& snapshot); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal(DataSnapshotInternal&& snapshot); DataSnapshotInternal& operator=(DataSnapshotInternal&& snapshot); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~DataSnapshotInternal(); diff --git a/database/src/desktop/database_reference_desktop.cc b/database/src/desktop/database_reference_desktop.cc index 7ad0d5a254..d924c63ed6 100644 --- a/database/src/desktop/database_reference_desktop.cc +++ b/database/src/desktop/database_reference_desktop.cc @@ -61,7 +61,6 @@ DatabaseReferenceInternal& DatabaseReferenceInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal::DatabaseReferenceInternal( DatabaseReferenceInternal&& internal) { if (database_) { @@ -80,7 +79,6 @@ DatabaseReferenceInternal& DatabaseReferenceInternal::operator=( QueryInternal::operator=(std::move(internal)); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Database* DatabaseReferenceInternal::GetDatabase() const { return database_ ? Database::GetInstance(database_->GetApp()) : nullptr; diff --git a/database/src/desktop/database_reference_desktop.h b/database/src/desktop/database_reference_desktop.h index 40b75131b9..41b5e8afd9 100644 --- a/database/src/desktop/database_reference_desktop.h +++ b/database/src/desktop/database_reference_desktop.h @@ -40,11 +40,9 @@ class DatabaseReferenceInternal : public QueryInternal { DatabaseReferenceInternal& operator=( const DatabaseReferenceInternal& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal(DatabaseReferenceInternal&& reference); DatabaseReferenceInternal& operator=(DatabaseReferenceInternal&& reference); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Database* GetDatabase() const; diff --git a/database/src/desktop/query_desktop.cc b/database/src/desktop/query_desktop.cc index 5fba0e1035..3636c75610 100644 --- a/database/src/desktop/query_desktop.cc +++ b/database/src/desktop/query_desktop.cc @@ -111,7 +111,6 @@ QueryInternal& QueryInternal::operator=(const QueryInternal& internal) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal::QueryInternal(QueryInternal&& internal) : database_(internal.database_), query_spec_(std::move(internal.query_spec_)) { @@ -130,7 +129,6 @@ QueryInternal& QueryInternal::operator=(QueryInternal&& internal) { } return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal::~QueryInternal() {} diff --git a/database/src/desktop/query_desktop.h b/database/src/desktop/query_desktop.h index 3b21ea6f5e..869edd0d6f 100644 --- a/database/src/desktop/query_desktop.h +++ b/database/src/desktop/query_desktop.h @@ -46,11 +46,9 @@ class QueryInternal { QueryInternal& operator=(const QueryInternal& query); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal(QueryInternal&& query); QueryInternal& operator=(QueryInternal&& query); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) virtual ~QueryInternal(); diff --git a/database/src/include/firebase/database/data_snapshot.h b/database/src/include/firebase/database/data_snapshot.h index cb83292a79..0d1b1a8db7 100644 --- a/database/src/include/firebase/database/data_snapshot.h +++ b/database/src/include/firebase/database/data_snapshot.h @@ -72,7 +72,7 @@ class DataSnapshot { /// @returns Reference to the destination DataSnapshot. DataSnapshot& operator=(const DataSnapshot& snapshot); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// @brief Move constructor. DataSnapshots are immutable, so they can be /// efficiently moved. /// @@ -86,7 +86,7 @@ class DataSnapshot { /// /// @returns Reference to this destination DataSnapshot. DataSnapshot& operator=(DataSnapshot&& snapshot); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG /// Destructor. ~DataSnapshot(); diff --git a/database/src/include/firebase/database/database_reference.h b/database/src/include/firebase/database/database_reference.h index ccbe51a145..1ed47ad5fc 100644 --- a/database/src/include/firebase/database/database_reference.h +++ b/database/src/include/firebase/database/database_reference.h @@ -69,7 +69,7 @@ class DatabaseReference : public Query { /// @returns Reference to the destination DatabaseReference. DatabaseReference& operator=(const DatabaseReference& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for /// DatabaseReference instances. /// @@ -83,7 +83,7 @@ class DatabaseReference : public Query { /// /// @returns Reference to the destination DatabaseReference. DatabaseReference& operator=(DatabaseReference&& reference); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG /// @brief Gets the database to which we refer. /// @@ -203,7 +203,7 @@ class DatabaseReference : public Query { DoTransactionWithContext transaction_function, void* context, bool trigger_local_events = true); -#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#ifndef SWIG /// @brief Run a user-supplied callback, possibly multiple times, to perform /// an atomic transaction on the database. /// @@ -234,7 +234,7 @@ class DatabaseReference : public Query { Future RunTransaction( DoTransactionFunction transaction_function, bool trigger_local_events = true); -#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#endif // SWIG /// @brief Get the result of the most recent call to RunTransaction(). /// diff --git a/database/src/include/firebase/database/mutable_data.h b/database/src/include/firebase/database/mutable_data.h index 97d716f814..3a8dbfe57c 100644 --- a/database/src/include/firebase/database/mutable_data.h +++ b/database/src/include/firebase/database/mutable_data.h @@ -34,14 +34,15 @@ class Repo; #endif // SWIG class MutableData { public: -#if defined(FIREBASE_USE_MOVE_OPERATORS) - /// Move constructor +#ifndef SWIG + /// Move constructor. /// Move is more efficient than copy and delete. MutableData(MutableData&& rhs); - // MutableData may be moved. + /// Move assignment operator. + /// Move is more efficient than copy and delete. MutableData& operator=(MutableData&& rhs); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) +#endif // SWIG /// Destructor. ~MutableData(); diff --git a/database/src/include/firebase/database/query.h b/database/src/include/firebase/database/query.h index c60707a7ee..8b01ef59e8 100644 --- a/database/src/include/firebase/database/query.h +++ b/database/src/include/firebase/database/query.h @@ -48,12 +48,12 @@ class Query { /// independently of each other. Query& operator=(const Query& query); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// Move constructor. Query(Query&& query); /// Move assignment operator. Query& operator=(Query&& query); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG /// @brief Required virtual destructor. virtual ~Query(); diff --git a/database/src/include/firebase/database/transaction.h b/database/src/include/firebase/database/transaction.h index ab91818be7..5821e21023 100644 --- a/database/src/include/firebase/database/transaction.h +++ b/database/src/include/firebase/database/transaction.h @@ -15,16 +15,14 @@ #ifndef FIREBASE_DATABASE_SRC_INCLUDE_FIREBASE_DATABASE_TRANSACTION_H_ #define FIREBASE_DATABASE_SRC_INCLUDE_FIREBASE_DATABASE_TRANSACTION_H_ +#include + #include "firebase/database/common.h" #include "firebase/database/data_snapshot.h" #include "firebase/database/mutable_data.h" #include "firebase/internal/common.h" #include "firebase/variant.h" -#if defined(FIREBASE_USE_STD_FUNCTION) -#include -#endif // defined(FIREBASE_USE_STD_FUNCTION) - namespace firebase { namespace database { @@ -83,7 +81,7 @@ typedef TransactionResult (*DoTransaction)(MutableData* data); typedef TransactionResult (*DoTransactionWithContext)(MutableData* data, void* context); -#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#ifndef SWIG /// Your own transaction handler function or lambda, which the Firebase Realtime /// Database library may call multiple times to apply changes to the data, and /// should return success or failure depending on whether it succeeds. @@ -91,7 +89,7 @@ typedef TransactionResult (*DoTransactionWithContext)(MutableData* data, /// @see DoTransactionWithContext for more information. typedef std::function DoTransactionFunction; -#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) +#endif // SWIG } // namespace database } // namespace firebase diff --git a/database/src/ios/data_snapshot_ios.h b/database/src/ios/data_snapshot_ios.h index aeb265d380..26e36fd3ae 100644 --- a/database/src/ios/data_snapshot_ios.h +++ b/database/src/ios/data_snapshot_ios.h @@ -53,11 +53,9 @@ class DataSnapshotInternal { DataSnapshotInternal& operator=(const DataSnapshotInternal& snapshot); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal(DataSnapshotInternal&& snapshot); DataSnapshotInternal& operator=(DataSnapshotInternal&& snapshot); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~DataSnapshotInternal(); diff --git a/database/src/ios/data_snapshot_ios.mm b/database/src/ios/data_snapshot_ios.mm index ad7e0b0f16..ca70d2100f 100644 --- a/database/src/ios/data_snapshot_ios.mm +++ b/database/src/ios/data_snapshot_ios.mm @@ -45,7 +45,6 @@ return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal::DataSnapshotInternal(DataSnapshotInternal&& other) { database_ = std::move(other.database_); impl_ = std::move(other.impl_); @@ -58,7 +57,6 @@ other.impl_ = std::make_unique(nil); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DataSnapshotInternal::~DataSnapshotInternal() {} diff --git a/database/src/ios/database_reference_ios.h b/database/src/ios/database_reference_ios.h index ad4af87ec7..2f70159d82 100644 --- a/database/src/ios/database_reference_ios.h +++ b/database/src/ios/database_reference_ios.h @@ -58,11 +58,9 @@ class DatabaseReferenceInternal : public QueryInternal { DatabaseReferenceInternal& operator=( const DatabaseReferenceInternal& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal(DatabaseReferenceInternal&& reference); DatabaseReferenceInternal& operator=(DatabaseReferenceInternal&& reference); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Gets the database to which we refer. Database* GetDatabase() const; diff --git a/database/src/ios/database_reference_ios.mm b/database/src/ios/database_reference_ios.mm index 6582b5dd84..b2143ed1c2 100644 --- a/database/src/ios/database_reference_ios.mm +++ b/database/src/ios/database_reference_ios.mm @@ -62,7 +62,6 @@ return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) DatabaseReferenceInternal::DatabaseReferenceInternal(DatabaseReferenceInternal&& other) : QueryInternal(std::move(other)), impl_(std::move(other.impl_)) { other.impl_ = std::make_unique(nil); @@ -76,7 +75,6 @@ database_->future_manager().MoveFutureApi(&other.future_api_id_, &future_api_id_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Database* DatabaseReferenceInternal::GetDatabase() const { return Database::GetInstance(database_->GetApp()); diff --git a/database/src/ios/query_ios.h b/database/src/ios/query_ios.h index fc8436bdab..a29b995561 100644 --- a/database/src/ios/query_ios.h +++ b/database/src/ios/query_ios.h @@ -93,11 +93,9 @@ class QueryInternal { QueryInternal& operator=(const QueryInternal& query); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal(QueryInternal&& query); QueryInternal& operator=(QueryInternal&& query); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) virtual ~QueryInternal(); diff --git a/database/src/ios/query_ios.mm b/database/src/ios/query_ios.mm index a1ba81abeb..1359f10c7d 100644 --- a/database/src/ios/query_ios.mm +++ b/database/src/ios/query_ios.mm @@ -105,7 +105,6 @@ void LogException(Logger* logger, const char* name, const char* url, NSException return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal::QueryInternal(QueryInternal&& other) : database_(other.database_) { impl_ = std::move(other.impl_); other.impl_ = std::make_unique(nil); @@ -120,7 +119,6 @@ void LogException(Logger* logger, const char* name, const char* url, NSException query_spec_ = other.query_spec_; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) QueryInternal::~QueryInternal() { database_->future_manager().ReleaseFutureApi(&future_api_id_); } diff --git a/functions/src/android/callable_reference_android.cc b/functions/src/android/callable_reference_android.cc index 7cb1df998f..3f9a39c616 100644 --- a/functions/src/android/callable_reference_android.cc +++ b/functions/src/android/callable_reference_android.cc @@ -97,7 +97,6 @@ HttpsCallableReferenceInternal& HttpsCallableReferenceInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReferenceInternal::HttpsCallableReferenceInternal( HttpsCallableReferenceInternal&& src) : functions_(src.functions_) { @@ -113,7 +112,6 @@ HttpsCallableReferenceInternal& HttpsCallableReferenceInternal::operator=( functions_->future_manager().MoveFutureApi(&src, this); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReferenceInternal::~HttpsCallableReferenceInternal() { if (obj_ != nullptr) { diff --git a/functions/src/android/callable_reference_android.h b/functions/src/android/callable_reference_android.h index 54a9d84e5c..811ca4efb3 100644 --- a/functions/src/android/callable_reference_android.h +++ b/functions/src/android/callable_reference_android.h @@ -43,12 +43,10 @@ class HttpsCallableReferenceInternal { HttpsCallableReferenceInternal& operator=( const HttpsCallableReferenceInternal& ref); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReferenceInternal(HttpsCallableReferenceInternal&& ref); HttpsCallableReferenceInternal& operator=( HttpsCallableReferenceInternal&& ref); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~HttpsCallableReferenceInternal(); diff --git a/functions/src/common/callable_reference.cc b/functions/src/common/callable_reference.cc index 54b1dcb01e..88ccf22056 100644 --- a/functions/src/common/callable_reference.cc +++ b/functions/src/common/callable_reference.cc @@ -89,7 +89,6 @@ HttpsCallableReference& HttpsCallableReference::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReference::HttpsCallableReference(HttpsCallableReference&& other) { UnregisterForCleanup(&other, other.internal_); internal_ = other.internal_; @@ -107,7 +106,6 @@ HttpsCallableReference& HttpsCallableReference::operator=( RegisterForCleanup(this, internal_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReference::~HttpsCallableReference() { UnregisterForCleanup(this, internal_); diff --git a/functions/src/desktop/callable_reference_desktop.cc b/functions/src/desktop/callable_reference_desktop.cc index c99a1a44d5..96534d43e8 100644 --- a/functions/src/desktop/callable_reference_desktop.cc +++ b/functions/src/desktop/callable_reference_desktop.cc @@ -63,7 +63,6 @@ HttpsCallableReferenceInternal& HttpsCallableReferenceInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReferenceInternal::HttpsCallableReferenceInternal( HttpsCallableReferenceInternal&& other) : functions_(other.functions_), @@ -84,7 +83,6 @@ HttpsCallableReferenceInternal& HttpsCallableReferenceInternal::operator=( functions_->future_manager().MoveFutureApi(&other, this); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Functions* HttpsCallableReferenceInternal::functions() const { return Functions::GetInstance(functions_->app()); diff --git a/functions/src/desktop/callable_reference_desktop.h b/functions/src/desktop/callable_reference_desktop.h index d8654aeb87..9fe272fc65 100644 --- a/functions/src/desktop/callable_reference_desktop.h +++ b/functions/src/desktop/callable_reference_desktop.h @@ -69,7 +69,6 @@ class HttpsCallableReferenceInternal { HttpsCallableReferenceInternal& operator=( const HttpsCallableReferenceInternal& other); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Move constructor. Moving is an efficient operation for // HttpsCallableReferenceInternal instances. HttpsCallableReferenceInternal(HttpsCallableReferenceInternal&& other); @@ -78,7 +77,6 @@ class HttpsCallableReferenceInternal { // HttpsCallableReferenceInternal instances. HttpsCallableReferenceInternal& operator=( HttpsCallableReferenceInternal&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Gets the functions to which we refer. // TODO(klimt): Do we really need this method? diff --git a/functions/src/include/firebase/functions/callable_reference.h b/functions/src/include/firebase/functions/callable_reference.h index 58329cab13..ea70bc317f 100644 --- a/functions/src/include/firebase/functions/callable_reference.h +++ b/functions/src/include/firebase/functions/callable_reference.h @@ -75,7 +75,6 @@ class HttpsCallableReference { /// @returns Reference to the destination HttpsCallableReference. HttpsCallableReference& operator=(const HttpsCallableReference& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) /// @brief Move constructor. Moving is an efficient operation for /// HttpsCallableReference instances. /// @@ -89,7 +88,6 @@ class HttpsCallableReference { /// /// @returns Reference to the destination HttpsCallableReference. HttpsCallableReference& operator=(HttpsCallableReference&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) /// @brief Gets the firebase::functions::Functions instance to which we refer. /// diff --git a/functions/src/include/firebase/functions/callable_result.h b/functions/src/include/firebase/functions/callable_result.h index 5186377ae8..3868cce25f 100644 --- a/functions/src/include/firebase/functions/callable_result.h +++ b/functions/src/include/firebase/functions/callable_result.h @@ -15,6 +15,8 @@ #ifndef FIREBASE_FUNCTIONS_SRC_INCLUDE_FIREBASE_FUNCTIONS_CALLABLE_RESULT_H_ #define FIREBASE_FUNCTIONS_SRC_INCLUDE_FIREBASE_FUNCTIONS_CALLABLE_RESULT_H_ +#include + #include "firebase/functions/common.h" #include "firebase/variant.h" @@ -50,7 +52,6 @@ class HttpsCallableResult { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) /// @brief Move constructor. Moving is an efficient operation for /// HttpsCallableResult instances. /// @@ -70,8 +71,6 @@ class HttpsCallableResult { return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) - /// @brief Returns the data that is the result of a Call. /// /// @returns The variant containing the data. @@ -82,9 +81,7 @@ class HttpsCallableResult { // Only functions are allowed to construct results. friend class ::firebase::functions::internal::HttpsCallableReferenceInternal; HttpsCallableResult(const Variant& data) : data_(data) {} -#if defined(FIREBASE_USE_MOVE_OPERATORS) HttpsCallableResult(Variant&& data) : data_(std::move(data)) {} -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) Variant data_; /// @endcond diff --git a/functions/src/ios/callable_reference_ios.h b/functions/src/ios/callable_reference_ios.h index 9fba56e16a..7f94993c1f 100644 --- a/functions/src/ios/callable_reference_ios.h +++ b/functions/src/ios/callable_reference_ios.h @@ -55,7 +55,6 @@ class HttpsCallableReferenceInternal { // location. HttpsCallableReferenceInternal& operator=(const HttpsCallableReferenceInternal& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Move constructor. Moving is an efficient operation for // HttpsCallableReferenceInternal instances. HttpsCallableReferenceInternal(HttpsCallableReferenceInternal&& other); @@ -63,7 +62,6 @@ class HttpsCallableReferenceInternal { // Move assignment operator. Moving is an efficient operation for // HttpsCallableReferenceInternal instances. HttpsCallableReferenceInternal& operator=(HttpsCallableReferenceInternal&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Gets the functions to which we refer. Functions* functions(); diff --git a/functions/src/ios/callable_reference_ios.mm b/functions/src/ios/callable_reference_ios.mm index 66519336de..b13ea3cb06 100644 --- a/functions/src/ios/callable_reference_ios.mm +++ b/functions/src/ios/callable_reference_ios.mm @@ -82,7 +82,6 @@ Error NSErrorToErrorCode(NSError* error) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) HttpsCallableReferenceInternal::HttpsCallableReferenceInternal( HttpsCallableReferenceInternal&& other) : functions_(other.functions_), impl_(std::move(other.impl_)) { @@ -100,7 +99,6 @@ Error NSErrorToErrorCode(NSError* error) { functions_->future_manager().MoveFutureApi(&other, this); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Functions* HttpsCallableReferenceInternal::functions() { return Functions::GetInstance(functions_->app()); diff --git a/storage/src/android/metadata_android.cc b/storage/src/android/metadata_android.cc index 38088cfb08..2924410152 100644 --- a/storage/src/android/metadata_android.cc +++ b/storage/src/android/metadata_android.cc @@ -148,7 +148,6 @@ MetadataInternal& MetadataInternal::operator=(const MetadataInternal& src) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal::MetadataInternal(MetadataInternal&& src) : storage_(src.storage_) { obj_ = src.obj_; @@ -182,7 +181,6 @@ MetadataInternal& MetadataInternal::operator=(MetadataInternal&& src) { constants_ = src.constants_; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) void MetadataInternal::CopyJavaMetadataObject(JNIEnv* env, jobject src_obj) { // Use StorageMetadata.Builder to create a copy of the existing object. diff --git a/storage/src/android/metadata_android.h b/storage/src/android/metadata_android.h index b54030e05e..c37ffe3436 100644 --- a/storage/src/android/metadata_android.h +++ b/storage/src/android/metadata_android.h @@ -106,11 +106,9 @@ class MetadataInternal { MetadataInternal& operator=(const MetadataInternal& ref); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal(MetadataInternal&& ref); MetadataInternal& operator=(MetadataInternal&& ref); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~MetadataInternal(); diff --git a/storage/src/android/storage_reference_android.cc b/storage/src/android/storage_reference_android.cc index 7797542a67..75943faa43 100644 --- a/storage/src/android/storage_reference_android.cc +++ b/storage/src/android/storage_reference_android.cc @@ -161,7 +161,6 @@ StorageReferenceInternal& StorageReferenceInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageReferenceInternal::StorageReferenceInternal( StorageReferenceInternal&& src) : storage_(src.storage_) { @@ -177,7 +176,6 @@ StorageReferenceInternal& StorageReferenceInternal::operator=( storage_->future_manager().MoveFutureApi(&src, this); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageReferenceInternal::~StorageReferenceInternal() { if (obj_ != nullptr) { diff --git a/storage/src/android/storage_reference_android.h b/storage/src/android/storage_reference_android.h index 94c70e5c5f..1ba48cee1e 100644 --- a/storage/src/android/storage_reference_android.h +++ b/storage/src/android/storage_reference_android.h @@ -41,11 +41,9 @@ class StorageReferenceInternal { StorageReferenceInternal& operator=(const StorageReferenceInternal& ref); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageReferenceInternal(StorageReferenceInternal&& ref); StorageReferenceInternal& operator=(StorageReferenceInternal&& ref); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~StorageReferenceInternal(); diff --git a/storage/src/common/controller.cc b/storage/src/common/controller.cc index 8832c6fa6e..0d48638526 100644 --- a/storage/src/common/controller.cc +++ b/storage/src/common/controller.cc @@ -49,7 +49,6 @@ Controller& Controller::operator=(const Controller& other) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Controller::Controller(Controller&& other) { internal_ = other.internal_; other.internal_ = nullptr; @@ -61,7 +60,6 @@ Controller& Controller::operator=(Controller&& other) { other.internal_ = nullptr; return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Controller::~Controller() { if (internal_) delete internal_; diff --git a/storage/src/common/list_result.cc b/storage/src/common/list_result.cc index 1aafac0b47..c02dbab8e4 100644 --- a/storage/src/common/list_result.cc +++ b/storage/src/common/list_result.cc @@ -42,7 +42,6 @@ StorageListResult& StorageListResult::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageListResult::StorageListResult(StorageListResult&& other) : internal_(other.internal_) { other.internal_ = nullptr; @@ -56,7 +55,6 @@ StorageListResult& StorageListResult::operator=(StorageListResult&& other) { } return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) const std::vector& StorageListResult::prefixes() const { static const std::vector empty_vector; diff --git a/storage/src/common/metadata.cc b/storage/src/common/metadata.cc index 6bf9ece640..fb94ac3eb6 100644 --- a/storage/src/common/metadata.cc +++ b/storage/src/common/metadata.cc @@ -105,7 +105,6 @@ Metadata& Metadata::operator=(const Metadata& src) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Metadata::Metadata(Metadata&& other) : internal_(other.internal_) { MetadataInternalCommon::UnregisterForCleanup(&other, other.internal_); other.internal_ = nullptr; @@ -120,7 +119,6 @@ Metadata& Metadata::operator=(Metadata&& other) { MetadataInternalCommon::RegisterForCleanup(this, internal_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Metadata::~Metadata() { MetadataInternalCommon::DeleteInternal(this); } diff --git a/storage/src/common/storage_reference.cc b/storage/src/common/storage_reference.cc index 1b5fb4e3b2..c40cf23d4d 100644 --- a/storage/src/common/storage_reference.cc +++ b/storage/src/common/storage_reference.cc @@ -100,7 +100,6 @@ StorageReference& StorageReference::operator=(const StorageReference& other) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageReference::StorageReference(StorageReference&& other) { StorageReferenceInternalCommon::UnregisterForCleanup(&other, other.internal_); internal_ = other.internal_; @@ -116,7 +115,6 @@ StorageReference& StorageReference::operator=(StorageReference&& other) { StorageReferenceInternalCommon::RegisterForCleanup(this, internal_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageReference::~StorageReference() { StorageReferenceInternalCommon::DeleteInternal(this); diff --git a/storage/src/desktop/metadata_desktop.cc b/storage/src/desktop/metadata_desktop.cc index 90121bf036..68b543df02 100644 --- a/storage/src/desktop/metadata_desktop.cc +++ b/storage/src/desktop/metadata_desktop.cc @@ -98,7 +98,6 @@ MetadataInternal& MetadataInternal::operator=( return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal::MetadataInternal(MetadataInternal&& other) { *this = std::move(other); } @@ -126,7 +125,6 @@ MetadataInternal& MetadataInternal::operator=(MetadataInternal&& other) { download_url_ = std::move(other.download_url_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) const char* MetadataInternal::download_url() const { return download_url_.c_str(); diff --git a/storage/src/desktop/metadata_desktop.h b/storage/src/desktop/metadata_desktop.h index a772b8a968..65c1b70634 100644 --- a/storage/src/desktop/metadata_desktop.h +++ b/storage/src/desktop/metadata_desktop.h @@ -59,11 +59,9 @@ class MetadataInternal { MetadataInternal& operator=(const MetadataInternal& metadata); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal(MetadataInternal&& other); MetadataInternal& operator=(MetadataInternal&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~MetadataInternal() {} diff --git a/storage/src/include/firebase/storage/controller.h b/storage/src/include/firebase/storage/controller.h index 33e10f3612..aa57791281 100644 --- a/storage/src/include/firebase/storage/controller.h +++ b/storage/src/include/firebase/storage/controller.h @@ -71,7 +71,7 @@ class Controller { /// @returns Reference to the destination Controller. Controller& operator=(const Controller& other); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for /// Controller instances. /// @@ -85,7 +85,7 @@ class Controller { /// /// @returns Reference to the destination Controller. Controller& operator=(Controller&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG /// @brief Pauses the operation currently in progress. /// diff --git a/storage/src/include/firebase/storage/list_result.h b/storage/src/include/firebase/storage/list_result.h index 9dbdc5579c..b693dedde0 100644 --- a/storage/src/include/firebase/storage/list_result.h +++ b/storage/src/include/firebase/storage/list_result.h @@ -51,7 +51,7 @@ class StorageListResult { /// @returns Reference to the destination StorageListResult. StorageListResult& operator=(const StorageListResult& other); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// @brief Move constructor. /// /// @param[in] other StorageListResult to move data from. @@ -63,7 +63,7 @@ class StorageListResult { /// /// @returns Reference to the destination StorageListResult. StorageListResult& operator=(StorageListResult&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG /// @brief Returns the prefixes (folders) returned by the List operation. /// diff --git a/storage/src/include/firebase/storage/metadata.h b/storage/src/include/firebase/storage/metadata.h index ff8c44f6a4..d49cead055 100644 --- a/storage/src/include/firebase/storage/metadata.h +++ b/storage/src/include/firebase/storage/metadata.h @@ -63,7 +63,7 @@ class Metadata { /// @returns Reference to the destination Metadata. Metadata& operator=(const Metadata& other); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for Metadata. /// /// @param[in] other Metadata to move from. @@ -76,7 +76,7 @@ class Metadata { /// /// @returns Reference to the destination Metadata. Metadata& operator=(Metadata&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG ~Metadata(); diff --git a/storage/src/include/firebase/storage/storage_reference.h b/storage/src/include/firebase/storage/storage_reference.h index 305e8cee25..f332c6588f 100644 --- a/storage/src/include/firebase/storage/storage_reference.h +++ b/storage/src/include/firebase/storage/storage_reference.h @@ -68,7 +68,7 @@ class StorageReference { /// @returns Reference to the destination StorageReference. StorageReference& operator=(const StorageReference& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for /// StorageReference instances. /// @@ -82,7 +82,7 @@ class StorageReference { /// /// @returns Reference to the destination StorageReference. StorageReference& operator=(StorageReference&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) +#endif // SWIG /// @brief Gets the firebase::storage::Storage instance to which we refer. /// diff --git a/storage/src/ios/metadata_ios.h b/storage/src/ios/metadata_ios.h index 1ae06eecea..30328e5a43 100644 --- a/storage/src/ios/metadata_ios.h +++ b/storage/src/ios/metadata_ios.h @@ -52,11 +52,9 @@ class MetadataInternal { MetadataInternal& operator=(const MetadataInternal& metadata); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal(MetadataInternal&& other); MetadataInternal& operator=(MetadataInternal&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) ~MetadataInternal(); diff --git a/storage/src/ios/metadata_ios.mm b/storage/src/ios/metadata_ios.mm index a005f06706..ca921c242e 100644 --- a/storage/src/ios/metadata_ios.mm +++ b/storage/src/ios/metadata_ios.mm @@ -80,7 +80,6 @@ static int64_t NSDateToMilliseconds(NSDate *date) { return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal::MetadataInternal(MetadataInternal&& other) { storage_ = other.storage_; other.storage_ = nullptr; @@ -98,7 +97,6 @@ static int64_t NSDateToMilliseconds(NSDate *date) { custom_metadata_ = std::move(other.custom_metadata_); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) MetadataInternal::~MetadataInternal() { if (custom_metadata_) { diff --git a/storage/src/ios/storage_reference_ios.h b/storage/src/ios/storage_reference_ios.h index 58b8b49732..bafff399b7 100644 --- a/storage/src/ios/storage_reference_ios.h +++ b/storage/src/ios/storage_reference_ios.h @@ -60,7 +60,6 @@ class StorageReferenceInternal { StorageReferenceInternal& operator=( const StorageReferenceInternal& reference); -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Move constructor. Moving is an efficient operation for // StorageReferenceInternal instances. StorageReferenceInternal(StorageReferenceInternal&& other); @@ -68,7 +67,6 @@ class StorageReferenceInternal { // Move assignment operator. Moving is an efficient operation for // StorageReferenceInternal instances. StorageReferenceInternal& operator=(StorageReferenceInternal&& other); -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) // Gets the storage to which we refer. Storage* _Nonnull storage(); diff --git a/storage/src/ios/storage_reference_ios.mm b/storage/src/ios/storage_reference_ios.mm index 7630a957fc..20f911ac3e 100644 --- a/storage/src/ios/storage_reference_ios.mm +++ b/storage/src/ios/storage_reference_ios.mm @@ -72,7 +72,6 @@ return *this; } -#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) StorageReferenceInternal::StorageReferenceInternal(StorageReferenceInternal&& other) : storage_(other.storage_), impl_(std::move(other.impl_)) { other.storage_ = nullptr; @@ -89,7 +88,6 @@ storage_->future_manager().MoveFutureApi(&other, this); return *this; } -#endif // defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN) Storage* StorageReferenceInternal::storage() { return Storage::GetInstance(storage_->app()); From 60c79e599fa1c7bcc9e85dd1b3f2c69526e3b944 Mon Sep 17 00:00:00 2001 From: austinbenoit Date: Fri, 27 Nov 2026 17:05:07 +0000 Subject: [PATCH 2/2] Keep PR strictly macro removal: drop added #ifndef SWIG guards and intrusive_list logic edits --- app/src/include/firebase/future.h | 12 ---- app/src/intrusive_list.h | 18 ++---- app/tests/intrusive_list_test.cc | 55 ------------------- .../include/firebase/database/data_snapshot.h | 2 - .../firebase/database/database_reference.h | 4 -- .../include/firebase/database/mutable_data.h | 2 - .../src/include/firebase/database/query.h | 2 - .../include/firebase/database/transaction.h | 2 - .../src/include/firebase/storage/controller.h | 2 - .../include/firebase/storage/list_result.h | 2 - .../src/include/firebase/storage/metadata.h | 2 - .../firebase/storage/storage_reference.h | 2 - 12 files changed, 6 insertions(+), 99 deletions(-) diff --git a/app/src/include/firebase/future.h b/app/src/include/firebase/future.h index 8f8bdbc6d2..00b591739c 100644 --- a/app/src/include/firebase/future.h +++ b/app/src/include/firebase/future.h @@ -67,11 +67,9 @@ class FutureHandle { FutureHandle(const FutureHandle& rhs); FutureHandle& operator=(const FutureHandle& rhs); -#ifndef SWIG // Move constructor and assignment operator. FutureHandle(FutureHandle&& rhs) noexcept; FutureHandle& operator=(FutureHandle&& rhs) noexcept; -#endif // SWIG // Comparison operators. bool operator!=(const FutureHandle& rhs) const { return !(*this == rhs); } @@ -156,7 +154,6 @@ class FutureBase { /// Copy an untyped future. FutureBase& operator=(const FutureBase& rhs); -#ifndef SWIG /// Move constructor. /// Move is more efficient than copy and delete because we don't touch the /// reference counting in the API. @@ -164,7 +161,6 @@ class FutureBase { /// Move an untyped future. FutureBase& operator=(FutureBase&& rhs) noexcept; -#endif // SWIG /// Explicitly release the internal resources for a future. /// Future will become invalid. @@ -233,7 +229,6 @@ class FutureBase { /// callback. void OnCompletion(CompletionCallback callback, void* user_data) const; -#ifndef SWIG /// Register a single callback that will be called at most once, when the /// future is completed. /// @@ -251,7 +246,6 @@ class FutureBase { /// /// @param[in] callback Function or lambda to call. void OnCompletion(std::function callback) const; -#endif // SWIG #if defined(INTERNAL_EXPERIMENTAL) /// Like OnCompletion, but allows adding multiple callbacks. @@ -272,7 +266,6 @@ class FutureBase { CompletionCallbackHandle AddOnCompletion(CompletionCallback callback, void* user_data) const; -#ifndef SWIG /// Like OnCompletion, but allows adding multiple callbacks. /// /// If you call AddCompletion() more than once, all of the completions that @@ -288,7 +281,6 @@ class FutureBase { /// @return A handle that can be passed to RemoveOnCompletion. CompletionCallbackHandle AddOnCompletion( std::function callback) const; -#endif // SWIG /// Unregisters a callback that was previously registered with /// AddOnCompletion. @@ -454,7 +446,6 @@ class Future : public FutureBase { inline void OnCompletion(TypedCompletionCallback callback, void* user_data) const; -#ifndef SWIG /// Register a single callback that will be called at most once, when the /// future is completed. /// @@ -468,7 +459,6 @@ class Future : public FutureBase { /// registered one will run. inline void OnCompletion( std::function&)> callback) const; -#endif // SWIG #if defined(INTERNAL_EXPERIMENTAL) /// Like OnCompletion, but allows adding multiple callbacks. @@ -489,7 +479,6 @@ class Future : public FutureBase { inline CompletionCallbackHandle AddOnCompletion( TypedCompletionCallback callback, void* user_data) const; -#ifndef SWIG /// Like OnCompletion, but allows adding multiple callbacks. /// /// If you call AddCompletion() more than once, all of the completions that @@ -505,7 +494,6 @@ class Future : public FutureBase { /// @return A handle that can be passed to RemoveOnCompletion. inline CompletionCallbackHandle AddOnCompletion( std::function&)> callback) const; -#endif // SWIG #endif // defined(INTERNAL_EXPERIMENTAL) }; diff --git a/app/src/intrusive_list.h b/app/src/intrusive_list.h index af714949c3..55aa00e8c2 100644 --- a/app/src/intrusive_list.h +++ b/app/src/intrusive_list.h @@ -131,11 +131,9 @@ class intrusive_list_node { // Move assignment operator. intrusive_list_node& operator=(intrusive_list_node&& other) FIREBASE_NOEXCEPT { - if (this != &other) { - next_->previous_ = previous_; - previous_->next_ = next_; - move(other); - } + next_->previous_ = previous_; + previous_->next_ = next_; + move(other); return *this; } @@ -249,15 +247,11 @@ class intrusive_list { explicit intrusive_list(intrusive_list_node T::*node_member) : data_(&data_, &data_), node_offset_(offset_of_node(node_member)) {} - intrusive_list(this_type&& other) noexcept - : data_(std::move(other.data_)), node_offset_(other.node_offset_) {} + intrusive_list(this_type&& other) noexcept { *this = std::move(other); } intrusive_list& operator=(this_type&& other) noexcept { - if (this != &other) { - clear(); - data_ = std::move(other.data_); - node_offset_ = other.node_offset_; - } + data_ = std::move(other.data_); + node_offset_ = std::move(other.node_offset_); return *this; } diff --git a/app/tests/intrusive_list_test.cc b/app/tests/intrusive_list_test.cc index a998aaf81e..aca49c8264 100644 --- a/app/tests/intrusive_list_test.cc +++ b/app/tests/intrusive_list_test.cc @@ -1084,61 +1084,6 @@ TEST_F(intrusive_list_test, move_assignment) { EXPECT_EQ(other.end(), iter); } -TEST_F(intrusive_list_test, move_assignment_non_empty_destination) { - list_.push_back(one_); - list_.push_back(two_); - - firebase::intrusive_list other(&IntegerListNode::node); - other.push_back(three_); - other.push_back(four_); - other.push_back(five_); - - other = std::move(list_); - - EXPECT_TRUE(list_.empty()); - EXPECT_TRUE(one_.node.in_list()); - EXPECT_TRUE(two_.node.in_list()); - EXPECT_FALSE(three_.node.in_list()); - EXPECT_FALSE(four_.node.in_list()); - EXPECT_FALSE(five_.node.in_list()); - - auto iter = other.begin(); - EXPECT_EQ(1, iter->value()); - ++iter; - EXPECT_EQ(2, iter->value()); - ++iter; - EXPECT_EQ(other.end(), iter); - - // Previously evicted elements must be safe to re-insert. - list_.push_back(three_); - list_.push_back(four_); - EXPECT_TRUE(three_.node.in_list()); - EXPECT_TRUE(four_.node.in_list()); -} - -TEST_F(intrusive_list_test, move_assignment_self) { - list_.push_back(one_); - list_.push_back(two_); - list_.push_back(three_); - - firebase::intrusive_list& self_ref = list_; - list_ = std::move(self_ref); - - EXPECT_FALSE(list_.empty()); - EXPECT_TRUE(one_.node.in_list()); - EXPECT_TRUE(two_.node.in_list()); - EXPECT_TRUE(three_.node.in_list()); - - auto iter = list_.begin(); - EXPECT_EQ(1, iter->value()); - ++iter; - EXPECT_EQ(2, iter->value()); - ++iter; - EXPECT_EQ(3, iter->value()); - ++iter; - EXPECT_EQ(list_.end(), iter); -} - TEST_F(intrusive_list_test, swap) { list_.push_back(one_); list_.push_back(two_); diff --git a/database/src/include/firebase/database/data_snapshot.h b/database/src/include/firebase/database/data_snapshot.h index 0d1b1a8db7..d7aa3a60b0 100644 --- a/database/src/include/firebase/database/data_snapshot.h +++ b/database/src/include/firebase/database/data_snapshot.h @@ -72,7 +72,6 @@ class DataSnapshot { /// @returns Reference to the destination DataSnapshot. DataSnapshot& operator=(const DataSnapshot& snapshot); -#ifndef SWIG /// @brief Move constructor. DataSnapshots are immutable, so they can be /// efficiently moved. /// @@ -86,7 +85,6 @@ class DataSnapshot { /// /// @returns Reference to this destination DataSnapshot. DataSnapshot& operator=(DataSnapshot&& snapshot); -#endif // SWIG /// Destructor. ~DataSnapshot(); diff --git a/database/src/include/firebase/database/database_reference.h b/database/src/include/firebase/database/database_reference.h index 1ed47ad5fc..792d4c43f2 100644 --- a/database/src/include/firebase/database/database_reference.h +++ b/database/src/include/firebase/database/database_reference.h @@ -69,7 +69,6 @@ class DatabaseReference : public Query { /// @returns Reference to the destination DatabaseReference. DatabaseReference& operator=(const DatabaseReference& reference); -#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for /// DatabaseReference instances. /// @@ -83,7 +82,6 @@ class DatabaseReference : public Query { /// /// @returns Reference to the destination DatabaseReference. DatabaseReference& operator=(DatabaseReference&& reference); -#endif // SWIG /// @brief Gets the database to which we refer. /// @@ -203,7 +201,6 @@ class DatabaseReference : public Query { DoTransactionWithContext transaction_function, void* context, bool trigger_local_events = true); -#ifndef SWIG /// @brief Run a user-supplied callback, possibly multiple times, to perform /// an atomic transaction on the database. /// @@ -234,7 +231,6 @@ class DatabaseReference : public Query { Future RunTransaction( DoTransactionFunction transaction_function, bool trigger_local_events = true); -#endif // SWIG /// @brief Get the result of the most recent call to RunTransaction(). /// diff --git a/database/src/include/firebase/database/mutable_data.h b/database/src/include/firebase/database/mutable_data.h index 3a8dbfe57c..9e94c0c377 100644 --- a/database/src/include/firebase/database/mutable_data.h +++ b/database/src/include/firebase/database/mutable_data.h @@ -34,7 +34,6 @@ class Repo; #endif // SWIG class MutableData { public: -#ifndef SWIG /// Move constructor. /// Move is more efficient than copy and delete. MutableData(MutableData&& rhs); @@ -42,7 +41,6 @@ class MutableData { /// Move assignment operator. /// Move is more efficient than copy and delete. MutableData& operator=(MutableData&& rhs); -#endif // SWIG /// Destructor. ~MutableData(); diff --git a/database/src/include/firebase/database/query.h b/database/src/include/firebase/database/query.h index 8b01ef59e8..5bf8eb5a23 100644 --- a/database/src/include/firebase/database/query.h +++ b/database/src/include/firebase/database/query.h @@ -48,12 +48,10 @@ class Query { /// independently of each other. Query& operator=(const Query& query); -#ifndef SWIG /// Move constructor. Query(Query&& query); /// Move assignment operator. Query& operator=(Query&& query); -#endif // SWIG /// @brief Required virtual destructor. virtual ~Query(); diff --git a/database/src/include/firebase/database/transaction.h b/database/src/include/firebase/database/transaction.h index 5821e21023..1b88b967b8 100644 --- a/database/src/include/firebase/database/transaction.h +++ b/database/src/include/firebase/database/transaction.h @@ -81,7 +81,6 @@ typedef TransactionResult (*DoTransaction)(MutableData* data); typedef TransactionResult (*DoTransactionWithContext)(MutableData* data, void* context); -#ifndef SWIG /// Your own transaction handler function or lambda, which the Firebase Realtime /// Database library may call multiple times to apply changes to the data, and /// should return success or failure depending on whether it succeeds. @@ -89,7 +88,6 @@ typedef TransactionResult (*DoTransactionWithContext)(MutableData* data, /// @see DoTransactionWithContext for more information. typedef std::function DoTransactionFunction; -#endif // SWIG } // namespace database } // namespace firebase diff --git a/storage/src/include/firebase/storage/controller.h b/storage/src/include/firebase/storage/controller.h index aa57791281..d270ef9fbc 100644 --- a/storage/src/include/firebase/storage/controller.h +++ b/storage/src/include/firebase/storage/controller.h @@ -71,7 +71,6 @@ class Controller { /// @returns Reference to the destination Controller. Controller& operator=(const Controller& other); -#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for /// Controller instances. /// @@ -85,7 +84,6 @@ class Controller { /// /// @returns Reference to the destination Controller. Controller& operator=(Controller&& other); -#endif // SWIG /// @brief Pauses the operation currently in progress. /// diff --git a/storage/src/include/firebase/storage/list_result.h b/storage/src/include/firebase/storage/list_result.h index b693dedde0..346878f3e8 100644 --- a/storage/src/include/firebase/storage/list_result.h +++ b/storage/src/include/firebase/storage/list_result.h @@ -51,7 +51,6 @@ class StorageListResult { /// @returns Reference to the destination StorageListResult. StorageListResult& operator=(const StorageListResult& other); -#ifndef SWIG /// @brief Move constructor. /// /// @param[in] other StorageListResult to move data from. @@ -63,7 +62,6 @@ class StorageListResult { /// /// @returns Reference to the destination StorageListResult. StorageListResult& operator=(StorageListResult&& other); -#endif // SWIG /// @brief Returns the prefixes (folders) returned by the List operation. /// diff --git a/storage/src/include/firebase/storage/metadata.h b/storage/src/include/firebase/storage/metadata.h index d49cead055..0b7a27bfb3 100644 --- a/storage/src/include/firebase/storage/metadata.h +++ b/storage/src/include/firebase/storage/metadata.h @@ -63,7 +63,6 @@ class Metadata { /// @returns Reference to the destination Metadata. Metadata& operator=(const Metadata& other); -#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for Metadata. /// /// @param[in] other Metadata to move from. @@ -76,7 +75,6 @@ class Metadata { /// /// @returns Reference to the destination Metadata. Metadata& operator=(Metadata&& other); -#endif // SWIG ~Metadata(); diff --git a/storage/src/include/firebase/storage/storage_reference.h b/storage/src/include/firebase/storage/storage_reference.h index f332c6588f..3627492116 100644 --- a/storage/src/include/firebase/storage/storage_reference.h +++ b/storage/src/include/firebase/storage/storage_reference.h @@ -68,7 +68,6 @@ class StorageReference { /// @returns Reference to the destination StorageReference. StorageReference& operator=(const StorageReference& reference); -#ifndef SWIG /// @brief Move constructor. Moving is an efficient operation for /// StorageReference instances. /// @@ -82,7 +81,6 @@ class StorageReference { /// /// @returns Reference to the destination StorageReference. StorageReference& operator=(StorageReference&& other); -#endif // SWIG /// @brief Gets the firebase::storage::Storage instance to which we refer. ///