AsyncResource: Local param instead of MaybeLocal#732
Merged
kkoopa merged 2 commits intonodejs:masterfrom Feb 13, 2018
Merged
Conversation
No need to use a MaybeLocal. It is possible to pass an empty Local to indicate that an object should be allocated automatically. For further convenience, change the order of the parameters to allow for a default value for resource.
f2365d0 to
265b640
Compare
Collaborator
|
Windows builds are currently failing due to a couple (unrelated) things in two new tests from the previous PRs: https://ci.appveyor.com/project/RodVagg/nan/build/job/8vx1q4hhlnetncsi test\cpp\callbackcontext.cpp(38): error C2466: cannot allocate an array of constant size 0 Please pass null instead. You can add the commit here if you like. |
Contributor
Author
|
Fixed the windows build. |
Collaborator
|
Ah, nevermind then. All tests seem to pass on all platforms now. I will merge this later today.
…On February 13, 2018 5:26:42 PM GMT+02:00, Ali Ijaz Sheikh ***@***.***> wrote:
ofrobots commented on this pull request.
> #if NODE_MODULE_VERSION >= NODE_8_0_MODULE_VERSION
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::Local<v8::Object> resource =
- maybe_resource.IsEmpty() ? New<v8::Object>()
- : maybe_resource.ToLocalChecked();
+ if (resource.IsEmpty()) {
+ resource = New<v8::Object>();
+ }
An empty handle is not the same as a handle pointing to a newly
allocated object.
```c++
Local<v8::Object> handle1;
Local<v8::Object> handle2 = New<v8::Object>();
assert(handle1.IsEmpty() == true);
assert(handle2.IsEmpty() == false);
```
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No need to use a
MaybeLocal. It is possible to pass an emptyLocalto indicated that an object should be allocated automatically.