… | |
… | |
93 | |
93 | |
94 | /* using a template here would require quite a bit more lines, |
94 | /* using a template here would require quite a bit more lines, |
95 | * so a macro solution was chosen */ |
95 | * so a macro solution was chosen */ |
96 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
96 | #define EV_BEGIN_WATCHER(cppstem,cstem) \ |
97 | \ |
97 | \ |
98 | static void cb_ ## cppstem (EV_P_ struct ev_ ## cstem *w, int revents); \ |
|
|
99 | \ |
|
|
100 | struct cppstem : ev_ ## cstem, callback<cppstem> \ |
98 | struct cppstem : ev_ ## cstem, callback<cppstem> \ |
101 | { \ |
99 | { \ |
102 | EV_CONSTRUCT (cppstem) \ |
100 | EV_CONSTRUCT (cppstem) \ |
103 | { \ |
101 | { \ |
104 | ev_init (static_cast<ev_ ## cstem *>(this), cb_ ## cppstem); \ |
102 | ev_init (static_cast<ev_ ## cstem *>(this), thunk); \ |
105 | } \ |
103 | } \ |
106 | \ |
104 | \ |
107 | bool is_active () const \ |
105 | bool is_active () const \ |
108 | { \ |
106 | { \ |
109 | return ev_is_active (static_cast<const ev_ ## cstem *>(this)); \ |
107 | return ev_is_active (static_cast<const ev_ ## cstem *>(this)); \ |
… | |
… | |
137 | private: \ |
135 | private: \ |
138 | \ |
136 | \ |
139 | cppstem (const cppstem &o) \ |
137 | cppstem (const cppstem &o) \ |
140 | : callback<cppstem> (this, (void (cppstem::*)(cppstem &, int))0) \ |
138 | : callback<cppstem> (this, (void (cppstem::*)(cppstem &, int))0) \ |
141 | { /* disabled */ } \ |
139 | { /* disabled */ } \ |
|
|
140 | \ |
142 | void operator =(const cppstem &o) { /* disabled */ } \ |
141 | void operator =(const cppstem &o) { /* disabled */ } \ |
143 | \ |
142 | \ |
|
|
143 | static void thunk (EV_P_ struct ev_ ## cstem *w, int revents) \ |
|
|
144 | { \ |
|
|
145 | (*static_cast<cppstem *>(w))(revents); \ |
|
|
146 | } \ |
|
|
147 | \ |
144 | public: |
148 | public: |
145 | |
149 | |
146 | #define EV_END_WATCHER(cppstem,cstem) \ |
150 | #define EV_END_WATCHER(cppstem,cstem) \ |
147 | }; \ |
|
|
148 | \ |
|
|
149 | static void cb_ ## cppstem (EV_P_ struct ev_ ## cstem *w, int revents) \ |
|
|
150 | { \ |
|
|
151 | (*static_cast<cppstem *>(w))(revents); \ |
|
|
152 | } |
151 | }; |
153 | |
152 | |
154 | EV_BEGIN_WATCHER (io, io) |
153 | EV_BEGIN_WATCHER (io, io) |
155 | void set (int fd, int events) |
154 | void set (int fd, int events) |
156 | { |
155 | { |
157 | int active = is_active (); |
156 | int active = is_active (); |