Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 3a86e86e020cbc9448c50f2ccd21476035a66c2e..0fe03ef81430cb6b5730511ec7b66a1234582adf 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -695,6 +695,16 @@ template <class T> class Persistent // NOLINT |
*/ |
V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other)); |
+ /** |
+ * Returns the underlying raw pointer and clears the handle. The caller is |
+ * responsible of eventually destroying the underlying object (by creating a |
+ * Persistent handle which points to it and Disposing it). In the future, |
+ * destructing a Persistent will also Dispose it. With this function, the |
+ * embedder can let the Persistent go out of scope without it getting |
+ * disposed. |
+ */ |
+ V8_INLINE(T* ClearAndLeak()); |
+ |
#ifndef V8_USE_UNSAFE_HANDLES |
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
@@ -5384,6 +5394,7 @@ void Persistent<T>::SetWrapperClassId(uint16_t class_id) { |
SetWrapperClassId(Isolate::GetCurrent(), class_id); |
} |
+ |
template <class T> |
void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { |
Dispose(isolate); |
@@ -5400,6 +5411,21 @@ void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) { |
#endif |
} |
+ |
+template <class T> |
+T* Persistent<T>::ClearAndLeak() { |
+ T* old; |
+#ifdef V8_USE_UNSAFE_HANDLES |
+ old = **this; |
+ *this = Persistent<T>(); |
+#else |
+ old = val_; |
+ val_ = NULL; |
+#endif |
+ return old; |
+} |
+ |
+ |
template <class T> |
void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { |
typedef internal::Internals I; |