From cbb5004ff97ba16823fd96666edde067799f8691 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 10 Aug 2014 12:17:47 +0800 Subject: [PATCH] Fix compilation error of Constructor and ScopedPersistent in node 0.10. --- native_mate/constructor.h | 10 +++++----- native_mate/scoped_persistent.h | 13 +++++++------ native_mate_files.gypi | 1 - 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/native_mate/constructor.h b/native_mate/constructor.h index 5ac28829cae2..9a43b7602891 100644 --- a/native_mate/constructor.h +++ b/native_mate/constructor.h @@ -126,7 +126,7 @@ class Constructor { Constructor(const base::StringPiece& name) : name_(name) {} virtual ~Constructor() { - constructor_.Reset(); + MATE_PERSISTENT_RESET(constructor_); } v8::Handle GetFunctionTemplate( @@ -136,7 +136,8 @@ class Constructor { isolate, base::Bind(&Constructor::New, factory)); constructor->InstanceTemplate()->SetInternalFieldCount(1); constructor->SetClassName(StringToV8(isolate, name_)); - constructor_.Reset(isolate, constructor); + MATE_PERSISTENT_ASSIGN(v8::FunctionTemplate, isolate, constructor_, + constructor); } return MATE_PERSISTENT_TO_LOCAL( @@ -144,9 +145,8 @@ class Constructor { } private: - static void New(const WrappableFactoryFunction& factory, - v8::Isolate* isolate, - Arguments* args) { + static MATE_METHOD_RETURN_TYPE New(const WrappableFactoryFunction& factory, + v8::Isolate* isolate, Arguments* args) { Wrappable* object = internal::InvokeFactory(args, factory); if (object) object->Wrap(isolate, args->GetThis()); diff --git a/native_mate/scoped_persistent.h b/native_mate/scoped_persistent.h index 4d7b0c074591..44580221ba0a 100644 --- a/native_mate/scoped_persistent.h +++ b/native_mate/scoped_persistent.h @@ -35,14 +35,14 @@ class ScopedPersistent { void reset(v8::Isolate* isolate, v8::Handle handle) { if (!handle.IsEmpty()) { isolate_ = isolate; - handle_.Reset(isolate, handle); + MATE_PERSISTENT_ASSIGN(T, isolate, handle_, handle); } else { reset(); } } void reset() { - handle_.Reset(); + MATE_PERSISTENT_RESET(handle_); } bool IsEmpty() const { @@ -59,10 +59,9 @@ class ScopedPersistent { return v8::Local::New(isolate, handle_); } - template - void SetWeak(P* parameter, - typename v8::WeakCallbackData::Callback callback) { - handle_.SetWeak(parameter, callback); + template + void SetWeak(P* parameter, C callback) { + MATE_PERSISTENT_SET_WEAK(handle_, parameter, callback); } v8::Isolate* isolate() const { return isolate_; } @@ -76,11 +75,13 @@ class ScopedPersistent { return GetIsolate(object_handle->CreationContext()); return GetIsolate(); } +#if NODE_VERSION_AT_LEAST(0, 11, 0) v8::Isolate* GetIsolate(v8::Handle context_handle) const { if (!context_handle.IsEmpty()) return context_handle->GetIsolate(); return GetIsolate(); } +#endif v8::Isolate* GetIsolate( v8::Handle template_handle) const { return GetIsolate(); diff --git a/native_mate_files.gypi b/native_mate_files.gypi index 944483e4863c..a9e9de3375aa 100644 --- a/native_mate_files.gypi +++ b/native_mate_files.gypi @@ -4,7 +4,6 @@ 'native_mate/arguments.cc', 'native_mate/arguments.h', 'native_mate/compat.h', -# 'native_mate/constructor.cc', 'native_mate/constructor.h', 'native_mate/converter.cc', 'native_mate/converter.h',