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

src: remove usage of V8 deprecated APIs in node_url.cc #11066

Closed
wants to merge 1 commit into from

Conversation

TimothyGu
Copy link
Member

@TimothyGu TimothyGu commented Jan 29, 2017

CI: https://ci.nodejs.org/job/node-test-pull-request/6097/

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

url

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Jan 29, 2017
@TimothyGu TimothyGu changed the title src: remove usage of V8 deprecated API in node_url.cc src: remove usage of V8 soon-to-be-deprecated API in node_url.cc Jan 29, 2017
@TimothyGu TimothyGu changed the title src: remove usage of V8 soon-to-be-deprecated API in node_url.cc src: remove usage of V8 deprecated APIs in node_url.cc Jan 29, 2017
src/node_url.cc Outdated
@@ -1316,7 +1318,8 @@ namespace url {
Utf8Value input(env->isolate(), args[0]);
enum url_parse_state override = kUnknownState;
if (args[1]->IsNumber())
override = (enum url_parse_state)(args[1]->Uint32Value());
override = (enum url_parse_state)(
args[1]->Uint32Value(env->context()).ToChecked());
Copy link
Member

Choose a reason for hiding this comment

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

We use FromJust in the code base

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

src/node_url.cc Outdated
@@ -1316,7 +1318,8 @@ namespace url {
Utf8Value input(env->isolate(), args[0]);
enum url_parse_state override = kUnknownState;
if (args[1]->IsNumber())
Copy link
Member

Choose a reason for hiding this comment

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

I'd add braces here for clarity now that it expands on two lines

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.

LGTM with a suggestion

src/node_url.cc Outdated
override = (enum url_parse_state)(args[1]->Uint32Value());
if (args[1]->IsNumber()) {
override = (enum url_parse_state)(
args[1]->Uint32Value(env->context()).FromJust());
Copy link
Member

Choose a reason for hiding this comment

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

Can you turn this into a reinterpret_cast and rename override to something that’s not a language keyword?

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out static_cast works but reinterpret_cast doesn't. override bit fixed.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM, looks like it needs a rebase

Also:

- Avoid using 'override' as variable name
- Use explicit static_cast instead of C-style cast
@TimothyGu
Copy link
Member Author

@jasnell, rebased.

@targos, @addaleax, PTAL.

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.

Thanks, LGTM!

@jasnell
Copy link
Member

jasnell commented Jan 31, 2017

New CI after rebase: https://ci.nodejs.org/job/node-test-pull-request/6127/

@jasnell
Copy link
Member

jasnell commented Jan 31, 2017

Some failures in that last CI run, trying again: https://ci.nodejs.org/job/node-test-pull-request/6138/

@TimothyGu
Copy link
Member Author

Landed in c7e1be8.

@TimothyGu TimothyGu closed this Feb 1, 2017
@TimothyGu TimothyGu deleted the url-cpp-deprecated branch February 1, 2017 07:58
TimothyGu added a commit that referenced this pull request Feb 1, 2017
Also:

- Avoid using 'override' as variable name
- Use explicit static_cast instead of C-style cast

PR-URL: #11066
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 2, 2017
Also:

- Avoid using 'override' as variable name
- Use explicit static_cast instead of C-style cast

PR-URL: nodejs#11066
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 14, 2017
Also:

- Avoid using 'override' as variable name
- Use explicit static_cast instead of C-style cast

PR-URL: nodejs#11066
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
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++. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants