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

adds experimental napi_date #497

Closed
wants to merge 2 commits into from
Closed

adds experimental napi_date #497

wants to merge 2 commits into from

Conversation

mathiask88
Copy link
Contributor

I tried to add the experimental date stuff. I'll add the docs if the rest is correct.

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

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

Hi @mathiask88,
good work, thanks for adding this new API. There are some tasks to address. Hope to hear you very soon.

napi.h Show resolved Hide resolved
napi.h Outdated Show resolved Hide resolved
napi.h Show resolved Hide resolved
napi.h Outdated Show resolved Hide resolved
@mathiask88
Copy link
Contributor Author

I added some docs, but the current doc structure and naming is not fully consistent. I tried to stay file scope consistent.

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

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

Some little comment about the documentation.

doc/date.md Outdated Show resolved Hide resolved
doc/date.md Outdated Show resolved Hide resolved
doc/date.md Outdated Show resolved Hide resolved
doc/date.md Show resolved Hide resolved
doc/date.md Outdated Show resolved Hide resolved
doc/date.md Outdated Show resolved Hide resolved
@mhdawson
Copy link
Member

On other through, the doc sections should probably indicate that the Date related parts are experimental.

@mathiask88
Copy link
Contributor Author

@mhdawson True, I thought about it, but didn't add anything because BigInt isn't explicitly indicated as experimental. I'll add it and open another PR for all the mentioned doc stuff. Why was Date as a basic JavaScript object even added that late to N-API? And is it experimental because every new stuff starts as experimental? Just curious.

@mhdawson
Copy link
Member

@mathiask88, new functions are added to N-API as experimental. This allows us to properly managed what is in each N-API version and confirm that the new functions don't have fundamental usage issues before we can no longer change them. N-API does not cover all of the JavaScript spec, instead we drove the APIs based on what we saw being used in the most used modules. So it's just most likely that Date was not in the set that we'd looked at.

As I wrote my comment I was thinking that we probably were not good about marking things as experimental before but I still think its a good idea going forward. Just to say that I understand why it would not have been evident that it was something to do.

@mhdawson
Copy link
Member

@mathiask88, also wanted to say thanks for being so understanding. We still have some work to go in getting the module to be consistent and to iorn out how we handle experimental/new functions.

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

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

It's ok for me just one last little task. Good work @mathiask88 .

napi.h Outdated Show resolved Hide resolved
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

@mathiask88
Copy link
Contributor Author

@mhdawson Thanks, but there is still an open question #497 (comment)

@mhdawson
Copy link
Member

mhdawson commented Jun 28, 2019

@mathiask88 good point, I've commented above that I'm ok with valueOf instead.

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

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

LGTM

@gabrielschulhof
Copy link
Contributor

Shouldn't it be ValueOf(), with a capital 'V'?

@NickNaso
Copy link
Member

@gabrielschulhof yes you're right. @mathiask88 could you change the method name like repoter by @gabrielschulhof ?

@mathiask88
Copy link
Contributor Author

@gabrielschulhof @NickNaso Oh, sure. I was in JavaScript lower camel case land :)

@gabrielschulhof
Copy link
Contributor

@gabrielschulhof @NickNaso Oh, sure. I was in JavaScript lower camel case land :)

😂 I know the feeling.

@NickNaso
Copy link
Member

Hi everyone,
is it possible merge this PR?

@gabrielschulhof
Copy link
Contributor

@NickNaso I'll start the CI.

@gabrielschulhof
Copy link
Contributor

@NickNaso 🤦 can't land this until date is actually backported to v10.x and v8.x. Sorry, I forgot!

@NickNaso
Copy link
Member

NickNaso commented Jul 17, 2019

@gabrielschulhof It's ok so it could be a good idea mark this PR with do not land tag and I will provide to link it the PR to the issue where we are tracking the backporting tasks. Do you agree?

@gabrielschulhof
Copy link
Contributor

@NickNaso SGTM 👍

@mathiask88
Copy link
Contributor Author

Any news on this? How long does it usually take until a backport lands? I would like to see this basic functionality implemented in node/napi.

@mhdawson
Copy link
Member

@mathiask88 V8 is in maintenance so updates are not frequent. @gabrielschulhof with the proper version checks this could probably be landed but only be enable version N-API version >5 right? What we'd want to avoid in that case is it 8.x supporting V 5 before 10.x does.

@mhdawson
Copy link
Member

mhdawson commented Sep 4, 2019

@mathiask88 coud you update to add the N-API version checks so that the functionality is only enabled if N-API is set to version 5 or greater?

@mathiask88
Copy link
Contributor Author

@mhdawson Something like this? I left this line intentionally so that I don't get a linker error when I run npm test with my local node v12. Because without specifying --NAPI_VERSION= the binding.cc defaults to experimental.

@mhdawson
Copy link
Member

mhdawson commented Sep 4, 2019

I'm confused because it looks like from the CI output the data tests are running on 10 and 12 which I don't expect.

