⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 155357 in webkit


Ignore:
Timestamp:
Sep 9, 2013, 10:10:19 AM (13 years ago)
Author:
andersca@apple.com
Message:

Begin moving off of TypeTraits.h
https://bugs.webkit.org/show_bug.cgi?id=121006

Reviewed by Darin Adler.

Source/JavaScriptCore:

Convert uses of WTF type traits to STL type traits.

  • heap/PassWeak.h:
  • runtime/JSCell.h:

(JSC::jsCast):
(JSC::jsDynamicCast):

  • runtime/WriteBarrier.h:

(JSC::validateCell):

Source/WebKit2:

Convert uses of WTF type traits to STL type traits.

  • Platform/CoreIPC/ArgumentCoder.h:
  • Platform/CoreIPC/ArgumentCoders.h:
  • Platform/CoreIPC/ArgumentDecoder.h:
  • Platform/CoreIPC/ArgumentEncoder.h:
  • Platform/CoreIPC/Arguments.h:
  • Shared/API/c/WKSharedAPICast.h:

(WebKit::toImpl):

Source/WTF:

The C++11 has its own type traits implementation that is more complete and handles corner cases better
since it ties into the compiler. Begin switching uses of WTF type traits to STL type traits.

  • wtf/CheckedArithmetic.h:
  • wtf/HashTraits.h:
  • wtf/NeverDestroyed.h:
  • wtf/OwnPtr.h:
  • wtf/PassOwnPtr.h:

(WTF::adoptPtr):

  • wtf/RetainPtr.h:
Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r155317 r155357  
     12013-09-08  Anders Carlsson  <andersca@apple.com>
     2
     3        Begin moving off of TypeTraits.h
     4        https://bugs.webkit.org/show_bug.cgi?id=121006
     5
     6        Reviewed by Darin Adler.
     7
     8        Convert uses of WTF type traits to STL type traits.
     9
     10        * heap/PassWeak.h:
     11        * runtime/JSCell.h:
     12        (JSC::jsCast):
     13        (JSC::jsDynamicCast):
     14        * runtime/WriteBarrier.h:
     15        (JSC::validateCell):
     16
    1172013-09-08  Mark Hahnenberg  <mhahnenberg@apple.com>
    218
  • trunk/Source/JavaScriptCore/heap/PassWeak.h

    r147962 r155357  
    3131#include <wtf/Assertions.h>
    3232#include <wtf/NullPtr.h>
    33 #include <wtf/TypeTraits.h>
    3433
    3534namespace JSC {
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r154459 r155357  
    3232#include "WriteBarrier.h"
    3333#include <wtf/Noncopyable.h>
    34 #include <wtf/TypeTraits.h>
    3534
    3635namespace JSC {
     
    179178inline To jsCast(From* from)
    180179{
    181     ASSERT(!from || from->JSCell::inherits(WTF::RemovePointer<To>::Type::info()));
     180    ASSERT(!from || from->JSCell::inherits(std::remove_pointer<To>::type::info()));
    182181    return static_cast<To>(from);
    183182}
     
    186185inline To jsCast(JSValue from)
    187186{
    188     ASSERT(from.isCell() && from.asCell()->JSCell::inherits(WTF::RemovePointer<To>::Type::info()));
     187    ASSERT(from.isCell() && from.asCell()->JSCell::inherits(std::remove_pointer<To>::type::info()));
    189188    return static_cast<To>(from.asCell());
    190189}
     
    193192inline To jsDynamicCast(From* from)
    194193{
    195     return from->inherits(WTF::RemovePointer<To>::Type::info()) ? static_cast<To>(from) : 0;
     194    return from->inherits(std::remove_pointer<To>::type::info()) ? static_cast<To>(from) : 0;
    196195}
    197196
     
    199198inline To jsDynamicCast(JSValue from)
    200199{
    201     return from.isCell() && from.asCell()->inherits(WTF::RemovePointer<To>::Type::info()) ? static_cast<To>(from.asCell()) : 0;
     200    return from.isCell() && from.asCell()->inherits(std::remove_pointer<To>::type::info()) ? static_cast<To>(from.asCell()) : 0;
    202201}
    203202
  • trunk/Source/JavaScriptCore/runtime/WriteBarrier.h

    r154162 r155357  
    3131#include "Heap.h"
    3232#include "SamplingCounter.h"
    33 #include <wtf/TypeTraits.h>
    3433
    3534namespace JSC {
     
    5251template<class T> inline void validateCell(T cell)
    5352{
    54     ASSERT_GC_OBJECT_INHERITS(cell, WTF::RemovePointer<T>::Type::info());
     53    ASSERT_GC_OBJECT_INHERITS(cell, std::remove_pointer<T>::type::info());
    5554}
    5655
  • trunk/Source/WTF/ChangeLog

    r155338 r155357  
     12013-09-08  Anders Carlsson  <andersca@apple.com>
     2
     3        Begin moving off of TypeTraits.h
     4        https://bugs.webkit.org/show_bug.cgi?id=121006
     5
     6        Reviewed by Darin Adler.
     7
     8        The C++11 has its own type traits implementation that is more complete and handles corner cases better
     9        since it ties into the compiler. Begin switching uses of WTF type traits to STL type traits.
     10
     11        * wtf/CheckedArithmetic.h:
     12        * wtf/HashTraits.h:
     13        * wtf/NeverDestroyed.h:
     14        * wtf/OwnPtr.h:
     15        * wtf/PassOwnPtr.h:
     16        (WTF::adoptPtr):
     17        * wtf/RetainPtr.h:
     18
    1192013-09-09  Julien Brianceau  <jbriance@cisco.com>
    220
  • trunk/Source/WTF/wtf/CheckedArithmetic.h

    r154498 r155357  
    2929#include <wtf/Assertions.h>
    3030#include <wtf/EnumClass.h>
    31 #include <wtf/TypeTraits.h>
    3231
    3332#include <limits>
    3433#include <stdint.h>
     34#include <type_traits>
    3535
    3636/* Checked<T>
     
    162162};
    163163
    164 template <typename Target, typename Source, bool CanElide = IsSameType<Target, Source>::value || (sizeof(Target) > sizeof(Source)) > struct BoundsCheckElider;
     164template <typename Target, typename Source, bool CanElide = std::is_same<Target, Source>::value || (sizeof(Target) > sizeof(Source)) > struct BoundsCheckElider;
    165165template <typename Target, typename Source> struct BoundsCheckElider<Target, Source, true> {
    166166    static bool inBounds(Source) { return true; }
  • trunk/Source/WTF/wtf/HashTraits.h

    r149739 r155357  
    2424#include <wtf/HashFunctions.h>
    2525#include <wtf/StdLibExtras.h>
    26 #include <wtf/TypeTraits.h>
    2726#include <utility>
    2827#include <limits>
     
    6463    };
    6564
    66     template<typename T> struct GenericHashTraits : GenericHashTraitsBase<IsInteger<T>::value, T> {
     65    template<typename T> struct GenericHashTraits : GenericHashTraitsBase<std::is_integral<T>::value, T> {
    6766        typedef T TraitType;
    6867        typedef T EmptyValueType;
  • trunk/Source/WTF/wtf/NeverDestroyed.h

    r150451 r155357  
    3030#include <wtf/Noncopyable.h>
    3131#include <wtf/StdLibExtras.h>
    32 #include <wtf/TypeTraits.h>
    3332
    3433// NeverDestroyed is a smart pointer like class who ensures that the destructor
     
    7675#endif
    7776
    78     typedef typename WTF::RemoveConst<T>::Type *PointerType;
     77    typedef typename std::remove_const<T>::type *PointerType;
    7978
    8079    PointerType asPtr() { return reinterpret_cast<PointerType>(&m_storage); }
  • trunk/Source/WTF/wtf/OwnPtr.h

    r128203 r155357  
    2626#include <wtf/NullPtr.h>
    2727#include <wtf/OwnPtrCommon.h>
    28 #include <wtf/TypeTraits.h>
    2928#include <algorithm>
    3029#include <memory>
     
    4443#endif
    4544    public:
    46         typedef typename RemovePointer<T>::Type ValueType;
     45        typedef typename std::remove_pointer<T>::type ValueType;
    4746        typedef ValueType* PtrType;
    4847
  • trunk/Source/WTF/wtf/PassOwnPtr.h

    r149341 r155357  
    3030#include <wtf/NullPtr.h>
    3131#include <wtf/OwnPtrCommon.h>
    32 #include <wtf/TypeTraits.h>
     32#include <type_traits>
    3333
    3434namespace WTF {
     
    4545    template<typename T> class PassOwnPtr {
    4646    public:
    47         typedef typename RemovePointer<T>::Type ValueType;
     47        typedef typename std::remove_pointer<T>::type ValueType;
    4848        typedef ValueType* PtrType;
    4949
     
    148148    template<typename T> inline PassOwnPtr<T> adoptPtr(T* ptr)
    149149    {
    150         COMPILE_ASSERT(!(IsSubclass<T, RefCountedBase>::value), DoNotUseAdoptPtrWithRefCounted);
    151         COMPILE_ASSERT(!(IsSubclass<T, ThreadSafeRefCountedBase>::value), DoNotUseAdoptPtrWithThreadSafeRefCounted);
     150        static_assert(!std::is_convertible<T*, RefCountedBase*>::value, "Do not use adoptPtr with RefCounted, use adoptPtr!");
     151        static_assert(!std::is_convertible<T*, ThreadSafeRefCountedBase*>::value, "Do not use adoptPtr with ThreadSafeRefCounted, use adoptPtr!");
    152152
    153153        return PassOwnPtr<T>(ptr);
  • trunk/Source/WTF/wtf/RetainPtr.h

    r155319 r155357  
    2626#include <wtf/HashTraits.h>
    2727#include <wtf/NullPtr.h>
    28 #include <wtf/TypeTraits.h>
    2928#include <algorithm>
    3029
     
    7675    template<typename T> class RetainPtr {
    7776    public:
    78         typedef typename RemovePointer<T>::Type ValueType;
     77        typedef typename std::remove_pointer<T>::type ValueType;
    7978        typedef ValueType* PtrType;
    8079        typedef CFTypeRef StorageType;
  • trunk/Source/WebKit2/ChangeLog

    r155353 r155357  
     12013-09-08  Anders Carlsson  <andersca@apple.com>
     2
     3        Begin moving off of TypeTraits.h
     4        https://bugs.webkit.org/show_bug.cgi?id=121006
     5
     6        Reviewed by Darin Adler.
     7
     8        Convert uses of WTF type traits to STL type traits.
     9
     10        * Platform/CoreIPC/ArgumentCoder.h:
     11        * Platform/CoreIPC/ArgumentCoders.h:
     12        * Platform/CoreIPC/ArgumentDecoder.h:
     13        * Platform/CoreIPC/ArgumentEncoder.h:
     14        * Platform/CoreIPC/Arguments.h:
     15        * Shared/API/c/WKSharedAPICast.h:
     16        (WebKit::toImpl):
     17
    1182013-09-09  Gustavo Noronha Silva  <gns@gnome.org>
    219
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentCoder.h

    r141619 r155357  
    2727#define ArgumentCoder_h
    2828
    29 #include <wtf/TypeTraits.h>
    30 
    3129namespace CoreIPC {
    3230
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h

    r149848 r155357  
    3232#include <wtf/Forward.h>
    3333#include <wtf/HashMap.h>
    34 #include <wtf/TypeTraits.h>
    3534#include <wtf/Vector.h>
    3635
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h

    r148043 r155357  
    3030#include "Attachment.h"
    3131#include <wtf/PassOwnPtr.h>
    32 #include <wtf/TypeTraits.h>
    3332#include <wtf/Vector.h>
    3433
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h

    r149944 r155357  
    3030#include "Attachment.h"
    3131#include <wtf/PassOwnPtr.h>
    32 #include <wtf/TypeTraits.h>
    3332#include <wtf/Vector.h>
    3433
  • trunk/Source/WebKit2/Platform/CoreIPC/Arguments.h

    r143052 r155357  
    2929#include "ArgumentDecoder.h"
    3030#include "ArgumentEncoder.h"
    31 #include <wtf/TypeTraits.h>
    3231
    3332namespace CoreIPC {
     
    4746
    4847template<typename T1> struct Arguments1 {
    49     typedef Arguments1<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type> ValueType;
     48    typedef Arguments1<typename std::remove_const<typename std::remove_reference<T1>::type>::type> ValueType;
    5049
    5150    Arguments1()
     
    7271   
    7372template<typename T1, typename T2> struct Arguments2 : Arguments1<T1> {
    74     typedef Arguments2<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    75                        typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type> ValueType;
     73    typedef Arguments2<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     74                       typename std::remove_const<typename std::remove_reference<T2>::type>::type> ValueType;
    7675
    7776    Arguments2()
     
    103102
    104103template<typename T1, typename T2, typename T3> struct Arguments3 : Arguments2<T1, T2> {
    105     typedef Arguments3<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    106                        typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    107                        typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type> ValueType;
     104    typedef Arguments3<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     105                       typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     106                       typename std::remove_const<typename std::remove_reference<T3>::type>::type> ValueType;
    108107
    109108    Arguments3()
     
    135134
    136135template<typename T1, typename T2, typename T3, typename T4> struct Arguments4 : Arguments3<T1, T2, T3> {
    137     typedef Arguments4<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    138                        typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    139                        typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type,
    140                        typename WTF::RemoveConst<typename WTF::RemoveReference<T4>::Type>::Type> ValueType;
     136    typedef Arguments4<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     137                       typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     138                       typename std::remove_const<typename std::remove_reference<T3>::type>::type,
     139                       typename std::remove_const<typename std::remove_reference<T4>::type>::type> ValueType;
    141140
    142141    Arguments4()
     
    168167
    169168template<typename T1, typename T2, typename T3, typename T4, typename T5> struct Arguments5 : Arguments4<T1, T2, T3, T4> {
    170     typedef Arguments5<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    171                        typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    172                        typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type,
    173                        typename WTF::RemoveConst<typename WTF::RemoveReference<T4>::Type>::Type,
    174                        typename WTF::RemoveConst<typename WTF::RemoveReference<T5>::Type>::Type> ValueType;
     169    typedef Arguments5<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     170                       typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     171                       typename std::remove_const<typename std::remove_reference<T3>::type>::type,
     172                       typename std::remove_const<typename std::remove_reference<T4>::type>::type,
     173                       typename std::remove_const<typename std::remove_reference<T5>::type>::type> ValueType;
    175174
    176175    Arguments5()
     
    202201
    203202template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct Arguments6 : Arguments5<T1, T2, T3, T4, T5> {
    204     typedef Arguments6<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    205                        typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    206                        typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type,
    207                        typename WTF::RemoveConst<typename WTF::RemoveReference<T4>::Type>::Type,
    208                        typename WTF::RemoveConst<typename WTF::RemoveReference<T5>::Type>::Type,
    209                        typename WTF::RemoveConst<typename WTF::RemoveReference<T6>::Type>::Type> ValueType;
     203    typedef Arguments6<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     204                       typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     205                       typename std::remove_const<typename std::remove_reference<T3>::type>::type,
     206                       typename std::remove_const<typename std::remove_reference<T4>::type>::type,
     207                       typename std::remove_const<typename std::remove_reference<T5>::type>::type,
     208                       typename std::remove_const<typename std::remove_reference<T6>::type>::type> ValueType;
    210209
    211210    Arguments6()
     
    237236
    238237template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct Arguments7 : Arguments6<T1, T2, T3, T4, T5, T6> {
    239     typedef Arguments7<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    240                        typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    241                        typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type,
    242                        typename WTF::RemoveConst<typename WTF::RemoveReference<T4>::Type>::Type,
    243                        typename WTF::RemoveConst<typename WTF::RemoveReference<T5>::Type>::Type,
    244                        typename WTF::RemoveConst<typename WTF::RemoveReference<T6>::Type>::Type,
    245                        typename WTF::RemoveConst<typename WTF::RemoveReference<T7>::Type>::Type> ValueType;
     238    typedef Arguments7<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     239                       typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     240                       typename std::remove_const<typename std::remove_reference<T3>::type>::type,
     241                       typename std::remove_const<typename std::remove_reference<T4>::type>::type,
     242                       typename std::remove_const<typename std::remove_reference<T5>::type>::type,
     243                       typename std::remove_const<typename std::remove_reference<T6>::type>::type,
     244                       typename std::remove_const<typename std::remove_reference<T7>::type>::type> ValueType;
    246245
    247246    Arguments7()
     
    273272
    274273template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> struct Arguments8 : Arguments7<T1, T2, T3, T4, T5, T6, T7> {
    275     typedef Arguments8<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    276     typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    277     typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type,
    278     typename WTF::RemoveConst<typename WTF::RemoveReference<T4>::Type>::Type,
    279     typename WTF::RemoveConst<typename WTF::RemoveReference<T5>::Type>::Type,
    280     typename WTF::RemoveConst<typename WTF::RemoveReference<T6>::Type>::Type,
    281     typename WTF::RemoveConst<typename WTF::RemoveReference<T7>::Type>::Type,
    282     typename WTF::RemoveConst<typename WTF::RemoveReference<T8>::Type>::Type> ValueType;
     274    typedef Arguments8<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     275    typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     276    typename std::remove_const<typename std::remove_reference<T3>::type>::type,
     277    typename std::remove_const<typename std::remove_reference<T4>::type>::type,
     278    typename std::remove_const<typename std::remove_reference<T5>::type>::type,
     279    typename std::remove_const<typename std::remove_reference<T6>::type>::type,
     280    typename std::remove_const<typename std::remove_reference<T7>::type>::type,
     281    typename std::remove_const<typename std::remove_reference<T8>::type>::type> ValueType;
    283282
    284283    Arguments8() { }
     
    308307
    309308template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> struct Arguments10 : Arguments8<T1, T2, T3, T4, T5, T6, T7, T8> {
    310     typedef Arguments10<typename WTF::RemoveConst<typename WTF::RemoveReference<T1>::Type>::Type,
    311     typename WTF::RemoveConst<typename WTF::RemoveReference<T2>::Type>::Type,
    312     typename WTF::RemoveConst<typename WTF::RemoveReference<T3>::Type>::Type,
    313     typename WTF::RemoveConst<typename WTF::RemoveReference<T4>::Type>::Type,
    314     typename WTF::RemoveConst<typename WTF::RemoveReference<T5>::Type>::Type,
    315     typename WTF::RemoveConst<typename WTF::RemoveReference<T6>::Type>::Type,
    316     typename WTF::RemoveConst<typename WTF::RemoveReference<T7>::Type>::Type,
    317     typename WTF::RemoveConst<typename WTF::RemoveReference<T8>::Type>::Type,
    318     typename WTF::RemoveConst<typename WTF::RemoveReference<T9>::Type>::Type,
    319     typename WTF::RemoveConst<typename WTF::RemoveReference<T10>::Type>::Type> ValueType;
     309    typedef Arguments10<typename std::remove_const<typename std::remove_reference<T1>::type>::type,
     310    typename std::remove_const<typename std::remove_reference<T2>::type>::type,
     311    typename std::remove_const<typename std::remove_reference<T3>::type>::type,
     312    typename std::remove_const<typename std::remove_reference<T4>::type>::type,
     313    typename std::remove_const<typename std::remove_reference<T5>::type>::type,
     314    typename std::remove_const<typename std::remove_reference<T6>::type>::type,
     315    typename std::remove_const<typename std::remove_reference<T7>::type>::type,
     316    typename std::remove_const<typename std::remove_reference<T8>::type>::type,
     317    typename std::remove_const<typename std::remove_reference<T9>::type>::type,
     318    typename std::remove_const<typename std::remove_reference<T10>::type>::type> ValueType;
    320319
    321320    Arguments10() { }
  • trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h

    r151656 r155357  
    5656#include <WebCore/UserContentTypes.h>
    5757#include <WebCore/UserScriptTypes.h>
    58 #include <wtf/TypeTraits.h>
    5958
    6059namespace WebKit {
     
    143142    // const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> ImmutableArray*
    144143   
    145     typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType;
    146     typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType;
     144    typedef typename std::remove_pointer<T>::type PotentiallyConstValueType;
     145    typedef typename std::remove_const<PotentiallyConstValueType>::type NonConstValueType;
    147146
    148147    return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
Note: See TracChangeset for help on using the changeset viewer.