@@ -160,8 +160,8 @@ function calls and return a result. This is the main and only needed source
160160 return;
161161 }
162162
163- Local<Number> num = Number::New( args[0]->NumberValue() +
164- args[1]->NumberValue() );
163+ double value = args[0]->NumberValue() + args[1]->NumberValue();
164+ Local<Number> num = Number::New(isolate, value );
165165
166166 args.GetReturnValue().Set(num);
167167 }
@@ -197,7 +197,7 @@ there. Here's `addon.cc`:
197197 Local<Function> cb = Local<Function>::Cast(args[0]);
198198 const unsigned argc = 1;
199199 Local<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") };
200- cb->Call(Context::GetCurrent ()->Global(), argc, argv);
200+ cb->Call(isolate->GetCurrentContext ()->Global(), argc, argv);
201201 }
202202
203203 void Init(Handle<Object> exports, Handle<Object> module) {
@@ -236,7 +236,7 @@ the string passed to `createObject()`:
236236 Isolate* isolate = Isolate::GetCurrent();
237237 HandleScope scope(isolate);
238238
239- Local<Object> obj = Object::New();
239+ Local<Object> obj = Object::New(isolate );
240240 obj->Set(String::NewFromUtf8(isolate, "msg"), args[0]->ToString());
241241
242242 args.GetReturnValue().Set(obj);
@@ -278,7 +278,7 @@ wraps a C++ function:
278278 Isolate* isolate = Isolate::GetCurrent();
279279 HandleScope scope(isolate);
280280
281- Local<FunctionTemplate> tpl = FunctionTemplate::New(MyFunction);
281+ Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, MyFunction);
282282 Local<Function> fn = tpl->GetFunction();
283283
284284 // omit this to make it anonymous
@@ -366,7 +366,7 @@ prototype:
366366 Isolate* isolate = Isolate::GetCurrent();
367367
368368 // Prepare constructor template
369- Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
369+ Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
370370 tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
371371 tpl->InstanceTemplate()->SetInternalFieldCount(1);
372372
@@ -404,7 +404,7 @@ prototype:
404404 MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
405405 obj->value_ += 1;
406406
407- args.GetReturnValue().Set(Number::New(obj->value_));
407+ args.GetReturnValue().Set(Number::New(isolate, obj->value_));
408408 }
409409
410410Test it with:
@@ -494,7 +494,7 @@ The implementation is similar to the above in `myobject.cc`:
494494 void MyObject::Init() {
495495 Isolate* isolate = Isolate::GetCurrent();
496496 // Prepare constructor template
497- Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
497+ Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
498498 tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
499499 tpl->InstanceTemplate()->SetInternalFieldCount(1);
500500
@@ -542,7 +542,7 @@ The implementation is similar to the above in `myobject.cc`:
542542 MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
543543 obj->value_ += 1;
544544
545- args.GetReturnValue().Set(Number::New(obj->value_));
545+ args.GetReturnValue().Set(Number::New(isolate, obj->value_));
546546 }
547547
548548Test it with:
@@ -591,7 +591,7 @@ In the following `addon.cc` we introduce a function `add()` that can take on two
591591 args[1]->ToObject());
592592
593593 double sum = obj1->value() + obj2->value();
594- args.GetReturnValue().Set(Number::New(sum));
594+ args.GetReturnValue().Set(Number::New(isolate, sum));
595595 }
596596
597597 void InitAll(Handle<Object> exports) {
@@ -650,7 +650,7 @@ The implementation of `myobject.cc` is similar as before:
650650 Isolate* isolate = Isolate::GetCurrent();
651651
652652 // Prepare constructor template
653- Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
653+ Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
654654 tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
655655 tpl->InstanceTemplate()->SetInternalFieldCount(1);
656656
0 commit comments