-
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: move public C++ APIs into src/api/*.cc #25541
Conversation
nit: Some APIs, like |
What is our API? Is it everything visible to Breaking the node.cc monolith up a bit is great, but what's the criteria for including/excluding code from src/api/*.cc? It should be stated clearly enough (in a file in src or src/api) that independent reviewers can come to the same conclusion on whether code belongs in src/api or just src/, otherwise the distinction will rot with time, and the creating of a new sub-dir will come to be seen as an accident of history. |
It's a remnant from when node was still young and undisciplined. |
Yes. No matter we want it or not they are already in the header so are considered "documented".
For this PR my criteria was: everything visible in "node.h" except those that cannot even be tested by us (e.g. I also left out the addon loading code because I want to focus this PR mostly on code moves, but I plan to move the common bits ( |
I can document that in the C++ style guide but I'd prefer we do not document it in |
@joyeecheung I'm not suggesting reams of formal docs. I suggest a prominent comment in node.h to the effect that anything visible from including IMO, its a bit odd that node.h (since it defines our API) is not itself in api/, along with all the headers it includes. Putting all the api headers in a place so they are clearly seen as our API, rather being mixed in with the various internal headers, would be at least as useful as moving the source, maybe more so. It also makes review easy, if an include of a .h file NOT in api/ was ever added to a header in api/, it would be obvious that this is an inadvertent API addition. |
@sam-github I don't quite understand the request, why would we want to put Moving the implementation to
I don't think we would want to add any more includes in
There are only two public headers, |
Yes, that's common, but node doesn't do that. I think if you don't write down somewhere what src/api is for so that future devs will understand clearly, then the distinction won't be kept. node.h was only one suggestion, the top of every .cc file in src/api is another, and I don't see the problem with a 3 line text file in src/api either. Or you can not document and see how it goes, but "api" is pretty generic. Many aspects of the node javascript API are implemented in C++, a reasonable person might conclude the C++ that implements the node JS API should be in src/api. Maybe "node" would make more sense, if its the implementation of whatever was declared in "node.h". In short, you've been doing lots of reorg in src/, I'm not objecting to this, just commenting. I trust this reorg makes sense to you, but it wasn't (and still isn't) clear to me why its so beneficial to have a new directory. I'm having to guess the motivation. It looks to me is that you want to break up node.cc, because its a giant mix of way too many different kinds of things? having src/node_encoding.cc, src/node_callback.cc would do that as well without introducing a new sub-dir. |
The benefit is at least it's obvious to people who realize what
That should be addressed in documentations about the general directory structure, we could go anywhere with plain guessing. For people who are aware that
That was my intention, moving them to |
I wasn't suggesting that any reasonable person would think src/ contains javascript. Some of the C++ in
If |
I don't think addon is a particularly good description though, as the C++ APIs are also for embedders - speaking of which we also have N-API headers starting with
That's a typo of mine - if One could argue that having |
So that the v8_platform global variable can be referenced in other files.
This patch moves most of the public C++ APIs into src/api/*.cc so that it's easier to tell that we need to be careful about the compatibility of these code. Some APIs, like `node::LoadEnvironmet()`, `node::Start()` and `node::Init()` still stay in `node.cc` because they are still very specific to our use cases and do not work quite well yet for embedders anyway - we could not even manage to write cctest for them at the moment.
Rebased. CI: https://ci.nodejs.org/job/node-test-pull-request/20483/ If there are no objections I'd like to land this on Friday. While I agree some of @sam-github 's concerns are valid I still think this is an improvement compared to putting all of these functions in the |
So that the v8_platform global variable can be referenced in other files. PR-URL: #25541 Reviewed-By: Gus Caplan <[email protected]>
This patch moves most of the public C++ APIs into src/api/*.cc so that it's easier to tell that we need to be careful about the compatibility of these code. Some APIs, like `node::LoadEnvironmet()`, `node::Start()` and `node::Init()` still stay in `node.cc` because they are still very specific to our use cases and do not work quite well yet for embedders anyway - we could not even manage to write cctest for them at the moment. PR-URL: #25541 Reviewed-By: Gus Caplan <[email protected]>
Landed in 5d4b085...ca9e24e |
@joyeecheung This needs a manual backport for v11.x, it seems. |
So that the v8_platform global variable can be referenced in other files. PR-URL: nodejs#25541 Reviewed-By: Gus Caplan <[email protected]>
This patch moves most of the public C++ APIs into src/api/*.cc so that it's easier to tell that we need to be careful about the compatibility of these code. Some APIs, like `node::LoadEnvironmet()`, `node::Start()` and `node::Init()` still stay in `node.cc` because they are still very specific to our use cases and do not work quite well yet for embedders anyway - we could not even manage to write cctest for them at the moment. PR-URL: nodejs#25541 Reviewed-By: Gus Caplan <[email protected]>
So that the v8_platform global variable can be referenced in other files. PR-URL: #25541 Reviewed-By: Gus Caplan <[email protected]>
This patch moves most of the public C++ APIs into src/api/*.cc so that it's easier to tell that we need to be careful about the compatibility of these code. Some APIs, like `node::LoadEnvironmet()`, `node::Start()` and `node::Init()` still stay in `node.cc` because they are still very specific to our use cases and do not work quite well yet for embedders anyway - we could not even manage to write cctest for them at the moment. PR-URL: #25541 Reviewed-By: Gus Caplan <[email protected]>
src: move v8_platform implementation into node_v8_platform-inl.h
So that the v8_platform global variable can be referenced in other
files.
src: move public C++ APIs into src/api/*.cc
This patch moves most of the public C++ APIs into src/api/*.cc
so that it's easier to tell that we need to be careful about
the compatibility of these code.
Some APIs, like
node::LoadEnvironmet()
,node::Start()
andnode::Init()
still stay innode.cc
because they are stillvery specific to our use cases and do not work quite well yet
for embedders anyway - we could not even manage to write cctest for
them at the moment.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes