-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Extract base64 encoding/decoding code into headers #6910
Conversation
/cc @nodejs/ctc Is this an API we want to support? I'm leaning towards -1 but more like -0.5 I guess.... EDIT: Thinking about this more I move my vote to -1 ;-) |
-1 from me as well, this is an implementation detail, not an API. |
This looks like a refactoring of code so base64 could be used in other parts of Node core. This is not a new API. Did I miss something? |
@eugeneo The commit message should be formatted according to the commit guidelines: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md |
@ofrobots This PR moves the code from the existing |
But I could use the same 'API' by including |
@ofrobots this doesn't really feat into the concept of API, IMO. Node.js is about JS VM, OS bindings, and the rest. |
|
||
|
||
// supports regular and URL-safe base64 | ||
static const int8_t unbase64_table[] = |
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 you leave the table itself in string_bytes.cc? Just drop the static
keyword and declare it here. Maybe add [256]
so there is no confusion about its size.
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.
Done.
I somehow missed the PR link the first time. I rescind my -1 vote. |
I updated the commit message & moved the array. Please take another look. |
If it is not public - should we add something like this to the header?
Sorry, but not LGTM to me yet. |
Node already has support for base64 encoding and decoding that is not visible outside the string_bytes.cc file. Our work on providing a support for the Chrome inspector protocol (#6792) requires base64 encoding support. Rather then introducing a second copy of the base64 encoder, we suggest moving this code into a separate header.
@indutny I've added the condition to a header. Please note that it looks like there are no other headers with such directives - e.g. node-internal.h does not have the condition, it is node.h that conditionally includes node-internal.h. |
@eugeneo thank you! I know that it is not present anywhere else, but if we don't want this header to be used in general user addons, we have to protect it somehow! |
LGTM |
LGTM. New CI: https://ci.nodejs.org/job/node-test-pull-request/2752/ |
Node already has support for base64 encoding and decoding that is not visible outside the string_bytes.cc file. Our work on providing a support for the Chrome inspector protocol (#6792) requires base64 encoding support. Rather then introducing a second copy of the base64 encoder, we suggest moving this code into a separate header. PR-URL: #6910 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
Landed as 706e699. |
For consistency with the newly added src/base64.h header, check that NODE_WANT_INTERNALS is defined and set in internal headers. PR-URL: nodejs#6948 Refs: nodejs#6910 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Node already has support for base64 encoding and decoding that is not visible outside the string_bytes.cc file. Our work on providing a support for the Chrome inspector protocol (nodejs#6792) requires base64 encoding support. Rather then introducing a second copy of the base64 encoder, we suggest moving this code into a separate header. PR-URL: nodejs#6910 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
For consistency with the newly added src/base64.h header, check that NODE_WANT_INTERNALS is defined and set in internal headers. PR-URL: nodejs#6948 Refs: nodejs#6910 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Node already has support for base64 encoding and decoding that is not visible outside the string_bytes.cc file. Our work on providing a support for the Chrome inspector protocol (#6792) requires base64 encoding support. Rather then introducing a second copy of the base64 encoder, we suggest moving this code into a separate header. PR-URL: #6910 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
For consistency with the newly added src/base64.h header, check that NODE_WANT_INTERNALS is defined and set in internal headers. PR-URL: #6948 Refs: #6910 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@ofrobots @indutny @bnoordhuis @AndreasMadsen should this be included in #7048? |
@thealphanerd No, but it should be included if/when the V8 inspector changes are back-ported. |
This is related to PR #6792
For our protocol, we need Base64 encoder. It already exists in string_bytes.cc so I simply extracted it to the header. For symmetry, I also extracted decoder.