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

Comparing libev/ev++.h (file contents):
Revision 1.13 by root, Tue Dec 4 16:23:29 2007 UTC vs.
Revision 1.19 by root, Fri Dec 14 17:47:52 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_watcher *w, int revents)) 25 void set_ (void *data, void (*cb)(EV_P_ ev_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<ev_watcher *>(this), cb);
29 } 29 }
30 30
31 // method callback
31 template<class K, void (K::*method)(watcher &w, int)> 32 template<class K, void (K::*method)(watcher &w, int)>
32 void set (K *object) 33 void set (K *object)
33 { 34 {
34 set_ (object, method_thunk<K, method>); 35 set_ (object, method_thunk<K, method>);
35 } 36 }
36 37
37 template<class K, void (K::*method)(watcher &w, int)> 38 template<class K, void (K::*method)(watcher &w, int)>
38 static void method_thunk (ev_watcher *w, int revents) 39 static void method_thunk (EV_P_ ev_watcher *w, int revents)
39 { 40 {
40 watcher *self = static_cast<watcher *>(w);
41 K *obj = static_cast<K *>(self->data); 41 K *obj = static_cast<K *>(w->data);
42 (obj->*method) (*self, revents); 42 (obj->*method) (*static_cast<watcher *>(w), revents);
43 } 43 }
44 44
45 // const method callback
45 template<class K, void (K::*method)(watcher &w, int) const> 46 template<class K, void (K::*method)(watcher &w, int) const>
46 void set (const K *object) 47 void set (const K *object)
47 { 48 {
48 set_ (object, const_method_thunk<K, method>); 49 set_ (object, const_method_thunk<K, method>);
49 } 50 }
50 51
51 template<class K, void (K::*method)(watcher &w, int) const> 52 template<class K, void (K::*method)(watcher &w, int) const>
52 static void const_method_thunk (ev_watcher *w, int revents) 53 static void const_method_thunk (EV_P_ ev_watcher *w, int revents)
53 { 54 {
54 watcher *self = static_cast<watcher *>(w);
55 K *obj = static_cast<K *>(self->data); 55 K *obj = static_cast<K *>(w->data);
56 (obj->*method) (*self, revents); 56 (static_cast<K *>(w->data)->*method) (*static_cast<watcher *>(w), revents);
57 } 57 }
58 58
59 // function callback
59 template<void (*function)(watcher &w, int)> 60 template<void (*function)(watcher &w, int)>
60 void set () 61 void set (void *data = 0)
61 { 62 {
62 set_ (0, function_thunk<function>); 63 set_ (data, function_thunk<function>);
63 } 64 }
64 65
65 template<void (*function)(watcher &w, int)> 66 template<void (*function)(watcher &w, int)>
66 static void function_thunk (ev_watcher *w, int revents) 67 static void function_thunk (EV_P_ ev_watcher *w, int revents)
68 {
69 function (*static_cast<watcher *>(w), revents);
67 { 70 }
68 watcher *self = static_cast<watcher *>(w); 71
69 function (*self, revents); 72 // simple callback
73 template<class K, void (K::*method)()>
74 void set (K *object)
75 {
76 set_ (object, method_noargs_thunk<K, method>);
77 }
78
79 template<class K, void (K::*method)()>
80 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
81 {
82 K *obj = static_cast<K *>(w->data);
83 (obj->*method) ();
70 } 84 }
71 85
72 void operator ()(int events = EV_UNDEF) 86 void operator ()(int events = EV_UNDEF)
73 { 87 {
74 return e_cb (static_cast<ev_watcher *>(this)) (events); 88 return ev_cb (static_cast<ev_watcher *>(this))
89 (static_cast<ev_watcher *>(this), events);
75 } 90 }
76 91
77 bool is_active () const 92 bool is_active () const
78 { 93 {
79 return ev_is_active (static_cast<const ev_watcher *>(this)); 94 return ev_is_active (static_cast<const ev_watcher *>(this));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines