* cell remain and IsEmpty will still return false.
*/
inline void Dispose();
+ inline void Dispose(Isolate* isolate);
/**
* Make the reference to this object weak. When only weak handles
static internal::Object** GlobalizeReference(internal::Object** handle);
static void DisposeGlobal(internal::Object** global_handle);
+ static void DisposeGlobal(internal::Isolate* isolate,
+ internal::Object** global_handle);
static void MakeWeak(internal::Object** global_handle,
void* data,
WeakReferenceCallback);
}
+template <class T>
+void Persistent<T>::Dispose(Isolate* isolate) {
+ if (this->IsEmpty()) return;
+ V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(**this));
+}
+
+
template <class T>
Persistent<T>::Persistent() : Handle<T>() { }
isolate->global_handles()->Destroy(obj);
}
+
+void V8::DisposeGlobal(i::Isolate* isolate, i::Object** obj) {
+ ASSERT(isolate == i::Isolate::Current());
+ LOG_API(isolate, "DisposeGlobal");
+ if (!isolate->IsInitialized()) return;
+ isolate->global_handles()->Destroy(obj);
+}
+
// --- H a n d l e s ---
}
CHECK_EQ(global->Length(), 3);
global.Dispose();
+
+ {
+ v8::HandleScope scope;
+ Local<String> str = v8_str("str");
+ global = v8::Persistent<String>::New(str);
+ }
+ CHECK_EQ(global->Length(), 3);
+ global.Dispose(v8::Isolate::GetCurrent());
}