// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef HEAP_STUBS_H_ #define HEAP_STUBS_H_ #include "stddef.h" #define WTF_MAKE_FAST_ALLOCATED \ public: \ void* operator new(size_t, void* p); \ void* operator new[](size_t, void* p); \ void* operator new(size_t size); \ private: \ typedef int __thisIsHereToForceASemicolonAfterThisMacro namespace WTF { template class RefCounted { }; template class RawPtr { public: operator T*() const { return 0; } T* operator->() { return 0; } }; template class RefPtr { public: ~RefPtr() { } operator T*() const { return 0; } T* operator->() { return 0; } }; template class OwnPtr { public: ~OwnPtr() { } operator T*() const { return 0; } T* operator->() { return 0; } }; class DefaultAllocator { public: static const bool isGarbageCollected = false; }; template struct VectorTraits { static const bool needsDestruction = true; }; template class VectorDestructorBase { public: ~VectorDestructorBase() {} }; template class VectorDestructorBase {}; template<> class VectorDestructorBase<0, true, true> {}; template< typename T, size_t inlineCapacity = 0, typename Allocator = DefaultAllocator> class Vector : public VectorDestructorBase::needsDestruction> { public: size_t size(); T& operator[](size_t); }; template< typename T, size_t inlineCapacity = 0, typename Allocator = DefaultAllocator> class Deque {}; template< typename ValueArg, typename HashArg = void, typename TraitsArg = void, typename Allocator = DefaultAllocator> class HashSet {}; template< typename ValueArg, typename HashArg = void, typename TraitsArg = void, typename Allocator = DefaultAllocator> class ListHashSet {}; template< typename ValueArg, typename HashArg = void, typename TraitsArg = void, typename Allocator = DefaultAllocator> class LinkedHashSet {}; template< typename ValueArg, typename HashArg = void, typename TraitsArg = void, typename Allocator = DefaultAllocator> class HashCountedSet {}; template< typename KeyArg, typename MappedArg, typename HashArg = void, typename KeyTraitsArg = void, typename MappedTraitsArg = void, typename Allocator = DefaultAllocator> class HashMap {}; } // Empty namespace declaration to exercise internal // handling of namespace equality. namespace std { /* empty */ } namespace std { template class unique_ptr { public: ~unique_ptr() { } operator T*() const { return 0; } T* operator->() { return 0; } }; } namespace blink { using namespace WTF; #define DISALLOW_NEW() \ private: \ void* operator new(size_t) = delete; \ void* operator new(size_t, void*) = delete; #define STACK_ALLOCATED() \ private: \ __attribute__((annotate("blink_stack_allocated"))) \ void* operator new(size_t) = delete; \ void* operator new(size_t, void*) = delete; #define ALLOW_ONLY_INLINE_ALLOCATION() \ public: \ void* operator new(size_t, void*); \ private: \ void* operator new(size_t) = delete; #define GC_PLUGIN_IGNORE(bug) \ __attribute__((annotate("blink_gc_plugin_ignore"))) #define USING_GARBAGE_COLLECTED_MIXIN(type) \ public: \ virtual void adjustAndMark(Visitor*) const override { } \ virtual bool isHeapObjectAlive(Visitor*) const override { return 0; } #define EAGERLY_FINALIZED() typedef int IsEagerlyFinalizedMarker template class GarbageCollected { }; template class GarbageCollectedFinalized : public GarbageCollected { }; template class RefCountedGarbageCollected : public GarbageCollectedFinalized { }; template class Member { public: operator T*() const { return 0; } T* operator->() { return 0; } bool operator!() const { return false; } }; template class WeakMember { public: operator T*() const { return 0; } T* operator->() { return 0; } bool operator!() const { return false; } }; template class Persistent { public: operator T*() const { return 0; } T* operator->() { return 0; } bool operator!() const { return false; } }; template class WeakPersistent { public: operator T*() const { return 0; } T* operator->() { return 0; } bool operator!() const { return false; } }; template class CrossThreadPersistent { public: operator T*() const { return 0; } T* operator->() { return 0; } bool operator!() const { return false; } }; template class CrossThreadWeakPersistent { public: operator T*() const { return 0; } T* operator->() { return 0; } bool operator!() const { return false; } }; class HeapAllocator { public: static const bool isGarbageCollected = true; }; template class HeapVector : public Vector { }; template class HeapDeque : public Vector { }; template class HeapHashSet : public HashSet { }; template class HeapListHashSet : public ListHashSet { }; template class HeapLinkedHashSet : public LinkedHashSet { }; template class HeapHashCountedSet : public HashCountedSet { }; template class HeapHashMap : public HashMap { }; template class PersistentHeapVector : public Vector { }; template class VisitorHelper { public: template void trace(const T&); }; class Visitor : public VisitorHelper { public: template void registerWeakMembers(const T* obj); }; class InlinedGlobalMarkingVisitor : public VisitorHelper { public: InlinedGlobalMarkingVisitor* operator->() { return this; } template void registerWeakMembers(const T* obj); }; class GarbageCollectedMixin { public: virtual void adjustAndMark(Visitor*) const = 0; virtual bool isHeapObjectAlive(Visitor*) const = 0; virtual void trace(Visitor*) { } }; template struct TraceIfNeeded { static void trace(Visitor*, T*); }; } namespace WTF { template struct VectorTraits > { static const bool needsDestruction = false; }; } #endif