… | |
… | |
20 | base () |
20 | base () |
21 | { |
21 | { |
22 | ev_init (this, 0); |
22 | ev_init (this, 0); |
23 | } |
23 | } |
24 | |
24 | |
25 | void set_ (void *object, void (*cb)(ev_watcher *w, int revents)) |
25 | void set_ (void *object, void (*cb)(EV_P_ ev_watcher *w, int revents)) |
26 | { |
26 | { |
27 | this->data = object; |
27 | this->data = object; |
28 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
28 | ev_set_cb (static_cast<ev_watcher *>(this), cb); |
29 | } |
29 | } |
30 | |
30 | |
… | |
… | |
33 | { |
33 | { |
34 | set_ (object, method_thunk<K, method>); |
34 | set_ (object, method_thunk<K, method>); |
35 | } |
35 | } |
36 | |
36 | |
37 | template<class K, void (K::*method)(watcher &w, int)> |
37 | template<class K, void (K::*method)(watcher &w, int)> |
38 | static void method_thunk (ev_watcher *w, int revents) |
38 | static void method_thunk (EV_P_ ev_watcher *w, int revents) |
39 | { |
39 | { |
40 | watcher *self = static_cast<watcher *>(w); |
40 | watcher *self = static_cast<watcher *>(w); |
41 | K *obj = static_cast<K *>(self->data); |
41 | K *obj = static_cast<K *>(self->data); |
42 | (obj->*method) (*self, revents); |
42 | (obj->*method) (*self, revents); |
43 | } |
43 | } |
… | |
… | |
47 | { |
47 | { |
48 | set_ (object, const_method_thunk<K, method>); |
48 | set_ (object, const_method_thunk<K, method>); |
49 | } |
49 | } |
50 | |
50 | |
51 | template<class K, void (K::*method)(watcher &w, int) const> |
51 | template<class K, void (K::*method)(watcher &w, int) const> |
52 | static void const_method_thunk (ev_watcher *w, int revents) |
52 | static void const_method_thunk (EV_P_ ev_watcher *w, int revents) |
53 | { |
53 | { |
54 | watcher *self = static_cast<watcher *>(w); |
54 | watcher *self = static_cast<watcher *>(w); |
55 | K *obj = static_cast<K *>(self->data); |
55 | K *obj = static_cast<K *>(self->data); |
56 | (obj->*method) (*self, revents); |
56 | (obj->*method) (*self, revents); |
57 | } |
57 | } |
… | |
… | |
61 | { |
61 | { |
62 | set_ (0, function_thunk<function>); |
62 | set_ (0, function_thunk<function>); |
63 | } |
63 | } |
64 | |
64 | |
65 | template<void (*function)(watcher &w, int)> |
65 | template<void (*function)(watcher &w, int)> |
66 | static void function_thunk (ev_watcher *w, int revents) |
66 | static void function_thunk (EV_P_ ev_watcher *w, int revents) |
67 | { |
67 | { |
68 | watcher *self = static_cast<watcher *>(w); |
68 | watcher *self = static_cast<watcher *>(w); |
69 | function (*self, revents); |
69 | function (*self, revents); |
70 | } |
70 | } |
71 | |
71 | |