@@ -48,15 +48,15 @@ First we create a file `hello.cc`:
48
48
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
49
49
}
50
50
51
- void init(Handle <Object> exports) {
51
+ void init(Local <Object> exports) {
52
52
NODE_SET_METHOD(exports, "hello", Method);
53
53
}
54
54
55
55
NODE_MODULE(addon, init)
56
56
57
57
Note that all io.js addons must export an initialization function:
58
58
59
- void Initialize (Handle <Object> exports);
59
+ void Initialize(Local <Object> exports);
60
60
NODE_MODULE(module_name, Initialize)
61
61
62
62
There is no semi-colon after ` NODE_MODULE ` as it's not a function (see
@@ -164,7 +164,7 @@ function calls and return a result. This is the main and only needed source
164
164
args.GetReturnValue().Set(num);
165
165
}
166
166
167
- void Init(Handle <Object> exports) {
167
+ void Init(Local <Object> exports) {
168
168
NODE_SET_METHOD(exports, "add", Add);
169
169
}
170
170
@@ -196,7 +196,7 @@ there. Here's `addon.cc`:
196
196
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
197
197
}
198
198
199
- void Init(Handle <Object> exports, Handle <Object> module) {
199
+ void Init(Local <Object> exports, Local <Object> module) {
200
200
NODE_SET_METHOD(module, "exports", RunCallback);
201
201
}
202
202
@@ -237,7 +237,7 @@ the string passed to `createObject()`:
237
237
args.GetReturnValue().Set(obj);
238
238
}
239
239
240
- void Init(Handle <Object> exports, Handle <Object> module) {
240
+ void Init(Local <Object> exports, Local <Object> module) {
241
241
NODE_SET_METHOD(module, "exports", CreateObject);
242
242
}
243
243
@@ -280,7 +280,7 @@ wraps a C++ function:
280
280
args.GetReturnValue().Set(fn);
281
281
}
282
282
283
- void Init(Handle <Object> exports, Handle <Object> module) {
283
+ void Init(Local <Object> exports, Local <Object> module) {
284
284
NODE_SET_METHOD(module, "exports", CreateFunction);
285
285
}
286
286
@@ -307,7 +307,7 @@ module `addon.cc`:
307
307
308
308
using namespace v8;
309
309
310
- void InitAll(Handle <Object> exports) {
310
+ void InitAll(Local <Object> exports) {
311
311
MyObject::Init(exports);
312
312
}
313
313
@@ -324,7 +324,7 @@ Then in `myobject.h` make your wrapper inherit from `node::ObjectWrap`:
324
324
325
325
class MyObject : public node::ObjectWrap {
326
326
public:
327
- static void Init(v8::Handle <v8::Object> exports);
327
+ static void Init(v8::Local <v8::Object> exports);
328
328
329
329
private:
330
330
explicit MyObject(double value = 0);
@@ -355,7 +355,7 @@ prototype:
355
355
MyObject::~MyObject() {
356
356
}
357
357
358
- void MyObject::Init(Handle <Object> exports) {
358
+ void MyObject::Init(Local <Object> exports) {
359
359
Isolate* isolate = exports->GetIsolate();
360
360
361
361
// Prepare constructor template
@@ -429,7 +429,7 @@ Let's register our `createObject` method in `addon.cc`:
429
429
MyObject::NewInstance(args);
430
430
}
431
431
432
- void InitAll(Handle <Object> exports, Handle <Object> module) {
432
+ void InitAll(Local <Object> exports, Local <Object> module) {
433
433
MyObject::Init(exports->GetIsolate());
434
434
435
435
NODE_SET_METHOD(module, "exports", CreateObject);
@@ -514,7 +514,7 @@ The implementation is similar to the above in `myobject.cc`:
514
514
Isolate* isolate = args.GetIsolate();
515
515
516
516
const unsigned argc = 1;
517
- Handle <Value> argv[argc] = { args[0] };
517
+ Local <Value> argv[argc] = { args[0] };
518
518
Local<Function> cons = Local<Function>::New(isolate, constructor);
519
519
Local<Object> instance = cons->NewInstance(argc, argv);
520
520
@@ -576,7 +576,7 @@ In the following `addon.cc` we introduce a function `add()` that can take on two
576
576
args.GetReturnValue().Set(Number::New(isolate, sum));
577
577
}
578
578
579
- void InitAll(Handle <Object> exports) {
579
+ void InitAll(Local <Object> exports) {
580
580
MyObject::Init(exports->GetIsolate());
581
581
582
582
NODE_SET_METHOD(exports, "createObject", CreateObject);
@@ -659,7 +659,7 @@ The implementation of `myobject.cc` is similar as before:
659
659
Isolate* isolate = args.GetIsolate();
660
660
661
661
const unsigned argc = 1;
662
- Handle <Value> argv[argc] = { args[0] };
662
+ Local <Value> argv[argc] = { args[0] };
663
663
Local<Function> cons = Local<Function>::New(isolate, constructor);
664
664
Local<Object> instance = cons->NewInstance(argc, argv);
665
665
0 commit comments