Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/rest/controller_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ControllerCurl::~ControllerCurl() {
}
}

#if defined(FIREBASE_USE_MOVE_OPERATORS) || defined(DOXYGEN)
ControllerCurl::ControllerCurl(ControllerCurl&& other) noexcept {
*this = std::move(other);
}
Expand All @@ -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_) {
Expand Down
2 changes: 0 additions & 2 deletions app/rest/controller_curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions app/src/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
#ifndef FIREBASE_APP_SRC_CALLBACK_H_
#define FIREBASE_APP_SRC_CALLBACK_H_

#include <functional>
#include <tuple>
#include <utility>

#include "firebase/internal/common.h"

#ifdef FIREBASE_USE_STD_FUNCTION
#include <functional>
#endif

/// @cond FIREBASE_APP_INTERNAL

/// This file is intended for use with the C# interfaces, to allow registration
Expand Down Expand Up @@ -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:
Expand All @@ -288,7 +284,6 @@ class CallbackStdFunction : public Callback {
private:
std::function<void()> func_;
};
#endif

template <int...>
struct IntegerSequence {};
Expand Down
22 changes: 3 additions & 19 deletions app/src/include/firebase/future.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@
#include <stddef.h>
#include <stdint.h>

#include <functional>
#include <utility>

#include "firebase/internal/common.h"
#include "firebase/internal/mutex.h"

#ifdef FIREBASE_USE_STD_FUNCTION
#include <functional>
#endif

namespace firebase {

// Predeclarations.
Expand Down Expand Up @@ -70,11 +67,9 @@ class FutureHandle {
FutureHandle(const FutureHandle& rhs);
FutureHandle& operator=(const FutureHandle& rhs);

#if defined(FIREBASE_USE_MOVE_OPERATORS)
// Move constructor and assignment operator.
FutureHandle(FutureHandle&& rhs) noexcept;
FutureHandle& operator=(FutureHandle&& rhs) noexcept;
#endif // defined(FIREBASE_USE_MOVE_OPERATORS)

// Comparison operators.
bool operator!=(const FutureHandle& rhs) const { return !(*this == rhs); }
Expand Down Expand Up @@ -159,15 +154,13 @@ class FutureBase {
/// Copy an untyped future.
FutureBase& operator=(const FutureBase& rhs);

#if defined(FIREBASE_USE_MOVE_OPERATORS)
/// Move constructor and operator.
/// 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)

/// Explicitly release the internal resources for a future.
/// Future will become invalid.
Expand Down Expand Up @@ -236,7 +229,6 @@ class FutureBase {
/// callback.
void OnCompletion(CompletionCallback callback, void* user_data) const;

#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
/// Register a single callback that will be called at most once, when the
/// future is completed.
///
Expand All @@ -254,7 +246,6 @@ class FutureBase {
///
/// @param[in] callback Function or lambda to call.
void OnCompletion(std::function<void(const FutureBase&)> callback) const;
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)

#if defined(INTERNAL_EXPERIMENTAL)
/// Like OnCompletion, but allows adding multiple callbacks.
Expand All @@ -275,7 +266,6 @@ class FutureBase {
CompletionCallbackHandle AddOnCompletion(CompletionCallback callback,
void* user_data) const;

#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
/// Like OnCompletion, but allows adding multiple callbacks.
///
/// If you call AddCompletion() more than once, all of the completions that
Expand All @@ -292,8 +282,6 @@ class FutureBase {
CompletionCallbackHandle AddOnCompletion(
std::function<void(const FutureBase&)> callback) const;

#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)

/// Unregisters a callback that was previously registered with
/// AddOnCompletion.
///
Expand Down Expand Up @@ -458,7 +446,6 @@ class Future : public FutureBase {
inline void OnCompletion(TypedCompletionCallback callback,
void* user_data) const;

#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
/// Register a single callback that will be called at most once, when the
/// future is completed.
///
Expand All @@ -472,7 +459,6 @@ class Future : public FutureBase {
/// registered one will run.
inline void OnCompletion(
std::function<void(const Future<ResultType>&)> callback) const;
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)

#if defined(INTERNAL_EXPERIMENTAL)
/// Like OnCompletion, but allows adding multiple callbacks.
Expand All @@ -493,7 +479,6 @@ class Future : public FutureBase {
inline CompletionCallbackHandle AddOnCompletion(
TypedCompletionCallback callback, void* user_data) const;

#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
/// Like OnCompletion, but allows adding multiple callbacks.
///
/// If you call AddCompletion() more than once, all of the completions that
Expand All @@ -509,7 +494,6 @@ class Future : public FutureBase {
/// @return A handle that can be passed to RemoveOnCompletion.
inline CompletionCallbackHandle AddOnCompletion(
std::function<void(const Future<ResultType>&)> callback) const;
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
#endif // defined(INTERNAL_EXPERIMENTAL)
};

Expand Down
5 changes: 0 additions & 5 deletions app/src/include/firebase/internal/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

#include <utility>

// 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.
Expand Down
17 changes: 2 additions & 15 deletions app/src/include/firebase/internal/future_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@

/// @cond FIREBASE_APP_INTERNAL

#include <utility>

// 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 <utility>
#endif // defined(FIREBASE_USE_MOVE_OPERATORS)

namespace firebase {

class ReferenceCountedFutureImpl;
Expand Down Expand Up @@ -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.
///
Expand All @@ -109,7 +106,6 @@ class FutureApiInterface {
const FutureHandle& handle,
std::function<void(const FutureBase&)> 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;
Expand Down Expand Up @@ -194,7 +190,6 @@ void Future<T>::OnCompletion(TypedCompletionCallback callback,
}
}

#if defined(FIREBASE_USE_STD_FUNCTION)
template <class ResultType>
inline void Future<ResultType>::OnCompletion(
std::function<void(const Future<ResultType>&)> callback) const {
Expand All @@ -206,7 +201,6 @@ inline void Future<ResultType>::OnCompletion(
});
}
}
#endif // defined(FIREBASE_USE_STD_FUNCTION)

#if defined(INTERNAL_EXPERIMENTAL)
template <class T>
Expand All @@ -227,7 +221,6 @@ FutureBase::CompletionCallbackHandle Future<T>::AddOnCompletion(
return CompletionCallbackHandle();
}

#if defined(FIREBASE_USE_STD_FUNCTION)
template <class ResultType>
inline FutureBase::CompletionCallbackHandle Future<ResultType>::AddOnCompletion(
std::function<void(const Future<ResultType>&)> callback) const {
Expand All @@ -238,7 +231,6 @@ inline FutureBase::CompletionCallbackHandle Future<ResultType>::AddOnCompletion(
callback(static_cast<const Future<ResultType>&>(future));
});
}
#endif // defined(FIREBASE_USE_STD_FUNCTION)

#endif // defined(INTERNAL_EXPERIMENTAL)

Expand Down Expand Up @@ -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
Expand All @@ -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_);
Expand Down Expand Up @@ -379,7 +369,6 @@ inline void FutureBase::RemoveOnCompletion(
}
#endif // defined(INTERNAL_EXPERIMENTAL)

#if defined(FIREBASE_USE_STD_FUNCTION)
inline void FutureBase::OnCompletion(
std::function<void(const FutureBase&)> callback) const {
MutexLock lock(mutex_);
Expand All @@ -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

Expand Down
3 changes: 0 additions & 3 deletions app/src/include/firebase/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions app/src/intrusive_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cassert>
#include <cstddef>
#include <functional>
#include <utility>

#if defined(_MSC_FULL_VER)
#pragma warning(push)
Expand Down Expand Up @@ -246,15 +247,13 @@ 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); }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Lint warning: Single-parameter constructors should be marked explicit.


intrusive_list& operator=(this_type&& other) noexcept {
data_ = std::move(other.data_);
node_offset_ = std::move(other.node_offset_);
return *this;
}
#endif

#if defined(_MSC_VER)
// Normally we need to disallow copying. Ideally we'd put this in the
Expand Down
5 changes: 1 addition & 4 deletions app/src/jobject_reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <jni.h>

#include <cassert>
#include <utility>

#include "app/src/assert.h"
// util_android.h is included for GetThreadsafeJNIEnv()
Expand All @@ -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); }

Expand All @@ -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_;
Expand All @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions app/src/jobject_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading