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

confusion about NAPI_VERSION, NAPI_EXPERIMENTAL #421

Closed
DaAitch opened this issue Dec 28, 2018 · 6 comments
Closed

confusion about NAPI_VERSION, NAPI_EXPERIMENTAL #421

DaAitch opened this issue Dec 28, 2018 · 6 comments
Labels

Comments

@DaAitch
Copy link
Contributor

DaAitch commented Dec 28, 2018

I'm a bit confused about the NAPI versioning, like NAPI_VERSION, NAPI_EXPERIMENTAL macros.

1. deprecation of NAPI_EXPERIMENTAL

With 73fed84 impl has been changed to only use NAPI_VERSION to determine whether features can be used.

  1. What not has been adapted are the #endif comments like 73fed84#diff-f546e4cc35b454813e5264fe9c9e6fc8R307.
  2. Tests are still defining NAPI_EXPERIMENTAL: this can be removed I think, as well as any other occurrence of NAPI_EXPERIMENTAL in the project
  3. npm test --NAPI_VERSION=... should be documented or defined as npm scripts, like npm run test:v2, npm run test:v3, etc.

2. experimental versions

For features which will land with any future napi version currently not defined, we have those #if (NAPI_VERSION > 2147483646) statements. I think it would be easier to read:

#define NAPI_VERSION_EXPERIMENTAL 2147483647

// [...]

#if (NAPI_VERSION == NAPI_VERSION_EXPERIMENTAL)
// ...
#endif

As well as documentation or defining scripts npm run test:experimental

What do you think?

@gabrielschulhof
Copy link
Contributor

@DaAitch NAPI_EXPERIMENTAL comes from N-API. I guess you're right though in that we should not base our decisions on whether NAPI_EXPERIMENTAL is defined, but rather only on what value NAPI_VERSION takes. NAPI_EXPERIMENTAL should only be used to crank up the version number so as to make available all the experimental APIs.

This has to be done in both Node.js core and in node-addon-api though.

mhdawson added a commit to mhdawson/io.js that referenced this issue Jan 2, 2019
Refs: nodejs/node-addon-api#421

Define NAPI_VERSION_EXPERIMENTAL so that it can be
used to guard code in addons that need to check
if a function they want to use is available.
@mhdawson
Copy link
Member

mhdawson commented Jan 2, 2019

I'd have to look more closely as I think we need NAPI_EXPERIMENTAL to be defined in the tests as that is what ends up making NAPI_VERSION 2147483646 the default so that without any options npm test runs all of the tests.

I do agree that we should have a constant for NAPI_VERSION_EXPERIMENTAL but I think it makes sense in node core were NAPI_EXPERIMENTAL is defined. Just opened a PR here for that: nodejs/node#25319 . However, we probably need a defined in node-addon-api which sets it if it is not defined so that we cover older versions.

Good point that I missed updating the #endifs

I also definitely agree with us needing to document npm test --NAPI_VERSION=... It's on my long list of TODO's but if you have time to do it I'd be happy :)

@DaAitch
Copy link
Contributor Author

DaAitch commented Jan 3, 2019

(also discussed in NAPI team meeting)

  • both NAPI_VERSION and NAPI_EXPERIMENTAL are needed
  • NAPI_VERSION for using a specific version to compile against (current/default version is 3)
  • NAPI_EXPERIMENTAL for using new experimental features not having any version yet

next steps:

  • PR src: add NAPI_VERSION_EXPERIMENTAL node#25319 (#define NAPI_VERSION_EXPERIMENTAL 2147483647)
  • PR node-addon-api
    • substitute magic number with NAPI_VERSION_EXPERIMENTAL
    • documentation, e.g. describe npm run test --NAPI_VERSION=3
  • close issue

anything missing?

@mhdawson
Copy link
Member

mhdawson commented Jan 4, 2019

@DaAitch sounds good to me.

mhdawson added a commit to nodejs/node that referenced this issue Jan 4, 2019
Refs: nodejs/node-addon-api#421

Define NAPI_VERSION_EXPERIMENTAL so that it can be
used to guard code in addons that need to check
if a function they want to use is available.

PR-URL: #25319
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
addaleax pushed a commit to nodejs/node that referenced this issue Jan 5, 2019
Refs: nodejs/node-addon-api#421

Define NAPI_VERSION_EXPERIMENTAL so that it can be
used to guard code in addons that need to check
if a function they want to use is available.

PR-URL: #25319
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
refack pushed a commit to refack/node that referenced this issue Jan 14, 2019
Refs: nodejs/node-addon-api#421

Define NAPI_VERSION_EXPERIMENTAL so that it can be
used to guard code in addons that need to check
if a function they want to use is available.

PR-URL: nodejs#25319
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
BridgeAR pushed a commit to BridgeAR/node that referenced this issue Jan 16, 2019
Refs: nodejs/node-addon-api#421

Define NAPI_VERSION_EXPERIMENTAL so that it can be
used to guard code in addons that need to check
if a function they want to use is available.

PR-URL: nodejs#25319
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@github-actions
Copy link
Contributor

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Dec 17, 2020
@mhdawson
Copy link
Member

The referenced PR landed, more recently we've added some doc to the README.md so I think this can be closed. Please let us know if you think that was not the right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants