summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/wtf
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-01-11 10:03:25 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-01-11 10:03:25 +0100
commitd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (patch)
treeb318cf594dc1da2fa48224005945c9157f35bb41 /Source/JavaScriptCore/wtf
parent6300a96eca9f152b379f1bcf3d9efdc5572d989a (diff)
downloadqtwebkit-d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9.tar.gz
Imported WebKit commit 75bb2fc5882d2e1b3d5572c2961507996cbca5e3 (http://svn.webkit.org/repository/webkit/trunk@104681)
Diffstat (limited to 'Source/JavaScriptCore/wtf')
-rw-r--r--Source/JavaScriptCore/wtf/Assertions.cpp46
-rw-r--r--Source/JavaScriptCore/wtf/ByteArray.h2
-rw-r--r--Source/JavaScriptCore/wtf/CMakeLists.txt10
-rw-r--r--Source/JavaScriptCore/wtf/DateMath.cpp1
-rw-r--r--Source/JavaScriptCore/wtf/Functional.h20
-rw-r--r--Source/JavaScriptCore/wtf/ListHashSet.h2
-rw-r--r--Source/JavaScriptCore/wtf/OwnFastMallocPtr.h53
-rw-r--r--Source/JavaScriptCore/wtf/TypeTraits.cpp13
-rw-r--r--Source/JavaScriptCore/wtf/TypeTraits.h46
-rw-r--r--Source/JavaScriptCore/wtf/text/StringImpl.h1
-rw-r--r--Source/JavaScriptCore/wtf/wtf.pro1
11 files changed, 128 insertions, 67 deletions
diff --git a/Source/JavaScriptCore/wtf/Assertions.cpp b/Source/JavaScriptCore/wtf/Assertions.cpp
index de062ce25..3da67effe 100644
--- a/Source/JavaScriptCore/wtf/Assertions.cpp
+++ b/Source/JavaScriptCore/wtf/Assertions.cpp
@@ -98,7 +98,7 @@ static void vprintf_stderr_common(const char* format, va_list args)
// Fall through to write to stderr in the same manner as other platforms.
#elif PLATFORM(BLACKBERRY)
- BlackBerry::Platform::logV(BlackBerry::Platform::LogLevelInfo, format, args);
+ BlackBerry::Platform::logStreamV(format, args);
#elif HAVE(ISDEBUGGERPRESENT)
if (IsDebuggerPresent()) {
size_t size = 1024;
@@ -133,7 +133,9 @@ static void vprintf_stderr_common(const char* format, va_list args)
} while (size > 1024);
}
#endif
+#if !PLATFORM(BLACKBERRY)
vfprintf(stderr, format, args);
+#endif
}
#if COMPILER(CLANG) || (COMPILER(GCC) && GCC_VERSION_AT_LEAST(4, 6, 0))
@@ -194,8 +196,26 @@ static void printCallSite(const char* file, int line, const char* function)
#endif
}
+#if PLATFORM(BLACKBERRY)
+struct WTFLogLocker {
+ WTFLogLocker(BlackBerry::Platform::MessageLogLevel logLevel)
+ {
+ BlackBerry::Platform::lockLogging(logLevel);
+ }
+
+ ~WTFLogLocker()
+ {
+ BlackBerry::Platform::unlockLogging();
+ }
+};
+#endif
+
void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion)
{
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical);
+#endif
+
if (assertion)
printf_stderr_common("ASSERTION FAILED: %s\n", assertion);
else
@@ -205,6 +225,10 @@ void WTFReportAssertionFailure(const char* file, int line, const char* function,
void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...)
{
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical);
+#endif
+
va_list args;
va_start(args, format);
vprintf_stderr_with_prefix("ASSERTION FAILED: ", format, args);
@@ -215,6 +239,10 @@ void WTFReportAssertionFailureWithMessage(const char* file, int line, const char
void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion)
{
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical);
+#endif
+
printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion);
printCallSite(file, line, function);
}
@@ -275,6 +303,10 @@ void WTFReportBacktrace()
void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
{
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelCritical);
+#endif
+
va_list args;
va_start(args, format);
vprintf_stderr_with_prefix("FATAL ERROR: ", format, args);
@@ -285,6 +317,10 @@ void WTFReportFatalError(const char* file, int line, const char* function, const
void WTFReportError(const char* file, int line, const char* function, const char* format, ...)
{
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelWarn);
+#endif
+
va_list args;
va_start(args, format);
vprintf_stderr_with_prefix("ERROR: ", format, args);
@@ -298,6 +334,10 @@ void WTFLog(WTFLogChannel* channel, const char* format, ...)
if (channel->state != WTFLogChannelOn)
return;
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelInfo);
+#endif
+
va_list args;
va_start(args, format);
vprintf_stderr_with_trailing_newline(format, args);
@@ -309,6 +349,10 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann
if (channel->state != WTFLogChannelOn)
return;
+#if PLATFORM(BLACKBERRY)
+ WTFLogLocker locker(BlackBerry::Platform::LogLevelInfo);
+#endif
+
va_list args;
va_start(args, format);
vprintf_stderr_with_trailing_newline(format, args);
diff --git a/Source/JavaScriptCore/wtf/ByteArray.h b/Source/JavaScriptCore/wtf/ByteArray.h
index 009ec5850..6964a33df 100644
--- a/Source/JavaScriptCore/wtf/ByteArray.h
+++ b/Source/JavaScriptCore/wtf/ByteArray.h
@@ -97,7 +97,7 @@ namespace WTF {
// MSVC can't handle correctly unsized array.
// warning C4200: nonstandard extension used : zero-sized array in struct/union
// Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
-#if COMPILER(MSVC) && !COMPILER(INTEL)
+#if (COMPILER(MSVC) || COMPILER(SUNCC)) && !COMPILER(INTEL)
unsigned char m_data[INT_MAX];
#else
unsigned char m_data[];
diff --git a/Source/JavaScriptCore/wtf/CMakeLists.txt b/Source/JavaScriptCore/wtf/CMakeLists.txt
index 6d1cee899..52d3e3c4d 100644
--- a/Source/JavaScriptCore/wtf/CMakeLists.txt
+++ b/Source/JavaScriptCore/wtf/CMakeLists.txt
@@ -56,7 +56,6 @@ SET(WTF_HEADERS
OSAllocator.h
OSRandomSource.h
OwnArrayPtr.h
- OwnFastMallocPtr.h
OwnPtr.h
OwnPtrCommon.h
PageAllocation.h
@@ -187,12 +186,12 @@ SET(WTF_INCLUDE_DIRECTORIES
"${JAVASCRIPTCORE_DIR}/wtf/unicode"
"${JAVASCRIPTCORE_DIR}/wtf/dtoa"
"${JavaScriptCore_INCLUDE_DIRECTORIES}"
+ "${THIRDPARTY_DIR}"
)
SET(WTF_LIBRARIES
)
-
IF (ENABLE_FAST_MALLOC)
LIST(APPEND WTF_SOURCES
TCSystemAlloc.cpp
@@ -201,15 +200,8 @@ ELSE ()
ADD_DEFINITIONS(-DUSE_SYSTEM_MALLOC=1)
ENDIF()
-
-SET(WTF_PORT_FLAGS )
INCLUDE_IF_EXISTS(${JAVASCRIPTCORE_DIR}/wtf/Platform${PORT}.cmake)
-LIST(APPEND WTF_INCLUDE_DIRECTORIES
- "${CMAKE_BINARY_DIR}"
- "${CMAKE_SOURCE_DIR}/Source/ThirdParty"
-)
-
WEBKIT_WRAP_SOURCELIST(${WTF_SOURCES})
INCLUDE_DIRECTORIES(${WTF_INCLUDE_DIRECTORIES})
ADD_DEFINITIONS(-DBUILDING_WTF)
diff --git a/Source/JavaScriptCore/wtf/DateMath.cpp b/Source/JavaScriptCore/wtf/DateMath.cpp
index 86bd99527..dc503ca2a 100644
--- a/Source/JavaScriptCore/wtf/DateMath.cpp
+++ b/Source/JavaScriptCore/wtf/DateMath.cpp
@@ -961,6 +961,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString, bool& haveT
else
offset = o * 60 * sgn;
} else { // GMT+05:00
+ ++dateString; // skip the ':'
long o2;
if (!parseLong(dateString, &newPosStr, 10, &o2))
return std::numeric_limits<double>::quiet_NaN();
diff --git a/Source/JavaScriptCore/wtf/Functional.h b/Source/JavaScriptCore/wtf/Functional.h
index 86d6203cf..bd0f3e282 100644
--- a/Source/JavaScriptCore/wtf/Functional.h
+++ b/Source/JavaScriptCore/wtf/Functional.h
@@ -136,6 +136,26 @@ private:
R (*m_function)(P1, P2);
};
+template<typename R, typename P1, typename P2, typename P3>
+class FunctionWrapper<R (*)(P1, P2, P3)> {
+public:
+ typedef R ResultType;
+ static const bool shouldRefFirstParameter = false;
+
+ explicit FunctionWrapper(R (*function)(P1, P2, P3))
+ : m_function(function)
+ {
+ }
+
+ R operator()(P1 p1, P2 p2, P3 p3)
+ {
+ return m_function(p1, p2, p3);
+ }
+
+private:
+ R (*m_function)(P1, P2, P3);
+};
+
template<typename R, typename C>
class FunctionWrapper<R (C::*)()> {
public:
diff --git a/Source/JavaScriptCore/wtf/ListHashSet.h b/Source/JavaScriptCore/wtf/ListHashSet.h
index 3b413406d..32bd23832 100644
--- a/Source/JavaScriptCore/wtf/ListHashSet.h
+++ b/Source/JavaScriptCore/wtf/ListHashSet.h
@@ -375,7 +375,7 @@ namespace WTF {
private:
typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
typedef ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg> reverse_iterator;
- typedef ListHashSetConstIterator<ValueArg, inlineCapacity, HashArg> const_reverse_iterator;
+ typedef ListHashSetConstReverseIterator<ValueArg, inlineCapacity, HashArg> const_reverse_iterator;
typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
typedef ValueArg ValueType;
typedef ValueType& ReferenceType;
diff --git a/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h b/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h
deleted file mode 100644
index 183bfec8f..000000000
--- a/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef OwnFastMallocPtr_h
-#define OwnFastMallocPtr_h
-
-#include "FastMalloc.h"
-#include <wtf/Noncopyable.h>
-
-namespace WTF {
-
- template<class T> class OwnFastMallocPtr {
- WTF_MAKE_NONCOPYABLE(OwnFastMallocPtr);
- public:
- explicit OwnFastMallocPtr(T* ptr) : m_ptr(ptr)
- {
- }
-
- ~OwnFastMallocPtr()
- {
- fastFree(const_cast<void*>(static_cast<const void*>(const_cast<const T*>(m_ptr))));
- }
-
- T* get() const { return m_ptr; }
- T* release() { T* ptr = m_ptr; m_ptr = 0; return ptr; }
-
- private:
- T* m_ptr;
- };
-
-} // namespace WTF
-
-using WTF::OwnFastMallocPtr;
-
-#endif // OwnFastMallocPtr_h
diff --git a/Source/JavaScriptCore/wtf/TypeTraits.cpp b/Source/JavaScriptCore/wtf/TypeTraits.cpp
index afeaa5e4c..7cea256b7 100644
--- a/Source/JavaScriptCore/wtf/TypeTraits.cpp
+++ b/Source/JavaScriptCore/wtf/TypeTraits.cpp
@@ -139,4 +139,17 @@ COMPILE_ASSERT((!IsSameType<int, RemovePointer<int**>::Type>::value), WTF_Test_R
COMPILE_ASSERT((IsSameType<int, RemoveReference<int>::Type>::value), WTF_Test_RemoveReference_int);
COMPILE_ASSERT((IsSameType<int, RemoveReference<int&>::Type>::value), WTF_Test_RemoveReference_int_reference);
+
+typedef int IntArray[];
+typedef int IntArraySized[4];
+
+COMPILE_ASSERT((IsArray<IntArray>::value), WTF_Test_IsArray_int_array);
+COMPILE_ASSERT((IsArray<IntArraySized>::value), WTF_Test_IsArray_int_sized_array);
+
+COMPILE_ASSERT((IsSameType<int, RemoveExtent<IntArray>::Type>::value), WTF_Test_RemoveExtent_int_array);
+COMPILE_ASSERT((IsSameType<int, RemoveExtent<IntArraySized>::Type>::value), WTF_Test_RemoveReference_int_sized_array);
+
+COMPILE_ASSERT((IsSameType<int*, DecayArray<IntArray>::Type>::value), WTF_Test_DecayArray_int_array);
+COMPILE_ASSERT((IsSameType<int*, DecayArray<IntArraySized>::Type>::value), WTF_Test_DecayArray_int_sized_array);
+
} // namespace WTF
diff --git a/Source/JavaScriptCore/wtf/TypeTraits.h b/Source/JavaScriptCore/wtf/TypeTraits.h
index 6c7466acc..34e8b79a3 100644
--- a/Source/JavaScriptCore/wtf/TypeTraits.h
+++ b/Source/JavaScriptCore/wtf/TypeTraits.h
@@ -35,10 +35,14 @@ namespace WTF {
// The following are provided in this file:
//
+ // Conditional<Predicate, If, Then>::Type
+ //
// IsInteger<T>::value
// IsPod<T>::value, see the definition for a note about its limitations
// IsConvertibleToInteger<T>::value
//
+ // IsArray<T>::value
+ //
// IsSameType<T, U>::value
//
// RemovePointer<T>::Type
@@ -46,9 +50,15 @@ namespace WTF {
// RemoveConst<T>::Type
// RemoveVolatile<T>::Type
// RemoveConstVolatile<T>::Type
+ // RemoveExtent<T>::Type
+ //
+ // DecayArray<T>::Type
//
// COMPILE_ASSERT's in TypeTraits.cpp illustrate their usage and what they do.
+ template <bool Predicate, class If, class Then> struct Conditional { typedef If Type; };
+ template <class If, class Then> struct Conditional<false, If, Then> { typedef Then Type; };
+
template<typename T> struct IsInteger { static const bool value = false; };
template<> struct IsInteger<bool> { static const bool value = true; };
template<> struct IsInteger<char> { static const bool value = true; };
@@ -104,6 +114,20 @@ namespace WTF {
static const bool value = IsInteger<T>::value || IsConvertibleToDouble<!IsInteger<T>::value, T>::value;
};
+
+ template <class T> struct IsArray {
+ static const bool value = false;
+ };
+
+ template <class T> struct IsArray<T[]> {
+ static const bool value = true;
+ };
+
+ template <class T, size_t N> struct IsArray<T[N]> {
+ static const bool value = true;
+ };
+
+
template <typename T, typename U> struct IsSameType {
static const bool value = false;
};
@@ -182,6 +206,28 @@ namespace WTF {
typedef T Type;
};
+ template <typename T> struct RemoveExtent {
+ typedef T Type;
+ };
+
+ template <typename T> struct RemoveExtent<T[]> {
+ typedef T Type;
+ };
+
+ template <typename T, size_t N> struct RemoveExtent<T[N]> {
+ typedef T Type;
+ };
+
+ template <class T> struct DecayArray {
+ typedef typename RemoveReference<T>::Type U;
+ public:
+ typedef typename Conditional<
+ IsArray<U>::value,
+ typename RemoveExtent<U>::Type*,
+ typename RemoveConstVolatile<U>::Type
+ >::Type Type;
+ };
+
#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
// GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace.
diff --git a/Source/JavaScriptCore/wtf/text/StringImpl.h b/Source/JavaScriptCore/wtf/text/StringImpl.h
index a3008e1d3..003c44ce6 100644
--- a/Source/JavaScriptCore/wtf/text/StringImpl.h
+++ b/Source/JavaScriptCore/wtf/text/StringImpl.h
@@ -26,7 +26,6 @@
#include <limits.h>
#include <wtf/ASCIICType.h>
#include <wtf/Forward.h>
-#include <wtf/OwnFastMallocPtr.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringHasher.h>
#include <wtf/Vector.h>
diff --git a/Source/JavaScriptCore/wtf/wtf.pro b/Source/JavaScriptCore/wtf/wtf.pro
index e59d118e2..234348f2b 100644
--- a/Source/JavaScriptCore/wtf/wtf.pro
+++ b/Source/JavaScriptCore/wtf/wtf.pro
@@ -90,7 +90,6 @@ HEADERS += \
OSAllocator.h \
OSRandomSource.h \
OwnArrayPtr.h \
- OwnFastMallocPtr.h \
OwnPtr.h \
OwnPtrCommon.h \
PackedIntVector.h \