OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 class Value; | 108 class Value; |
109 template <class T> class Handle; | 109 template <class T> class Handle; |
110 template <class T> class Local; | 110 template <class T> class Local; |
111 template <class T> | 111 template <class T> |
112 class MaybeLocal; | 112 class MaybeLocal; |
113 template <class T> class Eternal; | 113 template <class T> class Eternal; |
114 template<class T> class NonCopyablePersistentTraits; | 114 template<class T> class NonCopyablePersistentTraits; |
115 template<class T> class PersistentBase; | 115 template<class T> class PersistentBase; |
116 template<class T, | 116 template<class T, |
117 class M = NonCopyablePersistentTraits<T> > class Persistent; | 117 class M = NonCopyablePersistentTraits<T> > class Persistent; |
118 template<class T> class UniquePersistent; | 118 template <class T> |
| 119 class Global; |
119 template<class K, class V, class T> class PersistentValueMap; | 120 template<class K, class V, class T> class PersistentValueMap; |
120 template <class K, class V, class T> | 121 template <class K, class V, class T> |
121 class PersistentValueMapBase; | 122 class PersistentValueMapBase; |
122 template <class K, class V, class T> | 123 template <class K, class V, class T> |
123 class PhantomPersistentValueMap; | 124 class PhantomPersistentValueMap; |
124 template<class V, class T> class PersistentValueVector; | 125 template<class V, class T> class PersistentValueVector; |
125 template<class T, class P> class WeakCallbackObject; | 126 template<class T, class P> class WeakCallbackObject; |
126 class FunctionTemplate; | 127 class FunctionTemplate; |
127 class ObjectTemplate; | 128 class ObjectTemplate; |
128 class Data; | 129 class Data; |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 * was previously assigned. | 650 * was previously assigned. |
650 */ | 651 */ |
651 V8_INLINE uint16_t WrapperClassId() const; | 652 V8_INLINE uint16_t WrapperClassId() const; |
652 | 653 |
653 private: | 654 private: |
654 friend class Isolate; | 655 friend class Isolate; |
655 friend class Utils; | 656 friend class Utils; |
656 template<class F> friend class Handle; | 657 template<class F> friend class Handle; |
657 template<class F> friend class Local; | 658 template<class F> friend class Local; |
658 template<class F1, class F2> friend class Persistent; | 659 template<class F1, class F2> friend class Persistent; |
659 template<class F> friend class UniquePersistent; | 660 template <class F> |
| 661 friend class Global; |
660 template<class F> friend class PersistentBase; | 662 template<class F> friend class PersistentBase; |
661 template<class F> friend class ReturnValue; | 663 template<class F> friend class ReturnValue; |
662 template <class F1, class F2, class F3> | 664 template <class F1, class F2, class F3> |
663 friend class PersistentValueMapBase; | 665 friend class PersistentValueMapBase; |
664 template<class F1, class F2> friend class PersistentValueVector; | 666 template<class F1, class F2> friend class PersistentValueVector; |
665 friend class Object; | 667 friend class Object; |
666 | 668 |
667 explicit V8_INLINE PersistentBase(T* val) : val_(val) {} | 669 explicit V8_INLINE PersistentBase(T* val) : val_(val) {} |
668 PersistentBase(PersistentBase& other) = delete; // NOLINT | 670 PersistentBase(PersistentBase& other) = delete; // NOLINT |
669 void operator=(PersistentBase&) = delete; | 671 void operator=(PersistentBase&) = delete; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 template<class S, class M2> | 807 template<class S, class M2> |
806 V8_INLINE void Copy(const Persistent<S, M2>& that); | 808 V8_INLINE void Copy(const Persistent<S, M2>& that); |
807 }; | 809 }; |
808 | 810 |
809 | 811 |
810 /** | 812 /** |
811 * A PersistentBase which has move semantics. | 813 * A PersistentBase which has move semantics. |
812 * | 814 * |
813 * Note: Persistent class hierarchy is subject to future changes. | 815 * Note: Persistent class hierarchy is subject to future changes. |
814 */ | 816 */ |
815 template<class T> | 817 template <class T> |
816 class UniquePersistent : public PersistentBase<T> { | 818 class Global : public PersistentBase<T> { |
817 public: | 819 public: |
818 /** | 820 /** |
819 * A UniquePersistent with no storage cell. | 821 * A Global with no storage cell. |
820 */ | 822 */ |
821 V8_INLINE UniquePersistent() : PersistentBase<T>(nullptr) {} | 823 V8_INLINE Global() : PersistentBase<T>(nullptr) {} |
822 /** | 824 /** |
823 * Construct a UniquePersistent from a Handle. | 825 * Construct a Global from a Handle. |
824 * When the Handle is non-empty, a new storage cell is created | 826 * When the Handle is non-empty, a new storage cell is created |
825 * pointing to the same object, and no flags are set. | 827 * pointing to the same object, and no flags are set. |
826 */ | 828 */ |
827 template <class S> | 829 template <class S> |
828 V8_INLINE UniquePersistent(Isolate* isolate, Handle<S> that) | 830 V8_INLINE Global(Isolate* isolate, Handle<S> that) |
829 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { | 831 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { |
830 TYPE_CHECK(T, S); | 832 TYPE_CHECK(T, S); |
831 } | 833 } |
832 /** | 834 /** |
833 * Construct a UniquePersistent from a PersistentBase. | 835 * Construct a Global from a PersistentBase. |
834 * When the Persistent is non-empty, a new storage cell is created | 836 * When the Persistent is non-empty, a new storage cell is created |
835 * pointing to the same object, and no flags are set. | 837 * pointing to the same object, and no flags are set. |
836 */ | 838 */ |
837 template <class S> | 839 template <class S> |
838 V8_INLINE UniquePersistent(Isolate* isolate, const PersistentBase<S>& that) | 840 V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that) |
839 : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) { | 841 : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) { |
840 TYPE_CHECK(T, S); | 842 TYPE_CHECK(T, S); |
841 } | 843 } |
842 /** | 844 /** |
843 * Move constructor. | 845 * Move constructor. |
844 */ | 846 */ |
845 V8_INLINE UniquePersistent(UniquePersistent&& other) | 847 V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) { |
846 : PersistentBase<T>(other.val_) { | |
847 other.val_ = nullptr; | 848 other.val_ = nullptr; |
848 } | 849 } |
849 V8_INLINE ~UniquePersistent() { this->Reset(); } | 850 V8_INLINE ~Global() { this->Reset(); } |
850 /** | 851 /** |
851 * Move via assignment. | 852 * Move via assignment. |
852 */ | 853 */ |
853 template <class S> | 854 template <class S> |
854 V8_INLINE UniquePersistent& operator=(UniquePersistent<S>&& rhs) { | 855 V8_INLINE Global& operator=(Global<S>&& rhs) { |
855 TYPE_CHECK(T, S); | 856 TYPE_CHECK(T, S); |
856 if (this != &rhs) { | 857 if (this != &rhs) { |
857 this->Reset(); | 858 this->Reset(); |
858 this->val_ = rhs.val_; | 859 this->val_ = rhs.val_; |
859 rhs.val_ = nullptr; | 860 rhs.val_ = nullptr; |
860 } | 861 } |
861 return *this; | 862 return *this; |
862 } | 863 } |
863 /** | 864 /** |
864 * Pass allows returning uniques from functions, etc. | 865 * Pass allows returning uniques from functions, etc. |
865 */ | 866 */ |
866 UniquePersistent Pass() { return static_cast<UniquePersistent&&>(*this); } | 867 Global Pass() { return static_cast<Global&&>(*this); } |
867 | 868 |
868 private: | 869 private: |
869 UniquePersistent(UniquePersistent&) = delete; | 870 Global(Global&) = delete; |
870 void operator=(UniquePersistent&) = delete; | 871 void operator=(Global&) = delete; |
871 }; | 872 }; |
872 | 873 |
873 | 874 |
| 875 // UniquePersistent is an alias for Global for historical reason. |
| 876 template <class T> |
| 877 using UniquePersistent = Global<T>; |
| 878 |
| 879 |
874 /** | 880 /** |
875 * A stack-allocated class that governs a number of local handles. | 881 * A stack-allocated class that governs a number of local handles. |
876 * After a handle scope has been created, all local handles will be | 882 * After a handle scope has been created, all local handles will be |
877 * allocated within that handle scope until either the handle scope is | 883 * allocated within that handle scope until either the handle scope is |
878 * deleted or another handle scope is created. If there is already a | 884 * deleted or another handle scope is created. If there is already a |
879 * handle scope and a new one is created, all allocations will take | 885 * handle scope and a new one is created, all allocations will take |
880 * place in the new handle scope until it is deleted. After that, | 886 * place in the new handle scope until it is deleted. After that, |
881 * new handles will again be allocated in the original handle scope. | 887 * new handles will again be allocated in the original handle scope. |
882 * | 888 * |
883 * After the handle scope of a local handle has been deleted the | 889 * After the handle scope of a local handle has been deleted the |
(...skipping 6854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7738 */ | 7744 */ |
7739 | 7745 |
7740 | 7746 |
7741 } // namespace v8 | 7747 } // namespace v8 |
7742 | 7748 |
7743 | 7749 |
7744 #undef TYPE_CHECK | 7750 #undef TYPE_CHECK |
7745 | 7751 |
7746 | 7752 |
7747 #endif // V8_H_ | 7753 #endif // V8_H_ |
OLD | NEW |