Fix compilation error of Constructor and ScopedPersistent in node 0.10.
This commit is contained in:
parent
9145a08395
commit
cbb5004ff9
3 changed files with 12 additions and 12 deletions
|
@ -126,7 +126,7 @@ class Constructor {
|
||||||
|
|
||||||
Constructor(const base::StringPiece& name) : name_(name) {}
|
Constructor(const base::StringPiece& name) : name_(name) {}
|
||||||
virtual ~Constructor() {
|
virtual ~Constructor() {
|
||||||
constructor_.Reset();
|
MATE_PERSISTENT_RESET(constructor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Handle<v8::FunctionTemplate> GetFunctionTemplate(
|
v8::Handle<v8::FunctionTemplate> GetFunctionTemplate(
|
||||||
|
@ -136,7 +136,8 @@ class Constructor {
|
||||||
isolate, base::Bind(&Constructor::New, factory));
|
isolate, base::Bind(&Constructor::New, factory));
|
||||||
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
constructor->SetClassName(StringToV8(isolate, name_));
|
constructor->SetClassName(StringToV8(isolate, name_));
|
||||||
constructor_.Reset(isolate, constructor);
|
MATE_PERSISTENT_ASSIGN(v8::FunctionTemplate, isolate, constructor_,
|
||||||
|
constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MATE_PERSISTENT_TO_LOCAL(
|
return MATE_PERSISTENT_TO_LOCAL(
|
||||||
|
@ -144,9 +145,8 @@ class Constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void New(const WrappableFactoryFunction& factory,
|
static MATE_METHOD_RETURN_TYPE New(const WrappableFactoryFunction& factory,
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate, Arguments* args) {
|
||||||
Arguments* args) {
|
|
||||||
Wrappable* object = internal::InvokeFactory(args, factory);
|
Wrappable* object = internal::InvokeFactory(args, factory);
|
||||||
if (object)
|
if (object)
|
||||||
object->Wrap(isolate, args->GetThis());
|
object->Wrap(isolate, args->GetThis());
|
||||||
|
|
|
@ -35,14 +35,14 @@ class ScopedPersistent {
|
||||||
void reset(v8::Isolate* isolate, v8::Handle<T> handle) {
|
void reset(v8::Isolate* isolate, v8::Handle<T> handle) {
|
||||||
if (!handle.IsEmpty()) {
|
if (!handle.IsEmpty()) {
|
||||||
isolate_ = isolate;
|
isolate_ = isolate;
|
||||||
handle_.Reset(isolate, handle);
|
MATE_PERSISTENT_ASSIGN(T, isolate, handle_, handle);
|
||||||
} else {
|
} else {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
handle_.Reset();
|
MATE_PERSISTENT_RESET(handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEmpty() const {
|
bool IsEmpty() const {
|
||||||
|
@ -59,10 +59,9 @@ class ScopedPersistent {
|
||||||
return v8::Local<T>::New(isolate, handle_);
|
return v8::Local<T>::New(isolate, handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename P>
|
template<typename P, typename C>
|
||||||
void SetWeak(P* parameter,
|
void SetWeak(P* parameter, C callback) {
|
||||||
typename v8::WeakCallbackData<T, P>::Callback callback) {
|
MATE_PERSISTENT_SET_WEAK(handle_, parameter, callback);
|
||||||
handle_.SetWeak(parameter, callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Isolate* isolate() const { return isolate_; }
|
v8::Isolate* isolate() const { return isolate_; }
|
||||||
|
@ -76,11 +75,13 @@ class ScopedPersistent {
|
||||||
return GetIsolate(object_handle->CreationContext());
|
return GetIsolate(object_handle->CreationContext());
|
||||||
return GetIsolate();
|
return GetIsolate();
|
||||||
}
|
}
|
||||||
|
#if NODE_VERSION_AT_LEAST(0, 11, 0)
|
||||||
v8::Isolate* GetIsolate(v8::Handle<v8::Context> context_handle) const {
|
v8::Isolate* GetIsolate(v8::Handle<v8::Context> context_handle) const {
|
||||||
if (!context_handle.IsEmpty())
|
if (!context_handle.IsEmpty())
|
||||||
return context_handle->GetIsolate();
|
return context_handle->GetIsolate();
|
||||||
return GetIsolate();
|
return GetIsolate();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
v8::Isolate* GetIsolate(
|
v8::Isolate* GetIsolate(
|
||||||
v8::Handle<v8::ObjectTemplate> template_handle) const {
|
v8::Handle<v8::ObjectTemplate> template_handle) const {
|
||||||
return GetIsolate();
|
return GetIsolate();
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
'native_mate/arguments.cc',
|
'native_mate/arguments.cc',
|
||||||
'native_mate/arguments.h',
|
'native_mate/arguments.h',
|
||||||
'native_mate/compat.h',
|
'native_mate/compat.h',
|
||||||
# 'native_mate/constructor.cc',
|
|
||||||
'native_mate/constructor.h',
|
'native_mate/constructor.h',
|
||||||
'native_mate/converter.cc',
|
'native_mate/converter.cc',
|
||||||
'native_mate/converter.h',
|
'native_mate/converter.h',
|
||||||
|
|
Loading…
Reference in a new issue