diff --git a/doc/api/addons.markdown b/doc/api/addons.markdown index d81847cda2c3f8..58e99e60f1566d 100644 --- a/doc/api/addons.markdown +++ b/doc/api/addons.markdown @@ -48,7 +48,7 @@ First we create a file `hello.cc`: args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world")); } - void init(Handle exports) { + void init(Local exports) { NODE_SET_METHOD(exports, "hello", Method); } @@ -56,7 +56,7 @@ First we create a file `hello.cc`: Note that all io.js addons must export an initialization function: - void Initialize (Handle exports); + void Initialize(Local exports); NODE_MODULE(module_name, Initialize) 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 args.GetReturnValue().Set(num); } - void Init(Handle exports) { + void Init(Local exports) { NODE_SET_METHOD(exports, "add", Add); } @@ -196,7 +196,7 @@ there. Here's `addon.cc`: cb->Call(isolate->GetCurrentContext()->Global(), argc, argv); } - void Init(Handle exports, Handle module) { + void Init(Local exports, Local module) { NODE_SET_METHOD(module, "exports", RunCallback); } @@ -237,7 +237,7 @@ the string passed to `createObject()`: args.GetReturnValue().Set(obj); } - void Init(Handle exports, Handle module) { + void Init(Local exports, Local module) { NODE_SET_METHOD(module, "exports", CreateObject); } @@ -280,7 +280,7 @@ wraps a C++ function: args.GetReturnValue().Set(fn); } - void Init(Handle exports, Handle module) { + void Init(Local exports, Local module) { NODE_SET_METHOD(module, "exports", CreateFunction); } @@ -307,7 +307,7 @@ module `addon.cc`: using namespace v8; - void InitAll(Handle exports) { + void InitAll(Local exports) { MyObject::Init(exports); } @@ -324,7 +324,7 @@ Then in `myobject.h` make your wrapper inherit from `node::ObjectWrap`: class MyObject : public node::ObjectWrap { public: - static void Init(v8::Handle exports); + static void Init(v8::Local exports); private: explicit MyObject(double value = 0); @@ -355,7 +355,7 @@ prototype: MyObject::~MyObject() { } - void MyObject::Init(Handle exports) { + void MyObject::Init(Local exports) { Isolate* isolate = exports->GetIsolate(); // Prepare constructor template @@ -429,7 +429,7 @@ Let's register our `createObject` method in `addon.cc`: MyObject::NewInstance(args); } - void InitAll(Handle exports, Handle module) { + void InitAll(Local exports, Local module) { MyObject::Init(exports->GetIsolate()); NODE_SET_METHOD(module, "exports", CreateObject); @@ -514,7 +514,7 @@ The implementation is similar to the above in `myobject.cc`: Isolate* isolate = args.GetIsolate(); const unsigned argc = 1; - Handle argv[argc] = { args[0] }; + Local argv[argc] = { args[0] }; Local cons = Local::New(isolate, constructor); Local instance = cons->NewInstance(argc, argv); @@ -576,7 +576,7 @@ In the following `addon.cc` we introduce a function `add()` that can take on two args.GetReturnValue().Set(Number::New(isolate, sum)); } - void InitAll(Handle exports) { + void InitAll(Local exports) { MyObject::Init(exports->GetIsolate()); NODE_SET_METHOD(exports, "createObject", CreateObject); @@ -659,7 +659,7 @@ The implementation of `myobject.cc` is similar as before: Isolate* isolate = args.GetIsolate(); const unsigned argc = 1; - Handle argv[argc] = { args[0] }; + Local argv[argc] = { args[0] }; Local cons = Local::New(isolate, constructor); Local instance = cons->NewInstance(argc, argv);