src: add context-aware helpers and init macro#21318
src: add context-aware helpers and init macro#21318gabrielschulhof wants to merge 3 commits intonodejs:masterfrom
Conversation
e292f6d to
f25f30b
Compare
src/node.h
Outdated
There was a problem hiding this comment.
I wouldn’t be a fan of including this in our public API, unless there’s a reason why we would export it from core
We originally had more core of this sort around (e.g. node_object_wrap.h), but it’s a good idea that this generally moved into Nan territory? I’d suggest PR’ing it there
doc/api/addons.md
Outdated
There was a problem hiding this comment.
node-gyp -> `node-gyp` for consistency with other mentions?
doc/api/addons.md
Outdated
There was a problem hiding this comment.
Missing final backtick and period?
doc/api/addons.md
Outdated
There was a problem hiding this comment.
Should the first letter case be unified in this list?
e83beeb to
0f7d65d
Compare
|
@addaleax @bnoordhuis I have reduced the scope of the PR to the |
|
@vsemozhetbyt I have fixed the issues you mention. |
|
Doc format LGTM. |
237c4f3 to
ac20ee3
Compare
doc/api/addons.md
Outdated
There was a problem hiding this comment.
nit: "When building addons with..."
There was a problem hiding this comment.
Yep, I let that one slip :) Thanks!
ac20ee3 to
49360b2
Compare
49360b2 to
6b68df1
Compare
|
Another CI before I land: https://ci.nodejs.org/job/node-test-pull-request/15639/ |
|
this needs another approval to land |
|
@devsnek aaah, thank you! Wasn't sure. |
|
It seems our docs state only one approving is needed to land a not fast-track PR. |
|
@vsemozhetbyt actually, it says it must be two if a Collaborator is the originator of the PR. I checked after @devsnek's reminder: https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#code-reviews |
|
Do you refer this sentence?
I read it as "One Collaborator is the PR author, another Collaborator is a reviewer". |
|
I don't read it that way, because I know that the PR's author may not
approve. Therefore, since all PRs need at least one approver, and a
Collaborator's PR needs and additional approver, I conclude that a
Collaborator's PR needs to approvers. Still, it should maybe state
explicitly that a Collaborator's PR needs the approver of two Collaborators.
…On Wed, Jun 27, 2018 at 10:29 AM, Vse Mozhet Byt ***@***.***> wrote:
Do you refer this sentence?
In the case of pull requests proposed by an existing Collaborator, an
additional Collaborator is required for sign-off.
I read it as "One Collaborator is the PR author, another Collaborator is a
reviewer".
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21318 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA7k0YUDmU2AqXPuk33Qw_GV-exV3InLks5uA5awgaJpZM4UmriR>
.
|
|
Let's see how others understand this. It seems we have a bit confusing wording here. |
|
This does not need a second reviewer, although I would try pinging a relevant team or two before landing, just to get a second one. |
|
@nodejs/collaborators in the spirit of #21565 (comment), could somebody else please have a look? 🙂 |
|
Aww, the dreaded mention. P.S. I'll take a look :) |
doc/api/addons.md
Outdated
There was a problem hiding this comment.
Can you please articulate what could be those cases?
There was a problem hiding this comment.
@mcollina how about the new paragraph I added?
|
@addaleax could you please take another look? |
Introduces macro `NODE_MODULE_INIT()` which creates the boilerplate for a context-aware module which can be loaded multiple times via the special symbol mechanism. Additionally, provides an example of using the new macro to construct an addon which stores per-addon-instance data in a heap-allocated structure that gets passed to each binding, rather than in a collection of global static variables. Re: nodejs#21291 (comment)
f81217c to
9402ca1
Compare
|
Rebased and added doc for |
|
Landed in 602da64. |
Introduces macros `NODE_MODULE_INITIALIZER` which expands to the name of the special symbol that process.dlopen() will look for to initialize an addon, and `NODE_MODULE_INIT()` which creates the boilerplate for a context-aware module which can be loaded multiple times via the special symbol mechanism. Additionally, provides an example of using the new macro to construct an addon which stores per-addon-instance data in a heap-allocated structure that gets passed to each binding, rather than in a collection of global static variables. Re: nodejs#21291 (comment) PR-URL: nodejs#21318 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
|
CI was not green. I think we need stronger wording in our docs about not landing stuff when CI is not green. I'll open a PR for that right now. If you have a mostly-green node-test-pull-request, you're fairly certain the not-green stuff isn't relevant to your changes, and you want to re-run just the things that aren't green, use "Resume Build" on the left menu. It will create a new node-test-pull-request, copy over all the green stuff, and only re-run the red/yellow/grey stuff.
EDIT: Can't re-run CI because the branch has been deleted. So in lieu of that, here's a node-daily-master run manually kicked off to re-test this: https://ci.nodejs.org/job/node-daily-master/1203/ |
|
@Trott sorry about that! One job failed on what looked like an infra issue (unable to create a directory). Using "Resume Build" is an awesome option! I didn't know about it. |
Sorry, didn't mean to pick on you! No need to apologize. You're far from alone. I'm just trying to spread the word about Resume Build. :-D (I didn't know about it until someone else on Build showed it to me...I think it was @refack.) |
Introduces macros `NODE_MODULE_INITIALIZER` which expands to the name of the special symbol that process.dlopen() will look for to initialize an addon, and `NODE_MODULE_INIT()` which creates the boilerplate for a context-aware module which can be loaded multiple times via the special symbol mechanism. Additionally, provides an example of using the new macro to construct an addon which stores per-addon-instance data in a heap-allocated structure that gets passed to each binding, rather than in a collection of global static variables. Re: #21291 (comment) PR-URL: #21318 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Introduces macro
NODE_MODULE_INIT()which creates the boilerplate fora context-aware module which can be loaded multiple times via the
special symbol mechanism.
Also introduces class
node::WeakDatawith which one can weaklyassociate a native class instance with a JavaScript object, and
convenience methods
node::SetMethodWithData()andnode::SetPrototypeMethodWithData()which pass a native pointerthrough to bindings.
Together, these APIs allow one to avoid using global static data in
an addon.
Re: #21291 (comment)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes