Skip to content
Merged
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
1 change: 0 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ set(common_SRCS
src/reference_counted_future_impl.cc
src/scheduler.cc
src/thread_cpp11.cc
src/thread_pthread.cc
src/time.cc
src/secure/user_secure_manager.cc
src/util.cc
Expand Down
4 changes: 1 addition & 3 deletions app/src/app_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ const char* kCpuArchitecture = "mips64";
#error Unknown Android architecture.
#endif // Architecture

#if defined(_STLPORT_VERSION)
const char* kCppRuntimeOrStl = "stlport";
#elif defined(_GLIBCXX_UTILITY)
#if defined(_GLIBCXX_UTILITY)
const char* kCppRuntimeOrStl = "gnustl";
#elif defined(_LIBCPP_STD_VER)
const char* kCppRuntimeOrStl = "libcpp";
Expand Down
9 changes: 3 additions & 6 deletions app/src/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef FIREBASE_APP_SRC_CALLBACK_H_
#define FIREBASE_APP_SRC_CALLBACK_H_

#include <tuple>
#include <utility>

#include "firebase/internal/common.h"
Expand Down Expand Up @@ -76,8 +77,8 @@ class CallbackArg<const char*> {
};

/// Interface for Callbacks that will later be called from the correct context.
/// We don't use std::function because stlport has weak support for it, and we
/// need to guarantee that any string conversion happens on the C# thread.
/// We don't use std::function because we need to guarantee that any string
/// conversion happens on the C# thread.
class Callback {
public:
virtual ~Callback() {}
Expand Down Expand Up @@ -289,9 +290,6 @@ class CallbackStdFunction : public Callback {
};
#endif

// STLPort doens't support std::tuple or std::get, which are needed for
// CallbackVariadic to work.
#if !defined(_STLPORT_VERSION)
template <int...>
struct IntegerSequence {};

Expand Down Expand Up @@ -357,7 +355,6 @@ template <typename... CallbackAndArgs>
Callback* NewCallback(CallbackAndArgs... callback_and_args) {
return NewCallbackHelper(callback_and_args...);
}
#endif // !defined(_STLPORT_VERSION)

/// Adds a Callback to be called on the next PollCallbacks call.
/// This function returns a reference in the queue that can be used to remove
Expand Down
12 changes: 0 additions & 12 deletions app/src/include/firebase/future.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ class FutureBase {
#endif
///
/// @param[in] callback Function or lambda to call.
///
/// @note This method is not available when using STLPort on Android, as
/// `std::function` is not supported on STLPort.
void OnCompletion(std::function<void(const FutureBase&)> callback) const;
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)

Expand Down Expand Up @@ -292,9 +289,6 @@ class FutureBase {
///
/// @param[in] callback Function or lambda to call.
/// @return A handle that can be passed to RemoveOnCompletion.
///
/// @note This method is not available when using STLPort on Android, as
/// `std::function` is not supported on STLPort.
CompletionCallbackHandle AddOnCompletion(
std::function<void(const FutureBase&)> callback) const;

Expand Down Expand Up @@ -473,9 +467,6 @@ class Future : public FutureBase {
///
/// @param[in] callback Function or lambda to call.
///
/// @note This method is not available when using STLPort on Android, as
/// `std::function` is not supported on STLPort.
///
/// @note This is the same callback as FutureBase::OnCompletion(), so you
/// can't expect to set both and have both run; again, only the most recently
/// registered one will run.
Expand Down Expand Up @@ -516,9 +507,6 @@ class Future : public FutureBase {
///
/// @param[in] callback Function or lambda to call.
/// @return A handle that can be passed to RemoveOnCompletion.
///
/// @note This method is not available when using STLPort on Android, as
/// `std::function` is not supported on STLPort.
inline CompletionCallbackHandle AddOnCompletion(
std::function<void(const Future<ResultType>&)> callback) const;
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
Expand Down
40 changes: 2 additions & 38 deletions app/src/include/firebase/internal/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,12 @@

// This file contains definitions that configure the SDK.

// Include a STL header file, othewise _STLPORT_VERSION won't be set.
#include <utility>

// Move operators use rvalue references, which are a C++11 extension.
// Also, Visual Studio 2010 and later actually support move operators despite
// reporting __cplusplus to be 199711L, so explicitly check for that.
// Also, stlport doesn't implement std::move().
#if (__cplusplus >= 201103L || _MSC_VER >= 1600) && !defined(_STLPORT_VERSION)
// 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we need these anymore, since they are always being defined now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — we don't need them anymore, and every remaining check (~73 files across app, auth, database, functions, and storage) is a positive #if/#ifdef. Added a TODO(b/582384770) note here in c8ed6e6 and filed b/582384770 to unwrap and remove them in a dedicated follow-up PR so this diff stays focused.

#endif

// stlport doesn't implement std::function.
#if !defined(_STLPORT_VERSION)
#define FIREBASE_USE_STD_FUNCTION
#endif // !defined(_STLPORT_VERSION)

// stlport doesn't implement std::aligned_storage.
#if defined(_STLPORT_VERSION)
#include <cstddef>

namespace firebase {
template <std::size_t Length, std::size_t Alignment>
struct AlignedStorage {
struct type {
alignas(Alignment) unsigned char data[Length];
};
};
} // namespace firebase
#define FIREBASE_ALIGNED_STORAGE ::firebase::AlignedStorage
#else
#include <type_traits>
#define FIREBASE_ALIGNED_STORAGE std::aligned_storage
#endif // defined(_STLPORT_VERSION)

// Visual Studio 2013 does not support snprintf, so use streams instead.
#if !(defined(_MSC_VER) && _MSC_VER <= 1800)
#define FIREBASE_USE_SNPRINTF
#endif // !(defined(_MSC_VER) && _MSC_VER <= 1800)

#if !(defined(_MSC_VER) && _MSC_VER <= 1800)
#define FIREBASE_USE_EXPLICIT_DEFAULT_METHODS
#endif // !(defined(_MSC_VER) && _MSC_VER <= 1800)

#if !defined(DOXYGEN) && !defined(SWIG)
#if !defined(_WIN32) && !defined(__CYGWIN__)
Expand Down
103 changes: 32 additions & 71 deletions app/src/include/firebase/internal/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef FIREBASE_APP_SRC_INCLUDE_FIREBASE_INTERNAL_TYPE_TRAITS_H_
#define FIREBASE_APP_SRC_INCLUDE_FIREBASE_INTERNAL_TYPE_TRAITS_H_

#include <cstdlib>
#include <type_traits>

// Doxygen breaks trying to parse this file, and since it is internal logic,
Expand All @@ -27,104 +26,66 @@
namespace firebase {

template <typename T>
struct remove_reference {
typedef T type;
};

template <typename T>
struct remove_reference<T&> {
typedef T type;
};

template <typename T>
struct remove_reference<T&&> {
typedef T type;
};

template <typename T>
struct is_array {
static constexpr bool value = false;
};

template <typename T>
struct is_array<T[]> {
static constexpr bool value = true;
};

template <typename T, std::size_t N>
struct is_array<T[N]> {
static constexpr bool value = true;
};
using remove_reference = std::remove_reference<T>;

template <typename T>
struct is_lvalue_reference {
static constexpr bool value = false;
};
using is_array = std::is_array<T>;

template <typename T>
struct is_lvalue_reference<T&> {
static constexpr bool value = true;
};

// STLPort does include <type_traits> header, but its contents are in `std::tr1`
// namespace. To work around this, use aliases.
// TODO(varconst): all of the reimplementations of traits above can be replaced
// with appropriate aliases.
// TODO(varconst): the traits in this file would be more conformant if they
// inherited from `std::integral_constant`.
#ifdef STLPORT
#define FIREBASE_TYPE_TRAITS_NS std::tr1
#else
#define FIREBASE_TYPE_TRAITS_NS std
#endif
using is_lvalue_reference = std::is_lvalue_reference<T>;

template <typename T>
using decay = FIREBASE_TYPE_TRAITS_NS::decay<T>;
using decay = std::decay<T>;

template <typename T>
using decay_t = typename decay<T>::type;

template <bool value, typename T = void>
using enable_if = FIREBASE_TYPE_TRAITS_NS::enable_if<value, T>;
using enable_if = std::enable_if<value, T>;

template <typename T>
using is_floating_point = FIREBASE_TYPE_TRAITS_NS::is_floating_point<T>;
using is_floating_point = std::is_floating_point<T>;

template <typename T>
using is_integral = FIREBASE_TYPE_TRAITS_NS::is_integral<T>;
using is_integral = std::is_integral<T>;

template <typename T, typename U>
using is_same = FIREBASE_TYPE_TRAITS_NS::is_same<T, U>;
using is_same = std::is_same<T, U>;

template <typename T, T value>
using integral_constant = FIREBASE_TYPE_TRAITS_NS::integral_constant<T, value>;
using integral_constant = std::integral_constant<T, value>;

using true_type = FIREBASE_TYPE_TRAITS_NS::true_type;
using false_type = FIREBASE_TYPE_TRAITS_NS::false_type;
using true_type = std::true_type;
using false_type = std::false_type;

#undef FIREBASE_TYPE_TRAITS_NS
namespace internal {

// `is_char<T>::value` is true iff `T` is a character type (including `wchar_t`
// and C++11 fixed-width character types).
template <typename T>
struct is_char {
static constexpr bool value =
#if __cplusplus >= 202002L
is_same<T, char8_t>::value ||
struct is_char_no_cv
: integral_constant<
bool,
#if defined(__cpp_char8_t)
is_same<T, char8_t>::value ||
#endif
#if __cplusplus >= 201103L
is_same<T, char16_t>::value || is_same<T, char32_t>::value ||
#endif
is_same<T, char>::value || is_same<T, signed char>::value ||
is_same<T, unsigned char>::value || is_same<T, wchar_t>::value;
is_same<T, char16_t>::value || is_same<T, char32_t>::value ||
is_same<T, char>::value || is_same<T, signed char>::value ||
is_same<T, unsigned char>::value || is_same<T, wchar_t>::value> {
};

} // namespace internal

// `is_char<T>::value` is true iff `T` is a character type (including `wchar_t`
// and fixed-width character types, ignoring cv-qualifiers).
template <typename T>
struct is_char : internal::is_char_no_cv<typename std::remove_cv<T>::type> {};

// A subset of `std::is_integral`: excludes `bool` and character types.
template <typename T>
struct is_integer {
static constexpr bool value =
is_integral<T>::value && !is_same<T, bool>::value && !is_char<T>::value;
};
struct is_integer
: integral_constant<
bool, is_integral<T>::value &&
!is_same<typename std::remove_cv<T>::type, bool>::value &&
!is_char<T>::value> {};

// NOLINTNEXTLINE - allow namespace overridden
} // namespace firebase
Expand Down
Loading
Loading