// 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; } }; class DefaultAllocator { public: static const bool isGarbageCollected = false; }; template class Vector { public: using iterator = T*; using const_iterator = const T*; using reverse_iterator = T*; using const_reverse_iterator = const T*; size_t size(); T& operator[](size_t); ~Vector() {} }; template class Deque { public: using iterator = T*; using const_iterator = const T*; using reverse_iterator = T*; using const_reverse_iterator = const T*; ~Deque() {} }; template class HashSet { public: typedef ValueArg* iterator; typedef const ValueArg* const_iterator; typedef ValueArg* reverse_iterator; typedef const ValueArg* const_reverse_iterator; ~HashSet() {} }; template class ListHashSet { public: typedef ValueArg* iterator; typedef const ValueArg* const_iterator; typedef ValueArg* reverse_iterator; typedef const ValueArg* const_reverse_iterator; ~ListHashSet() {} }; template class LinkedHashSet { public: typedef ValueArg* iterator; typedef const ValueArg* const_iterator; typedef ValueArg* reverse_iterator; typedef const ValueArg* const_reverse_iterator; ~LinkedHashSet() {} }; template class HashCountedSet { public: ~HashCountedSet() {} }; template class HashMap { public: typedef MappedArg* iterator; typedef const MappedArg* const_iterator; typedef MappedArg* reverse_iterator; typedef const MappedArg* const_reverse_iterator; ~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; } }; template unique_ptr make_unique(Args&&... args) { return unique_ptr(); } } // namespace std namespace base { template std::unique_ptr WrapUnique(T* ptr) { return std::unique_ptr(); } template class Optional {}; } // namespace base 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 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW() \ 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; } \ void* mixin_constructor_marker_ #define USING_GARBAGE_COLLECTED_MIXIN_NEW(type) \ public: \ virtual void AdjustAndMark(Visitor*) const override {} \ virtual bool IsHeapObjectAlive(Visitor*) const override { return 0; } \ typedef int HasUsingGarbageCollectedMixinMacro template class GarbageCollected { }; template class RefCountedGarbageCollected : public GarbageCollected {}; 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; } }; template class TraceWrapperV8Reference { 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 { }; class Visitor { public: template void RegisterWeakMembers(const T* obj); template void Trace(const T&); }; 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&); }; } #endif