Skip to content
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

icu: make process.binding('icu') internal #23234

Merged
merged 3 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ const {
kMaxLength,
kStringMaxLength
} = process.binding('buffer');
// We cannot use internalBinding unconditionally here because of the way
// that test/parallel/test-buffer-bindingobj-no-zerofill.js is written.
let isAnyArrayBuffer;
try {
isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer;
} catch (e) {
isAnyArrayBuffer = require('util').types.isAnyArrayBuffer;
}
const { isAnyArrayBuffer } = internalBinding('types');
const {
customInspectSymbol,
isInsideNodeModules,
Expand Down Expand Up @@ -1078,7 +1071,7 @@ if (process.binding('config').hasIntl) {
const {
icuErrName,
transcode: _transcode
} = process.binding('icu');
} = internalBinding('icu');

// Transcodes the Buffer from one encoding to another, returning a new
// Buffer instance.
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@
new SafeSet([
'cares_wrap',
'fs_event_wrap',
'icu',
'udp_wrap',
'uv',
'pipe_wrap',
Expand Down Expand Up @@ -654,7 +655,7 @@

function setupProcessICUVersions() {
const icu = process.binding('config').hasIntl ?
process.binding('icu') : undefined;
internalBinding('icu') : undefined;
if (!icu) return; // no Intl/ICU: nothing to add here.
// With no argument, getVersion() returns a comma separated list
// of possible types.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function makeTextDecoderICU() {
decode: _decode,
getConverter,
hasConverter
} = process.binding('icu');
} = internalBinding('icu');

class TextDecoder {
constructor(encoding = 'utf-8', options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CSI.kClearLine = CSI`2K`;
CSI.kClearScreenDown = CSI`0J`;

if (process.binding('config').hasIntl) {
const icu = process.binding('icu');
const icu = internalBinding('icu');
getStringWidth = function getStringWidth(str, options) {
options = options || {};
if (!Number.isInteger(str))
Expand Down
2 changes: 1 addition & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'use strict';

const { toASCII } = process.binding('config').hasIntl ?
process.binding('icu') : require('punycode');
internalBinding('icu') : require('punycode');

const { hexTable } = require('internal/querystring');

Expand Down
2 changes: 1 addition & 1 deletion src/node_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,6 @@ void Initialize(Local<Object> target,
} // namespace i18n
} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(icu, node::i18n::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(icu, node::i18n::Initialize)

#endif // NODE_HAVE_I18N_SUPPORT
49 changes: 0 additions & 49 deletions test/parallel/test-buffer-bindingobj-no-zerofill.js

This file was deleted.

4 changes: 3 additions & 1 deletion test/parallel/test-icu-punycode.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';
// Flags: --expose-internals
const common = require('../common');

if (!common.hasIntl)
common.skip('missing Intl');

const icu = process.binding('icu');
const { internalBinding } = require('internal/test/binding');
const icu = internalBinding('icu');
const assert = require('assert');

const tests = require('../fixtures/url-idna.js');
Expand Down