diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2009-12-28 16:18:03 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2009-12-29 21:12:32 +0100 |
commit | 153b75593678a801985ce27a2af0d2235dcf74d3 (patch) | |
tree | fc82eaa1d5d93581dae79672a9981b4861648643 /src/node_io_watcher.cc | |
parent | 6e5abf4551634ee27d6e3a25499ec6f4f94215c0 (diff) | |
download | node-153b75593678a801985ce27a2af0d2235dcf74d3.tar.gz |
Change IOWatcher constructor to have no arguments
Diffstat (limited to 'src/node_io_watcher.cc')
-rw-r--r-- | src/node_io_watcher.cc | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/node_io_watcher.cc b/src/node_io_watcher.cc index 3c60a7bac..4a2d9378d 100644 --- a/src/node_io_watcher.cc +++ b/src/node_io_watcher.cc @@ -37,7 +37,11 @@ void IOWatcher::Callback(EV_P_ ev_io *w, int revents) { HandleScope scope; Local<Value> callback_v = io->handle_->Get(callback_symbol); - assert(callback_v->IsFunction()); + if (!callback_v->IsFunction()) { + io->Stop(); + return; + } + Local<Function> callback = Local<Function>::Cast(callback_v); TryCatch try_catch; @@ -64,19 +68,9 @@ void IOWatcher::Callback(EV_P_ ev_io *w, int revents) { Handle<Value> IOWatcher::New(const Arguments& args) { HandleScope scope; - if (!args[0]->IsFunction()) { - return ThrowException(Exception::TypeError( - String::New("First arg should a callback."))); - } - - Local<Function> callback = Local<Function>::Cast(args[0]); - IOWatcher *s = new IOWatcher(); - s->Wrap(args.This()); - s->handle_->Set(callback_symbol, callback); - return args.This(); } @@ -136,7 +130,6 @@ Handle<Value> IOWatcher::Stop(const Arguments& args) { void IOWatcher::Stop () { if (watcher_.active) { - HandleScope scope; ev_io_stop(EV_DEFAULT_UC_ &watcher_); Unref(); } |