Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85042380 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: hide helper classes from export

This is done to limit API breaking due to inadvertant symbol export.

Bug: 79494020
Change-Id: I277ecbd3505c415101eb7bfcd780ff1bdaebec23
parent 39947040
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@
#include <media/stagefright/foundation/TypeTraits.h>
#include <media/stagefright/foundation/Flagged.h>

#undef HIDE
#define HIDE __attribute__((visibility("hidden")))

namespace android {

/**
@@ -78,7 +81,7 @@ namespace android {
 * This class is needed as member function specialization is not allowed for a
 * templated class.
 */
struct _AUnion_impl {
struct HIDE _AUnion_impl {
    /**
     * Calls placement constuctor for type T with arbitrary arguments for a storage at an address.
     * Storage MUST be large enough to contain T.
@@ -113,13 +116,13 @@ struct _AUnion_impl {

/** Constructor specialization for void type */
template<>
inline void _AUnion_impl::emplace<void>(size_t totalSize, void *addr) {
HIDE inline void _AUnion_impl::emplace<void>(size_t totalSize, void *addr) {
    memset(addr, 0, totalSize);
}

/** Destructor specialization for void type */
template<>
inline void _AUnion_impl::del<void>(void *) {
HIDE inline void _AUnion_impl::del<void>(void *) {
}

/// \endcond
@@ -221,7 +224,7 @@ public:
template<
        typename T,
        bool=std::is_copy_assignable<T>::value>
struct _AData_copier {
struct HIDE _AData_copier {
    static_assert(std::is_copy_assignable<T>::value, "T must be copy assignable here");

    /**
@@ -294,7 +297,7 @@ struct _AData_copier {
 *
 */
template<typename T>
struct _AData_copier<T, false> {
struct HIDE _AData_copier<T, false> {
    static_assert(!std::is_copy_assignable<T>::value, "T must not be copy assignable here");
    static_assert(std::is_copy_constructible<T>::value, "T must be copy constructible here");

@@ -318,7 +321,7 @@ struct _AData_copier<T, false> {
template<
        typename T,
        bool=std::is_move_assignable<T>::value>
struct _AData_mover {
struct HIDE _AData_mover {
    static_assert(std::is_move_assignable<T>::value, "T must be move assignable here");

    /**
@@ -389,7 +392,7 @@ struct _AData_mover {
 *
 */
template<typename T>
struct _AData_mover<T, false> {
struct HIDE _AData_mover<T, false> {
    static_assert(!std::is_move_assignable<T>::value, "T must not be move assignable here");
    static_assert(std::is_move_constructible<T>::value, "T must be move constructible here");

@@ -407,13 +410,13 @@ struct _AData_mover<T, false> {
 * \param Ts types to consider for the member
 */
template<typename Flagger, typename U, typename ...Ts>
struct _AData_deleter;
struct HIDE _AData_deleter;

/**
 * Template specialization when there are still types to consider (T and rest)
 */
template<typename Flagger, typename U, typename T, typename ...Ts>
struct _AData_deleter<Flagger, U, T, Ts...> {
struct HIDE _AData_deleter<Flagger, U, T, Ts...> {
    static bool del(typename Flagger::type flags, U &data) {
        if (Flagger::canDeleteAs(flags, Flagger::flagFor((T*)0))) {
            data.template del<T>();
@@ -427,7 +430,7 @@ struct _AData_deleter<Flagger, U, T, Ts...> {
 * Template specialization when there are no more types to consider.
 */
template<typename Flagger, typename U>
struct _AData_deleter<Flagger, U> {
struct HIDE _AData_deleter<Flagger, U> {
    inline static bool del(typename Flagger::type, U &) {
        return false;
    }
+25 −22
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@

#include <type_traits>

#undef HIDE
#define HIDE __attribute__((visibility("hidden")))

namespace android {

/**
@@ -31,7 +34,7 @@ namespace android {
 * Type support utility class to check if a type is an integral type or an enum.
 */
template<typename T>
struct is_integral_or_enum
struct HIDE is_integral_or_enum
    : std::integral_constant<bool, std::is_integral<T>::value || std::is_enum<T>::value> { };

/**
@@ -46,7 +49,7 @@ template<typename T,
        typename U=typename std::enable_if<is_integral_or_enum<T>::value>::type,
        bool=std::is_enum<T>::value,
        bool=std::is_integral<T>::value>
struct underlying_integral_type {
struct HIDE underlying_integral_type {
    static_assert(!std::is_enum<T>::value, "T should not be enum here");
    static_assert(!std::is_integral<T>::value, "T should not be integral here");
    typedef U type;
@@ -54,7 +57,7 @@ struct underlying_integral_type {

/** Specialization for enums. */
template<typename T, typename U>
struct underlying_integral_type<T, U, true, false> {
struct HIDE underlying_integral_type<T, U, true, false> {
    static_assert(std::is_enum<T>::value, "T should be enum here");
    static_assert(!std::is_integral<T>::value, "T should not be integral here");
    typedef typename std::underlying_type<T>::type type;
@@ -62,7 +65,7 @@ struct underlying_integral_type<T, U, true, false> {

/** Specialization for non-enum std-integral types. */
template<typename T, typename U>
struct underlying_integral_type<T, U, false, true> {
struct HIDE underlying_integral_type<T, U, false, true> {
    static_assert(!std::is_enum<T>::value, "T should not be enum here");
    static_assert(std::is_integral<T>::value, "T should be integral here");
    typedef T type;
@@ -72,7 +75,7 @@ struct underlying_integral_type<T, U, false, true> {
 * Type support utility class to check if the underlying integral type is signed.
 */
template<typename T>
struct is_signed_integral
struct HIDE is_signed_integral
    : std::integral_constant<bool, std::is_signed<
            typename underlying_integral_type<T, unsigned>::type>::value> { };

@@ -80,7 +83,7 @@ struct is_signed_integral
 * Type support utility class to check if the underlying integral type is unsigned.
 */
template<typename T>
struct is_unsigned_integral
struct HIDE is_unsigned_integral
    : std::integral_constant<bool, std::is_unsigned<
            typename underlying_integral_type<T, signed>::type>::value> {
};
@@ -92,26 +95,26 @@ struct is_unsigned_integral
 * member constant |value| equal to true. Otherwise value is false.
 */
template<typename T, typename ...Us>
struct is_one_of;
struct HIDE is_one_of;

/// \if 0
/**
 * Template specialization when first type matches the searched type.
 */
template<typename T, typename ...Us>
struct is_one_of<T, T, Us...> : std::true_type {};
struct HIDE is_one_of<T, T, Us...> : std::true_type {};

/**
 * Template specialization when first type does not match the searched type.
 */
template<typename T, typename U, typename ...Us>
struct is_one_of<T, U, Us...> : is_one_of<T, Us...> {};
struct HIDE is_one_of<T, U, Us...> : is_one_of<T, Us...> {};

/**
 * Template specialization when there are no types to search.
 */
template<typename T>
struct is_one_of<T> : std::false_type {};
struct HIDE is_one_of<T> : std::false_type {};
/// \endif

/**
@@ -121,44 +124,44 @@ struct is_one_of<T> : std::false_type {};
 * Otherwise value is false.
 */
template<typename ...Us>
struct are_unique;
struct HIDE are_unique;

/// \if 0
/**
 * Template specialization when there are no types.
 */
template<>
struct are_unique<> : std::true_type {};
struct HIDE are_unique<> : std::true_type {};

/**
 * Template specialization when there is at least one type to check.
 */
template<typename T, typename ...Us>
struct are_unique<T, Us...>
struct HIDE are_unique<T, Us...>
    : std::integral_constant<bool, are_unique<Us...>::value && !is_one_of<T, Us...>::value> {};
/// \endif

/// \if 0
template<size_t Base, typename T, typename ...Us>
struct _find_first_impl;
struct HIDE _find_first_impl;

/**
 * Template specialization when there are no types to search.
 */
template<size_t Base, typename T>
struct _find_first_impl<Base, T> : std::integral_constant<size_t, 0> {};
struct HIDE _find_first_impl<Base, T> : std::integral_constant<size_t, 0> {};

/**
 * Template specialization when T is the first type in Us.
 */
template<size_t Base, typename T, typename ...Us>
struct _find_first_impl<Base, T, T, Us...> : std::integral_constant<size_t, Base> {};
struct HIDE _find_first_impl<Base, T, T, Us...> : std::integral_constant<size_t, Base> {};

/**
 * Template specialization when T is not the first type in Us.
 */
template<size_t Base, typename T, typename U, typename ...Us>
struct _find_first_impl<Base, T, U, Us...>
struct HIDE _find_first_impl<Base, T, U, Us...>
    : std::integral_constant<size_t, _find_first_impl<Base + 1, T, Us...>::value> {};

/// \endif
@@ -169,7 +172,7 @@ struct _find_first_impl<Base, T, U, Us...>
 * If T occurs in Us, index is the 1-based left-most index of T in Us. Otherwise, index is 0.
 */
template<typename T, typename ...Us>
struct find_first {
struct HIDE find_first {
    static constexpr size_t index = _find_first_impl<1, T, Us...>::value;
};

@@ -180,13 +183,13 @@ struct find_first {
 * Adds a base index.
 */
template<size_t Base, typename T, typename ...Us>
struct _find_first_convertible_to_helper;
struct HIDE _find_first_convertible_to_helper;

/**
 * Template specialization for when there are more types to consider
 */
template<size_t Base, typename T, typename U, typename ...Us>
struct _find_first_convertible_to_helper<Base, T, U, Us...> {
struct HIDE _find_first_convertible_to_helper<Base, T, U, Us...> {
    static constexpr size_t index =
        std::is_convertible<T, U>::value ? Base :
                _find_first_convertible_to_helper<Base + 1, T, Us...>::index;
@@ -199,7 +202,7 @@ struct _find_first_convertible_to_helper<Base, T, U, Us...> {
 * Template specialization for when there are no more types to consider
 */
template<size_t Base, typename T>
struct _find_first_convertible_to_helper<Base, T> {
struct HIDE _find_first_convertible_to_helper<Base, T> {
    static constexpr size_t index = 0;
    typedef void type;
};
@@ -216,7 +219,7 @@ struct _find_first_convertible_to_helper<Base, T> {
 * \param Us types into which the conversion is considered
 */
template<typename T, typename ...Us>
struct find_first_convertible_to : public _find_first_convertible_to_helper<1, T, Us...> { };
struct HIDE find_first_convertible_to : public _find_first_convertible_to_helper<1, T, Us...> { };

}  // namespace android