src: fixup strings, general code cleanup#14937
src: fixup strings, general code cleanup#14937jasnell wants to merge 2 commits intonodejs:masterfrom
Conversation
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base.
| PROVIDERS_LENGTH, | ||
| }; | ||
|
|
||
| enum Flags { |
There was a problem hiding this comment.
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.
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.
| PushBackDestroyId(Environment::GetCurrent(args), args[0]->NumberValue()); | ||
| } | ||
|
|
||
| void AsyncWrap::AddWrapMethods(Environment* env, |
There was a problem hiding this comment.
Can we bikeshed about the name.
IMHO Add -> Bind and Wrap -> AsyncHooks so BindAsyncHooksMethods
There was a problem hiding this comment.
Add->Bind
Why? I’d disagree.
Wrap->AsyncHooks
Not the same things.
There was a problem hiding this comment.
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.
I felt AddWrapMethods doesn't convey the semantics clearly, so I tried to decostruct, and see what felt wrong.
Add->BindWhy? 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->AsyncHooksNot 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.
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.
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 <anna@addaleax.net>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
Landed in 771a03d and 5e7c697 |
PR-URL: nodejs/node#14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
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 <anna@addaleax.net>
PR-URL: nodejs/node#14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
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 <anna@addaleax.net>
PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Adds `AsyncWrap::AddWrapMethods()` to add common methods to a `Local<FunctionTemplate>`. Follows same pattern as stream base. PR-URL: #14937 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
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::AddWrapMethodsChecklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
src