ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/callback.h
Revision: 1.11
Committed: Tue Dec 4 16:57:54 2007 UTC (16 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.10: +0 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.5 // 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 pcg 1.1
5     /*
6     callback.h -- C++ callback mechanism
7 root 1.9 Copyright (C) 2003-2007 Marc Lehmann <pcg@goof.com>
8 pcg 1.1
9 root 1.5 This file is part of GVPE.
10    
11     GVPE is free software; you can redistribute it and/or modify
12 pcg 1.1 it under the terms of the GNU General Public License as published by
13     the Free Software Foundation; either version 2 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 root 1.5 along with gvpe; if not, write to the Free Software
23 root 1.4 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 pcg 1.1 */
25    
26 pcg 1.2 #ifndef CALLBACK_H__
27     #define CALLBACK_H__
28 pcg 1.1
29 root 1.9 #define CALLBACK_H_VERSION 3
30 root 1.8
31 root 1.10 template<typename signature>
32     struct callback;
33 root 1.8
34 pcg 1.1 template<class R>
35 root 1.10 struct callback<R ()>
36 root 1.8 {
37 root 1.10 typedef R (*ptr_type)(void *self);
38 pcg 1.1
39 root 1.10 private:
40 root 1.8
41 root 1.10 void *self;
42     ptr_type func;
43    
44     protected:
45    
46     template<typename method>
47     struct thunktype;
48    
49     template<class klass>
50     struct thunktype<R (klass::*)>
51     {
52     typedef klass K;
53     };
54    
55     template<class klass, R (klass::*method)()>
56     static R thunk (void *self)
57     {
58     klass *obj = static_cast<klass *>(self);
59     return (obj->*method) ();
60     }
61 pcg 1.1
62     public:
63 root 1.10 template<class K, R (K::*method)()>
64     void set (K *object)
65 root 1.9 {
66 root 1.10 self = object;
67     func = thunk<K, method>;
68 root 1.9 }
69    
70 root 1.10 R call () const
71 root 1.9 {
72 root 1.10 return func (self);
73 root 1.9 }
74 pcg 1.1
75 root 1.5 R operator ()() const
76 root 1.9 {
77     return call ();
78     }
79 pcg 1.1 };
80    
81 root 1.10 template<class R, class A1>
82     struct callback<R (A1)>
83 root 1.8 {
84 root 1.10 typedef R (*ptr_type)(void *self, A1);
85    
86     private:
87    
88     void *self;
89     ptr_type func;
90 root 1.8
91 root 1.10 protected:
92 root 1.8
93 root 1.10 template<typename method>
94     struct thunktype;
95 pcg 1.1
96 root 1.10 template<class klass>
97     struct thunktype<R (klass::*)>
98     {
99     typedef klass K;
100     };
101 pcg 1.1
102 root 1.10 template<class klass, R (klass::*method)(A1)>
103     static R thunk (void *self, A1 a1)
104     {
105     klass *obj = static_cast<klass *>(self);
106     return (obj->*method) (a1);
107     }
108 pcg 1.1
109     public:
110 root 1.10 template<class K, R (K::*method)(A1)>
111     void set (K *object)
112 root 1.9 {
113 root 1.10 self = object;
114     func = thunk<K, method>;
115 root 1.9 }
116    
117 root 1.10 R call (A1 a1) const
118 root 1.9 {
119 root 1.10 return func (self, a1);
120 root 1.9 }
121 pcg 1.1
122 root 1.5 R operator ()(A1 a1) const
123 root 1.9 {
124     return call (a1);
125     }
126 pcg 1.1 };
127    
128 root 1.10 template<class R, class A1, class A2>
129     struct callback<R (A1, A2)>
130 root 1.8 {
131 root 1.10 typedef R (*ptr_type)(void *self, A1, A2);
132    
133     private:
134    
135     void *self;
136     ptr_type func;
137 root 1.8
138 root 1.10 protected:
139 root 1.8
140 root 1.10 template<typename method>
141     struct thunktype;
142 root 1.8
143 root 1.10 template<class klass>
144     struct thunktype<R (klass::*)>
145     {
146     typedef klass K;
147     };
148 pcg 1.1
149 root 1.10 template<class klass, R (klass::*method)(A1, A2)>
150     static R thunk (void *self, A1 a1, A2 a2)
151     {
152     klass *obj = static_cast<klass *>(self);
153     return (obj->*method) (a1, a2);
154     }
155 pcg 1.1
156     public:
157 root 1.10 template<class K, R (K::*method)(A1, A2)>
158     void set (K *object)
159 root 1.9 {
160 root 1.10 self = object;
161     func = thunk<K, method>;
162 root 1.9 }
163    
164 root 1.10 R call (A1 a1, A2 a2) const
165 root 1.9 {
166 root 1.10 return func (self, a1, a2);
167 root 1.9 }
168 pcg 1.1
169 root 1.5 R operator ()(A1 a1, A2 a2) const
170 root 1.9 {
171     return call (a1, a2);
172     }
173 pcg 1.1 };
174    
175 root 1.10 template<class R, class A1, class A2, class A3>
176     struct callback<R (A1, A2, A3)>
177 root 1.8 {
178 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3);
179    
180     private:
181    
182     void *self;
183     ptr_type func;
184 root 1.8
185 root 1.10 protected:
186 root 1.8
187 root 1.10 template<typename method>
188     struct thunktype;
189 pcg 1.1
190 root 1.10 template<class klass>
191     struct thunktype<R (klass::*)>
192     {
193     typedef klass K;
194     };
195 root 1.8
196 root 1.10 template<class klass, R (klass::*method)(A1, A2, A3)>
197     static R thunk (void *self, A1 a1, A2 a2, A3 a3)
198     {
199     klass *obj = static_cast<klass *>(self);
200     return (obj->*method) (a1, a2, a3);
201     }
202 pcg 1.1
203     public:
204 root 1.10 template<class K, R (K::*method)(A1, A2, A3)>
205     void set (K *object)
206 root 1.9 {
207 root 1.10 self = object;
208     func = thunk<K, method>;
209 root 1.9 }
210    
211 root 1.10 R call (A1 a1, A2 a2, A3 a3) const
212 root 1.9 {
213 root 1.10 return func (self, a1, a2, a3);
214 root 1.9 }
215 pcg 1.1
216 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3) const
217 root 1.9 {
218     return call (a1, a2, a3);
219     }
220 pcg 1.1 };
221    
222 root 1.10 template<class R, class A1, class A2, class A3, class A4>
223     struct callback<R (A1, A2, A3, A4)>
224 root 1.8 {
225 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
226    
227     private:
228 root 1.8
229 root 1.10 void *self;
230     ptr_type func;
231 root 1.8
232 root 1.10 protected:
233 root 1.8
234 root 1.10 template<typename method>
235     struct thunktype;
236 pcg 1.1
237 root 1.10 template<class klass>
238     struct thunktype<R (klass::*)>
239     {
240     typedef klass K;
241     };
242    
243     template<class klass, R (klass::*method)(A1, A2, A3, A4)>
244     static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4)
245     {
246     klass *obj = static_cast<klass *>(self);
247     return (obj->*method) (a1, a2, a3, a4);
248     }
249 pcg 1.1
250     public:
251 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4)>
252     void set (K *object)
253 root 1.9 {
254 root 1.10 self = object;
255     func = thunk<K, method>;
256 root 1.9 }
257    
258 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
259 root 1.9 {
260 root 1.10 return func (self, a1, a2, a3, a4);
261 root 1.9 }
262 pcg 1.1
263 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
264 root 1.9 {
265     return call (a1, a2, a3, a4);
266     }
267 pcg 1.1 };
268    
269 root 1.10 template<class R, class A1, class A2, class A3, class A4, class A5>
270     struct callback<R (A1, A2, A3, A4, A5)>
271 root 1.8 {
272 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
273    
274     private:
275    
276     void *self;
277     ptr_type func;
278 root 1.8
279 root 1.10 protected:
280 root 1.8
281 root 1.10 template<typename method>
282     struct thunktype;
283 pcg 1.1
284 root 1.10 template<class klass>
285     struct thunktype<R (klass::*)>
286     {
287     typedef klass K;
288     };
289 pcg 1.1
290 root 1.10 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)>
291     static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
292     {
293     klass *obj = static_cast<klass *>(self);
294     return (obj->*method) (a1, a2, a3, a4, a5);
295     }
296 pcg 1.1
297     public:
298 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
299     void set (K *object)
300 root 1.9 {
301 root 1.10 self = object;
302     func = thunk<K, method>;
303 root 1.9 }
304    
305 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
306 root 1.9 {
307 root 1.10 return func (self, a1, a2, a3, a4, a5);
308 root 1.9 }
309 pcg 1.1
310 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
311 root 1.9 {
312     return call (a1, a2, a3, a4, a5);
313     }
314 pcg 1.1 };
315    
316 root 1.10 template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
317     struct callback<R (A1, A2, A3, A4, A5, A6)>
318 root 1.8 {
319 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
320    
321     private:
322    
323     void *self;
324     ptr_type func;
325 root 1.8
326 root 1.10 protected:
327 root 1.8
328 root 1.10 template<typename method>
329     struct thunktype;
330 root 1.8
331 root 1.10 template<class klass>
332     struct thunktype<R (klass::*)>
333     {
334     typedef klass K;
335     };
336 pcg 1.1
337 root 1.10 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)>
338     static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
339     {
340     klass *obj = static_cast<klass *>(self);
341     return (obj->*method) (a1, a2, a3, a4, a5, a6);
342     }
343 pcg 1.1
344     public:
345 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
346     void set (K *object)
347 root 1.9 {
348 root 1.10 self = object;
349     func = thunk<K, method>;
350 root 1.9 }
351    
352 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
353 root 1.9 {
354 root 1.10 return func (self, a1, a2, a3, a4, a5, a6);
355 root 1.9 }
356 pcg 1.1
357 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
358 root 1.9 {
359     return call (a1, a2, a3, a4, a5, a6);
360     }
361 pcg 1.1 };
362    
363 root 1.10 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
364     struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
365 root 1.8 {
366 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
367    
368     private:
369 root 1.8
370 root 1.10 void *self;
371     ptr_type func;
372 root 1.8
373 root 1.10 protected:
374 pcg 1.1
375 root 1.10 template<typename method>
376     struct thunktype;
377 root 1.8
378 root 1.10 template<class klass>
379     struct thunktype<R (klass::*)>
380     {
381     typedef klass K;
382     };
383    
384     template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)>
385     static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
386     {
387     klass *obj = static_cast<klass *>(self);
388     return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
389     }
390 pcg 1.1
391     public:
392 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
393     void set (K *object)
394 root 1.9 {
395 root 1.10 self = object;
396     func = thunk<K, method>;
397 root 1.9 }
398    
399 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
400 root 1.9 {
401 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7);
402 root 1.9 }
403 pcg 1.1
404 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
405 root 1.9 {
406     return call (a1, a2, a3, a4, a5, a6, a7);
407     }
408 pcg 1.1 };
409    
410 root 1.10 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
411     struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)>
412 root 1.8 {
413 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8);
414    
415     private:
416    
417     void *self;
418     ptr_type func;
419 root 1.8
420 root 1.10 protected:
421 root 1.8
422 root 1.10 template<typename method>
423     struct thunktype;
424 root 1.8
425 root 1.10 template<class klass>
426     struct thunktype<R (klass::*)>
427     {
428     typedef klass K;
429     };
430 root 1.8
431 root 1.10 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
432     static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
433     {
434     klass *obj = static_cast<klass *>(self);
435     return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
436     }
437 root 1.8
438     public:
439 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
440     void set (K *object)
441 root 1.9 {
442 root 1.10 self = object;
443     func = thunk<K, method>;
444 root 1.9 }
445    
446 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
447 root 1.9 {
448 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
449 root 1.9 }
450 root 1.8
451     R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
452 root 1.9 {
453     return call (a1, a2, a3, a4, a5, a6, a7, a8);
454     }
455 root 1.8 };
456    
457 root 1.10 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
458     struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>
459 root 1.8 {
460 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9);
461    
462     private:
463    
464     void *self;
465     ptr_type func;
466 root 1.8
467 root 1.10 protected:
468 root 1.8
469 root 1.10 template<typename method>
470     struct thunktype;
471 root 1.8
472 root 1.10 template<class klass>
473     struct thunktype<R (klass::*)>
474     {
475     typedef klass K;
476     };
477 root 1.8
478 root 1.10 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
479     static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
480     {
481     klass *obj = static_cast<klass *>(self);
482     return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9);
483     }
484 root 1.8
485     public:
486 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
487     void set (K *object)
488 root 1.9 {
489 root 1.10 self = object;
490     func = thunk<K, method>;
491 root 1.9 }
492    
493 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
494 root 1.9 {
495 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
496 root 1.9 }
497 root 1.8
498     R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
499 root 1.9 {
500     return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
501     }
502 root 1.8 };
503    
504 root 1.10 template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
505     struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
506 root 1.8 {
507 root 1.10 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
508    
509     private:
510    
511     void *self;
512     ptr_type func;
513 root 1.8
514 root 1.10 protected:
515 root 1.8
516 root 1.10 template<typename method>
517     struct thunktype;
518 root 1.8
519 root 1.10 template<class klass>
520     struct thunktype<R (klass::*)>
521     {
522     typedef klass K;
523     };
524 root 1.8
525 root 1.10 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
526     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)
527     {
528     klass *obj = static_cast<klass *>(self);
529     return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
530     }
531 root 1.8
532     public:
533 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
534     void set (K *object)
535 root 1.9 {
536 root 1.10 self = object;
537     func = thunk<K, method>;
538 root 1.9 }
539    
540 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
541 root 1.9 {
542 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
543 root 1.9 }
544 root 1.8
545     R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
546 root 1.9 {
547     return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
548     }
549 root 1.8 };
550    
551    
552 pcg 1.1 #endif