@mathiask88
Copy link
Contributor Author

mathiask88 commented Sep 5, 2019

Locally I have node 12.10.0 + WIN10 and following tests are running

npm test
Starting test suite

Running test 'arraybuffer'
Running test 'asynccontext'
Running test 'asyncworker'
Running test 'asyncworker-nocallback'
Running test 'asyncworker-persistent'
Running test 'basic_types/array'
Running test 'basic_types/boolean'
Running test 'basic_types/number'
Running test 'basic_types/value'
Running test 'bigint'
Running test 'date'
Running test 'buffer'
Running test 'callbackscope'
Running test 'dataview/dataview'
Running test 'dataview/dataview_read_write'
Running test 'error'
Running test 'external'
Running test 'function'
Running test 'handlescope'
Running test 'memory_management'
Running test 'name'
Running test 'object/delete_property'
Running test 'object/get_property'
Running test 'object/has_own_property'
Running test 'object/has_property'
Running test 'object/object'
Running test 'object/object_deprecated'
Running test 'object/set_property'
Running test 'promise'
Running test 'threadsafe_function/threadsafe_function_ptr'
Running test 'threadsafe_function/threadsafe_function'
Running test 'typedarray'
Running test 'typedarray-bigint'
Running test 'objectwrap'
Running test 'objectreference'
Running test 'version_management'

All tests passed!
npm test --NAPI_VERSION=4
Starting test suite

Running test 'arraybuffer'
Running test 'asynccontext'
Running test 'asyncworker'
Running test 'asyncworker-nocallback'
Running test 'asyncworker-persistent'
Running test 'basic_types/array'
Running test 'basic_types/boolean'
Running test 'basic_types/number'
Running test 'basic_types/value'
Running test 'buffer'
Running test 'callbackscope'
Running test 'dataview/dataview'
Running test 'dataview/dataview_read_write'
Running test 'error'
Running test 'external'
Running test 'function'
Running test 'handlescope'
Running test 'memory_management'
Running test 'name'
Running test 'object/delete_property'
Running test 'object/get_property'
Running test 'object/has_own_property'
Running test 'object/has_property'
Running test 'object/object'
Running test 'object/object_deprecated'
Running test 'object/set_property'
Running test 'promise'
Running test 'threadsafe_function/threadsafe_function_ptr'
Running test 'threadsafe_function/threadsafe_function'
Running test 'typedarray'
Running test 'objectwrap'
Running test 'objectreference'
Running test 'version_management'

All tests passed!

npm test --NAPI_VERSION=5 Does obviously not compile

Is NAPI_VERSION not specified in the CI?

@mhdawson
Copy link
Member

mhdawson commented Sep 5, 2019

The CI uses the process.versions to set the --NAPI_VERSION to the one reported by the version of Node.js being tested.

@mhdawson
Copy link
Member

mhdawson commented Sep 5, 2019

From the CI job, this is how it gets and sets it.

 echo 'console.log(process.versions.napi)' >get_napi_version.js
    NAPI_VERSION_REPORTED=`node get_napi_version.js`
    npm test --NAPI_VERSION=$NAPI_VERSION_REPORTED

So it should be being set appropriately for the Node.js version. When I looked it was still 4 for 10.x which is why I was confused that it ran in https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-new/nodes=rhel72-s390x/550/console

@mathiask88
Copy link
Contributor Author

@mhdawson Seems like there is a version check on adding --NAPI_VERSION
Have a look at the win10 test on v8.x

+ '[' 8 -gt 9 ']'
+ echo 'console.log(process.versions.napi)'
++ node get_napi_version.js
+ NAPI_VERSION_REPORTED=4
+ npm test --NAPI_VERSION=4

and for v10.x

+ '[' 10 -gt 9 ']'
+ npm test

@mhdawson
Copy link
Member

mhdawson commented Sep 5, 2019

@mathiask88 good catch , that explains why they are running. We should leave it that way as it's good to run the tests if we can.

The CI has


  if [ ${NODEJS_MAJOR_VERSION} -gt "9" ]; then
    # These can run experimental tests
    npm test
  else
    echo 'console.log(process.versions.napi)' >get_napi_version.js
    NAPI_VERSION_REPORTED=`node get_napi_version.js`
    npm test --NAPI_VERSION=$NAPI_VERSION_REPORTED
  fi

@mhdawson
Copy link
Member

mhdawson commented Sep 5, 2019

CI looks good to me.

mhdawson pushed a commit that referenced this pull request Sep 5, 2019
PR-URL: #497
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@mhdawson
Copy link
Member

mhdawson commented Sep 5, 2019

Landed as 6192e70. Thanks @mathiask88

@mhdawson mhdawson closed this Sep 5, 2019
@mathiask88
Copy link
Contributor Author

Thank you!

kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#497
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#497
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#497
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
austinli64 added a commit to austinli64/node-addon-api that referenced this pull request May 9, 2023
PR-URL: nodejs/node-addon-api#497
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#497
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants