Skip to content

Commit

Permalink
process: add process.features, remove process.useUV
Browse files Browse the repository at this point in the history
Partially fixes #1385.
  • Loading branch information
bnoordhuis committed Jul 23, 2011
1 parent 50e147b commit aa0308d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
15 changes: 14 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aa0308d

Please sign in to comment.