ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev++.h
(Generate patch)

Comparing libev/ev++.h (file contents):
Revision 1.16 by root, Fri Dec 7 20:13:08 2007 UTC vs.
Revision 1.17 by root, Sat Dec 8 14:27:38 2007 UTC

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_P_ ev_watcher *w, int revents)) 25 void set_ (void *data, void (*cb)(EV_P_ watcher *w, int revents))
26 { 26 {
27 this->data = object; 27 this->data = data;
28 ev_set_cb (static_cast<ev_watcher *>(this), cb); 28 ev_set_cb (static_cast<watcher *>(this), cb);
29 } 29 }
30 30
31 template<class K, void (K::*method)(watcher &w, int)> 31 template<class K, void (K::*method)(watcher &w, int)>
32 void set (K *object) 32 void set (K *object)
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_P_ ev_watcher *w, int revents) 38 static void method_thunk (EV_P_ watcher *w, int revents)
39 { 39 {
40 watcher *self = static_cast<watcher *>(w);
41 K *obj = static_cast<K *>(self->data); 40 K *obj = static_cast<K *>(w->data);
42 (obj->*method) (*self, revents); 41 (obj->*method) (*w, revents);
43 } 42 }
44 43
45 template<class K, void (K::*method)(watcher &w, int) const> 44 template<class K, void (K::*method)(watcher &w, int) const>
46 void set (const K *object) 45 void set (const K *object)
47 { 46 {
48 set_ (object, const_method_thunk<K, method>); 47 set_ (object, const_method_thunk<K, method>);
49 } 48 }
50 49
51 template<class K, void (K::*method)(watcher &w, int) const> 50 template<class K, void (K::*method)(watcher &w, int) const>
52 static void const_method_thunk (EV_P_ ev_watcher *w, int revents) 51 static void const_method_thunk (EV_P_ watcher *w, int revents)
53 { 52 {
54 watcher *self = static_cast<watcher *>(w);
55 K *obj = static_cast<K *>(self->data); 53 K *obj = static_cast<K *>(w->data);
56 (obj->*method) (*self, revents); 54 (obj->*method) (*w, revents);
57 } 55 }
58 56
59 template<void (*function)(watcher &w, int), void *data = 0> 57 template<void (*function)(watcher &w, int)>
60 void set () 58 void set (void *data = 0)
61 { 59 {
62 set_ (data, function_thunk<function>); 60 set_ (data, function_thunk<function>);
63 } 61 }
64 62
65 template<void (*function)(watcher &w, int)> 63 template<void (*function)(watcher &w, int)>
66 static void function_thunk (EV_P_ ev_watcher *w, int revents) 64 static void function_thunk (EV_P_ watcher *w, int revents)
67 { 65 {
68 watcher *self = static_cast<watcher *>(w);
69 function (*self, revents); 66 function (*w, revents);
70 } 67 }
71 68
72 void operator ()(int events = EV_UNDEF) 69 void operator ()(int events = EV_UNDEF)
73 { 70 {
74 return ev_cb (static_cast<ev_watcher *>(this)) 71 return ev_cb (static_cast<ev_watcher *>(this))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines