Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index b113d74792108c62ff13627b8117598c17b1b297..59b70f2ac0d9d9d2f9de741d4d433d79d12594c5 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -676,6 +676,11 @@ template <class T> class Persistent // NOLINT |
// TODO(dcarney): remove before cutover |
V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); |
+ /** |
+ * Disposes the current contents of the handle and replaces it. |
+ */ |
+ V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); |
+ |
#ifndef V8_USE_UNSAFE_HANDLES |
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
@@ -5349,6 +5354,20 @@ void Persistent<T>::SetWrapperClassId(uint16_t class_id) { |
} |
template <class T> |
+void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { |
+ Dispose(isolate); |
+#ifdef V8_USE_UNSAFE_HANDLES |
+ *this = *New(isolate, other); |
+#else |
+ if (other.IsEmpty()) |
+ return; |
Sven Panne
2013/05/07 09:49:31
Style nit: Put this on the previous line. Debatabl
marja
2013/05/07 11:17:17
I added "this->val_ = NULL" here, so this became a
|
+ internal::Object** p = reinterpret_cast<internal::Object**>(other.val_); |
+ val_ = reinterpret_cast<T*>( |
+ V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p)); |
+#endif |
+} |
+ |
+template <class T> |
void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { |
typedef internal::Internals I; |
if (this->IsEmpty()) return; |