From 2b557c467f8411bbcf16bfe05e715821ecfe76ca Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 18 Jun 2009 14:58:17 +0200 Subject: [PATCH] Namespace trimming: remove node.constants --- src/file.js | 24 ++++++++++++------------ src/node.cc | 4 +--- website/api.html | 6 +++--- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/file.js b/src/file.js index a087be4ad9..b4b99fefde 100644 --- a/src/file.js +++ b/src/file.js @@ -12,7 +12,7 @@ node.fs.cat = function (path, encoding, callback) { callback(-1); }; - var content = (encoding == node.constants.UTF8 ? "" : []); + var content = (encoding == node.UTF8 ? "" : []); var pos = 0; var chunkSize = 16*1024; @@ -41,9 +41,9 @@ node.fs.File = function (options) { options = options || {}; if (options.encoding === "utf8") { - self.encoding = node.constants.UTF8; + self.encoding = node.UTF8; } else { - self.encoding = node.constants.RAW; + self.encoding = node.RAW; } //node.debug("encoding: opts=" + options.encoding + " self=" + self.encoding); @@ -104,22 +104,22 @@ node.fs.File = function (options) { var flags; switch (mode) { case "r": - flags = node.constants.O_RDONLY; + flags = node.O_RDONLY; break; case "r+": - flags = node.constants.O_RDWR; + flags = node.O_RDWR; break; case "w": - flags = node.constants.O_CREAT | node.constants.O_TRUNC | node.constants.O_WRONLY; + flags = node.O_CREAT | node.O_TRUNC | node.O_WRONLY; break; case "w+": - flags = node.constants.O_CREAT | node.constants.O_TRUNC | node.constants.O_RDWR; + flags = node.O_CREAT | node.O_TRUNC | node.O_RDWR; break; case "a": - flags = node.constants.O_APPEND | node.constants.O_CREAT | node.constants.O_WRONLY; + flags = node.O_APPEND | node.O_CREAT | node.O_WRONLY; break; case "a+": - flags = node.constants.O_APPEND | node.constants.O_CREAT | node.constants.O_RDWR; + flags = node.O_APPEND | node.O_CREAT | node.O_RDWR; break; default: throw "Unknown mode"; @@ -173,9 +173,9 @@ node.fs.File = function (options) { }; }; -stdout = new node.fs.File({ fd: node.constants.STDOUT_FILENO }); -stderr = new node.fs.File({ fd: node.constants.STDERR_FILENO }); -stdin = new node.fs.File({ fd: node.constants.STDIN_FILENO }); +stdout = new node.fs.File({ fd: node.STDOUT_FILENO }); +stderr = new node.fs.File({ fd: node.STDERR_FILENO }); +stdin = new node.fs.File({ fd: node.STDIN_FILENO }); puts = stdout.puts; print = stdout.print; diff --git a/src/node.cc b/src/node.cc index 31005d91b1..07384838b7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -303,9 +303,7 @@ Load (int argc, char *argv[]) Timer::Initialize(node_obj); - Local constants = Object::New(); - node_obj->Set(String::NewSymbol("constants"), constants); - DefineConstants(constants); + DefineConstants(node_obj); Local fs = Object::New(); node_obj->Set(String::NewSymbol("fs"), fs); diff --git a/website/api.html b/website/api.html index 4ec4061e05..59bb15a4ac 100644 --- a/website/api.html +++ b/website/api.html @@ -206,7 +206,7 @@ node.fs.rename("/tmp/hello", "/tmp/world", function (status) { open(2)

The constants like O_CREAT are defined at - node.constants.O_CREAT. + node.O_CREAT.

@@ -243,8 +243,8 @@ node.fs.rename("/tmp/hello", "/tmp/world", function (status) {

- encoding is either node.constants.UTF8 - or node.constants.RAW. + encoding is either node.UTF8 + or node.RAW.