Unverified Commit 8cc9e5eb authored by Gabriel Schulhof's avatar Gabriel Schulhof Committed by Shelley Vohr
Browse files

n-api: support type-tagging objects

`napi_instanceof()` is insufficient for reliably establishing the data
type to which a pointer stored with `napi_wrap()` or
`napi_create_external()` inside a JavaScript object points. Thus, we
need a way to "mark" an object with a value that, when later retrieved,
can unambiguously tell us whether it is safe to cast the pointer stored
inside it to a certain structure.

Such a check must survive loading/unloading/multiple instances of an
addon, so we use UUIDs chosen *a priori*.

Fixes: https://github.com/nodejs/node/issues/28164


Co-authored-by: default avatarAnna Henningsen <github@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/28237


Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
Reviewed-By: default avatarMichael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Signed-off-by: default avatarGabriel Schulhof <gabriel.schulhof@intel.com>
parent 212d17fa
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment