diff --git a/src/http.cc b/src/http.cc index bed07efc724..45e2f95b3c8 100644 --- a/src/http.cc +++ b/src/http.cc @@ -78,13 +78,13 @@ HTTPConnection::Initialize (Handle target) { HandleScope scope; - Local t = FunctionTemplate::New(HTTPConnection::v8NewClient); + Local t = FunctionTemplate::New(v8NewClient); client_constructor_template = Persistent::New(t); client_constructor_template->Inherit(Connection::constructor_template); client_constructor_template->InstanceTemplate()->SetInternalFieldCount(1); target->Set(String::NewSymbol("HTTPClient"), client_constructor_template->GetFunction()); - t = FunctionTemplate::New(HTTPConnection::v8NewServer); + t = FunctionTemplate::New(v8NewServer); server_constructor_template = Persistent::New(t); server_constructor_template->Inherit(Connection::constructor_template); server_constructor_template->InstanceTemplate()->SetInternalFieldCount(1); @@ -298,9 +298,8 @@ HTTPServer::Initialize (Handle target) { HandleScope scope; - Local t = FunctionTemplate::New(HTTPServer::v8New); + Local t = FunctionTemplate::New(v8New); constructor_template = Persistent::New(t); - constructor_template->Inherit(Acceptor::constructor_template); constructor_template->InstanceTemplate()->SetInternalFieldCount(1); target->Set(String::NewSymbol("HTTPServer"), constructor_template->GetFunction()); @@ -323,7 +322,7 @@ HTTPServer::v8New (const Arguments& args) options = Object::New(); } - new HTTPServer(args.Holder(), protocol_class, options); + new HTTPServer(args.This(), protocol_class, options); return args.This(); } diff --git a/src/http.h b/src/http.h index df8959145e1..1fb3abbd9f1 100644 --- a/src/http.h +++ b/src/http.h @@ -43,15 +43,15 @@ protected: class HTTPServer : public Acceptor { public: static void Initialize (v8::Handle target); + static v8::Persistent constructor_template; protected: - static v8::Persistent constructor_template; static v8::Handle v8New (const v8::Arguments& args); HTTPServer (v8::Handle handle, v8::Handle protocol_class, v8::Handle options) - :Acceptor(handle, protocol_class, options) {}; + : Acceptor(handle, protocol_class, options) {} Connection* OnConnection (struct sockaddr *addr, socklen_t len); }; diff --git a/src/net.cc b/src/net.cc index 02814f89be9..e1a8e8643df 100644 --- a/src/net.cc +++ b/src/net.cc @@ -342,13 +342,14 @@ Acceptor::Initialize (Handle target) HandleScope scope; Local t = FunctionTemplate::New(v8New); - t->InstanceTemplate()->SetInternalFieldCount(1); - target->Set(String::NewSymbol("TCPServer"), t->GetFunction()); - - NODE_SET_METHOD(t->InstanceTemplate(), "listen", v8Listen); - NODE_SET_METHOD(t->InstanceTemplate(), "close", v8Close); - constructor_template = Persistent::New(t); + + constructor_template->InstanceTemplate()->SetInternalFieldCount(1); + + NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "listen", v8Listen); + NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "close", v8Close); + + target->Set(String::NewSymbol("TCPServer"), constructor_template->GetFunction()); } Acceptor::Acceptor (Handle handle, Handle protocol_class, Handle options) diff --git a/src/node.cc b/src/node.cc index b53de86fac3..4b8863e9f10 100644 --- a/src/node.cc +++ b/src/node.cc @@ -251,8 +251,8 @@ main (int argc, char *argv[]) Acceptor::Initialize(g); Connection::Initialize(g); - HTTPConnection::Initialize(g); HTTPServer::Initialize(g); + HTTPConnection::Initialize(g); // NATIVE JAVASCRIPT MODULES TryCatch try_catch;