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

Unified Diff: include/v8.h

Issue 22384003: expose eternal handle api (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added uninitialized constant Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index b15b1bd21f04b699854a4bfa0b4d3154b81d4571..4b31e87273a5c7c89e503ab71934f73d84ad6341 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -388,6 +388,11 @@ template <class T> class Handle {
};
+// A value which will never be returned by Local::Eternalize
+// Useful for static initialization
+const int kUninitializedEternalIndex = -1;
+
+
/**
* A light-weight stack-allocated object handle. All operations
* that return objects from within v8 return them in local handles. They
@@ -433,6 +438,11 @@ template <class T> class Local : public Handle<T> {
return Local<S>::Cast(*this);
}
+ // Keep this Local alive for the lifetime of the Isolate.
+ // It remains retrievable via the returned index,
+ V8_INLINE(int Eternalize(Isolate* isolate));
+ V8_INLINE(static Local<T> GetEternal(Isolate* isolate, int index));
+
/**
* Create a local handle for the content of another handle.
* The referee is kept alive by the local handle even when
@@ -4787,6 +4797,9 @@ class V8_EXPORT V8 {
void* data,
RevivableCallback weak_reference_callback);
static void ClearWeak(internal::Object** global_handle);
+ static int Eternalize(internal::Isolate* isolate,
+ internal::Object** handle);
+ static internal::Object** GetEternal(internal::Isolate* isolate, int index);
template <class T> friend class Handle;
template <class T> friend class Local;
@@ -5650,6 +5663,21 @@ Local<T> Local<T>::New(Isolate* isolate, T* that) {
}
+template<class T>
+int Local<T>::Eternalize(Isolate* isolate) {
+ return V8::Eternalize(reinterpret_cast<internal::Isolate*>(isolate),
+ reinterpret_cast<internal::Object**>(this->val_));
+}
+
+
+template<class T>
+Local<T> Local<T>::GetEternal(Isolate* isolate, int index) {
+ internal::Object** handle =
+ V8::GetEternal(reinterpret_cast<internal::Isolate*>(isolate), index);
+ return Local<T>(T::Cast(reinterpret_cast<Value*>(handle)));
+}
+
+
#ifdef V8_USE_UNSAFE_HANDLES
template <class T>
Persistent<T> Persistent<T>::New(Handle<T> that) {
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698