node/doc/api
Jason Ginchereau 8ab8c33985 n-api: enable napi_wrap() to work with any object
Previously, napi_wrap() would only work with objects created from a
constructor returned by napi_define_class(). While the N-API team
was aware of this limitation, it was not clearly documented and is
likely to cause confusion anyway. It's much simpler if addons are
allowed to use any JS object. Also, the specific behavior of the
limitation is difficult to reimplement on other VMs that work
differently from V8.

V8 requires object internal fields to be declared on the object
prototype (which napi_define_class() used to do). Since it's too
late to modify the object prototype by the time napi_wrap() is
called, napi_wrap() now inserts a new object (with the internal
field) into the supplied object's prototype chain. Then it can be
retrieved from there later by napi_unwrap().

This change also includes improvements to the documentation for
napi_create_external(), partly to explain how it is different from
napi_wrap().

PR-URL: https://github.com/nodejs/node/pull/13250
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-06-01 11:46:55 -07:00
..
_toc.md inspector: JavaScript bindings for the inspector 2017-05-23 19:45:48 +02:00
addons.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
all.md inspector: JavaScript bindings for the inspector 2017-05-23 19:45:48 +02:00
assert.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
buffer.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
child_process.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
cli.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
cluster.md doc: sort bottom-of-file markdown links 2017-05-08 09:30:55 -07:00
console.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
crypto.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
debugger.md doc: remove unused/duplicated reference links 2017-05-21 00:10:47 +02:00
deprecations.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
dgram.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
dns.md dns: support promisified lookup(Service) 2017-05-09 15:01:46 +02:00
documentation.md doc: replace uses of you and other style nits 2017-04-28 07:57:11 -07:00
domain.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
errors.md doc: fix ordering error in errors.md 2017-05-31 10:21:29 -07:00
events.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
fs.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
globals.md doc: sort bottom-of-file markdown links 2017-05-08 09:30:55 -07:00
http.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
https.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
index.md doc: git mv to .md 2016-04-20 16:34:27 -07:00
inspector.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
modules.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
n-api.md n-api: enable napi_wrap() to work with any object 2017-06-01 11:46:55 -07:00
net.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
os.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
path.md doc: sort bottom-of-file markdown links 2017-05-08 09:30:55 -07:00
process.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
punycode.md doc: sort bottom-of-file markdown links 2017-05-08 09:30:55 -07:00
querystring.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
readline.md doc: make the style of notes consistent 2017-05-25 18:49:41 -04:00
repl.md doc: sort bottom-of-file markdown links 2017-05-08 09:30:55 -07:00
stream.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
string_decoder.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
synopsis.md cmd: support dash as stdin alias 2017-05-23 20:41:13 +02:00
timers.md timers: add promisify support 2017-05-09 15:01:44 +02:00
tls.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
tracing.md src: Node Tracing Controller 2016-12-20 12:31:09 -08:00
tty.md doc: add some info on tty#setRawMode() 2016-12-08 13:39:45 -05:00
url.md doc: fix code examples in url.md 2017-06-01 02:23:11 +03:00
util.md doc: modernize and fix code examples in util.md 2017-06-01 17:45:27 +03:00
v8.md 2017-05-30, Version 8.0.0 (Current) 2017-05-30 10:58:31 -07:00
vm.md doc: sort bottom-of-file markdown links 2017-05-08 09:30:55 -07:00
zlib.md zlib: expose amount of data read for engines 2017-06-01 00:22:23 +02:00