-
Notifications
You must be signed in to change notification settings - Fork 30k
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: fixup strings, general code cleanup #14937
Conversation
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base.
@@ -87,13 +87,22 @@ class AsyncWrap : public BaseObject { | |||
PROVIDERS_LENGTH, | |||
}; | |||
|
|||
enum Flags { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you’re passing it as ints, and since we have C++11 available: How about enum class JSMethodFlags {
(which would implicitly have the underlying type int
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrote it this way to be consistent with StreamBase::Flags. Converting these to enum class ...
is a bit more involved than I'd like to get here. If we want to convert those, then we can do both AsyncWrap::Flags and StreamBase::Flags at the same time in a separate PR.
@@ -468,6 +468,13 @@ void AsyncWrap::QueueDestroyId(const FunctionCallbackInfo<Value>& args) { | |||
PushBackDestroyId(Environment::GetCurrent(args), args[0]->NumberValue()); | |||
} | |||
|
|||
void AsyncWrap::AddWrapMethods(Environment* env, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we bikeshed about the name.
IMHO Add
-> Bind
and Wrap
-> AsyncHooks
so BindAsyncHooksMethods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
->Bind
Why? I’d disagree.
Wrap
->AsyncHooks
Not the same things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard that, this is static method anyway, so it would always seem redundant.AddAsyncWrapMethods
might be more explicit, if you like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt AddWrapMethods
doesn't convey the semantics clearly, so I tried to decostruct, and see what felt wrong.
Add
->Bind
Why? I’d disagree.
Add
has (for me) the connotation of creating something new, and since env->SetProtoMethod
AFAICT only creates JS binding for an existing native method Bind
sounds more appropriate. But we can also extend the existing metaphor and use Set
.
Wrap
->AsyncHooks
Not the same things.
Agreed, but AFAIK getAsyncId
and asyncReset
are new and only used in the context of the hooks so AsyncHooks
felt more focused.
Maybe AsyncIDs
is even better.
So to sum another option SetAsyncIDsMethods
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On third thought AsyncHooks
is not good, although that's the "context", the methods are only used by the hooks, and are not the hooks. so:
+2 for AsyncIDs
+1 for AsyncWrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm -1 on bikeshedding on this actually. Just don't see much point in doing so.
CI is green. One failure there is unrelated. |
PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
Landed in 771a03d and 5e7c697 |
PR-URL: nodejs/node#14937 Reviewed-By: Anna Henningsen <[email protected]>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: nodejs/node#14937 Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: nodejs/node#14937 Reviewed-By: Anna Henningsen <[email protected]>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: nodejs/node#14937 Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <[email protected]>
This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported |
Some general source cleanups
AsyncWrap::AddWrapMethods
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src