diff --git a/src/http.cc b/src/http.cc index a63c9537d38..fae75c971cc 100644 --- a/src/http.cc +++ b/src/http.cc @@ -70,7 +70,6 @@ appendHeaderValue (Handle message, Handle d) _append_header_value->Call(message->ToObject(), 2, argv); } - Persistent HTTPConnection::constructor_template; void @@ -79,11 +78,11 @@ HTTPConnection::Initialize (Handle target) HandleScope scope; Local t = FunctionTemplate::New(HTTPConnection::v8NewClient); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->Inherit(Connection::constructor_template); - target->Set(String::NewSymbol("HTTPClient"), t->GetFunction()); - constructor_template = Persistent::New(t); + + constructor_template->Inherit(Connection::constructor_template); + constructor_template->InstanceTemplate()->SetInternalFieldCount(1); + target->Set(String::NewSymbol("HTTPClient"), constructor_template->GetFunction()); } Handle diff --git a/src/net.cc b/src/net.cc index 457f7996621..17d2c687306 100644 --- a/src/net.cc +++ b/src/net.cc @@ -49,15 +49,16 @@ Connection::Initialize (v8::Handle target) HandleScope scope; Local t = FunctionTemplate::New(v8New); - t->InstanceTemplate()->SetInternalFieldCount(1); - target->Set(String::NewSymbol("TCPConnection"), t->GetFunction()); - - NODE_SET_METHOD(t->InstanceTemplate(), "connect", v8Connect); - NODE_SET_METHOD(t->InstanceTemplate(), "close", v8Close); - NODE_SET_METHOD(t->InstanceTemplate(), "send", v8Send); - NODE_SET_METHOD(t->InstanceTemplate(), "sendEOF", v8SendEOF); constructor_template = Persistent::New(t); + constructor_template->InstanceTemplate()->SetInternalFieldCount(1); + + NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "connect", v8Connect); + NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "close", v8Close); + NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "send", v8Send); + NODE_SET_METHOD(constructor_template->PrototypeTemplate(), "sendEOF", v8SendEOF); + + target->Set(String::NewSymbol("TCPConnection"), constructor_template->GetFunction()); } Connection::Connection (Handle handle, Handle protocol_class) diff --git a/src/node.cc b/src/node.cc index 7a556fac3c7..3d236753e7a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -245,10 +245,11 @@ main (int argc, char *argv[]) // BUILT-IN MODULES - Acceptor::Initialize(g); - Connection::Initialize(g); node::Init_timer(g); node::Init_file(g); + + Acceptor::Initialize(g); + Connection::Initialize(g); HTTPConnection::Initialize(g); // NATIVE JAVASCRIPT MODULES