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

node: deprecate public access to process.binding #2768

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Client.prototype._addHandle = function(desc) {
};


const natives = process.binding('natives');
const natives = require('binding/natives');


Client.prototype._addScript = function(desc) {
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const util = require('util');
const net = require('net');
const url = require('url');
const EventEmitter = require('events');
const HTTPParser = process.binding('http_parser').HTTPParser;
const HTTPParser = require('binding/http_parser').HTTPParser;
const assert = require('assert').ok;
const common = require('_http_common');
const httpSocketSetup = common.httpSocketSetup;
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const FreeList = require('internal/freelist').FreeList;
const HTTPParser = process.binding('http_parser').HTTPParser;
const HTTPParser = require('binding/http_parser').HTTPParser;

const incoming = require('_http_incoming');
const IncomingMessage = incoming.IncomingMessage;
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const util = require('util');
const net = require('net');
const EventEmitter = require('events');
const HTTPParser = process.binding('http_parser').HTTPParser;
const HTTPParser = require('binding/http_parser').HTTPParser;
const assert = require('assert').ok;
const common = require('_http_common');
const parsers = common.parsers;
Expand Down
4 changes: 2 additions & 2 deletions lib/_stream_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const assert = require('assert');
const util = require('util');
const Socket = require('net').Socket;
const JSStream = process.binding('js_stream').JSStream;
const uv = process.binding('uv');
const JSStream = require('binding/js_stream').JSStream;
const uv = require('binding/uv');
const debug = util.debuglog('stream_wrap');

function StreamWrap(stream) {
Expand Down
2 changes: 1 addition & 1 deletion lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tls = require('tls');
// Lazily loaded
var crypto = null;

const binding = process.binding('crypto');
const binding = require('binding/crypto');
const NativeSecureContext = binding.SecureContext;

function SecureContext(secureProtocol, flags, context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/_tls_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const util = require('util');
const common = require('_tls_common');
const debug = util.debuglog('tls-legacy');
const Buffer = require('buffer').Buffer;
const Timer = process.binding('timer_wrap').Timer;
const Timer = require('binding/timer_wrap').Timer;
var Connection = null;
try {
Connection = process.binding('crypto').Connection;
Connection = require('binding/crypto').Connection;
} catch (e) {
throw new Error('node.js not compiled with openssl crypto support.');
}
Expand Down
8 changes: 4 additions & 4 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const StreamWrap = require('_stream_wrap').StreamWrap;
const Buffer = require('buffer').Buffer;
const Duplex = require('stream').Duplex;
const debug = util.debuglog('tls');
const Timer = process.binding('timer_wrap').Timer;
const tls_wrap = process.binding('tls_wrap');
const TCP = process.binding('tcp_wrap').TCP;
const Pipe = process.binding('pipe_wrap').Pipe;
const Timer = require('binding/timer_wrap').Timer;
const tls_wrap = require('binding/tls_wrap');
const TCP = require('binding/tcp_wrap').TCP;
const Pipe = require('binding/pipe_wrap').Pipe;

function onhandshakestart() {
debug('onhandshakestart');
Expand Down
2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'use strict';

// UTILITY
const compare = process.binding('buffer').compare;
const compare = require('binding/buffer').compare;
const util = require('util');
const Buffer = require('buffer').Buffer;
const pSlice = Array.prototype.slice;
Expand Down
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable require-buffer */
'use strict';

const binding = process.binding('buffer');
const binding = require('binding/buffer');
const internalUtil = require('internal/util');
const bindingObj = {};

Expand Down
6 changes: 3 additions & 3 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const internalUtil = require('internal/util');
const debug = util.debuglog('child_process');
const constants = require('constants');

const uv = process.binding('uv');
const spawn_sync = process.binding('spawn_sync');
const uv = require('binding/uv');
const spawn_sync = require('binding/spawn_sync');
const Buffer = require('buffer').Buffer;
const Pipe = process.binding('pipe_wrap').Pipe;
const Pipe = require('binding/pipe_wrap').Pipe;
const child_process = require('internal/child_process');

const errnoException = util._errnoException;
Expand Down
2 changes: 1 addition & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const util = require('util');
const SCHED_NONE = 1;
const SCHED_RR = 2;

const uv = process.binding('uv');
const uv = require('binding/uv');

const cluster = new EventEmitter();
module.exports = cluster;
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';

module.exports = process.binding('constants');
module.exports = require('binding/constants');
2 changes: 1 addition & 1 deletion lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exports.DEFAULT_ENCODING = 'buffer';

try {
var binding = process.binding('crypto');
var binding = require('binding/crypto');
var randomBytes = binding.randomBytes;
var getCiphers = binding.getCiphers;
var getHashes = binding.getHashes;
Expand Down
4 changes: 2 additions & 2 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const util = require('util');
const EventEmitter = require('events');
const constants = require('constants');

const UDP = process.binding('udp_wrap').UDP;
const SendWrap = process.binding('udp_wrap').SendWrap;
const UDP = require('binding/udp_wrap').UDP;
const SendWrap = require('binding/udp_wrap').SendWrap;

const BIND_STATE_UNBOUND = 0;
const BIND_STATE_BINDING = 1;
Expand Down
4 changes: 2 additions & 2 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const net = require('net');
const util = require('util');

const cares = process.binding('cares_wrap');
const uv = process.binding('uv');
const cares = require('binding/cares_wrap');
const uv = require('binding/uv');

const GetAddrInfoReqWrap = cares.GetAddrInfoReqWrap;
const GetNameInfoReqWrap = cares.GetNameInfoReqWrap;
Expand Down
4 changes: 2 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const SlowBuffer = require('buffer').SlowBuffer;
const util = require('util');
const pathModule = require('path');

const binding = process.binding('fs');
const binding = require('binding/fs');
const constants = require('constants');
const fs = exports;
const Buffer = require('buffer').Buffer;
const Stream = require('stream').Stream;
const EventEmitter = require('events');
const FSReqWrap = binding.FSReqWrap;
const FSEvent = process.binding('fs_event_wrap').FSEvent;
const FSEvent = require('binding/fs_event_wrap').FSEvent;

const Readable = Stream.Readable;
const Writable = Stream.Writable;
Expand Down
14 changes: 7 additions & 7 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const util = require('util');
const constants = require('constants');
const assert = require('assert');

const Process = process.binding('process_wrap').Process;
const WriteWrap = process.binding('stream_wrap').WriteWrap;
const uv = process.binding('uv');
const Pipe = process.binding('pipe_wrap').Pipe;
const TTY = process.binding('tty_wrap').TTY;
const TCP = process.binding('tcp_wrap').TCP;
const UDP = process.binding('udp_wrap').UDP;
const Process = require('binding/process_wrap').Process;
const WriteWrap = require('binding/stream_wrap').WriteWrap;
const uv = require('binding/uv');
const Pipe = require('binding/pipe_wrap').Pipe;
const TTY = require('binding/tty_wrap').TTY;
const TCP = require('binding/tcp_wrap').TCP;
const UDP = require('binding/udp_wrap').UDP;
const SocketList = require('internal/socket_list');

const errnoException = util._errnoException;
Expand Down
4 changes: 2 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const runInThisContext = require('vm').runInThisContext;
const assert = require('assert').ok;
const fs = require('fs');
const path = require('path');
const internalModuleReadFile = process.binding('fs').internalModuleReadFile;
const internalModuleStat = process.binding('fs').internalModuleStat;
const internalModuleReadFile = require('binding/fs').internalModuleReadFile;
const internalModuleStat = require('binding/fs').internalModuleStat;


// If obj.hasOwnProperty has been overridden, then calling
Expand Down
18 changes: 9 additions & 9 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const timers = require('timers');
const util = require('util');
const internalUtil = require('internal/util');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const uv = process.binding('uv');
const cares = require('binding/cares_wrap');
const uv = require('binding/uv');

const Buffer = require('buffer').Buffer;
const TTYWrap = process.binding('tty_wrap');
const TCP = process.binding('tcp_wrap').TCP;
const Pipe = process.binding('pipe_wrap').Pipe;
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
const PipeConnectWrap = process.binding('pipe_wrap').PipeConnectWrap;
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;
const WriteWrap = process.binding('stream_wrap').WriteWrap;
const TTYWrap = require('binding/tty_wrap');
const TCP = require('binding/tcp_wrap').TCP;
const Pipe = require('binding/pipe_wrap').Pipe;
const TCPConnectWrap = require('binding/tcp_wrap').TCPConnectWrap;
const PipeConnectWrap = require('binding/pipe_wrap').PipeConnectWrap;
const ShutdownWrap = require('binding/stream_wrap').ShutdownWrap;
const WriteWrap = require('binding/stream_wrap').WriteWrap;


var cluster;
Expand Down
2 changes: 1 addition & 1 deletion lib/os.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const binding = process.binding('os');
const binding = require('binding/os');
const util = require('util');
const internalUtil = require('internal/util');
const isWindows = process.platform === 'win32';
Expand Down
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const Timer = process.binding('timer_wrap').Timer;
const Timer = require('binding/timer_wrap').Timer;
const L = require('internal/linkedlist');
const assert = require('assert').ok;
const util = require('util');
Expand Down
2 changes: 1 addition & 1 deletion lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const net = require('net');
const url = require('url');
const util = require('util');
const binding = process.binding('crypto');
const binding = require('binding/crypto');
const Buffer = require('buffer').Buffer;
const constants = require('constants');

Expand Down
4 changes: 2 additions & 2 deletions lib/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const util = require('util');
const internalUtil = require('internal/util');
const net = require('net');
const TTY = process.binding('tty_wrap').TTY;
const isTTY = process.binding('tty_wrap').isTTY;
const TTY = require('binding/tty_wrap').TTY;
const isTTY = require('binding/tty_wrap').isTTY;
const inherits = util.inherits;
const errnoException = util._errnoException;

Expand Down
4 changes: 2 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const uv = process.binding('uv');
const uv = require('binding/uv');
const Buffer = require('buffer').Buffer;
const internalUtil = require('internal/util');
const binding = process.binding('util');
const binding = require('binding/util');

var Debug;

Expand Down
2 changes: 1 addition & 1 deletion lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

'use strict';

const v8binding = process.binding('v8');
const v8binding = require('binding/v8');

const heapStatisticsBuffer =
new Uint32Array(v8binding.heapStatisticsArrayBuffer);
Expand Down
2 changes: 1 addition & 1 deletion lib/vm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const binding = process.binding('contextify');
const binding = require('binding/contextify');
const Script = binding.ContextifyScript;

// The binding provides a few useful primitives:
Expand Down
2 changes: 1 addition & 1 deletion lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Buffer = require('buffer').Buffer;
const Transform = require('_stream_transform');
const binding = process.binding('zlib');
const binding = require('binding/zlib');
const util = require('util');
const assert = require('assert').ok;
const kMaxLength = require('buffer').kMaxLength;
Expand Down
6 changes: 3 additions & 3 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2976,7 +2976,6 @@ void SetupProcessObject(Environment* env,
env->SetMethod(process, "uptime", Uptime);
env->SetMethod(process, "memoryUsage", MemoryUsage);

env->SetMethod(process, "binding", Binding);
env->SetMethod(process, "_linkedBinding", LinkedBinding);

env->SetMethod(process, "_setupNextTick", SetupNextTick);
Expand Down Expand Up @@ -3084,8 +3083,9 @@ void LoadEnvironment(Environment* env) {

env->SetMethod(env->process_object(), "_rawDebug", RawDebug);

Local<Value> arg = env->process_object();
f->Call(global, 1, &arg);
Local<Function> binding = env->NewFunctionTemplate(Binding)->GetFunction();
Local<Value> args[] = { env->process_object(), binding };
f->Call(global, ARRAY_SIZE(args), args);
}

static void PrintHelp();
Expand Down
Loading