Changeset 155883 in webkit
- Timestamp:
- Sep 16, 2013 10:50:20 AM (11 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r155832 r155883 1 2013-09-16 Anders Carlsson <andersca@apple.com> 2 3 Change a couple of COMPILE_ASSERTs to static_assert 4 https://bugs.webkit.org/show_bug.cgi?id=121441 5 6 Reviewed by Andreas Kling. 7 8 * wtf/BloomFilter.h: 9 * wtf/PackedIntVector.h: 10 (WTF::PackedIntVector::PackedIntVector): 11 * wtf/StdLibExtras.h: 12 (WTF::bitwise_cast): 13 (WTF::safeCast): 14 (WTF::roundUpToMultipleOf): 15 * wtf/StringHasher.h: 16 (WTF::StringHasher::hashMemory): 17 * wtf/Vector.h: 18 * wtf/text/AtomicString.cpp: 19 * wtf/unicode/Unicode.h: 20 1 21 2013-09-15 Gustavo Noronha Silva <gns@gnome.org> 2 22 -
trunk/Source/WTF/wtf/BloomFilter.h
r149673 r155883 38 38 WTF_MAKE_FAST_ALLOCATED; 39 39 public: 40 COMPILE_ASSERT(keyBits <= 16, bloom_filter_key_size);40 static_assert(keyBits <= 16, "BloomFilter key size must be less than or equal to 16!"); 41 41 42 42 static const size_t tableSize = 1 << keyBits; -
trunk/Source/WTF/wtf/PackedIntVector.h
r151689 r155883 41 41 class PackedIntVector { 42 42 public: 43 static_assert(bitCount, "bitCount must not be zero!"); 44 static_assert(bitCount < sizeof(void*) * 8, "bitCount must not exceed the address space limit!"); 45 43 46 PackedIntVector() 44 47 { 45 COMPILE_ASSERT(bitCount, bitCount_shall_not_be_zero);46 COMPILE_ASSERT(bitCount < sizeof(void*) * 8, bitCount_shall_not_exceed_address_space_limit);47 48 } 48 49 -
trunk/Source/WTF/wtf/StdLibExtras.h
r155280 r155883 130 130 * C++'s idea of a reinterpret_cast lacks sufficient cojones. 131 131 */ 132 template<typename T O, typename FROM>133 inline T O bitwise_cast(FROMfrom)134 { 135 COMPILE_ASSERT(sizeof(TO) == sizeof(FROM), WTF_bitwise_cast_sizeof_casted_types_is_equal);132 template<typename ToType, typename FromType> 133 inline ToType bitwise_cast(FromType from) 134 { 135 static_assert(sizeof(FromType) == sizeof(ToType), "bitwise_cast size of FromType and ToType must be equal!"); 136 136 union { 137 F ROMfrom;138 T Oto;137 FromType from; 138 ToType to; 139 139 } u; 140 140 u.from = from; … … 142 142 } 143 143 144 template<typename To , typename From>145 inline To safeCast(Fromvalue)146 { 147 ASSERT(isInBounds<To >(value));148 return static_cast<To >(value);144 template<typename ToType, typename FromType> 145 inline ToType safeCast(FromType value) 146 { 147 ASSERT(isInBounds<ToType>(value)); 148 return static_cast<ToType>(value); 149 149 } 150 150 … … 172 172 return (x + remainderMask) & ~remainderMask; 173 173 } 174 174 175 template<size_t divisor> inline size_t roundUpToMultipleOf(size_t x) 175 176 { 176 COMPILE_ASSERT(divisor && !(divisor & (divisor - 1)), divisor_is_a_power_of_two);177 static_assert(divisor && !(divisor & (divisor - 1)), "divisor must be a power of two!"); 177 178 return roundUpToMultipleOf(divisor, x); 178 179 } -
trunk/Source/WTF/wtf/StringHasher.h
r144552 r155883 249 249 template<size_t length> static unsigned hashMemory(const void* data) 250 250 { 251 COMPILE_ASSERT(!(length % 2), length_must_be_a_multiple_of_two);251 static_assert(!(length % 2), "length must be a multiple of two!"); 252 252 return hashMemory(data, length); 253 253 } -
trunk/Source/WTF/wtf/Vector.h
r155748 r155883 175 175 static void uninitializedFill(T* dst, T* dstEnd, const T& val) 176 176 { 177 COMPILE_ASSERT(sizeof(T) == sizeof(char), Size_of_type_should_be_equal_to_one);177 static_assert(sizeof(T) == 1, "Size of type T should be equal to one!"); 178 178 #if COMPILER(GCC) && defined(_FORTIFY_SOURCE) 179 179 if (!__builtin_constant_p(dstEnd - dst) || (!(dstEnd - dst))) -
trunk/Source/WTF/wtf/text/AtomicString.cpp
r152816 r155883 41 41 using namespace Unicode; 42 42 43 COMPILE_ASSERT(sizeof(AtomicString) == sizeof(String), atomic_string_and_string_must_be_same_size);43 static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString and String must be same size!"); 44 44 45 45 #if USE(WEB_THREAD) -
trunk/Source/WTF/wtf/unicode/Unicode.h
r142761 r155883 37 37 #endif 38 38 39 COMPILE_ASSERT(sizeof(UChar) == 2, UCharIsTwoBytes);39 static_assert(sizeof(UChar) == 2, "UChar must be two bytes!"); 40 40 41 41 #endif // WTF_UNICODE_H
Note: See TracChangeset
for help on using the changeset viewer.