Skip to content

Commit c4e1b82

Browse files
committed
doc: replace v8::Handle<T> with v8::Local<T>
v8::Handle is on its way out, to be replaced with v8::Local. Update the addons documentation accordingly. PR-URL: #1125 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent 2f1b783 commit c4e1b82

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

doc/api/addons.markdown

+13-13
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ First we create a file `hello.cc`:
4848
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
4949
}
5050

51-
void init(Handle<Object> exports) {
51+
void init(Local<Object> exports) {
5252
NODE_SET_METHOD(exports, "hello", Method);
5353
}
5454

5555
NODE_MODULE(addon, init)
5656

5757
Note that all io.js addons must export an initialization function:
5858

59-
void Initialize (Handle<Object> exports);
59+
void Initialize(Local<Object> exports);
6060
NODE_MODULE(module_name, Initialize)
6161

6262
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
164164
args.GetReturnValue().Set(num);
165165
}
166166

167-
void Init(Handle<Object> exports) {
167+
void Init(Local<Object> exports) {
168168
NODE_SET_METHOD(exports, "add", Add);
169169
}
170170

@@ -196,7 +196,7 @@ there. Here's `addon.cc`:
196196
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
197197
}
198198

199-
void Init(Handle<Object> exports, Handle<Object> module) {
199+
void Init(Local<Object> exports, Local<Object> module) {
200200
NODE_SET_METHOD(module, "exports", RunCallback);
201201
}
202202

@@ -237,7 +237,7 @@ the string passed to `createObject()`:
237237
args.GetReturnValue().Set(obj);
238238
}
239239

240-
void Init(Handle<Object> exports, Handle<Object> module) {
240+
void Init(Local<Object> exports, Local<Object> module) {
241241
NODE_SET_METHOD(module, "exports", CreateObject);
242242
}
243243

@@ -280,7 +280,7 @@ wraps a C++ function:
280280
args.GetReturnValue().Set(fn);
281281
}
282282

283-
void Init(Handle<Object> exports, Handle<Object> module) {
283+
void Init(Local<Object> exports, Local<Object> module) {
284284
NODE_SET_METHOD(module, "exports", CreateFunction);
285285
}
286286

@@ -307,7 +307,7 @@ module `addon.cc`:
307307

308308
using namespace v8;
309309

310-
void InitAll(Handle<Object> exports) {
310+
void InitAll(Local<Object> exports) {
311311
MyObject::Init(exports);
312312
}
313313

@@ -324,7 +324,7 @@ Then in `myobject.h` make your wrapper inherit from `node::ObjectWrap`:
324324

325325
class MyObject : public node::ObjectWrap {
326326
public:
327-
static void Init(v8::Handle<v8::Object> exports);
327+
static void Init(v8::Local<v8::Object> exports);
328328

329329
private:
330330
explicit MyObject(double value = 0);
@@ -355,7 +355,7 @@ prototype:
355355
MyObject::~MyObject() {
356356
}
357357

358-
void MyObject::Init(Handle<Object> exports) {
358+
void MyObject::Init(Local<Object> exports) {
359359
Isolate* isolate = exports->GetIsolate();
360360

361361
// Prepare constructor template
@@ -429,7 +429,7 @@ Let's register our `createObject` method in `addon.cc`:
429429
MyObject::NewInstance(args);
430430
}
431431

432-
void InitAll(Handle<Object> exports, Handle<Object> module) {
432+
void InitAll(Local<Object> exports, Local<Object> module) {
433433
MyObject::Init(exports->GetIsolate());
434434

435435
NODE_SET_METHOD(module, "exports", CreateObject);
@@ -514,7 +514,7 @@ The implementation is similar to the above in `myobject.cc`:
514514
Isolate* isolate = args.GetIsolate();
515515

516516
const unsigned argc = 1;
517-
Handle<Value> argv[argc] = { args[0] };
517+
Local<Value> argv[argc] = { args[0] };
518518
Local<Function> cons = Local<Function>::New(isolate, constructor);
519519
Local<Object> instance = cons->NewInstance(argc, argv);
520520

@@ -576,7 +576,7 @@ In the following `addon.cc` we introduce a function `add()` that can take on two
576576
args.GetReturnValue().Set(Number::New(isolate, sum));
577577
}
578578

579-
void InitAll(Handle<Object> exports) {
579+
void InitAll(Local<Object> exports) {
580580
MyObject::Init(exports->GetIsolate());
581581

582582
NODE_SET_METHOD(exports, "createObject", CreateObject);
@@ -659,7 +659,7 @@ The implementation of `myobject.cc` is similar as before:
659659
Isolate* isolate = args.GetIsolate();
660660

661661
const unsigned argc = 1;
662-
Handle<Value> argv[argc] = { args[0] };
662+
Local<Value> argv[argc] = { args[0] };
663663
Local<Function> cons = Local<Function>::New(isolate, constructor);
664664
Local<Object> instance = cons->NewInstance(argc, argv);
665665

0 commit comments

Comments
 (0)