0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00

Rename JS_ to NODE_ for method macros. add marcos to timers.cc

This commit is contained in:
Ryan 2009-04-21 15:55:11 +02:00
parent a0f2b8a0c5
commit 47fad676b4
4 changed files with 37 additions and 53 deletions

View File

@ -155,31 +155,31 @@ FileSystem::AfterStat (eio_req *req)
struct stat *s = static_cast<struct stat*>(req->ptr2);
/* ID of device containing file */
stats->Set(JS_SYMBOL("dev"), Integer::New(s->st_dev));
stats->Set(NODE_SYMBOL("dev"), Integer::New(s->st_dev));
/* inode number */
stats->Set(JS_SYMBOL("ino"), Integer::New(s->st_ino));
stats->Set(NODE_SYMBOL("ino"), Integer::New(s->st_ino));
/* protection */
stats->Set(JS_SYMBOL("mode"), Integer::New(s->st_mode));
stats->Set(NODE_SYMBOL("mode"), Integer::New(s->st_mode));
/* number of hard links */
stats->Set(JS_SYMBOL("nlink"), Integer::New(s->st_nlink));
stats->Set(NODE_SYMBOL("nlink"), Integer::New(s->st_nlink));
/* user ID of owner */
stats->Set(JS_SYMBOL("uid"), Integer::New(s->st_uid));
stats->Set(NODE_SYMBOL("uid"), Integer::New(s->st_uid));
/* group ID of owner */
stats->Set(JS_SYMBOL("gid"), Integer::New(s->st_gid));
stats->Set(NODE_SYMBOL("gid"), Integer::New(s->st_gid));
/* device ID (if special file) */
stats->Set(JS_SYMBOL("rdev"), Integer::New(s->st_rdev));
stats->Set(NODE_SYMBOL("rdev"), Integer::New(s->st_rdev));
/* total size, in bytes */
stats->Set(JS_SYMBOL("size"), Integer::New(s->st_size));
stats->Set(NODE_SYMBOL("size"), Integer::New(s->st_size));
/* blocksize for filesystem I/O */
stats->Set(JS_SYMBOL("blksize"), Integer::New(s->st_blksize));
stats->Set(NODE_SYMBOL("blksize"), Integer::New(s->st_blksize));
/* number of blocks allocated */
stats->Set(JS_SYMBOL("blocks"), Integer::New(s->st_blocks));
stats->Set(NODE_SYMBOL("blocks"), Integer::New(s->st_blocks));
/* time of last access */
stats->Set(JS_SYMBOL("atime"), Date::New(1000*static_cast<double>(s->st_atime)));
stats->Set(NODE_SYMBOL("atime"), Date::New(1000*static_cast<double>(s->st_atime)));
/* time of last modification */
stats->Set(JS_SYMBOL("mtime"), Date::New(1000*static_cast<double>(s->st_mtime)));
stats->Set(NODE_SYMBOL("mtime"), Date::New(1000*static_cast<double>(s->st_mtime)));
/* time of last status change */
stats->Set(JS_SYMBOL("ctime"), Date::New(1000*static_cast<double>(s->st_ctime)));
stats->Set(NODE_SYMBOL("ctime"), Date::New(1000*static_cast<double>(s->st_ctime)));
}
CallTopCallback(fs, argc, argv);
@ -499,16 +499,16 @@ NodeInit_file (Handle<Object> target)
target->Set(String::NewSymbol("File"), fs);
// file system methods
JS_SET_METHOD(fs, "_ffi_rename", FileSystem::Rename);
JS_SET_METHOD(fs, "_ffi_stat", FileSystem::Stat);
JS_SET_METHOD(fs, "strerror", FileSystem::StrError);
NODE_SET_METHOD(fs, "_ffi_rename", FileSystem::Rename);
NODE_SET_METHOD(fs, "_ffi_stat", FileSystem::Stat);
NODE_SET_METHOD(fs, "strerror", FileSystem::StrError);
fs->Set(String::NewSymbol("STDIN_FILENO"), Integer::New(STDIN_FILENO));
fs->Set(String::NewSymbol("STDOUT_FILENO"), Integer::New(STDOUT_FILENO));
fs->Set(String::NewSymbol("STDERR_FILENO"), Integer::New(STDERR_FILENO));
// file methods
JS_SET_METHOD(file_template->InstanceTemplate(), "_ffi_open", File::Open);
JS_SET_METHOD(file_template->InstanceTemplate(), "_ffi_close", File::Close);
JS_SET_METHOD(file_template->InstanceTemplate(), "_ffi_write", File::Write);
JS_SET_METHOD(file_template->InstanceTemplate(), "_ffi_read", File::Read);
NODE_SET_METHOD(file_template->InstanceTemplate(), "_ffi_open", File::Open);
NODE_SET_METHOD(file_template->InstanceTemplate(), "_ffi_close", File::Close);
NODE_SET_METHOD(file_template->InstanceTemplate(), "_ffi_write", File::Write);
NODE_SET_METHOD(file_template->InstanceTemplate(), "_ffi_read", File::Read);
}

View File

@ -87,7 +87,7 @@ ExecuteString(v8::Handle<v8::String> source,
return scope.Close(result);
}
JS_METHOD(compile)
NODE_METHOD(compile)
{
if (args.Length() < 2)
return Undefined();
@ -102,7 +102,7 @@ JS_METHOD(compile)
return scope.Close(result);
}
JS_METHOD(debug)
NODE_METHOD(debug)
{
if (args.Length() < 1)
return Undefined();
@ -194,8 +194,8 @@ main (int argc, char *argv[])
Local<Object> node = Object::New();
g->Set(String::New("node"), node);
JS_SET_METHOD(node, "compile", compile);
JS_SET_METHOD(node, "debug", debug);
NODE_SET_METHOD(node, "compile", compile);
NODE_SET_METHOD(node, "debug", debug);
Local<Array> arguments = Array::New(argc);
for (int i = 0; i < argc; i++) {

View File

@ -5,10 +5,10 @@
#include <eio.h>
#include <v8.h>
#define JS_SYMBOL(name) v8::String::NewSymbol(name)
#define JS_METHOD(name) v8::Handle<v8::Value> name (const v8::Arguments& args)
#define JS_SET_METHOD(obj, name, callback) \
obj->Set(JS_SYMBOL(name), v8::FunctionTemplate::New(callback)->GetFunction())
#define NODE_SYMBOL(name) v8::String::NewSymbol(name)
#define NODE_METHOD(name) v8::Handle<v8::Value> name (const v8::Arguments& args)
#define NODE_SET_METHOD(obj, name, callback) \
obj->Set(NODE_SYMBOL(name), v8::FunctionTemplate::New(callback)->GetFunction())
enum encoding {UTF8, RAW};

View File

@ -99,8 +99,7 @@ UnwrapTimeoutID (Handle<External> timeoutID)
//
// * delay is the number of milliseconds (thousandths of a second) that the
// function call should be delayed by.
static Handle<Value>
setTimeout(const Arguments& args)
NODE_METHOD(setTimeout)
{
if (args.Length() < 2)
return Undefined();
@ -108,7 +107,7 @@ setTimeout(const Arguments& args)
HandleScope scope;
Local<Function> callback = Local<Function>::Cast(args[0]);
uint32_t delay = args[1]->Uint32Value();
int delay = args[1]->IntegerValue();
ev_tstamp after = (double)delay / 1000.0;
@ -132,9 +131,7 @@ setTimeout(const Arguments& args)
}
// clearTimeout(timeoutID)
static Handle<Value> clearTimeout
( const Arguments& args
)
NODE_METHOD(clearTimeout)
{
if (args.Length() < 1)
return Undefined();
@ -161,9 +158,7 @@ static Handle<Value> clearTimeout
//
// * delay is the number of milliseconds (thousandths of a second) that the
// setInterval() function should wait before each call to func.
static Handle<Value> setInterval
( const Arguments& args
)
NODE_METHOD(setInterval)
{
if (args.Length() < 2)
return Undefined();
@ -171,7 +166,7 @@ static Handle<Value> setInterval
HandleScope scope;
Local<Function> callback = Local<Function>::Cast(args[0]);
uint32_t delay = args[1]->Uint32Value();
int delay = args[1]->IntegerValue();
ev_tstamp after = (double)delay / 1000.0;
@ -192,19 +187,8 @@ NodeInit_timers (Handle<Object> target)
{
HandleScope scope;
target->Set ( String::New("setTimeout")
, FunctionTemplate::New(setTimeout)->GetFunction()
);
target->Set ( String::New("clearTimeout")
, FunctionTemplate::New(clearTimeout)->GetFunction()
);
target->Set ( String::New("setInterval")
, FunctionTemplate::New(setInterval)->GetFunction()
);
target->Set ( String::New("clearInterval")
, FunctionTemplate::New(clearTimeout)->GetFunction()
);
NODE_SET_METHOD(target, "setTimeout", setTimeout);
NODE_SET_METHOD(target, "clearTimeout", clearTimeout);
NODE_SET_METHOD(target, "setInterval", setInterval);
NODE_SET_METHOD(target, "clearInterval", clearTimeout);
}