Skip to content

Commit

Permalink
Namespace trimming: remove node.constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 18, 2009
1 parent 89d891f commit 2b557c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
24 changes: 12 additions & 12 deletions src/file.js
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/node.cc
Expand Up @@ -303,9 +303,7 @@ Load (int argc, char *argv[])

Timer::Initialize(node_obj);

Local<Object> constants = Object::New();
node_obj->Set(String::NewSymbol("constants"), constants);
DefineConstants(constants);
DefineConstants(node_obj);

Local<Object> fs = Object::New();
node_obj->Set(String::NewSymbol("fs"), fs);
Expand Down
6 changes: 3 additions & 3 deletions website/api.html
Expand Up @@ -206,7 +206,7 @@ <h3 id="file_wrappers">POSIX Wrappers</h3>
<a href="http://opengroup.org/onlinepubs/007908799/xsh/open.html">open(2)</a>
<p>
The constants like <code>O_CREAT</code> are defined at
<code>node.constants.O_CREAT</code>.
<code>node.O_CREAT</code>.
</p>
</dd>

Expand Down Expand Up @@ -243,8 +243,8 @@ <h3 id="file_wrappers">POSIX Wrappers</h3>
</p>

<p>
<code>encoding</code> is either <code>node.constants.UTF8</code>
or <code>node.constants.RAW</code>.
<code>encoding</code> is either <code>node.UTF8</code>
or <code>node.RAW</code>.
</p>
</dd>
</dl>
Expand Down

0 comments on commit 2b557c4

Please sign in to comment.