doc: call js function in null context
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 11 Mar 2015 13:19:21 +0000 (14:19 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Sat, 21 Mar 2015 13:05:20 +0000 (14:05 +0100)
It's good practice now to call JS functions that don't execute in a
specific scope with v8::Null() as the receiver.  Update the addons
documentation.

PR-URL: https://github.com/iojs/io.js/pull/1125
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
doc/api/addons.markdown

index 8a008c2..1f0562e 100644 (file)
@@ -215,6 +215,7 @@ there. Here's `addon.cc`:
     using v8::HandleScope;
     using v8::Isolate;
     using v8::Local;
+    using v8::Null;
     using v8::Object;
     using v8::String;
     using v8::Value;
@@ -224,7 +225,7 @@ there. Here's `addon.cc`:
       Local<Function> cb = Local<Function>::Cast(args[0]);
       const unsigned argc = 1;
       Local<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") };
-      cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
+      cb->Call(Null(isolate), argc, argv);
     }
 
     void Init(Local<Object> exports, Local<Object> module) {