diff options
Diffstat (limited to 'Source/WTF/wtf')
-rw-r--r-- | Source/WTF/wtf/Assertions.cpp | 6 | ||||
-rw-r--r-- | Source/WTF/wtf/Atomics.h | 4 | ||||
-rw-r--r-- | Source/WTF/wtf/Compiler.h | 11 | ||||
-rw-r--r-- | Source/WTF/wtf/DataLog.h | 6 | ||||
-rw-r--r-- | Source/WTF/wtf/HashTable.h | 6 | ||||
-rw-r--r-- | Source/WTF/wtf/HashTraits.h | 13 | ||||
-rw-r--r-- | Source/WTF/wtf/MathExtras.h | 8 | ||||
-rw-r--r-- | Source/WTF/wtf/Vector.h | 25 | ||||
-rw-r--r-- | Source/WTF/wtf/qt/UtilsQt.h | 4 | ||||
-rw-r--r-- | Source/WTF/wtf/text/AtomicString.h | 11 | ||||
-rw-r--r-- | Source/WTF/wtf/text/WTFString.h | 9 |
11 files changed, 83 insertions, 20 deletions
diff --git a/Source/WTF/wtf/Assertions.cpp b/Source/WTF/wtf/Assertions.cpp index 8549f1ef2..8fe8a38de 100644 --- a/Source/WTF/wtf/Assertions.cpp +++ b/Source/WTF/wtf/Assertions.cpp @@ -58,6 +58,10 @@ #include <execinfo.h> #endif +#if OS(ANDROID) +#include "android/log.h" +#endif + #if PLATFORM(BLACKBERRY) #include <BlackBerryPlatformLog.h> #endif @@ -106,6 +110,8 @@ static void vprintf_stderr_common(const char* format, va_list args) #elif PLATFORM(BLACKBERRY) BlackBerry::Platform::logStreamV(format, args); +#elif OS(ANDROID) + __android_log_vprint(ANDROID_LOG_WARN, "WebKit", format, args); #elif HAVE(ISDEBUGGERPRESENT) if (IsDebuggerPresent()) { size_t size = 1024; diff --git a/Source/WTF/wtf/Atomics.h b/Source/WTF/wtf/Atomics.h index d70c72a1f..0442a7df4 100644 --- a/Source/WTF/wtf/Atomics.h +++ b/Source/WTF/wtf/Atomics.h @@ -121,7 +121,11 @@ inline int atomicDecrement(int volatile* addend) { return __gnu_cxx::__exchange_ #if OS(WINDOWS) inline bool weakCompareAndSwap(volatile unsigned* location, unsigned expected, unsigned newValue) { +#if OS(WINCE) + return InterlockedCompareExchange(reinterpret_cast<LONG*>(const_cast<unsigned*>(location)), static_cast<LONG>(newValue), static_cast<LONG>(expected)) == static_cast<LONG>(expected); +#else return InterlockedCompareExchange(reinterpret_cast<LONG volatile*>(location), static_cast<LONG>(newValue), static_cast<LONG>(expected)) == static_cast<LONG>(expected); +#endif } inline bool weakCompareAndSwap(void*volatile* location, void* expected, void* newValue) diff --git a/Source/WTF/wtf/Compiler.h b/Source/WTF/wtf/Compiler.h index 9637dc0bc..f40e15e60 100644 --- a/Source/WTF/wtf/Compiler.h +++ b/Source/WTF/wtf/Compiler.h @@ -48,9 +48,14 @@ #define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA) /* Specific compiler features */ -#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES __has_feature(cxx_variadic_templates) -#define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_feature(cxx_rvalue_references) -#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS __has_feature(cxx_deleted_functions) +#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES __has_extension(cxx_variadic_templates) + +/* There is a bug in clang that comes with Xcode 4.2 where AtomicStrings can't be implicitly converted to Strings + in the presence of move constructors and/or move assignment operators. This bug has been fixed in Xcode 4.3 clang, so we + check for both cxx_rvalue_references as well as the unrelated cxx_nonstatic_member_init feature which we know was added in 4.3 */ +#define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_extension(cxx_rvalue_references) && __has_extension(cxx_nonstatic_member_init) + +#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS __has_extension(cxx_deleted_functions) #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr) #define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks) #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert) diff --git a/Source/WTF/wtf/DataLog.h b/Source/WTF/wtf/DataLog.h index bcbebb9e2..cca04a3c4 100644 --- a/Source/WTF/wtf/DataLog.h +++ b/Source/WTF/wtf/DataLog.h @@ -33,10 +33,10 @@ namespace WTF { -FILE* dataFile(); +WTF_EXPORT_PRIVATE FILE* dataFile(); -void dataLogV(const char* format, va_list) WTF_ATTRIBUTE_PRINTF(1, 0); -void dataLog(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2); +WTF_EXPORT_PRIVATE void dataLogV(const char* format, va_list) WTF_ATTRIBUTE_PRINTF(1, 0); +WTF_EXPORT_PRIVATE void dataLog(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2); } // namespace WTF diff --git a/Source/WTF/wtf/HashTable.h b/Source/WTF/wtf/HashTable.h index 7625e56fe..ccf62dc00 100644 --- a/Source/WTF/wtf/HashTable.h +++ b/Source/WTF/wtf/HashTable.h @@ -285,7 +285,7 @@ namespace WTF { } // Swap pairs by component, in case of pair members that specialize swap. - template<typename T, typename U> inline void hashTableSwap(pair<T, U>& a, pair<T, U>& b) + template<typename T, typename U> inline void hashTableSwap(std::pair<T, U>& a, std::pair<T, U>& b) { swap(a.first, b.first); swap(a.second, b.second); @@ -392,8 +392,8 @@ namespace WTF { static ValueType* allocateTable(int size); static void deallocateTable(ValueType* table, int size); - typedef pair<ValueType*, bool> LookupType; - typedef pair<LookupType, unsigned> FullLookupType; + typedef std::pair<ValueType*, bool> LookupType; + typedef std::pair<LookupType, unsigned> FullLookupType; LookupType lookupForWriting(const Key& key) { return lookupForWriting<IdentityTranslatorType>(key); }; template<typename HashTranslator, typename T> FullLookupType fullLookupForWriting(const T&); diff --git a/Source/WTF/wtf/HashTraits.h b/Source/WTF/wtf/HashTraits.h index fdf1ab941..21ffdbb45 100644 --- a/Source/WTF/wtf/HashTraits.h +++ b/Source/WTF/wtf/HashTraits.h @@ -34,9 +34,6 @@ namespace WTF { template<typename T> class OwnPtr; template<typename T> class PassOwnPtr; - using std::pair; - using std::make_pair; - template<typename T> struct HashTraits; template<bool isInteger, typename T> struct GenericHashTraitsBase; @@ -169,14 +166,14 @@ namespace WTF { // special traits for pairs, helpful for their use in HashMap implementation template<typename FirstTraitsArg, typename SecondTraitsArg> - struct PairHashTraits : GenericHashTraits<pair<typename FirstTraitsArg::TraitType, typename SecondTraitsArg::TraitType> > { + struct PairHashTraits : GenericHashTraits<std::pair<typename FirstTraitsArg::TraitType, typename SecondTraitsArg::TraitType> > { typedef FirstTraitsArg FirstTraits; typedef SecondTraitsArg SecondTraits; - typedef pair<typename FirstTraits::TraitType, typename SecondTraits::TraitType> TraitType; - typedef pair<typename FirstTraits::EmptyValueType, typename SecondTraits::EmptyValueType> EmptyValueType; + typedef std::pair<typename FirstTraits::TraitType, typename SecondTraits::TraitType> TraitType; + typedef std::pair<typename FirstTraits::EmptyValueType, typename SecondTraits::EmptyValueType> EmptyValueType; static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero; - static EmptyValueType emptyValue() { return make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); } + static EmptyValueType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); } static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; @@ -187,7 +184,7 @@ namespace WTF { }; template<typename First, typename Second> - struct HashTraits<pair<First, Second> > : public PairHashTraits<HashTraits<First>, HashTraits<Second> > { }; + struct HashTraits<std::pair<First, Second> > : public PairHashTraits<HashTraits<First>, HashTraits<Second> > { }; } // namespace WTF diff --git a/Source/WTF/wtf/MathExtras.h b/Source/WTF/wtf/MathExtras.h index 956fc94cc..154c88725 100644 --- a/Source/WTF/wtf/MathExtras.h +++ b/Source/WTF/wtf/MathExtras.h @@ -302,6 +302,14 @@ using std::wtf_isnan; #define isnan(x) wtf_isnan(x) #endif +#ifndef UINT64_C +#if COMPILER(MSVC) +#define UINT64_C(c) c ## ui64 +#else +#define UINT64_C(c) c ## ull +#endif +#endif + // decompose 'number' to its sign, exponent, and mantissa components. // The result is interpreted as: diff --git a/Source/WTF/wtf/Vector.h b/Source/WTF/wtf/Vector.h index 19e6ffb8c..a3b6a0e62 100644 --- a/Source/WTF/wtf/Vector.h +++ b/Source/WTF/wtf/Vector.h @@ -518,6 +518,11 @@ namespace WTF { template<size_t otherCapacity> Vector& operator=(const Vector<T, otherCapacity>&); +#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) + Vector(Vector&&); + Vector& operator=(Vector&&); +#endif + size_t size() const { return m_size; } size_t capacity() const { return m_buffer.capacity(); } bool isEmpty() const { return !size(); } @@ -759,6 +764,24 @@ namespace WTF { return *this; } +#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) + template<typename T, size_t inlineCapacity> + Vector<T, inlineCapacity>::Vector(Vector<T, inlineCapacity>&& other) + : m_size(0) + { + // It's a little weird to implement a move constructor using swap but this way we + // don't have to add a move constructor to VectorBuffer. + swap(other); + } + + template<typename T, size_t inlineCapacity> + Vector<T, inlineCapacity>& Vector<T, inlineCapacity>::operator=(Vector<T, inlineCapacity>&& other) + { + swap(other); + return *this; + } +#endif + template<typename T, size_t inlineCapacity> template<typename U> bool Vector<T, inlineCapacity>::contains(const U& value) const @@ -1110,7 +1133,7 @@ namespace WTF { template<typename T, size_t inlineCapacity> inline void Vector<T, inlineCapacity>::remove(size_t position, size_t length) { - ASSERT(position < size()); + ASSERT(position <= size()); ASSERT(position + length <= size()); T* beginSpot = begin() + position; T* endSpot = beginSpot + length; diff --git a/Source/WTF/wtf/qt/UtilsQt.h b/Source/WTF/wtf/qt/UtilsQt.h index 74067a8ee..61c9e32c1 100644 --- a/Source/WTF/wtf/qt/UtilsQt.h +++ b/Source/WTF/wtf/qt/UtilsQt.h @@ -21,13 +21,13 @@ #define WTF_UtilsQt_h #include <QString> -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#if !HAVE(QT5) #include <QTextDocument> #endif inline QString escapeHtml(const QString& string) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#if HAVE(QT5) return string.toHtmlEscaped(); #else return Qt::escape(string); diff --git a/Source/WTF/wtf/text/AtomicString.h b/Source/WTF/wtf/text/AtomicString.h index ca133a5e1..73a855997 100644 --- a/Source/WTF/wtf/text/AtomicString.h +++ b/Source/WTF/wtf/text/AtomicString.h @@ -51,6 +51,17 @@ public: ATOMICSTRING_CONVERSION AtomicString(const String& s) : m_string(add(s.impl())) { } AtomicString(StringImpl* baseString, unsigned start, unsigned length) : m_string(add(baseString, start, length)) { } +#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) + // We have to declare the copy constructor and copy assignment operator as well, otherwise + // they'll be implicitly deleted by adding the move constructor and move assignment operator. + // FIXME: Instead of explicitly casting to String&& here, we should use std::move, but that requires us to + // have a standard library that supports move semantics. + AtomicString(const AtomicString& other) : m_string(other.m_string) { } + AtomicString(AtomicString&& other) : m_string(static_cast<String&&>(other.m_string)) { } + AtomicString& operator=(const AtomicString& other) { m_string = other.m_string; return *this; } + AtomicString& operator=(AtomicString&& other) { m_string = static_cast<String&&>(other.m_string); return *this; } +#endif + // Hash table deleted values, which are only constructed and never copied or destroyed. AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDeletedValue) { } bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue(); } diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h index 5e1763ad7..bfbfda4d4 100644 --- a/Source/WTF/wtf/text/WTFString.h +++ b/Source/WTF/wtf/text/WTFString.h @@ -131,6 +131,15 @@ public: String(PassRefPtr<StringImpl> impl) : m_impl(impl) { } String(RefPtr<StringImpl> impl) : m_impl(impl) { } +#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) + // We have to declare the copy constructor and copy assignment operator as well, otherwise + // they'll be implicitly deleted by adding the move constructor and move assignment operator. + String(const String& other) : m_impl(other.m_impl) { } + String(String&& other) : m_impl(other.m_impl.release()) { } + String& operator=(const String& other) { m_impl = other.m_impl; return *this; } + String& operator=(String&& other) { m_impl = other.m_impl.release(); return *this; } +#endif + // Inline the destructor. ALWAYS_INLINE ~String() { } |