Remove support for MSVC

I also removed COMPILER_SUPPORTS since
all of the checks were for old versions of
GCC which we no longer support.

Mojo requires GCC 4.8 or later.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/714393002
This commit is contained in:
Eric Seidel 2014-11-11 16:59:04 -08:00
parent ec084dc47a
commit 4ab80f640b
46 changed files with 9 additions and 1090 deletions

View File

@ -10,9 +10,6 @@
namespace blink {
#if COMPILER(MSVC)
__declspec(align(4))
#endif
struct SameSizeAsScriptWrappableBase { };
COMPILE_ASSERT(sizeof(ScriptWrappableBase) <= sizeof(SameSizeAsScriptWrappableBase), ScriptWrappableBase_should_stay_small);

View File

@ -48,26 +48,6 @@ namespace blink {
* variable which increase the size of instances. Some of the classes sensitive
* to the size inherit from this class. So this class must be zero size.
*/
#if COMPILER(MSVC)
// VC++ 2013 doesn't support EBCO (Empty Base Class Optimization). It causes
// that not always pointers to an empty base class are aligned to 4 byte
// alignment. For example,
//
// class EmptyBase1 {};
// class EmptyBase2 {};
// class Derived : public EmptyBase1, public EmptyBase2 {};
// Derived d;
// // &d == 0x1000
// // static_cast<EmptyBase1*>(&d) == 0x1000
// // static_cast<EmptyBase2*>(&d) == 0x1001 // Not 4 byte alignment!
//
// This doesn't happen with other compilers which support EBCO. All the
// addresses in the above example will be 0x1000 with EBCO supported.
//
// Since v8::Object::SetAlignedPointerInInternalField requires the pointers to
// be aligned, we need a hack to specify at least 4 byte alignment to MSVC.
__declspec(align(4))
#endif
class ScriptWrappableBase {
public:
template<typename T>

View File

@ -24,10 +24,6 @@
/* Include compiler specific macros */
#include "wtf/Compiler.h"
#if COMPILER(MSVC)
#define _USE_MATH_DEFINES // Make math.h behave like other platforms.
#endif
/* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
/* HAVE() - specific system features (headers, functions or similar) that are present or not */

View File

@ -104,11 +104,6 @@ private:
template<typename T> inline thisType* to##thisType(const RefPtr<T>& data) { return to##thisType(data.get()); } \
DEFINE_TYPE_CASTS(thisType, ElementData, data, pointerPredicate, referencePredicate)
#if COMPILER(MSVC)
#pragma warning(push)
#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning
#endif
// SharableElementData is managed by ElementDataCache and is produced by
// the parser during page load for elements that have identical attributes. This
// is a memory optimization since it's very common for many elements to have
@ -140,10 +135,6 @@ public:
DEFINE_ELEMENT_DATA_TYPE_CASTS(ShareableElementData, !data->isUnique(), !data.isUnique());
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
// UniqueElementData is created when an element needs to mutate its attributes
// or gains presentation attribute style (ex. width="10"). It does not need to
// be created to fill in values in the ElementData that are derived from

View File

@ -60,12 +60,6 @@ inline void advanceStringAndASSERT(SegmentedString& source, const char* expected
source.advanceAndASSERT(*expectedCharacters++);
}
#if COMPILER(MSVC)
// We need to disable the "unreachable code" warning because we want to assert
// that some code points aren't reached in the state machine.
#pragma warning(disable: 4702)
#endif
#define BEGIN_STATE(prefix, stateName) case prefix::stateName: stateName:
#define END_STATE() ASSERT_NOT_REACHED(); break;

View File

@ -120,7 +120,6 @@ public:
return *this;
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
Length(Length&& length)
{
memcpy(this, &length, sizeof(Length));
@ -148,7 +147,6 @@ public:
return *this;
}
#endif
~Length()
{

View File

@ -37,30 +37,9 @@
#endif
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if BLINK_PLATFORM_IMPLEMENTATION
#define PLATFORM_EXPORT __declspec(dllexport)
#else
#define PLATFORM_EXPORT __declspec(dllimport)
#endif
#else // defined(WIN32)
#define PLATFORM_EXPORT __attribute__((visibility("default")))
#endif
#else // defined(COMPONENT_BUILD)
#define PLATFORM_EXPORT
#endif
#if defined(_MSC_VER)
// MSVC Compiler warning C4275:
// non dll-interface class 'Bar' used as base for dll-interface class 'Foo'.
// Note that this is intended to be used only when no access to the base class'
// static data is done through derived classes or inline methods. For more info,
// see http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
//
// This pragma will allow exporting a class that inherits from a non-exported
// base class, anywhere in the Blink platform component. This is only
// a problem when using the MSVC compiler on Windows.
#pragma warning(suppress:4275)
#endif
#endif // PlatformExport_h

View File

@ -40,9 +40,6 @@ WebCursorInfo::WebCursorInfo(const Cursor& cursor)
, hotSpot(cursor.hotSpot())
, imageScaleFactor(cursor.imageScaleFactor())
, customImage(cursor.image())
#ifdef WIN32
, externalHandle(0)
#endif
{
}

View File

@ -23,153 +23,4 @@
*/
// FIXME: This is temporary until mac switch to using FontPlatformDataHarfBuzz.h and we merge it with this file.
#if !OS(MACOSX)
#include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h"
#else
#ifndef FontPlatformData_h
#define FontPlatformData_h
#include "platform/PlatformExport.h"
#include "platform/fonts/FontOrientation.h"
#include "platform/fonts/FontWidthVariant.h"
OBJC_CLASS NSFont;
typedef struct CGFont* CGFontRef;
typedef const struct __CTFont* CTFontRef;
#include <CoreFoundation/CFBase.h>
#include <objc/objc-auto.h>
#include "wtf/Forward.h"
#include "wtf/HashTableDeletedValueType.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RetainPtr.h"
#include "wtf/text/StringImpl.h"
#include "platform/fonts/mac/MemoryActivatedFont.h"
#include "third_party/skia/include/core/SkTypeface.h"
typedef struct CGFont* CGFontRef;
typedef const struct __CTFont* CTFontRef;
typedef UInt32 FMFont;
typedef FMFont ATSUFontID;
typedef UInt32 ATSFontRef;
namespace blink {
class HarfBuzzFace;
inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); }
class PLATFORM_EXPORT FontPlatformData {
public:
FontPlatformData(WTF::HashTableDeletedValueType);
FontPlatformData();
FontPlatformData(const FontPlatformData&);
FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool syntheticOblique = false,
FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant);
~FontPlatformData();
NSFont* font() const { return m_font; }
void setFont(NSFont*);
CGFontRef cgFont() const { return m_cgFont.get(); }
CTFontRef ctFont() const;
SkTypeface* typeface() const;
bool roundsGlyphAdvances() const;
bool allowsLigatures() const;
String fontFamilyName() const;
bool isFixedPitch() const;
float size() const { return m_size; }
void setSize(float size) { m_size = size; }
bool syntheticBold() const { return m_syntheticBold; }
bool syntheticOblique() const { return m_syntheticOblique; }
bool isColorBitmapFont() const { return m_isColorBitmapFont; }
bool isCompositeFontReference() const { return m_isCompositeFontReference; }
FontOrientation orientation() const { return m_orientation; }
FontWidthVariant widthVariant() const { return m_widthVariant; }
void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
HarfBuzzFace* harfBuzzFace();
unsigned hash() const
{
ASSERT(m_font || !m_cgFont);
uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cast<uintptr_t>(m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique) };
return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
}
const FontPlatformData& operator=(const FontPlatformData&);
bool operator==(const FontPlatformData& other) const
{
return platformIsEqual(other)
&& m_size == other.m_size
&& m_syntheticBold == other.m_syntheticBold
&& m_syntheticOblique == other.m_syntheticOblique
&& m_isColorBitmapFont == other.m_isColorBitmapFont
&& m_isCompositeFontReference == other.m_isCompositeFontReference
&& m_orientation == other.m_orientation
&& m_widthVariant == other.m_widthVariant;
}
bool isHashTableDeletedValue() const
{
return m_font == hashTableDeletedFontValue();
}
#ifndef NDEBUG
String description() const;
#endif
private:
bool platformIsEqual(const FontPlatformData&) const;
void platformDataInit(const FontPlatformData&);
const FontPlatformData& platformDataAssign(const FontPlatformData&);
#if OS(MACOSX)
// Load various data about the font specified by |nsFont| with the size fontSize into the following output paramters:
// Note: Callers should always take into account that for the Chromium port, |outNSFont| isn't necessarily the same
// font as |nsFont|. This because the sandbox may block loading of the original font.
// * outNSFont - The font that was actually loaded, for the Chromium port this may be different than nsFont.
// The caller is responsible for calling CFRelease() on this parameter when done with it.
// * cgFont - CGFontRef representing the input font at the specified point size.
void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&);
static NSFont* hashTableDeletedFontValue() { return reinterpret_cast<NSFont *>(-1); }
#endif
public:
bool m_syntheticBold;
bool m_syntheticOblique;
FontOrientation m_orientation;
float m_size;
FontWidthVariant m_widthVariant;
private:
NSFont* m_font;
RetainPtr<CGFontRef> m_cgFont;
mutable RetainPtr<CTFontRef> m_CTFont;
RefPtr<MemoryActivatedFont> m_inMemoryFont;
RefPtr<HarfBuzzFace> m_harfBuzzFace;
mutable RefPtr<SkTypeface> m_typeface;
bool m_isColorBitmapFont;
bool m_isCompositeFontReference;
};
} // namespace blink
#endif // FontPlatformData_h
#endif

View File

@ -56,11 +56,6 @@ struct GlyphData {
const SimpleFontData* fontData;
};
#if COMPILER(MSVC)
#pragma warning(push)
#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning
#endif
// A GlyphPage contains a fixed-size set of GlyphData mappings for a contiguous
// range of characters in the Unicode code space. GlyphPages are indexed
// starting from 0 and incrementing for each 256 glyphs.
@ -218,10 +213,6 @@ private:
const SimpleFontData* m_perGlyphFontData[0];
};
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
} // namespace blink
#endif // GlyphPage_h

View File

@ -35,7 +35,6 @@
namespace blink {
#if !COMPILER(MSVC)
// FIXME: Use C++11 strong enums to avoid static data member with initializer definition problems.
const RGBA32 Color::black;
const RGBA32 Color::white;
@ -43,7 +42,6 @@ const RGBA32 Color::darkGray;
const RGBA32 Color::gray;
const RGBA32 Color::lightGray;
const RGBA32 Color::transparent;
#endif
static const RGBA32 lightenedBlack = 0xFF545454;
static const RGBA32 darkenedWhite = 0xFFABABAB;

View File

@ -38,7 +38,6 @@
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/RetainPtr.h"
#include "wtf/text/WTFString.h"
namespace blink {

View File

@ -51,11 +51,7 @@ class PLATFORM_EXPORT TransformationMatrix {
public:
#if CPU(APPLE_ARMV7S) || defined(TRANSFORMATION_MATRIX_USE_X86_64_SSE2)
#if COMPILER(MSVC)
__declspec(align(16)) typedef double Matrix4[4][4];
#else
typedef double Matrix4[4][4] __attribute__((aligned (16)));
#endif
#else
typedef double Matrix4[4][4];
#endif

View File

@ -261,7 +261,6 @@ KURL& KURL::operator=(const KURL& other)
return *this;
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
KURL::KURL(KURL&& other)
: m_isValid(other.m_isValid)
, m_protocolIsInHTTPFamily(other.m_protocolIsInHTTPFamily)
@ -284,7 +283,6 @@ KURL& KURL::operator=(KURL&& other)
m_innerURL = other.m_innerURL.release();
return *this;
}
#endif
KURL KURL::copy() const
{

View File

@ -50,10 +50,8 @@ public:
KURL(const KURL&);
KURL& operator=(const KURL&);
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
KURL(KURL&&);
KURL& operator=(KURL&&);
#endif
// The argument is an absolute URL string. The string is assumed to be
// output of KURL::string() called on a valid KURL object, or indiscernible

View File

@ -31,10 +31,6 @@
#ifndef Platform_h
#define Platform_h
#ifdef WIN32
#include <windows.h>
#endif
#include "WebCommon.h"
#include "WebData.h"
#include "WebGestureDevice.h"
@ -80,12 +76,7 @@ struct WebSize;
class Platform {
public:
// HTML5 Database ------------------------------------------------------
#ifdef WIN32
typedef HANDLE FileHandle;
#else
typedef int FileHandle;
#endif
BLINK_PLATFORM_EXPORT static void initialize(Platform*);
BLINK_PLATFORM_EXPORT static void shutdown();

View File

@ -44,27 +44,9 @@
#endif
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if BLINK_IMPLEMENTATION
#define BLINK_EXPORT __declspec(dllexport)
#else // BLINK_IMPLEMENTATION
#define BLINK_EXPORT __declspec(dllimport)
#endif
#if BLINK_PLATFORM_IMPLEMENTATION
#define BLINK_PLATFORM_EXPORT __declspec(dllexport)
#else // BLINK_PLATFORM_IMPLEMENTATION
#define BLINK_PLATFORM_EXPORT __declspec(dllimport)
#endif
#if BLINK_COMMON_IMPLEMENTATION
#define BLINK_COMMON_EXPORT __declspec(dllexport)
#else // BLINK_COMMON_IMPLEMENTATION
#define BLINK_COMMON_EXPORT __declspec(dllimport)
#endif
#else // defined(WIN32)
#define BLINK_EXPORT __attribute__((visibility("default")))
#define BLINK_PLATFORM_EXPORT __attribute__((visibility("default")))
#define BLINK_COMMON_EXPORT __attribute__((visibility("default")))
#endif
#define BLINK_EXPORT __attribute__((visibility("default")))
#define BLINK_PLATFORM_EXPORT __attribute__((visibility("default")))
#define BLINK_COMMON_EXPORT __attribute__((visibility("default")))
#else // defined(COMPONENT_BUILD)
#define BLINK_EXPORT
#define BLINK_PLATFORM_EXPORT
@ -76,17 +58,7 @@
// Basic types
#include <stddef.h> // For size_t
#if defined(WIN32)
// Visual Studio doesn't have stdint.h.
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h> // For int32_t
#endif
namespace blink {
@ -94,11 +66,7 @@ namespace blink {
typedef int32_t WebUChar32;
// UTF-16 character type
#if defined(WIN32)
typedef wchar_t WebUChar;
#else
typedef unsigned short WebUChar;
#endif
// Latin-1 character type
typedef unsigned char WebLChar;

View File

@ -30,9 +30,6 @@ namespace WTF {
#if COMPILER(GCC)
#define WTF_ALIGN_OF(type) __alignof__(type)
#define WTF_ALIGNED(variable_type, variable, n) variable_type variable __attribute__((__aligned__(n)))
#elif COMPILER(MSVC)
#define WTF_ALIGN_OF(type) __alignof(type)
#define WTF_ALIGNED(variable_type, variable, n) __declspec(align(n)) variable_type variable
#else
#error WTF_ALIGN macros need alignment control.
#endif

View File

@ -70,7 +70,7 @@ static void vprintf_stderr_common(const char* format, va_list args)
vfprintf(stderr, format, args);
}
#if COMPILER(CLANG) || (COMPILER(GCC) && GCC_VERSION_AT_LEAST(4, 6, 0))
#if COMPILER(CLANG) || COMPILER(GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
@ -103,7 +103,7 @@ static void vprintf_stderr_with_trailing_newline(const char* format, va_list arg
vprintf_stderr_common(formatWithNewline.get(), args);
}
#if COMPILER(CLANG) || (COMPILER(GCC) && GCC_VERSION_AT_LEAST(4, 6, 0))
#if COMPILER(CLANG) || COMPILER(GCC)
#pragma GCC diagnostic pop
#endif

View File

@ -282,14 +282,8 @@ while (0)
/* COMPILE_ASSERT */
#ifndef COMPILE_ASSERT
#if COMPILER_SUPPORTS(C_STATIC_ASSERT)
/* Unlike static_assert below, this also works in plain C code. */
#define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name)
#elif COMPILER_SUPPORTS(CXX_STATIC_ASSERT)
#define COMPILE_ASSERT(exp, name) static_assert((exp), #name)
#else
#define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]
#endif
#endif
/* FATAL */

View File

@ -35,51 +35,12 @@
#include <stdint.h>
#if COMPILER(MSVC)
#include <windows.h>
#endif
#if defined(THREAD_SANITIZER)
#include <sanitizer/tsan_interface_atomic.h>
#endif
namespace WTF {
#if COMPILER(MSVC)
// atomicAdd returns the result of the addition.
ALWAYS_INLINE int atomicAdd(int volatile* addend, int increment)
{
return InterlockedExchangeAdd(reinterpret_cast<long volatile*>(addend), static_cast<long>(increment)) + increment;
}
// atomicSubtract returns the result of the subtraction.
ALWAYS_INLINE int atomicSubtract(int volatile* addend, int decrement)
{
return InterlockedExchangeAdd(reinterpret_cast<long volatile*>(addend), static_cast<long>(-decrement)) - decrement;
}
ALWAYS_INLINE int atomicIncrement(int volatile* addend) { return InterlockedIncrement(reinterpret_cast<long volatile*>(addend)); }
ALWAYS_INLINE int atomicDecrement(int volatile* addend) { return InterlockedDecrement(reinterpret_cast<long volatile*>(addend)); }
ALWAYS_INLINE int64_t atomicIncrement(int64_t volatile* addend) { return InterlockedIncrement64(reinterpret_cast<long long volatile*>(addend)); }
ALWAYS_INLINE int64_t atomicDecrement(int64_t volatile* addend) { return InterlockedDecrement64(reinterpret_cast<long long volatile*>(addend)); }
ALWAYS_INLINE int atomicTestAndSetToOne(int volatile* ptr)
{
int ret = InterlockedExchange(reinterpret_cast<long volatile*>(ptr), 1);
ASSERT(!ret || ret == 1);
return ret;
}
ALWAYS_INLINE void atomicSetOneToZero(int volatile* ptr)
{
ASSERT(*ptr == 1);
InterlockedExchange(reinterpret_cast<long volatile*>(ptr), 0);
}
#else
// atomicAdd returns the result of the addition.
ALWAYS_INLINE int atomicAdd(int volatile* addend, int increment) { return __sync_add_and_fetch(addend, increment); }
// atomicSubtract returns the result of the subtraction.
@ -103,7 +64,6 @@ ALWAYS_INLINE void atomicSetOneToZero(int volatile* ptr)
ASSERT(*ptr == 1);
__sync_lock_release(ptr);
}
#endif
#if defined(THREAD_SANITIZER)
ALWAYS_INLINE void releaseStore(volatile int* ptr, int value)
@ -129,14 +89,7 @@ ALWAYS_INLINE unsigned acquireLoad(volatile const unsigned* ptr)
#if CPU(X86) || CPU(X86_64)
// Only compiler barrier is needed.
#if COMPILER(MSVC)
// Starting from Visual Studio 2005 compiler guarantees acquire and release
// semantics for operations on volatile variables. See MSDN entry for
// MemoryBarrier macro.
#define MEMORY_BARRIER()
#else
#define MEMORY_BARRIER() __asm__ __volatile__("" : : : "memory")
#endif
#elif CPU(ARM) && (OS(LINUX) || OS(ANDROID))
// On ARM __sync_synchronize generates dmb which is very expensive on single
// core devices which don't actually need it. Avoid the cost by calling into

View File

@ -87,7 +87,6 @@ component("wtf") {
"NonCopyingSort.h",
"Noncopyable.h",
"NotFound.h",
"NullPtr.cpp",
"NullPtr.h",
"OwnPtr.h",
"OwnPtrCommon.h",
@ -105,7 +104,6 @@ component("wtf") {
"RefCountedLeakCounter.cpp",
"RefCountedLeakCounter.h",
"RefPtr.h",
"RetainPtr.h",
"SaturatedArithmetic.h",
"SizeLimits.cpp",
"SpinLock.h",

View File

@ -42,32 +42,9 @@
#include <stdint.h>
#if COMPILER(MSVC)
#include <intrin.h>
#endif
namespace WTF {
#if COMPILER(MSVC)
ALWAYS_INLINE uint32_t countLeadingZeros32(uint32_t x)
{
unsigned long index;
return LIKELY(_BitScanReverse(&index, x)) ? (31 - index) : 32;
}
#if CPU(64BIT)
// MSVC only supplies _BitScanForward64 when building for a 64-bit target.
ALWAYS_INLINE uint64_t countLeadingZeros64(uint64_t x)
{
unsigned long index;
return LIKELY(_BitScanReverse64(&index, x)) ? (63 - index) : 64;
}
#endif
#elif COMPILER(GCC)
#if COMPILER(GCC)
// This is very annoying. __builtin_clz has undefined behaviour for an input of
// 0, even though these's clearly a return value that makes sense, and even

View File

@ -36,22 +36,10 @@
#include <stdint.h>
#if COMPILER(MSVC)
#include <stdlib.h>
#endif
namespace WTF {
inline uint32_t wswap32(uint32_t x) { return ((x & 0xffff0000) >> 16) | ((x & 0x0000ffff) << 16); }
#if COMPILER(MSVC)
ALWAYS_INLINE uint64_t bswap64(uint64_t x) { return _byteswap_uint64(x); }
ALWAYS_INLINE uint32_t bswap32(uint32_t x) { return _byteswap_ulong(x); }
ALWAYS_INLINE uint16_t bswap16(uint16_t x) { return _byteswap_ushort(x); }
#else
ALWAYS_INLINE uint64_t bswap64(uint64_t x) { return __builtin_bswap64(x); }
ALWAYS_INLINE uint32_t bswap32(uint32_t x) { return __builtin_bswap32(x); }
// GCC 4.6 lacks __builtin_bswap16. Newer versions have it but we support 4.6.
@ -61,8 +49,6 @@ ALWAYS_INLINE uint16_t bswap16(uint16_t x) { return __builtin_bswap16(x); }
inline uint16_t bswap16(uint16_t x) { return ((x & 0xff00) >> 8) | ((x & 0x00ff) << 8); }
#endif
#endif
#if CPU(64BIT)
ALWAYS_INLINE size_t bswapuintptrt(size_t x) { return bswap64(x); }

View File

@ -70,7 +70,6 @@
#elif !defined(__ARM_EABI__) \
&& !defined(__EABI__) \
&& !defined(__VFP_FP__) \
&& !defined(_WIN32_WCE) \
&& !defined(ANDROID)
#define WTF_CPU_MIDDLE_ENDIAN 1
@ -159,7 +158,7 @@
#define WTF_CPU_ARM_NEON 1
#endif
#if CPU(ARM_NEON) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0))
#if CPU(ARM_NEON)
// All NEON intrinsics usage can be disabled by this macro.
#define HAVE_ARM_NEON_INTRINSICS 1
#endif

View File

@ -29,12 +29,6 @@
/* COMPILER() - the compiler being used to build the project */
#define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPILER_##WTF_FEATURE)
/* COMPILER_SUPPORTS() - whether the compiler being used to build the project supports the given feature. */
#define COMPILER_SUPPORTS(WTF_COMPILER_FEATURE) (defined WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE && WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE)
/* COMPILER_QUIRK() - whether the compiler being used to build the project requires a given quirk. */
#define COMPILER_QUIRK(WTF_COMPILER_QUIRK) (defined WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK && WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK)
/* ==== COMPILER() - the compiler being used to build the project ==== */
/* COMPILER(CLANG) - Clang */
@ -42,45 +36,12 @@
#define WTF_COMPILER_CLANG 1
#define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA)
/* Specific compiler features */
#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_NULLPTR __has_feature(cxx_nullptr)
#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explicit_conversions)
#define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks)
#define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert)
#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_extension(cxx_static_assert)
#define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial_destructor)
#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_extension(cxx_strong_enums)
#endif
#ifndef CLANG_PRAGMA
#define CLANG_PRAGMA(PRAGMA)
#endif
/* COMPILER(MSVC) - Microsoft Visual C++ */
#if defined(_MSC_VER)
#define WTF_COMPILER_MSVC 1
/* Specific compiler features */
#if !COMPILER(CLANG) && _MSC_VER >= 1600
#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
#endif
#if COMPILER(CLANG)
/* Keep strong enums turned off when building with clang-cl: We cannot yet build all of Blink without fallback to cl.exe, and strong enums are exposed at ABI boundaries. */
#undef WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS
#endif
#endif
/* COMPILER(GCC) - GNU Compiler Collection */
#if defined(__GNUC__)
#define WTF_COMPILER_GCC 1
@ -91,40 +52,14 @@
#define GCC_VERSION_AT_LEAST(major, minor, patch) 0
#endif
/* Specific compiler features */
#if COMPILER(GCC) && !COMPILER(CLANG)
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
/* C11 support */
#define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1
#endif
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L)
/* C++11 support */
#if GCC_VERSION_AT_LEAST(4, 3, 0)
#define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1
#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1
#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1
#endif
#if GCC_VERSION_AT_LEAST(4, 5, 0)
#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1
#endif
#if GCC_VERSION_AT_LEAST(4, 6, 0)
#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
/* Strong enums should work from gcc 4.4, but doesn't seem to support some operators */
#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1
#endif
#endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L) */
#endif /* COMPILER(GCC) */
/* ==== Compiler features ==== */
/* ALWAYS_INLINE */
#ifndef ALWAYS_INLINE
#if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW)
#if COMPILER(GCC) && defined(NDEBUG)
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
#elif COMPILER(MSVC) && defined(NDEBUG)
#define ALWAYS_INLINE __forceinline
#else
#define ALWAYS_INLINE inline
#endif
@ -136,8 +71,6 @@
#ifndef NEVER_INLINE
#if COMPILER(GCC)
#define NEVER_INLINE __attribute__((__noinline__))
#elif COMPILER(MSVC)
#define NEVER_INLINE __declspec(noinline)
#else
#define NEVER_INLINE
#endif
@ -172,8 +105,6 @@
#ifndef NO_RETURN
#if COMPILER(GCC)
#define NO_RETURN __attribute((__noreturn__))
#elif COMPILER(MSVC)
#define NO_RETURN __declspec(noreturn)
#else
#define NO_RETURN
#endif
@ -209,24 +140,10 @@
#endif
#endif
/* OBJC_CLASS */
#ifndef OBJC_CLASS
#ifdef __OBJC__
#define OBJC_CLASS @class
#else
#define OBJC_CLASS class
#endif
#endif
/* WTF_PRETTY_FUNCTION */
#if COMPILER(GCC)
#define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1
#define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif COMPILER(MSVC)
#define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1
#define WTF_PRETTY_FUNCTION __FUNCSIG__
#else
#define WTF_PRETTY_FUNCTION __FUNCTION__
#endif

View File

@ -53,82 +53,12 @@ namespace WTF {
// The ENUM_CLASS macros will use C++11's enum class if the compiler supports it.
// Otherwise, it will use the EnumClass template below.
#if COMPILER_SUPPORTS(CXX_STRONG_ENUMS)
#define ENUM_CLASS(__enumName) \
enum class __enumName
#define ENUM_CLASS_END(__enumName)
#else // !COMPILER_SUPPORTS(CXX_STRONG_ENUMS)
// How to define a type safe enum list using the EnumClass template?
// ================================================================
// Definition should be a struct that encapsulates an enum list.
// The enum list should be names Enums.
//
// Here's an example of how to define a type safe enum named MyEnum using
// the EnumClass template:
//
// struct MyEnumDefinition {
// enum Enums {
// ValueDefault,
// Value1,
// ...
// ValueN
// };
// };
// typedef EnumClass<MyEnumDefinition, MyEnumDefinition::ValueDefault> MyEnum;
//
// With that, you can now use MyEnum enum values as follow:
//
// MyEnum value1; // value1 is assigned MyEnum::ValueDefault by default.
// MyEnum value2 = MyEnum::Value1; // value2 is assigned MyEnum::Value1;
template <typename Definition>
class EnumClass : public Definition {
typedef enum Definition::Enums Value;
public:
ALWAYS_INLINE EnumClass() { }
ALWAYS_INLINE EnumClass(Value value) : m_value(value) { }
ALWAYS_INLINE Value value() const { return m_value; }
ALWAYS_INLINE bool operator==(const EnumClass other) { return m_value == other.m_value; }
ALWAYS_INLINE bool operator!=(const EnumClass other) { return m_value != other.m_value; }
ALWAYS_INLINE bool operator<(const EnumClass other) { return m_value < other.m_value; }
ALWAYS_INLINE bool operator<=(const EnumClass other) { return m_value <= other.m_value; }
ALWAYS_INLINE bool operator>(const EnumClass other) { return m_value > other.m_value; }
ALWAYS_INLINE bool operator>=(const EnumClass other) { return m_value >= other.m_value; }
ALWAYS_INLINE bool operator==(const Value value) { return m_value == value; }
ALWAYS_INLINE bool operator!=(const Value value) { return m_value != value; }
ALWAYS_INLINE bool operator<(const Value value) { return m_value < value; }
ALWAYS_INLINE bool operator<=(const Value value) { return m_value <= value; }
ALWAYS_INLINE bool operator>(const Value value) { return m_value > value; }
ALWAYS_INLINE bool operator>=(const Value value) { return m_value >= value; }
ALWAYS_INLINE operator Value() { return m_value; }
private:
Value m_value;
};
#define ENUM_CLASS(__enumName) \
struct __enumName ## Definition { \
enum Enums
#define ENUM_CLASS_END(__enumName) \
; \
}; \
typedef EnumClass< __enumName ## Definition > __enumName
#endif // !COMPILER_SUPPORTS(CXX_STRONG_ENUMS)
} // namespace WTF
#if !COMPILER_SUPPORTS(CXX_STRONG_ENUMS)
using WTF::EnumClass;
#endif
#endif // WTF_EnumClass_h

View File

@ -124,14 +124,7 @@ namespace WTF {
template<typename T> struct PtrHash {
static unsigned hash(T key)
{
#if COMPILER(MSVC)
#pragma warning(push)
#pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's conversion warnings
#endif
return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
}
static bool equal(T a, T b) { return a == b; }
static bool equal(std::nullptr_t, T b) { return b == 0; }
@ -205,11 +198,7 @@ namespace WTF {
template<> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long> Hash; };
template<> struct DefaultHash<long long> { typedef IntHash<unsigned long long> Hash; };
template<> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned long long> Hash; };
#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; };
#endif
template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; };
template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; };

View File

@ -43,9 +43,6 @@ const size_t extractNameFunctionPostfixLength = sizeof("]") - 1;
#elif COMPILER(GCC)
const size_t extractNameFunctionPrefixLength = sizeof("const char* WTF::extractNameFunction() [with T = ") - 1;
const size_t extractNameFunctionPostfixLength = sizeof("]") - 1;
#elif COMPILER(MSVC)
const size_t extractNameFunctionPrefixLength = sizeof("const char *__cdecl WTF::extractNameFunction<class ") - 1;
const size_t extractNameFunctionPostfixLength = sizeof(">(void)") - 1;
#else
#warning "Extracting typename is supported only in compiler GCC, CLANG and MSVC at this moment"
#endif
@ -54,7 +51,7 @@ const size_t extractNameFunctionPostfixLength = sizeof(">(void)") - 1;
// The result of extractNameFunction<T>() is given as |funcName|. |extractTypeNameFromFunctionName| then extracts a typename string from |funcName|.
String extractTypeNameFromFunctionName(const char* funcName)
{
#if COMPILER(CLANG) || COMPILER(GCC) || COMPILER(MSVC)
#if COMPILER(CLANG) || COMPILER(GCC)
size_t funcNameLength = strlen(funcName);
ASSERT(funcNameLength > extractNameFunctionPrefixLength + extractNameFunctionPostfixLength);

View File

@ -1,34 +0,0 @@
/*
Copyright (C) 2010 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "NullPtr.h"
#if !(COMPILER_SUPPORTS(CXX_NULLPTR) || defined(_LIBCPP_VERSION))
const std::nullptr_t nullptr;
#endif

View File

@ -27,45 +27,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef NullPtr_h
#define NullPtr_h
// For compilers and standard libraries that do not yet include it, this adds the
// nullptr_t type and nullptr object. They are defined in the same namespaces they
// would be in compiler and library that had the support.
#if COMPILER_SUPPORTS(CXX_NULLPTR) || defined(_LIBCPP_VERSION)
// libstdc++ supports nullptr_t starting with gcc 4.6. STLport doesn't define it.
#if (defined(__GLIBCXX__) && __GLIBCXX__ < 20110325) || defined(_STLPORT_VERSION)
namespace std {
typedef decltype(nullptr) nullptr_t;
}
#endif
#else
#include "wtf/WTFExport.h"
namespace std {
class nullptr_t {
public:
// Required in order to create const nullptr_t objects without an
// explicit initializer in GCC 4.5, a la:
//
// const std::nullptr_t nullptr;
nullptr_t() { }
// Make nullptr convertible to any pointer type.
template<typename T> operator T*() const { return 0; }
// Make nullptr convertible to any member pointer type.
template<typename C, typename T> operator T C::*() { return 0; }
private:
// Do not allow taking the address of nullptr.
void operator&();
};
}
WTF_EXPORT extern const std::nullptr_t nullptr;
#endif
#define WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(ClassName) \
private: \
ClassName(int) = delete

View File

@ -33,11 +33,9 @@ namespace WTF {
template<typename T> class PassOwnPtr;
template<typename T> class OwnPtr {
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
// If rvalue references are not supported, the copy constructor is
// public so OwnPtr cannot be marked noncopyable. See note below.
WTF_MAKE_NONCOPYABLE(OwnPtr);
#endif
WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(OwnPtr);
public:
typedef typename RemoveExtent<T>::Type ValueType;
@ -54,14 +52,6 @@ namespace WTF {
OwnPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
#if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
// This copy constructor is used implicitly by gcc when it generates
// transients for assigning a PassOwnPtr<T> object to a stack-allocated
// OwnPtr<T> object. It should never be called explicitly and gcc
// should optimize away the constructor when generating code.
OwnPtr(const OwnPtr&);
#endif
~OwnPtr()
{
OwnedPtrDeleter<T>::deletePtr(m_ptr);
@ -89,24 +79,17 @@ namespace WTF {
OwnPtr& operator=(std::nullptr_t) { clear(); return *this; }
template<typename U> OwnPtr& operator=(const PassOwnPtr<U>&);
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
OwnPtr(OwnPtr&&);
template<typename U> OwnPtr(OwnPtr<U>&&);
OwnPtr& operator=(OwnPtr&&);
template<typename U> OwnPtr& operator=(OwnPtr<U>&&);
#endif
void swap(OwnPtr& o) { std::swap(m_ptr, o.m_ptr); }
static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
private:
#if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
// If rvalue references are supported, noncopyable takes care of this.
OwnPtr& operator=(const OwnPtr&);
#endif
// We should never have two OwnPtrs for the same underlying object (otherwise we'll get
// double-destruction), so these equality operators should never be needed.
template<typename U> bool operator==(const OwnPtr<U>&) const { COMPILE_ASSERT(!sizeof(U*), OwnPtrs_should_never_be_equal); return false; }
@ -176,7 +159,6 @@ namespace WTF {
return *this;
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T> inline OwnPtr<T>::OwnPtr(OwnPtr<T>&& o)
: m_ptr(o.leakPtr())
{
@ -208,7 +190,6 @@ namespace WTF {
return *this;
}
#endif
template<typename T> inline void swap(OwnPtr<T>& a, OwnPtr<T>& b)
{

View File

@ -44,10 +44,8 @@ namespace WTF {
ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_ptr); }
template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgDecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); }
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
RefPtr(RefPtr&& o) : m_ptr(o.m_ptr) { o.m_ptr = 0; }
RefPtr& operator=(RefPtr&&);
#endif
// See comments in PassRefPtr.h for an explanation of why this takes a const reference.
template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleArgDecl(U, T));
@ -108,7 +106,6 @@ namespace WTF {
return *this;
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(RefPtr&& o)
{
// FIXME: Instead of explicitly casting to RefPtr&& here, we should use std::move, but that requires us to
@ -117,7 +114,6 @@ namespace WTF {
swap(ptr);
return *this;
}
#endif
template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr<U>& o)
{

View File

@ -20,7 +20,6 @@ TEST(RefPtrTest, Basic)
EXPECT_TRUE(!string);
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
TEST(RefPtrTest, MoveAssignmentOperator)
{
RefPtr<StringImpl> a = StringImpl::create("a");
@ -31,6 +30,5 @@ TEST(RefPtrTest, MoveAssignmentOperator)
EXPECT_TRUE(!!b);
EXPECT_TRUE(!a);
}
#endif
}

View File

@ -1,309 +0,0 @@
/*
* Copyright (C) 2005, 2006, 2007, 2008, 2010 Apple 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 RetainPtr_h
#define RetainPtr_h
#include "wtf/HashTableDeletedValueType.h"
#include "wtf/HashTraits.h"
#include "wtf/NullPtr.h"
#include "wtf/TypeTraits.h"
#include <algorithm>
#if USE(CF)
#include <CoreFoundation/CoreFoundation.h>
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#ifndef CF_RELEASES_ARGUMENT
#define CF_RELEASES_ARGUMENT
#endif
#ifndef NS_RELEASES_ARGUMENT
#define NS_RELEASES_ARGUMENT
#endif
namespace WTF {
// Unlike most most of our smart pointers, RetainPtr can take either the pointer type or the pointed-to type,
// so both RetainPtr<NSDictionary> and RetainPtr<CFDictionaryRef> will work.
enum AdoptCFTag { AdoptCF };
enum AdoptNSTag { AdoptNS };
#ifdef __OBJC__
inline void adoptNSReference(id ptr)
{
if (ptr) {
CFRetain(ptr);
[ptr release];
}
}
#endif
template<typename T> class RetainPtr {
public:
typedef typename RemovePointer<T>::Type ValueType;
typedef ValueType* PtrType;
RetainPtr() : m_ptr(0) {}
RetainPtr(PtrType ptr) : m_ptr(ptr) { if (ptr) CFRetain(ptr); }
RetainPtr(AdoptCFTag, PtrType ptr) : m_ptr(ptr) { }
RetainPtr(AdoptNSTag, PtrType ptr) : m_ptr(ptr) { adoptNSReference(ptr); }
RetainPtr(const RetainPtr& o) : m_ptr(o.m_ptr) { if (PtrType ptr = m_ptr) CFRetain(ptr); }
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
RetainPtr(RetainPtr&& o) : m_ptr(o.leakRef()) { }
#endif
// Hash table deleted values, which are only constructed and never copied or destroyed.
RetainPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
~RetainPtr() { if (PtrType ptr = m_ptr) CFRelease(ptr); }
template<typename U> RetainPtr(const RetainPtr<U>&);
void clear();
PtrType leakRef() WARN_UNUSED_RETURN;
PtrType get() const { return m_ptr; }
PtrType operator->() const { return m_ptr; }
#if COMPILER_SUPPORTS(CXX_EXPLICIT_CONVERSIONS)
explicit operator PtrType() const { return m_ptr; }
#endif
bool operator!() const { return !m_ptr; }
// This conversion operator allows implicit conversion to bool but not to other integer types.
typedef PtrType RetainPtr::*UnspecifiedBoolType;
operator UnspecifiedBoolType() const { return m_ptr ? &RetainPtr::m_ptr : 0; }
RetainPtr& operator=(const RetainPtr&);
template<typename U> RetainPtr& operator=(const RetainPtr<U>&);
RetainPtr& operator=(PtrType);
template<typename U> RetainPtr& operator=(U*);
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
RetainPtr& operator=(RetainPtr&&);
template<typename U> RetainPtr& operator=(RetainPtr<U>&&);
#endif
#if !COMPILER_SUPPORTS(CXX_NULLPTR)
RetainPtr& operator=(std::nullptr_t) { clear(); return *this; }
#endif
void adoptCF(PtrType);
void adoptNS(PtrType);
void swap(RetainPtr&);
private:
static PtrType hashTableDeletedValue() { return reinterpret_cast<PtrType>(-1); }
PtrType m_ptr;
};
template<typename T> template<typename U> inline RetainPtr<T>::RetainPtr(const RetainPtr<U>& o)
: m_ptr(o.get())
{
if (PtrType ptr = m_ptr)
CFRetain(ptr);
}
template<typename T> inline void RetainPtr<T>::clear()
{
if (PtrType ptr = m_ptr) {
m_ptr = 0;
CFRelease(ptr);
}
}
template<typename T> inline typename RetainPtr<T>::PtrType RetainPtr<T>::leakRef()
{
PtrType ptr = m_ptr;
m_ptr = 0;
return ptr;
}
template<typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr<T>& o)
{
PtrType optr = o.get();
if (optr)
CFRetain(optr);
PtrType ptr = m_ptr;
m_ptr = optr;
if (ptr)
CFRelease(ptr);
return *this;
}
template<typename T> template<typename U> inline RetainPtr<T>& RetainPtr<T>::operator=(const RetainPtr<U>& o)
{
PtrType optr = o.get();
if (optr)
CFRetain(optr);
PtrType ptr = m_ptr;
m_ptr = optr;
if (ptr)
CFRelease(ptr);
return *this;
}
template<typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(PtrType optr)
{
if (optr)
CFRetain(optr);
PtrType ptr = m_ptr;
m_ptr = optr;
if (ptr)
CFRelease(ptr);
return *this;
}
template<typename T> template<typename U> inline RetainPtr<T>& RetainPtr<T>::operator=(U* optr)
{
if (optr)
CFRetain(optr);
PtrType ptr = m_ptr;
m_ptr = optr;
if (ptr)
CFRelease(ptr);
return *this;
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T> inline RetainPtr<T>& RetainPtr<T>::operator=(RetainPtr<T>&& o)
{
adoptCF(o.leakRef());
return *this;
}
template<typename T> template<typename U> inline RetainPtr<T>& RetainPtr<T>::operator=(RetainPtr<U>&& o)
{
adoptCF(o.leakRef());
return *this;
}
#endif
template<typename T> inline void RetainPtr<T>::adoptCF(PtrType optr)
{
PtrType ptr = m_ptr;
m_ptr = optr;
if (ptr)
CFRelease(ptr);
}
template<typename T> inline void RetainPtr<T>::adoptNS(PtrType optr)
{
adoptNSReference(optr);
PtrType ptr = m_ptr;
m_ptr = optr;
if (ptr)
CFRelease(ptr);
}
template<typename T> inline void RetainPtr<T>::swap(RetainPtr<T>& o)
{
std::swap(m_ptr, o.m_ptr);
}
template<typename T> inline void swap(RetainPtr<T>& a, RetainPtr<T>& b)
{
a.swap(b);
}
template<typename T, typename U> inline bool operator==(const RetainPtr<T>& a, const RetainPtr<U>& b)
{
return a.get() == b.get();
}
template<typename T, typename U> inline bool operator==(const RetainPtr<T>& a, U* b)
{
return a.get() == b;
}
template<typename T, typename U> inline bool operator==(T* a, const RetainPtr<U>& b)
{
return a == b.get();
}
template<typename T, typename U> inline bool operator!=(const RetainPtr<T>& a, const RetainPtr<U>& b)
{
return a.get() != b.get();
}
template<typename T, typename U> inline bool operator!=(const RetainPtr<T>& a, U* b)
{
return a.get() != b;
}
template<typename T, typename U> inline bool operator!=(T* a, const RetainPtr<U>& b)
{
return a != b.get();
}
template<typename T> inline RetainPtr<T> adoptCF(T CF_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
template<typename T> inline RetainPtr<T> adoptCF(T o)
{
return RetainPtr<T>(AdoptCF, o);
}
template<typename T> inline RetainPtr<T> adoptNS(T NS_RELEASES_ARGUMENT) WARN_UNUSED_RETURN;
template<typename T> inline RetainPtr<T> adoptNS(T o)
{
return RetainPtr<T>(AdoptNS, o);
}
// Helper function for creating a RetainPtr using template argument deduction.
template<typename T> inline RetainPtr<T> retainPtr(T) WARN_UNUSED_RETURN;
template<typename T> inline RetainPtr<T> retainPtr(T o)
{
return RetainPtr<T>(o);
}
template<typename P> struct HashTraits<RetainPtr<P> > : SimpleClassHashTraits<RetainPtr<P> > { };
template<typename P> struct PtrHash<RetainPtr<P> > : PtrHash<typename RetainPtr<P>::PtrType> {
using PtrHash<typename RetainPtr<P>::PtrType>::hash;
static unsigned hash(const RetainPtr<P>& key) { return hash(key.get()); }
using PtrHash<typename RetainPtr<P>::PtrType>::equal;
static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) { return a == b; }
static bool equal(typename RetainPtr<P>::PtrType a, const RetainPtr<P>& b) { return a == b; }
static bool equal(const RetainPtr<P>& a, typename RetainPtr<P>::PtrType b) { return a == b; }
};
template<typename P> struct DefaultHash<RetainPtr<P> > { typedef PtrHash<RetainPtr<P> > Hash; };
} // namespace WTF
using WTF::AdoptCF;
using WTF::AdoptNS;
using WTF::adoptCF;
using WTF::adoptNS;
using WTF::RetainPtr;
using WTF::retainPtr;
#endif // WTF_RetainPtr_h

View File

@ -38,9 +38,7 @@ COMPILE_ASSERT(IsInteger<long>::value, WTF_IsInteger_long_true);
COMPILE_ASSERT(IsInteger<unsigned long>::value, WTF_IsInteger_unsigned_long_true);
COMPILE_ASSERT(IsInteger<long long>::value, WTF_IsInteger_long_long_true);
COMPILE_ASSERT(IsInteger<unsigned long long>::value, WTF_IsInteger_unsigned_long_long_true);
#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
COMPILE_ASSERT(IsInteger<wchar_t>::value, WTF_IsInteger_wchar_t_true);
#endif
COMPILE_ASSERT(!IsInteger<char*>::value, WTF_IsInteger_char_pointer_false);
COMPILE_ASSERT(!IsInteger<const char*>::value, WTF_IsInteger_const_char_pointer_false);
COMPILE_ASSERT(!IsInteger<volatile char*>::value, WTF_IsInteger_volatile_char_pointer_false);
@ -64,9 +62,7 @@ COMPILE_ASSERT(IsPod<long>::value, WTF_IsPod_long_true);
COMPILE_ASSERT(IsPod<unsigned long>::value, WTF_IsPod_unsigned_long_true);
COMPILE_ASSERT(IsPod<long long>::value, WTF_IsPod_long_long_true);
COMPILE_ASSERT(IsPod<unsigned long long>::value, WTF_IsPod_unsigned_long_long_true);
#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
COMPILE_ASSERT(IsPod<wchar_t>::value, WTF_IsPod_wchar_t_true);
#endif
COMPILE_ASSERT(IsPod<char*>::value, WTF_IsPod_char_pointer_true);
COMPILE_ASSERT(IsPod<const char*>::value, WTF_IsPod_const_char_pointer_true);
COMPILE_ASSERT(IsPod<volatile char*>::value, WTF_IsPod_volatile_char_pointer_true);
@ -89,9 +85,7 @@ COMPILE_ASSERT(IsConvertibleToInteger<long>::value, WTF_IsConvertibleToInteger_l
COMPILE_ASSERT(IsConvertibleToInteger<unsigned long>::value, WTF_IsConvertibleToInteger_unsigned_long_true);
COMPILE_ASSERT(IsConvertibleToInteger<long long>::value, WTF_IsConvertibleToInteger_long_long_true);
COMPILE_ASSERT(IsConvertibleToInteger<unsigned long long>::value, WTF_IsConvertibleToInteger_unsigned_long_long_true);
#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
COMPILE_ASSERT(IsConvertibleToInteger<wchar_t>::value, WTF_IsConvertibleToInteger_wchar_t_true);
#endif
COMPILE_ASSERT(IsConvertibleToInteger<double>::value, WTF_IsConvertibleToInteger_double_true);
COMPILE_ASSERT(IsConvertibleToInteger<long double>::value, WTF_IsConvertibleToInteger_long_double_true);
COMPILE_ASSERT(IsConvertibleToInteger<float>::value, WTF_IsConvertibleToInteger_float_true);

View File

@ -61,9 +61,7 @@ namespace WTF {
template<> struct IsInteger<unsigned long> { static const bool value = true; };
template<> struct IsInteger<long long> { static const bool value = true; };
template<> struct IsInteger<unsigned long long> { static const bool value = true; };
#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
template<> struct IsInteger<wchar_t> { static const bool value = true; };
#endif
template<typename T> struct IsFloatingPoint { static const bool value = false; };
template<> struct IsFloatingPoint<float> { static const bool value = true; };
@ -314,12 +312,8 @@ class NeedsTracing {
typedef struct NoType {
char padding[8];
} NoType;
#if COMPILER(MSVC)
template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0]);
#else
template<size_t> struct HasMethod;
template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V::trace)>*);
#endif // COMPILER(MSVC)
template<typename V> static NoType checkHasTraceMethod(...);
public:
// We add sizeof(T) to both sides here, because we want it to fail for

View File

@ -613,10 +613,8 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
template<size_t otherCapacity>
Vector& operator=(const Vector<T, otherCapacity, Allocator>&);
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
Vector(Vector&&);
Vector& operator=(Vector&&);
#endif
size_t size() const { return m_size; }
size_t capacity() const { return Base::capacity(); }
@ -796,7 +794,6 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
return *this;
}
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T, size_t inlineCapacity, typename Allocator>
Vector<T, inlineCapacity, Allocator>::Vector(Vector<T, inlineCapacity, Allocator>&& other)
{
@ -812,7 +809,6 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
swap(other);
return *this;
}
#endif
template<typename T, size_t inlineCapacity, typename Allocator>
template<typename U>

View File

@ -37,15 +37,7 @@
#endif
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if WTF_IMPLEMENTATION
#define WTF_EXPORT __declspec(dllexport)
#else
#define WTF_EXPORT __declspec(dllimport)
#endif
#else // defined(WIN32)
#define WTF_EXPORT __attribute__((visibility("default")))
#endif
#else // defined(COMPONENT_BUILD)
#define WTF_EXPORT
#endif

View File

@ -40,12 +40,6 @@
#include "wtf/ThreadingPrimitives.h"
#include "wtf/Vector.h"
#if COMPILER(MSVC)
#pragma warning(disable: 4244)
#pragma warning(disable: 4245)
#pragma warning(disable: 4554)
#endif
namespace WTF {
Mutex* s_dtoaP5Mutex;

View File

@ -49,35 +49,13 @@ defined(__ARMEL__) || defined(__aarch64__) || \
defined(__MIPSEL__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(_M_IX86) || defined(__i386__)
#if defined(_WIN32)
// Windows uses a 64bit wide floating point stack.
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#else
#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
#endif // _WIN32
#else
#error Target architecture was not detected as supported by Double-Conversion.
#endif
#if defined(_WIN32) && !defined(__MINGW32__)
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t; // NOLINT
typedef unsigned short uint16_t; // NOLINT
typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
// intptr_t and friends are defined in crtdefs.h through stdio.h.
#else
#include <stdint.h>
#endif
// The following macro works on both 32 and 64-bit platforms.
// Usage: instead of writing 0x1234567890123456
// write UINT64_2PART_C(0x12345678,90123456);

View File

@ -37,15 +37,7 @@
#endif
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if WTF_UNITTEST_HELPERS_IMPLEMENTATION
#define WTF_UNITTEST_HELPERS_EXPORT __declspec(dllexport)
#else
#define WTF_UNITTEST_HELPERS_EXPORT __declspec(dllimport)
#endif
#else // defined(WIN32)
#define WTF_UNITTEST_HELPERS_EXPORT __attribute__((visibility("default")))
#endif
#else // defined(COMPONENT_BUILD)
#define WTF_UNITTEST_HELPERS_EXPORT
#endif

View File

@ -32,14 +32,6 @@
#include "wtf/WTFExport.h"
#include "wtf/unicode/Unicode.h"
#if USE(CF)
typedef const struct __CFString * CFStringRef;
#endif
#ifdef __OBJC__
@class NSString;
#endif
namespace WTF {
struct AlreadyHashed;
@ -50,7 +42,6 @@ struct LCharBufferTranslator;
struct CharBufferFromLiteralDataTranslator;
struct SubstringTranslator;
struct UCharBufferTranslator;
template<typename> class RetainPtr;
enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
@ -399,13 +390,6 @@ public:
PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*);
PassRefPtr<StringImpl> upconvertedString();
#if USE(CF)
RetainPtr<CFStringRef> createCFString();
#endif
#ifdef __OBJC__
operator NSString*();
#endif
#ifdef STRING_STATS
ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; }
#endif

View File

@ -148,41 +148,6 @@ TEST(WTF, DISABLED_StringOperators)
EXPECT_N_WTF_STRING_COPIES(2, atomicString + literal + string + literal);
EXPECT_N_WTF_STRING_COPIES(2, atomicString + (literal + string + literal));
EXPECT_N_WTF_STRING_COPIES(2, (atomicString + literal) + (string + literal));
#if COMPILER(MSVC)
EXPECT_N_WTF_STRING_COPIES(1, L"wide string" + string);
EXPECT_N_WTF_STRING_COPIES(1, string + L"wide string");
EXPECT_N_WTF_STRING_COPIES(1, L"wide string" + atomicString);
EXPECT_N_WTF_STRING_COPIES(1, atomicString + L"wide string");
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + string + L"wide string" + string);
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + (string + L"wide string" + string));
EXPECT_N_WTF_STRING_COPIES(2, (L"wide string" + string) + (L"wide string" + string));
EXPECT_N_WTF_STRING_COPIES(2, string + L"wide string" + string + L"wide string");
EXPECT_N_WTF_STRING_COPIES(2, string + (L"wide string" + string + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, (string + L"wide string") + (string + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + atomicString + L"wide string" + atomicString);
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + (atomicString + L"wide string" + atomicString));
EXPECT_N_WTF_STRING_COPIES(2, (L"wide string" + atomicString) + (L"wide string" + atomicString));
EXPECT_N_WTF_STRING_COPIES(2, atomicString + L"wide string" + atomicString + L"wide string");
EXPECT_N_WTF_STRING_COPIES(2, atomicString + (L"wide string" + atomicString + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, (atomicString + L"wide string") + (atomicString + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + string + L"wide string" + atomicString);
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + (string + L"wide string" + atomicString));
EXPECT_N_WTF_STRING_COPIES(2, (L"wide string" + string) + (L"wide string" + atomicString));
EXPECT_N_WTF_STRING_COPIES(2, string + L"wide string" + atomicString + L"wide string");
EXPECT_N_WTF_STRING_COPIES(2, string + (L"wide string" + atomicString + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, (string + L"wide string") + (atomicString + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + atomicString + L"wide string" + string);
EXPECT_N_WTF_STRING_COPIES(2, L"wide string" + (atomicString + L"wide string" + string));
EXPECT_N_WTF_STRING_COPIES(2, (L"wide string" + atomicString) + (L"wide string" + string));
EXPECT_N_WTF_STRING_COPIES(2, atomicString + L"wide string" + string + L"wide string");
EXPECT_N_WTF_STRING_COPIES(2, atomicString + (L"wide string" + string + L"wide string"));
EXPECT_N_WTF_STRING_COPIES(2, (atomicString + L"wide string") + (string + L"wide string"));
#endif
}
} // namespace

View File

@ -469,9 +469,6 @@ String String::format(const char *format, ...)
Vector<char, 256> buffer;
// Do the format once to get the length.
#if COMPILER(MSVC)
int result = _vscprintf(format, args);
#else
char ch;
int result = vsnprintf(&ch, 1, format, args);
// We need to call va_end() and then va_start() again here, as the
@ -482,7 +479,6 @@ String String::format(const char *format, ...)
// systems, but fails e.g. on 64bit Linux.
va_end(args);
va_start(args, format);
#endif
if (result == 0)
return String("");
@ -1015,18 +1011,9 @@ static inline IntegralType toIntegralType(const CharType* data, size_t length, b
++data;
}
#if COMPILER(MSVC)
#pragma warning(push, 0)
#pragma warning(disable:4146)
#endif
if (isNegative)
value = -value;
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
// skip trailing space
while (length && isSpaceOrNewline(*data)) {
--length;

View File

@ -6,21 +6,12 @@
#define SKY_VIEWER_CC_SKY_VIEWER_CC_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(SKY_VIEWER_CC_IMPLEMENTATION)
#define SKY_VIEWER_CC_EXPORT __declspec(dllexport)
#else
#define SKY_VIEWER_CC_EXPORT __declspec(dllimport)
#endif // defined(SKY_VIEWER_CC_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(SKY_VIEWER_CC_IMPLEMENTATION)
#define SKY_VIEWER_CC_EXPORT __attribute__((visibility("default")))
#else
#define SKY_VIEWER_CC_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define SKY_VIEWER_CC_EXPORT