Commit 49d74c6
n-api: Sync with back-compat changes
Background: To enable N-API support for node versions back to v4, the
N-API code can also be built as an external addon. To make maintenance
easier, a single codebase needs to support both built-in and external
scenarios, along with Node versions >= 4 (and corresponding V8
versions).
This change includes several minor fixes to avoid using node
internal APIs and support older V8 versions:
- Expand node::arraysize
- In the CHECK_ENV() macro, return an error code instead of calling
node::FatalError(). This is more consistent with how other invalid
arguments to N-API functions are handled.
- In v8impl::SetterCallbackWrapper::SetReturnValue(), do nothing
instead of calling node::FatalError(). This is more consistent
with JavaScript setter callbacks, where any returned value is
silently ignored.
- When queueing async work items, get the uv default loop instead of
getting the loop from node::Environment::GetCurrent(). Currently
that returns the same loop anyway. If/when node supports multiple
environments, it should have a public API for getting the
environment & event loop, and we can update this implementation
then.
- Use v8::Maybe::FromJust() instead of the newer alias ToChecked()
Backport-PR-URL: #19447
PR-URL: #12674
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>1 parent bc25250 commit 49d74c6
1 file changed
+16
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
581 | 583 | | |
582 | 584 | | |
583 | 585 | | |
584 | | - | |
585 | | - | |
| 586 | + | |
586 | 587 | | |
587 | 588 | | |
588 | 589 | | |
| |||
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
748 | | - | |
| 749 | + | |
| 750 | + | |
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
| |||
1697 | 1699 | | |
1698 | 1700 | | |
1699 | 1701 | | |
1700 | | - | |
| 1702 | + | |
1701 | 1703 | | |
1702 | 1704 | | |
1703 | 1705 | | |
| |||
1716 | 1718 | | |
1717 | 1719 | | |
1718 | 1720 | | |
1719 | | - | |
| 1721 | + | |
1720 | 1722 | | |
1721 | 1723 | | |
1722 | 1724 | | |
| |||
1741 | 1743 | | |
1742 | 1744 | | |
1743 | 1745 | | |
1744 | | - | |
| 1746 | + | |
1745 | 1747 | | |
1746 | 1748 | | |
1747 | 1749 | | |
| |||
2822 | 2824 | | |
2823 | 2825 | | |
2824 | 2826 | | |
2825 | | - | |
2826 | | - | |
2827 | | - | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
2828 | 2832 | | |
2829 | 2833 | | |
2830 | 2834 | | |
| |||
0 commit comments