Skip to content

n-api: Sync with back-compat changes - #12674

Closed
jasongin wants to merge 1 commit into
nodejs:masterfrom
jasongin:napi-backcompat
Closed

n-api: Sync with back-compat changes#12674
jasongin wants to merge 1 commit into
nodejs:masterfrom
jasongin:napi-backcompat

Conversation

@jasongin

Copy link
Copy Markdown
Member

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()

These changes were copied directly from nodejs/node-addon-api@c7d4df4 where they were reviewed as part of
nodejs/node-addon-api#25

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

n-api

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()
These changes were copied directly from
nodejs/node-addon-api@c7d4df4
where they were reviewed as part of
nodejs/node-addon-api#25
@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API. labels Apr 26, 2017
@jasongin

Copy link
Copy Markdown
MemberAuthor

@mhdawson@addaleax You reviewed these changes already over at nodejs/node-addon-api#25. As discussed there, this is just merging them back to the node master branch.

@addaleax

Copy link
Copy Markdown
Member

@mhdawsonmhdawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jasongin

Copy link
Copy Markdown
MemberAuthor

The Windows CI job seems to have been... interrupted? Can someone restart it?

@mhdawson

Copy link
Copy Markdown
Member

I tried restarting one of the fanned jobs before without much luck so I'm just going to start a new ci run:https://ci.nodejs.org/job/node-test-pull-request/7711/

@mhdawson

Copy link
Copy Markdown
Member

CI clean, landing

@mhdawson

Copy link
Copy Markdown
Member

landed as 972bfe1

mhdawson pushed a commit that referenced this pull request Apr 28, 2017
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()
PR-URL: #12674
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@jasongin
jasongin deleted the napi-backcompat branch April 28, 2017 21:28
@jasnelljasnell mentioned this pull request May 11, 2017
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 10, 2018
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()
PR-URL: nodejs#12674
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
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 <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@MylesBorinsMylesBorins mentioned this pull request Apr 16, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.node-apiIssues and PRs related to the Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@jasongin@addaleax@mhdawson@nodejs-github-bot