Browse Source

process: add process.features, remove process.useUV

Partially fixes #1385.
v0.7.4-release
Ben Noordhuis 14 years ago
parent
commit
aa0308d618
  1. 15
      src/node.cc
  2. 8
      src/node.js
  3. 2
      test/internet/test-dns.js

15
src/node.cc

@ -2013,6 +2013,19 @@ static Handle<Array> EnvEnumerator(const AccessorInfo& info) {
}
static Handle<Object> GetFeatures() {
HandleScope scope;
Local<Object> obj = Object::New();
obj->Set(String::NewSymbol("uv"), Boolean::New(use_uv));
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
obj->Set(String::NewSymbol("tls"),
Boolean::New(get_builtin_module("crypto") != NULL));
return scope.Close(obj);
}
Handle<Object> SetupProcessObject(int argc, char *argv[]) {
HandleScope scope;
@ -2102,7 +2115,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
process->Set(String::NewSymbol("ENV"), ENV);
process->Set(String::NewSymbol("pid"), Integer::New(getpid()));
process->Set(String::NewSymbol("useUV"), use_uv ? True() : False());
process->Set(String::NewSymbol("features"), GetFeatures());
// -e, --eval
if (eval_string) {

8
src/node.js

@ -31,7 +31,7 @@
function startup() {
if (process.env.NODE_USE_UV == '1') process.useUV = true;
if (process.env.NODE_USE_UV == '1') process.features.uv = true;
EventEmitter = NativeModule.require('events').EventEmitter;
process.__proto__ = EventEmitter.prototype;
@ -389,13 +389,13 @@
function translateId(id) {
switch (id) {
case 'net':
return process.useUV ? 'net_uv' : 'net_legacy';
return process.features.uv ? 'net_uv' : 'net_legacy';
case 'timers':
return process.useUV ? 'timers_uv' : 'timers_legacy';
return process.features.uv ? 'timers_uv' : 'timers_legacy';
case 'dns':
return process.useUV ? 'dns_uv' : 'dns_legacy';
return process.features.uv ? 'dns_uv' : 'dns_legacy';
default:
return id;

2
test/internet/test-dns.js

@ -25,7 +25,7 @@ var assert = require('assert');
isIP = net.isIP,
isIPv4 = net.isIPv4,
isIPv6 = net.isIPv6,
uv = process.useUV;
uv = process.features.uv;
var expected = 0,
completed = 0,

Loading…
Cancel
Save