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: implement date object #25917

Closed
wants to merge 5 commits into from

Conversation

jarrodconnolly
Copy link
Contributor

@jarrodconnolly jarrodconnolly commented Feb 4, 2019

Implements napi_create_date() as well as napi_is_date() to
allow working with JavaScript Date objects.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Feb 4, 2019
@vsemozhetbyt vsemozhetbyt added the node-api Issues and PRs related to the Node-API. label Feb 4, 2019
@jarrodconnolly
Copy link
Contributor Author

I am working on adding napi_get_date_value to call the underlying V8 ValueOf() to get the value back out of the Date object.

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

@nodejs/n-api

src/js_native_api_v8.cc Outdated Show resolved Hide resolved
#include <js_native_api.h>
#include "../common.h"

static napi_value createDate(napi_env env, napi_callback_info info) {
Copy link
Member

Choose a reason for hiding this comment

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

I’m not sure if we follow a convention for these names in the N-API tests, but elsewhere in the code this would be either create_date or CreateDate :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was torn on this one as I saw a mix of case usage for the function names in the tests.

static napi_value createError(napi_env env, napi_callback_info info) {
static napi_value createPromise(napi_env env, napi_callback_info info) {
static napi_value CreateTypedArray(napi_env env, napi_callback_info info) {
static napi_value CreateDataView(napi_env env, napi_callback_info info) {

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have any different convention for N-API.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it’s not like it matters much – the latter style would be more consistent with the rest of core, that’s all.

@addaleax
Copy link
Member

addaleax commented Feb 6, 2019

doc/api/n-api.md 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.

@jarrodconnolly thanks for the PR. Left a couple of small comments.

doc/api/n-api.md 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

@addaleax
Copy link
Member

addaleax commented Feb 9, 2019

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM with a few tiny nits.

doc/api/n-api.md Outdated Show resolved Hide resolved
doc/api/n-api.md Outdated Show resolved Hide resolved
doc/api/n-api.md Outdated Show resolved Hide resolved
Implements `napi_create_date()` as well as `napi_is_date()` to
allow working with JavaScript Date objects.
Add the `napi_get_date_value` method to get the original
time value from the Date object.
@jarrodconnolly
Copy link
Contributor Author

All changes are complete for this PR including requested changes from the reviews.

I may try a PR at a later date to address the function naming convention across the n-api tests to see if there is interest in standardizing those with the rest of the coding standards.

@jarrodconnolly
Copy link
Contributor Author

@addaleax Can I get a CI run on this now that the changes are all complete and maybe an author ready label if the run is smooth? Let me know if there is anything else I need to do, thanks again for the help on this pr.

@vsemozhetbyt
Copy link
Contributor

@jarrodconnolly
Copy link
Contributor Author

Thanks for the CI run @vsemozhetbyt looks like it might be an unrelated failure.

The smartos17-64 tests timed out after an exception.

18:28:34 ok 1853 parallel/test-tls-sni-server-client
18:28:34   ---
18:28:34   duration_ms: 1.155
18:28:34   severity: ok
18:28:34   stack: |-
18:28:34 Exception in thread Thread-1:
18:28:34 Traceback (most recent call last):
18:28:34   File "/opt/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner
18:28:34     self.run()
18:28:34   File "/opt/local/lib/python2.7/threading.py", line 754, in run
18:28:34     self.__target(*self.__args, **self.__kwargs)
18:28:34   File "tools/test.py", line 192, in RunSingle
18:28:34     self.HasRun(output)
18:28:34   File "tools/test.py", line 361, in HasRun
18:28:34     self._printDiagnostic()
18:28:34   File "tools/test.py", line 289, in _printDiagnostic
18:28:34     for l in self.traceback.splitlines():
18:28:34 AttributeError: 'list' object has no attribute 'splitlines'
18:28:34 
18:43:34 Build timed out (after 15 minutes). Marking the build as failed.

@addaleax
Copy link
Member

@danbev
Copy link
Contributor

danbev commented Feb 20, 2019

Should this be land in a single commit or in two?

@jarrodconnolly
Copy link
Contributor Author

I believe it should be a single commit. I am guessing you are referring to the second commit which adds the napi_get_date_value. This was just something I thought to add after the original commit to round out the implementation.

Those are just my thoughts, others may have opinions on the regular procedure though.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 20, 2019
@jarrodconnolly
Copy link
Contributor Author

jarrodconnolly commented Feb 25, 2019

Just pinging to see if it would be possible to land this PR. My first and I am looking to complete the cycle once before moving on to future PRs.
@addaleax

@mhdawson
Copy link
Member

@jarrodconnolly at this point the CI is locked down due to the security release. If we don't land in the next few days after that release goes out please remind us and I'll try to get it landed.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 26, 2019

FWIW, the last CI run was green, so this should be able to land anytime.

@mhdawson
Copy link
Member

Lite CI since its low overhead just to double check nothing changed since the last CI https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/2720/

@mhdawson
Copy link
Member

Lite CI good Landed in 13b1aaf

@mhdawson mhdawson closed this Feb 28, 2019
mhdawson pushed a commit that referenced this pull request Feb 28, 2019
Implements `napi_create_date()` as well as `napi_is_date()` to
allow working with JavaScript Date objects.

PR-URL: #25917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 1, 2019
addaleax pushed a commit that referenced this pull request Mar 1, 2019
Implements `napi_create_date()` as well as `napi_is_date()` to
allow working with JavaScript Date objects.

PR-URL: #25917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Mar 4, 2019
BridgeAR added a commit that referenced this pull request Mar 5, 2019
Notable Changes

* n-api:
  * Implement date object (Jarrod Connolly)
    (#25917)
* util:
  * Group array elements together (Ruben Bridgewater)
    (#26269)
  * Add compact depth mode (Ruben Bridgewater)
    (#26269)
* worker:
  * Improve integration with native addons (Anna Henningsen)
    (#26175)
BridgeAR added a commit that referenced this pull request Mar 5, 2019
Notable Changes

* n-api:
  * Implement date object (Jarrod Connolly)
    #25917
* util:
  * Add compact depth mode for `util.inspect()` (Ruben Bridgewater)
    #26269
* worker:
  * Improve integration with native addons (Anna Henningsen)
    #26175
  * MessagePort.prototype.onmessage takes arguments closer to the Web
    specification now (Anna Henningsen)
    #26082
Trott pushed a commit to Trott/io.js that referenced this pull request Mar 6, 2019
Notable Changes

* n-api:
  * Implement date object (Jarrod Connolly)
    nodejs#25917
* util:
  * Add compact depth mode for `util.inspect()` (Ruben Bridgewater)
    nodejs#26269
* worker:
  * Improve integration with native addons (Anna Henningsen)
    nodejs#26175
  * MessagePort.prototype.onmessage takes arguments closer to the Web
    specification now (Anna Henningsen)
    nodejs#26082
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Sep 2, 2019
Implements `napi_create_date()` as well as `napi_is_date()` to
allow working with JavaScript Date objects.

PR-URL: nodejs#25917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Sep 2, 2019
Implements `napi_create_date()` as well as `napi_is_date()` to
allow working with JavaScript Date objects.

PR-URL: nodejs#25917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this pull request Sep 3, 2019
Implements `napi_create_date()` as well as `napi_is_date()` to
allow working with JavaScript Date objects.

Backport-PR-URL: #28298
PR-URL: #25917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Oct 7, 2019
BethGriggs added a commit that referenced this pull request Oct 22, 2019
Notable changes:

* crypto:
  * add support for chacha20-poly1305 for AEAD (chux0519)
    #24081
  * increase maxmem range from 32 to 53 bits (Tobias Nießen)
    #28799
* deps:
  * update npm to 6.11.3 (claudiahdz)
    #29430
  * upgrade openssl sources to 1.1.1d (Sam Roberts)
    #29921
* dns:
  * remove dns.promises experimental warning (cjihrig)
    #26592
* fs:
  * remove experimental warning for fs.promises (Anna Henningsen)
    #26581
* http:
  * makes response.writeHead return the response (Mark S. Everitt)
    #25974
* http2:
  * makes response.writeHead return the response (Mark S. Everitt)
    #25974
* n-api:
  * make func argument of napi\_create\_threadsafe\_function optional
    (legendecas)
    #27791
  * mark version 5 N-APIs as stable (Gabriel Schulhof)
    #29401
  * implement date object (Jarrod Connolly)
    #25917
* process:
  * add --unhandled-rejections flag (Ruben Bridgewater)
    #26599
* stream:
  * implement Readable.from async iterator utility (Guy Bedford)
    #27660
  * make Symbol.asyncIterator support stable (Matteo Collina)
    #26989

PR-URL: #29875
BethGriggs added a commit that referenced this pull request Oct 22, 2019
Notable changes:

* crypto:
  * add support for chacha20-poly1305 for AEAD (chux0519)
    #24081
  * increase maxmem range from 32 to 53 bits (Tobias Nießen)
    #28799
* deps:
  * update npm to 6.11.3 (claudiahdz)
    #29430
  * upgrade openssl sources to 1.1.1d (Sam Roberts)
    #29921
* dns:
  * remove dns.promises experimental warning (cjihrig)
    #26592
* fs:
  * remove experimental warning for fs.promises (Anna Henningsen)
    #26581
* http:
  * makes response.writeHead return the response (Mark S. Everitt)
    #25974
* http2:
  * makes response.writeHead return the response (Mark S. Everitt)
    #25974
* n-api:
  * make func argument of napi\_create\_threadsafe\_function optional
    (legendecas)
    #27791
  * mark version 5 N-APIs as stable (Gabriel Schulhof)
    #29401
  * implement date object (Jarrod Connolly)
    #25917
* process:
  * add --unhandled-rejections flag (Ruben Bridgewater)
    #26599
* stream:
  * implement Readable.from async iterator utility (Guy Bedford)
    #27660
  * make Symbol.asyncIterator support stable (Matteo Collina)
    #26989

PR-URL: #29875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants