Browse Source

Introduce NODE_SET_PROTOTYPE_METHOD which properly sets the signature.

v0.7.4-release
Ryan 16 years ago
parent
commit
427e3f5dcb
  1. 8
      src/file.cc
  2. 6
      src/http.js
  3. 14
      src/net.cc
  4. 1
      src/node.cc
  5. 8
      src/node.h
  6. 14
      src/timer.cc
  7. 2
      src/timer.h
  8. 3
      wscript

8
src/file.cc

@ -42,10 +42,10 @@ File::Initialize (Handle<Object> target)
file_template->InstanceTemplate()->SetInternalFieldCount(1);
// file methods
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);
NODE_SET_PROTOTYPE_METHOD(file_template, "_ffi_open", File::Open);
NODE_SET_PROTOTYPE_METHOD(file_template, "_ffi_close", File::Close);
NODE_SET_PROTOTYPE_METHOD(file_template, "_ffi_write", File::Write);
NODE_SET_PROTOTYPE_METHOD(file_template, "_ffi_read", File::Read);
file_template->InstanceTemplate()->SetAccessor(ENCODING_SYMBOL, File::GetEncoding, File::SetEncoding);

6
src/http.js

@ -47,7 +47,9 @@ var close_expression = /close/i;
var chunk_expression = /chunk/i;
var content_length_expression = /Content-Length/i;
node.http.server = function (RequestHandler, options) {
node.http.Server = function (RequestHandler, options) {
if (!(this instanceof node.http.Server))
throw Error("Constructor called as a function");
function Protocol (connection) {
@ -260,5 +262,5 @@ node.http.server = function (RequestHandler, options) {
};
}
return new node.http.LowLevelServer(Protocol, options);
this.__proto__.__proto__ = new node.http.LowLevelServer(Protocol, options);
};

14
src/net.cc

@ -51,11 +51,11 @@ Connection::Initialize (v8::Handle<v8::Object> target)
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "connect", v8Connect);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "send", v8Send);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "close", v8Close);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "fullClose", v8FullClose);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "forceClose", v8ForceClose);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "connect", v8Connect);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "send", v8Send);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "close", v8Close);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "fullClose", v8FullClose);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "forceClose", v8ForceClose);
target->Set(String::NewSymbol("TCPConnection"), constructor_template->GetFunction());
}
@ -354,8 +354,8 @@ Acceptor::Initialize (Handle<Object> target)
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "listen", v8Listen);
NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "close", v8Close);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "listen", v8Listen);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "close", v8Close);
target->Set(String::NewSymbol("TCPServer"), constructor_template->GetFunction());
}

1
src/node.cc

@ -178,6 +178,7 @@ NODE_METHOD(debug)
static void
OnFatalError (const char* location, const char* message)
{
#define FATAL_ERROR "\033[1;31mV8 FATAL ERROR.\033[m"
if (location)
fprintf(stderr, FATAL_ERROR " %s %s\n", location, message);

8
src/node.h

@ -13,6 +13,14 @@ namespace node {
obj->Set(NODE_SYMBOL(name), v8::FunctionTemplate::New(callback)->GetFunction())
#define NODE_UNWRAP(type, value) static_cast<type*>(node::ObjectWrap::Unwrap(value))
#define NODE_SET_PROTOTYPE_METHOD(templ, name, callback) \
do { \
Local<Signature> __callback##_SIG = Signature::New(templ); \
Local<FunctionTemplate> __callback##_TEM = \
FunctionTemplate::New(callback, Handle<Value>() , __callback##_SIG ); \
templ->PrototypeTemplate()->Set(NODE_SYMBOL(name), __callback##_TEM); \
} while(0)
enum encoding {UTF8, RAW};
void fatal_exception (v8::TryCatch &try_catch);
void eio_warmup (void); // call this before creating a new eio event.

14
src/timer.cc

@ -7,17 +7,21 @@ using namespace node;
#define CALLBACK_SYMBOL String::NewSymbol("callback")
Persistent<FunctionTemplate> Timer::constructor_template;
void
Timer::Initialize (Handle<Object> target)
{
HandleScope scope;
Local<FunctionTemplate> timer_template = FunctionTemplate::New(Timer::New);
timer_template->InstanceTemplate()->SetInternalFieldCount(1);
target->Set(String::NewSymbol("Timer"), timer_template->GetFunction());
Local<FunctionTemplate> t = FunctionTemplate::New(Timer::New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "start", Timer::Start);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "stop", Timer::Stop);
NODE_SET_METHOD(timer_template->InstanceTemplate(), "start", Timer::Start);
NODE_SET_METHOD(timer_template->InstanceTemplate(), "stop", Timer::Stop);
target->Set(String::NewSymbol("Timer"), constructor_template->GetFunction());
}
void

2
src/timer.h

@ -12,6 +12,8 @@ class Timer : ObjectWrap {
static void Initialize (v8::Handle<v8::Object> target);
protected:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
Timer(v8::Handle<v8::Object> handle,
v8::Handle<v8::Function> callback,
ev_tstamp after,

3
wscript

@ -53,7 +53,8 @@ def configure(conf):
conf.define("HAVE_CONFIG_H", 1)
conf.env.append_value("CCFLAGS", "-DEIO_STACKSIZE=%d" % (4096*8))
conf.check(lib='rt', uselib_store='RT')
#conf.check(lib='rt', uselib_store='RT')
conf.check(lib='profiler', uselib_store='PROFILER')

Loading…
Cancel
Save