ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/callback.h
Revision: 1.14
Committed: Thu May 22 18:54:32 2014 UTC (9 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_29, rxvt-unicode-rel-9_26, rxvt-unicode-rel-9_25, rxvt-unicode-rel-9_22, rxvt-unicode-rel-9_21, rxvt-unicode-rel-9_30, HEAD
Changes since 1.13: +1 -1 lines
Log Message:
GPLv3

File Contents

# Content
1 // THIS IS A GENERATED FILE: RUN callback.pl to regenerate it
2 // THIS IS A GENERATED FILE: callback.pl is part of the GVPE
3 // THIS IS A GENERATED FILE: distribution.
4
5 /*
6 callback.h -- C++ callback mechanism
7 Copyright (C) 2003-2007 Marc Lehmann <schmorp@schmorp.de>
8
9 This file is part of GVPE.
10
11 GVPE is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with gvpe; if not, write to the Free Software
23 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #ifndef CALLBACK_H__
27 #define CALLBACK_H__
28
29 #define CALLBACK_H_VERSION 3
30
31 template<typename signature>
32 struct callback;
33
34 template<class R>
35 struct callback<R ()>
36 {
37 typedef R (*ptr_type)(void *self);
38
39 template<class K, R (K::*method)()>
40 void set (K *object)
41 {
42 self = object;
43 func = thunk<K, method>;
44 }
45
46 R call () const
47 {
48 return func (self);
49 }
50
51 R operator ()() const
52 {
53 return call ();
54 }
55
56 private:
57
58 void *self;
59 ptr_type func;
60
61 template<class klass, R (klass::*method)()>
62 static R thunk (void *self)
63 {
64 klass *obj = static_cast<klass *>(self);
65 return (obj->*method) ();
66 }
67 };
68
69 template<class R, class A1>
70 struct callback<R (A1)>
71 {
72 typedef R (*ptr_type)(void *self, A1);
73
74 template<class K, R (K::*method)(A1)>
75 void set (K *object)
76 {
77 self = object;
78 func = thunk<K, method>;
79 }
80
81 R call (A1 a1) const
82 {
83 return func (self, a1);
84 }
85
86 R operator ()(A1 a1) const
87 {
88 return call (a1);
89 }
90
91 private:
92
93 void *self;
94 ptr_type func;
95
96 template<class klass, R (klass::*method)(A1)>
97 static R thunk (void *self, A1 a1)
98 {
99 klass *obj = static_cast<klass *>(self);
100 return (obj->*method) (a1);
101 }
102 };
103
104 template<class R, class A1, class A2>
105 struct callback<R (A1, A2)>
106 {
107 typedef R (*ptr_type)(void *self, A1, A2);
108
109 template<class K, R (K::*method)(A1, A2)>
110 void set (K *object)
111 {
112 self = object;
113 func = thunk<K, method>;
114 }
115
116 R call (A1 a1, A2 a2) const
117 {
118 return func (self, a1, a2);
119 }
120
121 R operator ()(A1 a1, A2 a2) const
122 {
123 return call (a1, a2);
124 }
125
126 private:
127
128 void *self;
129 ptr_type func;
130
131 template<class klass, R (klass::*method)(A1, A2)>
132 static R thunk (void *self, A1 a1, A2 a2)
133 {
134 klass *obj = static_cast<klass *>(self);
135 return (obj->*method) (a1, a2);
136 }
137 };
138
139 template<class R, class A1, class A2, class A3>
140 struct callback<R (A1, A2, A3)>
141 {
142 typedef R (*ptr_type)(void *self, A1, A2, A3);
143
144 template<class K, R (K::*method)(A1, A2, A3)>
145 void set (K *object)
146 {
147 self = object;
148 func = thunk<K, method>;
149 }
150
151 R call (A1 a1, A2 a2, A3 a3) const
152 {
153 return func (self, a1, a2, a3);
154 }
155
156 R operator ()(A1 a1, A2 a2, A3 a3) const
157 {
158 return call (a1, a2, a3);
159 }
160
161 private:
162
163 void *self;
164 ptr_type func;
165
166 template<class klass, R (klass::*method)(A1, A2, A3)>
167 static R thunk (void *self, A1 a1, A2 a2, A3 a3)
168 {
169 klass *obj = static_cast<klass *>(self);
170 return (obj->*method) (a1, a2, a3);
171 }
172 };
173
174 template<class R, class A1, class A2, class A3, class A4>
175 struct callback<R (A1, A2, A3, A4)>
176 {
177 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
178
179 template<class K, R (K::*method)(A1, A2, A3, A4)>
180 void set (K *object)
181 {
182 self = object;
183 func = thunk<K, method>;
184 }
185
186 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
187 {
188 return func (self, a1, a2, a3, a4);
189 }
190
191 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
192 {
193 return call (a1, a2, a3, a4);
194 }
195
196 private:
197
198 void *self;
199 ptr_type func;
200
201 template<class klass, R (klass::*method)(A1, A2, A3, A4)>
202 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4)
203 {
204 klass *obj = static_cast<klass *>(self);
205 return (obj->*method) (a1, a2, a3, a4);
206 }
207 };
208
209 template<class R, class A1, class A2, class A3, class A4, class A5>
210 struct callback<R (A1, A2, A3, A4, A5)>
211 {
212 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
213
214 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
215 void set (K *object)
216 {
217 self = object;
218 func = thunk<K, method>;
219 }
220
221 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
222 {
223 return func (self, a1, a2, a3, a4, a5);
224 }
225
226 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
227 {
228 return call (a1, a2, a3, a4, a5);
229 }
230
231 private:
232
233 void *self;
234 ptr_type func;
235
236 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)>
237 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
238 {
239 klass *obj = static_cast<klass *>(self);
240 return (obj->*method) (a1, a2, a3, a4, a5);
241 }
242 };
243
244 template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
245 struct callback<R (A1, A2, A3, A4, A5, A6)>
246 {
247 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
248
249 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
250 void set (K *object)
251 {
252 self = object;
253 func = thunk<K, method>;
254 }
255
256 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
257 {
258 return func (self, a1, a2, a3, a4, a5, a6);
259 }
260
261 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
262 {
263 return call (a1, a2, a3, a4, a5, a6);
264 }
265
266 private:
267
268 void *self;
269 ptr_type func;
270
271 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)>
272 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
273 {
274 klass *obj = static_cast<klass *>(self);
275 return (obj->*method) (a1, a2, a3, a4, a5, a6);
276 }
277 };
278
279 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
280 struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
281 {
282 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
283
284 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
285 void set (K *object)
286 {
287 self = object;
288 func = thunk<K, method>;
289 }
290
291 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
292 {
293 return func (self, a1, a2, a3, a4, a5, a6, a7);
294 }
295
296 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
297 {
298 return call (a1, a2, a3, a4, a5, a6, a7);
299 }
300
301 private:
302
303 void *self;
304 ptr_type func;
305
306 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)>
307 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
308 {
309 klass *obj = static_cast<klass *>(self);
310 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
311 }
312 };
313
314 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
315 struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)>
316 {
317 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8);
318
319 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
320 void set (K *object)
321 {
322 self = object;
323 func = thunk<K, method>;
324 }
325
326 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
327 {
328 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
329 }
330
331 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
332 {
333 return call (a1, a2, a3, a4, a5, a6, a7, a8);
334 }
335
336 private:
337
338 void *self;
339 ptr_type func;
340
341 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
342 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
343 {
344 klass *obj = static_cast<klass *>(self);
345 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
346 }
347 };
348
349 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
350 struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>
351 {
352 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9);
353
354 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
355 void set (K *object)
356 {
357 self = object;
358 func = thunk<K, method>;
359 }
360
361 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
362 {
363 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
364 }
365
366 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
367 {
368 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
369 }
370
371 private:
372
373 void *self;
374 ptr_type func;
375
376 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
377 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
378 {
379 klass *obj = static_cast<klass *>(self);
380 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9);
381 }
382 };
383
384 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
385 struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
386 {
387 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
388
389 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
390 void set (K *object)
391 {
392 self = object;
393 func = thunk<K, method>;
394 }
395
396 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
397 {
398 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
399 }
400
401 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
402 {
403 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
404 }
405
406 private:
407
408 void *self;
409 ptr_type func;
410
411 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
412 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
413 {
414 klass *obj = static_cast<klass *>(self);
415 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
416 }
417 };
418
419
420 #endif