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

Unified Diff: include/v8.h

Issue 14908004: add weakcallback without persistent copying (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: missed some instances Created 7 years, 8 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 b113d74792108c62ff13627b8117598c17b1b297..2e76c94f224f0e07d16177e668445358327dd657 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -191,8 +191,13 @@ class UniqueId {
* \param object the weak global object to be reclaimed by the garbage collector
* \param parameter the value passed in when making the weak global object
*/
-typedef void (*WeakReferenceCallback)(Persistent<Value> object,
- void* parameter);
+template<typename T, typename P>
+class WeakReferenceCallbacks {
+ public:
+ typedef void (*Revivable)(Isolate* isolate,
+ Persistent<T>* object,
+ P* parameter);
+};
// TODO(svenpanne) Temporary definition until Chrome is in sync.
typedef void (*NearDeathCallback)(Isolate* isolate,
@@ -598,8 +603,17 @@ template <class T> class Persistent // NOLINT
// TODO(dcarney): remove before cutover
V8_INLINE(void Dispose(Isolate* isolate));
- V8_INLINE(void MakeWeak(void* parameters,
- WeakReferenceCallback callback));
+ template<typename S, typename P>
+ V8_INLINE(void MakeWeak(
+ Isolate* isolate,
+ P* parameters,
+ typename WeakReferenceCallbacks<S, P>::Revivable callback));
+
+ template<typename P>
+ V8_INLINE(void MakeWeak(
+ Isolate* isolate,
+ P* parameters,
+ typename WeakReferenceCallbacks<T, P>::Revivable callback));
/**
* Make the reference to this object weak. When only weak handles
@@ -4363,10 +4377,11 @@ class V8EXPORT V8 {
internal::Object** handle);
static void DisposeGlobal(internal::Isolate* isolate,
internal::Object** global_handle);
+ typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
static void MakeWeak(internal::Isolate* isolate,
internal::Object** global_handle,
void* data,
- WeakReferenceCallback weak_reference_callback,
+ RevivableCallback weak_reference_callback,
NearDeathCallback near_death_callback);
static void ClearWeak(internal::Isolate* isolate,
internal::Object** global_handle);
@@ -5282,15 +5297,31 @@ void Persistent<T>::Dispose(Isolate* isolate) {
template <class T>
-void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
- Isolate* isolate = Isolate::GetCurrent();
+template <typename S, typename P>
+void Persistent<T>::MakeWeak(
+ Isolate* isolate,
+ P* parameters,
+ typename WeakReferenceCallbacks<S, P>::Revivable callback) {
+ TYPE_CHECK(S, T);
+ typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable;
V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(this->val_),
parameters,
- callback,
+ reinterpret_cast<Revivable>(callback),
NULL);
}
+
+template <class T>
+template <typename P>
+void Persistent<T>::MakeWeak(
+ Isolate* isolate,
+ P* parameters,
+ typename WeakReferenceCallbacks<T, P>::Revivable callback) {
+ MakeWeak<T, P>(isolate, parameters, callback);
+}
+
+
template <class T>
void Persistent<T>::MakeWeak(Isolate* isolate,
void* parameters,
« 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