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

Add missing methods to Nan::Maybe<T> #852

Merged
merged 2 commits into from May 16, 2019
Merged

Add missing methods to Nan::Maybe<T> #852

merged 2 commits into from May 16, 2019

Conversation

bnoordhuis
Copy link
Member

Nan::Maybe was an alias for v8::Maybe with most Node.js versions
but that's problematic because v8::Maybe has grown new methods over
time that are missing in older versions.

From now on we use our custom Maybe implementation with all Node.js
versions. This commit also adds the following missing methods:

  • Maybe::Check() const
  • Maybe::To(T*) const
  • Maybe::ToChecked() const

Fixes: #851

Copy link
Contributor

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the quick turn around on this 😍

@bnoordhuis bnoordhuis requested a review from kkoopa May 6, 2019 09:11
Copy link
Collaborator

@kkoopa kkoopa 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 small nit

nan.h Outdated
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
// Allow implicit conversions from v8::Maybe<T> to Nan::Maybe<T>.
Maybe(const v8::Maybe<T>& that)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a comment for the linter to suppress warnings about runtime/explicit here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, sorry about that. I added a second commit that fixes all the other style violations.

Nan::Maybe<T> was an alias for v8::Maybe<T> with most Node.js versions
but that's problematic because v8::Maybe<T> has grown new methods over
time that are missing in older versions.

From now on we use our custom Maybe<T> implementation with all Node.js
versions. This commit also adds the following missing methods:

* Maybe<T>::Check() const
* Maybe<T>::To(T*) const
* Maybe<T>::ToChecked() const

Fixes: #851
The code base is now `make lint`-clean again.
@kkoopa
Copy link
Collaborator

kkoopa commented May 16, 2019

Even better. Thanks.

@kkoopa kkoopa merged commit 4e96248 into nodejs:master May 16, 2019
@bnoordhuis
Copy link
Member Author

@kkoopa Is there a reason you squashed the commits? Not that it really matters, I'm just curious.

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.

Nan::Maybe<T> ToChecked not implemented for Node.js 6.x
3 participants