Update to API changes of V8 5.2
This commit is contained in:
parent
a1efa28520
commit
8a31e2d9c0
2 changed files with 19 additions and 11 deletions
|
@ -9,8 +9,9 @@ namespace mate {
|
|||
namespace internal {
|
||||
|
||||
CallbackHolderBase::CallbackHolderBase(v8::Isolate* isolate)
|
||||
: MATE_PERSISTENT_INIT(isolate, v8_ref_, MATE_EXTERNAL_NEW(isolate, this)) {
|
||||
MATE_PERSISTENT_SET_WEAK(v8_ref_, this, &CallbackHolderBase::WeakCallback);
|
||||
: v8_ref_(isolate, v8::External::New(isolate, this)) {
|
||||
v8_ref_.SetWeak(this, &CallbackHolderBase::FirstWeakCallback,
|
||||
v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
|
||||
CallbackHolderBase::~CallbackHolderBase() {
|
||||
|
@ -18,16 +19,20 @@ CallbackHolderBase::~CallbackHolderBase() {
|
|||
}
|
||||
|
||||
v8::Local<v8::External> CallbackHolderBase::GetHandle(v8::Isolate* isolate) {
|
||||
return MATE_PERSISTENT_TO_LOCAL(v8::External, isolate, v8_ref_);
|
||||
return v8::Local<v8::External>::New(isolate, v8_ref_);
|
||||
}
|
||||
|
||||
// static
|
||||
MATE_WEAK_CALLBACK(CallbackHolderBase::WeakCallback,
|
||||
v8::External,
|
||||
CallbackHolderBase) {
|
||||
MATE_WEAK_CALLBACK_INIT(CallbackHolderBase);
|
||||
MATE_PERSISTENT_RESET(self->v8_ref_);
|
||||
delete self;
|
||||
void CallbackHolderBase::FirstWeakCallback(
|
||||
const v8::WeakCallbackInfo<CallbackHolderBase>& data) {
|
||||
data.GetParameter()->v8_ref_.Reset();
|
||||
data.SetSecondPassCallback(SecondWeakCallback);
|
||||
}
|
||||
|
||||
// static
|
||||
void CallbackHolderBase::SecondWeakCallback(
|
||||
const v8::WeakCallbackInfo<CallbackHolderBase>& data) {
|
||||
delete data.GetParameter();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
|
|
@ -62,9 +62,12 @@ class CallbackHolderBase {
|
|||
virtual ~CallbackHolderBase();
|
||||
|
||||
private:
|
||||
static MATE_WEAK_CALLBACK(WeakCallback, v8::External, CallbackHolderBase);
|
||||
static void FirstWeakCallback(
|
||||
const v8::WeakCallbackInfo<CallbackHolderBase>& data);
|
||||
static void SecondWeakCallback(
|
||||
const v8::WeakCallbackInfo<CallbackHolderBase>& data);
|
||||
|
||||
v8::UniquePersistent<v8::External> v8_ref_;
|
||||
v8::Global<v8::External> v8_ref_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue