Fix compilation error of Constructor and ScopedPersistent in node 0.10.

This commit is contained in:
Cheng Zhao 2014-08-10 12:17:47 +08:00
parent 9145a08395
commit cbb5004ff9
3 changed files with 12 additions and 12 deletions

View file

@ -126,7 +126,7 @@ class Constructor {
Constructor(const base::StringPiece& name) : name_(name) {}
virtual ~Constructor() {
constructor_.Reset();
MATE_PERSISTENT_RESET(constructor_);
}
v8::Handle<v8::FunctionTemplate> 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());

View file

@ -35,14 +35,14 @@ class ScopedPersistent {
void reset(v8::Isolate* isolate, v8::Handle<T> 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<T>::New(isolate, handle_);
}
template<typename P>
void SetWeak(P* parameter,
typename v8::WeakCallbackData<T, P>::Callback callback) {
handle_.SetWeak(parameter, callback);
template<typename P, typename C>
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<v8::Context> context_handle) const {
if (!context_handle.IsEmpty())
return context_handle->GetIsolate();
return GetIsolate();
}
#endif
v8::Isolate* GetIsolate(
v8::Handle<v8::ObjectTemplate> template_handle) const {
return GetIsolate();

View file

@ -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',