Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N-API: Remove reference to node internals #13892

Closed

Conversation

gabrielschulhof
Copy link
Contributor

We must keep src/node_api.cc free of node internals because it must
build cleanly outside of node as well - for example in node_addon_api.

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

We must keep src/node_api.cc free of node internals because it must
build cleanly outside of node as well - for example in node_addon_api.
@nodejs-github-bot nodejs-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 Jun 23, 2017
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@mhdawson
Copy link
Member

@@ -17,7 +17,9 @@
#include <vector>
#include "uv.h"
#include "node_api.h"
#include "node_internals.h"

// We must avoid making use of node internals because this file must compile
Copy link
Contributor

Choose a reason for hiding this comment

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

Super-nitpicky- consider pointing to node-addon-api as an example here

@digitalinfinity
Copy link
Contributor

Is there a way to validate this in CI somehow so it doesn't break in the future? I'm not sure of the best way other than having some bizarre CI job that clones node-addon-api, replaces node_api.cc in it and then runs the node-addon-api test- surely there's a better way?

@mhdawson
Copy link
Member

@digitalinfinity thats probably a good idea to try for ci validation. We should likely open a separate issue for that. It would not necessarily need node-addon-api, unless it provides some elements needed to compile node_api.cc

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

If it's going to live in the node source tree, it should be idiomatic code.

If you want to make it build outside of the tree, provide facsimiles in out-of-tree builds.

On that topic: the use of assert() should be replaced by CHECK macros.

@mhdawson
Copy link
Member

@bnoordhuis I'm not sure being quite that black/white makes sense to me in this case. It's a small delta in order to avoid extra work to keep a separate copy which then needs to be kept in sync. Is it really that big a deal in this case ?

@cjihrig cjihrig mentioned this pull request Jun 28, 2017
4 tasks
@gabrielschulhof
Copy link
Contributor Author

gabrielschulhof commented Jun 29, 2017 via email

@bnoordhuis
Copy link
Member

I'm not sympathetic to the "it's more work" argument, that's the price of upstreaming. The out-of-tree project will become irrelevant over time whereas the in-tree version will stay around for many years to come.

we're only talking about no more than one reference to node::arraysize()

Also that calls to assert() should be replaced by CHECK macros, and I'm sure there is more. And if not now, then future refactorings are sure to introduce them.

n-api gets no special treatment. That's demanding everyone else do more work in order that the n-api people can get away with doing less.

@bnoordhuis
Copy link
Member

After seeing how #13971 copy/pastes whole functions from node.cc to node_api.cc I'm even more convinced the rules for n-api need to be tightened, not loosened. It's an unacceptable lowering of the code quality.

@gabrielschulhof
Copy link
Contributor Author

We've decided to use our own version of node_internals.h in node-addon-api along with possibly additional source files, in which we grab whatever we need from node. This should allow us to leave node_api.cc identical between the two repos.

@gabrielschulhof gabrielschulhof deleted the avoid-node-internals branch September 5, 2017 12:02
Sign up for free to 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-api Issues and PRs related to the Node-API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants