--- libev/ev++.h 2008/11/05 14:36:18 1.43 +++ libev/ev++.h 2008/12/03 15:23:44 1.44 @@ -162,24 +162,14 @@ } #if EV_MULTIPLICITY - bool operator == (struct ev_loop *other) const throw () + bool operator == (const EV_P) const throw () { - return this->EV_AX == other; + return this->EV_AX == EV_A; } - bool operator != (struct ev_loop *other) const throw () + bool operator != (const EV_P) const throw () { - return ! (*this == other); - } - - bool operator == (const struct ev_loop *other) const throw () - { - return this->EV_AX == other; - } - - bool operator != (const struct ev_loop *other) const throw () - { - return (*this == other); + return (*this == EV_A); } operator struct ev_loop * () const throw () @@ -253,7 +243,7 @@ } // function callback - void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void* arg = 0) throw () + void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw () { ev_once (EV_AX_ fd, events, timeout, cb, arg); } @@ -265,28 +255,21 @@ once (fd, events, timeout, method_thunk, object); } - template - static void method_thunk (int revents, void* arg) - { - K *obj = static_cast(arg); - (obj->*method) (revents); - } - - // const method callback - template - void once (int fd, int events, tstamp timeout, const K *object) throw () + // default method == operator () + template + void once (int fd, int events, tstamp timeout, K *object) throw () { - once (fd, events, timeout, const_method_thunk, object); + once (fd, events, timeout, method_thunk, object); } - template - static void const_method_thunk (int revents, void* arg) + template + static void method_thunk (int revents, void *arg) { - K *obj = static_cast(arg); - (obj->*method) (revents); + static_cast(arg)->*method + (revents); } - // simple method callback + // no-argument method callback template void once (int fd, int events, tstamp timeout, K *object) throw () { @@ -294,10 +277,10 @@ } template - static void method_noargs_thunk (int revents, void* arg) + static void method_noargs_thunk (int revents, void *arg) { - K *obj = static_cast(arg); - (obj->*method) (); + static_cast(arg)->*method + (); } // simpler function callback @@ -308,9 +291,10 @@ } template - static void simpler_func_thunk (int revents, void* arg) + static void simpler_func_thunk (int revents, void *arg) { - (*cb) (revents); + (*cb) + (revents); } // simplest function callback @@ -321,9 +305,10 @@ } template - static void simplest_func_thunk (int revents, void* arg) + static void simplest_func_thunk (int revents, void *arg) { - (*cb) (); + (*cb) + (); } void feed_fd_event (int fd, int revents) throw () @@ -423,7 +408,7 @@ #if EV_MULTIPLICITY EV_PX; - void set (EV_PX) throw () + void set (EV_P) throw () { this->EV_A = EV_A; } @@ -437,54 +422,48 @@ ev_init (this, 0); } - void set_ (void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw () + void set_ (const void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw () { - this->data = data; + this->data = (void *)data; ev_set_cb (static_cast(this), cb); } - // method callback - template - void set (K *object) throw () - { - set_ (object, method_thunk); - } - - template - static void method_thunk (EV_P_ ev_watcher *w, int revents) + // function callback + template + void set (void *data = 0) throw () { - K *obj = static_cast(w->data); - (obj->*method) (*static_cast(w), revents); + set_ (data, function_thunk); } - // const method callback - template - void set (const K *object) throw () + template + static void function_thunk (EV_P_ ev_watcher *w, int revents) { - set_ (object, const_method_thunk); + function + (*static_cast(w), revents); } - template - static void const_method_thunk (EV_P_ ev_watcher *w, int revents) + // method callback + template + void set (K *object) throw () { - K *obj = static_cast(w->data); - (static_cast(w->data)->*method) (*static_cast(w), revents); + set_ (object, method_thunk); } - // function callback - template - void set (void *data = 0) throw () + // default method == operator () + template + void set (K *object) throw () { - set_ (data, function_thunk); + set_ (object, method_thunk); } - template - static void function_thunk (EV_P_ ev_watcher *w, int revents) + template + static void method_thunk (EV_P_ ev_watcher *w, int revents) { - function (*static_cast(w), revents); + (static_cast(w->data)->*method) + (*static_cast(w), revents); } - // simple callback + // no-argument callback template void set (K *object) throw () { @@ -494,14 +473,15 @@ template static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) { - K *obj = static_cast(w->data); - (obj->*method) (); + static_cast(w->data)->*method + (); } void operator ()(int events = EV_UNDEF) { - return ev_cb (static_cast(this)) - (static_cast(this), events); + return + ev_cb (static_cast(this)) + (static_cast(this), events); } bool is_active () const throw ()