Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: include/v8.h

Issue 1145063002: Update ReturnValue to take non-deprecated versions of handles (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 * Pass allows returning uniques from functions, etc. 828 * Pass allows returning uniques from functions, etc.
829 */ 829 */
830 Global Pass() { return static_cast<Global&&>(*this); } 830 Global Pass() { return static_cast<Global&&>(*this); }
831 831
832 /* 832 /*
833 * For compatibility with Chromium's base::Bind (base::Passed). 833 * For compatibility with Chromium's base::Bind (base::Passed).
834 */ 834 */
835 typedef void MoveOnlyTypeForCPP03; 835 typedef void MoveOnlyTypeForCPP03;
836 836
837 private: 837 private:
838 template <class F>
839 friend class ReturnValue;
838 Global(Global&) = delete; 840 Global(Global&) = delete;
839 void operator=(Global&) = delete; 841 void operator=(Global&) = delete;
842 V8_INLINE T* operator*() const { return this->val_; }
840 }; 843 };
841 844
842 845
843 // UniquePersistent is an alias for Global for historical reason. 846 // UniquePersistent is an alias for Global for historical reason.
844 template <class T> 847 template <class T>
845 using UniquePersistent = Global<T>; 848 using UniquePersistent = Global<T>;
846 849
847 850
848 /** 851 /**
849 * A stack-allocated class that governs a number of local handles. 852 * A stack-allocated class that governs a number of local handles.
(...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 2969
2967 2970
2968 template<typename T> 2971 template<typename T>
2969 class ReturnValue { 2972 class ReturnValue {
2970 public: 2973 public:
2971 template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that) 2974 template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
2972 : value_(that.value_) { 2975 : value_(that.value_) {
2973 TYPE_CHECK(T, S); 2976 TYPE_CHECK(T, S);
2974 } 2977 }
2975 // Handle setters 2978 // Handle setters
2976 template <typename S> V8_INLINE void Set(const Persistent<S>& handle); 2979 template <typename S>
2977 template <typename S> V8_INLINE void Set(const Handle<S> handle); 2980 V8_INLINE V8_DEPRECATE_SOON("Use Global<> instead",
2981 void Set(const Persistent<S>& handle));
2982 template <typename S>
2983 V8_INLINE void Set(const Global<S>& handle);
2984 template <typename S>
2985 V8_INLINE void Set(const Local<S> handle);
2978 // Fast primitive setters 2986 // Fast primitive setters
2979 V8_INLINE void Set(bool value); 2987 V8_INLINE void Set(bool value);
2980 V8_INLINE void Set(double i); 2988 V8_INLINE void Set(double i);
2981 V8_INLINE void Set(int32_t i); 2989 V8_INLINE void Set(int32_t i);
2982 V8_INLINE void Set(uint32_t i); 2990 V8_INLINE void Set(uint32_t i);
2983 // Fast JS primitive setters 2991 // Fast JS primitive setters
2984 V8_INLINE void SetNull(); 2992 V8_INLINE void SetNull();
2985 V8_INLINE void SetUndefined(); 2993 V8_INLINE void SetUndefined();
2986 V8_INLINE void SetEmptyString(); 2994 V8_INLINE void SetEmptyString();
2987 // Convenience getter for Isolate 2995 // Convenience getter for Isolate
(...skipping 4135 matching lines...) Expand 10 before | Expand all | Expand 10 after
7123 template<typename S> 7131 template<typename S>
7124 void ReturnValue<T>::Set(const Persistent<S>& handle) { 7132 void ReturnValue<T>::Set(const Persistent<S>& handle) {
7125 TYPE_CHECK(T, S); 7133 TYPE_CHECK(T, S);
7126 if (V8_UNLIKELY(handle.IsEmpty())) { 7134 if (V8_UNLIKELY(handle.IsEmpty())) {
7127 *value_ = GetDefaultValue(); 7135 *value_ = GetDefaultValue();
7128 } else { 7136 } else {
7129 *value_ = *reinterpret_cast<internal::Object**>(*handle); 7137 *value_ = *reinterpret_cast<internal::Object**>(*handle);
7130 } 7138 }
7131 } 7139 }
7132 7140
7133 template<typename T> 7141 template <typename T>
7134 template<typename S> 7142 template <typename S>
7135 void ReturnValue<T>::Set(const Handle<S> handle) { 7143 void ReturnValue<T>::Set(const Global<S>& handle) {
7136 TYPE_CHECK(T, S); 7144 TYPE_CHECK(T, S);
7137 if (V8_UNLIKELY(handle.IsEmpty())) { 7145 if (V8_UNLIKELY(handle.IsEmpty())) {
7138 *value_ = GetDefaultValue(); 7146 *value_ = GetDefaultValue();
7147 } else {
7148 *value_ = *reinterpret_cast<internal::Object**>(*handle);
7149 }
7150 }
7151
7152 template <typename T>
7153 template <typename S>
7154 void ReturnValue<T>::Set(const Local<S> handle) {
7155 TYPE_CHECK(T, S);
7156 if (V8_UNLIKELY(handle.IsEmpty())) {
7157 *value_ = GetDefaultValue();
7139 } else { 7158 } else {
7140 *value_ = *reinterpret_cast<internal::Object**>(*handle); 7159 *value_ = *reinterpret_cast<internal::Object**>(*handle);
7141 } 7160 }
7142 } 7161 }
7143 7162
7144 template<typename T> 7163 template<typename T>
7145 void ReturnValue<T>::Set(double i) { 7164 void ReturnValue<T>::Set(double i) {
7146 TYPE_CHECK(T, Number); 7165 TYPE_CHECK(T, Number);
7147 Set(Number::New(GetIsolate(), i)); 7166 Set(Number::New(GetIsolate(), i));
7148 } 7167 }
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
8096 */ 8115 */
8097 8116
8098 8117
8099 } // namespace v8 8118 } // namespace v8
8100 8119
8101 8120
8102 #undef TYPE_CHECK 8121 #undef TYPE_CHECK
8103 8122
8104 8123
8105 #endif // V8_H_ 8124 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698