diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-05-26 20:04:17 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-05-30 00:12:49 +0200 |
commit | 448adaa4563fb035c5fccfe4a9a0cc74b5ca5ba0 (patch) | |
tree | 16c59ba2097f4862ff677e3da10588d830788e3f /src | |
parent | 4d68daea0f3b092743a7793748f684c2827d6210 (diff) | |
download | node-new-448adaa4563fb035c5fccfe4a9a0cc74b5ca5ba0.tar.gz |
src: simplify HandleWrap initialization
Diffstat (limited to 'src')
-rw-r--r-- | src/fs_event_wrap.cc | 1 | ||||
-rw-r--r-- | src/handle_wrap.cc | 10 | ||||
-rw-r--r-- | src/handle_wrap.h | 2 | ||||
-rw-r--r-- | src/pipe_wrap.cc | 1 | ||||
-rw-r--r-- | src/process_wrap.cc | 9 | ||||
-rw-r--r-- | src/stream_wrap.cc | 10 | ||||
-rw-r--r-- | src/stream_wrap.h | 1 | ||||
-rw-r--r-- | src/timer_wrap.cc | 1 | ||||
-rw-r--r-- | src/udp_wrap.cc | 1 |
9 files changed, 7 insertions, 29 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 69d3b155e6..f767db037c 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -53,7 +53,6 @@ private: FSEventWrap::FSEventWrap(Handle<Object> object) : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) { - handle_.data = static_cast<void*>(this); initialized_ = false; } diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 07f19ad222..390f686425 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -108,9 +108,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) { HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) { flags_ = 0; handle__ = h; - if (h) { - h->data = this; - } + handle__->data = this; HandleScope scope(node_isolate); assert(object_.IsEmpty()); @@ -121,12 +119,6 @@ HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) { } -void HandleWrap::SetHandle(uv_handle_t* h) { - handle__ = h; - h->data = this; -} - - HandleWrap::~HandleWrap() { assert(object_.IsEmpty()); ngx_queue_remove(&handle_wrap_queue_); diff --git a/src/handle_wrap.h b/src/handle_wrap.h index fcd9fb2cc7..d77485cdf6 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -65,8 +65,6 @@ class HandleWrap { HandleWrap(v8::Handle<v8::Object> object, uv_handle_t* handle); virtual ~HandleWrap(); - virtual void SetHandle(uv_handle_t* h); - v8::Persistent<v8::Object> object_; private: diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index dd2cbd6fb1..6449eebab9 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -139,7 +139,6 @@ PipeWrap::PipeWrap(Handle<Object> object, bool ipc) int r = uv_pipe_init(uv_default_loop(), &handle_, ipc); assert(r == 0); // How do we proxy this error up to javascript? // Suggestion: uv_pipe_init() returns void. - handle_.data = static_cast<void*>(this); UpdateWriteQueueSize(); } diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 8ed8976f77..02984976d2 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -87,8 +87,12 @@ class ProcessWrap : public HandleWrap { return scope.Close(args.This()); } - ProcessWrap(Handle<Object> object) : HandleWrap(object, NULL) { } - ~ProcessWrap() { } + ProcessWrap(Handle<Object> object) + : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&process_)) { + } + + ~ProcessWrap() { + } static void ParseStdioOptions(Local<Object> js_options, uv_process_options_t* options) { @@ -248,7 +252,6 @@ class ProcessWrap : public HandleWrap { SetErrno(uv_last_error(uv_default_loop())); } else { - wrap->SetHandle(reinterpret_cast<uv_handle_t*>(&wrap->process_)); assert(wrap->process_.data == wrap); wrap->object_->Set(String::New("pid"), Integer::New(wrap->process_.pid, node_isolate)); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index aaf4491c4e..61527ed0a3 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -112,9 +112,6 @@ void StreamWrap::Initialize(Handle<Object> target) { StreamWrap::StreamWrap(Handle<Object> object, uv_stream_t* stream) : HandleWrap(object, reinterpret_cast<uv_handle_t*>(stream)) { stream_ = stream; - if (stream) { - stream->data = this; - } } @@ -131,13 +128,6 @@ Handle<Value> StreamWrap::GetFD(Local<String>, const AccessorInfo& args) { } -void StreamWrap::SetHandle(uv_handle_t* h) { - HandleWrap::SetHandle(h); - stream_ = reinterpret_cast<uv_stream_t*>(h); - stream_->data = this; -} - - void StreamWrap::UpdateWriteQueueSize() { HandleScope scope(node_isolate); object_->Set(write_queue_size_sym, diff --git a/src/stream_wrap.h b/src/stream_wrap.h index ff355ed00b..8b58c8af68 100644 --- a/src/stream_wrap.h +++ b/src/stream_wrap.h @@ -57,7 +57,6 @@ class StreamWrap : public HandleWrap { static size_t WriteBuffer(v8::Handle<v8::Value> val, uv_buf_t* buf); StreamWrap(v8::Handle<v8::Object> object, uv_stream_t* stream); - virtual void SetHandle(uv_handle_t* h); void StateChange() { } void UpdateWriteQueueSize(); diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index 5e8ab051a6..a36cdabacd 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -86,7 +86,6 @@ class TimerWrap : public HandleWrap { : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) { int r = uv_timer_init(uv_default_loop(), &handle_); assert(r == 0); - handle_.data = this; } ~TimerWrap() { diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index f014a62cc6..b463a75c83 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -69,7 +69,6 @@ UDPWrap::UDPWrap(Handle<Object> object) : HandleWrap(object, reinterpret_cast<uv_handle_t*>(&handle_)) { int r = uv_udp_init(uv_default_loop(), &handle_); assert(r == 0); // can't fail anyway - handle_.data = reinterpret_cast<void*>(this); } |