From bf032c2ec8d4858e6cba4ccaf63200f7f39c7cd8 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 20 May 2015 01:59:43 -0700 Subject: [PATCH] Update ReturnValue to take non-deprecated versions of handles R=vogelheim@chromium.org BUG=none LOG=n Review URL: https://codereview.chromium.org/1145063002 Cr-Commit-Position: refs/heads/master@{#28501} --- include/v8.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/include/v8.h b/include/v8.h index 55e86b3de..f52f8b8cf 100644 --- a/include/v8.h +++ b/include/v8.h @@ -835,8 +835,11 @@ class Global : public PersistentBase { typedef void MoveOnlyTypeForCPP03; private: + template + friend class ReturnValue; Global(Global&) = delete; void operator=(Global&) = delete; + V8_INLINE T* operator*() const { return this->val_; } }; @@ -2973,8 +2976,13 @@ class ReturnValue { TYPE_CHECK(T, S); } // Handle setters - template V8_INLINE void Set(const Persistent& handle); - template V8_INLINE void Set(const Handle handle); + template + V8_INLINE V8_DEPRECATE_SOON("Use Global<> instead", + void Set(const Persistent& handle)); + template + V8_INLINE void Set(const Global& handle); + template + V8_INLINE void Set(const Local handle); // Fast primitive setters V8_INLINE void Set(bool value); V8_INLINE void Set(double i); @@ -7130,9 +7138,20 @@ void ReturnValue::Set(const Persistent& handle) { } } -template -template -void ReturnValue::Set(const Handle handle) { +template +template +void ReturnValue::Set(const Global& handle) { + TYPE_CHECK(T, S); + if (V8_UNLIKELY(handle.IsEmpty())) { + *value_ = GetDefaultValue(); + } else { + *value_ = *reinterpret_cast(*handle); + } +} + +template +template +void ReturnValue::Set(const Local handle) { TYPE_CHECK(T, S); if (V8_UNLIKELY(handle.IsEmpty())) { *value_ = GetDefaultValue(); -- 2.34.1