ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/callback.h
Revision: 1.12
Committed: Wed Dec 5 18:20:39 2007 UTC (16 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: before_dynamic_fontidx, rel-9_10, rel-9_0, rel-8_8, rel-8_9, dynamic_fontidx, rel-9_09, rel-9_02, rel-9_01, rel-9_06, rel-9_07, rel-9_05
Changes since 1.11: +102 -234 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 template<class K, R (K::*method)()>
40     void set (K *object)
41 root 1.9 {
42 root 1.10 self = object;
43     func = thunk<K, method>;
44 root 1.9 }
45    
46 root 1.10 R call () const
47 root 1.9 {
48 root 1.10 return func (self);
49 root 1.9 }
50 pcg 1.1
51 root 1.5 R operator ()() const
52 root 1.9 {
53     return call ();
54     }
55 root 1.10
56     private:
57    
58     void *self;
59     ptr_type func;
60 root 1.8
61 root 1.12 template<class klass, R (klass::*method)()>
62     static R thunk (void *self)
63 root 1.10 {
64     klass *obj = static_cast<klass *>(self);
65 root 1.12 return (obj->*method) ();
66 root 1.10 }
67 root 1.12 };
68    
69     template<class R, class A1>
70     struct callback<R (A1)>
71     {
72     typedef R (*ptr_type)(void *self, A1);
73 pcg 1.1
74 root 1.10 template<class K, R (K::*method)(A1)>
75     void set (K *object)
76 root 1.9 {
77 root 1.10 self = object;
78     func = thunk<K, method>;
79 root 1.9 }
80    
81 root 1.10 R call (A1 a1) const
82 root 1.9 {
83 root 1.10 return func (self, a1);
84 root 1.9 }
85 pcg 1.1
86 root 1.5 R operator ()(A1 a1) const
87 root 1.9 {
88     return call (a1);
89     }
90 root 1.10
91     private:
92    
93     void *self;
94     ptr_type func;
95 root 1.8
96 root 1.12 template<class klass, R (klass::*method)(A1)>
97     static R thunk (void *self, A1 a1)
98 root 1.10 {
99     klass *obj = static_cast<klass *>(self);
100 root 1.12 return (obj->*method) (a1);
101 root 1.10 }
102 root 1.12 };
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 pcg 1.1
109 root 1.10 template<class K, R (K::*method)(A1, A2)>
110     void set (K *object)
111 root 1.9 {
112 root 1.10 self = object;
113     func = thunk<K, method>;
114 root 1.9 }
115    
116 root 1.10 R call (A1 a1, A2 a2) const
117 root 1.9 {
118 root 1.10 return func (self, a1, a2);
119 root 1.9 }
120 pcg 1.1
121 root 1.5 R operator ()(A1 a1, A2 a2) const
122 root 1.9 {
123     return call (a1, a2);
124     }
125 root 1.10
126     private:
127    
128     void *self;
129     ptr_type func;
130 root 1.8
131 root 1.12 template<class klass, R (klass::*method)(A1, A2)>
132     static R thunk (void *self, A1 a1, A2 a2)
133 root 1.10 {
134     klass *obj = static_cast<klass *>(self);
135 root 1.12 return (obj->*method) (a1, a2);
136 root 1.10 }
137 root 1.12 };
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 pcg 1.1
144 root 1.10 template<class K, R (K::*method)(A1, A2, A3)>
145     void set (K *object)
146 root 1.9 {
147 root 1.10 self = object;
148     func = thunk<K, method>;
149 root 1.9 }
150    
151 root 1.10 R call (A1 a1, A2 a2, A3 a3) const
152 root 1.9 {
153 root 1.10 return func (self, a1, a2, a3);
154 root 1.9 }
155 pcg 1.1
156 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3) const
157 root 1.9 {
158     return call (a1, a2, a3);
159     }
160 root 1.10
161     private:
162 root 1.8
163 root 1.10 void *self;
164     ptr_type func;
165 root 1.8
166 root 1.12 template<class klass, R (klass::*method)(A1, A2, A3)>
167     static R thunk (void *self, A1 a1, A2 a2, A3 a3)
168 root 1.10 {
169     klass *obj = static_cast<klass *>(self);
170 root 1.12 return (obj->*method) (a1, a2, a3);
171 root 1.10 }
172 root 1.12 };
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 pcg 1.1
179 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4)>
180     void set (K *object)
181 root 1.9 {
182 root 1.10 self = object;
183     func = thunk<K, method>;
184 root 1.9 }
185    
186 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
187 root 1.9 {
188 root 1.10 return func (self, a1, a2, a3, a4);
189 root 1.9 }
190 pcg 1.1
191 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
192 root 1.9 {
193     return call (a1, a2, a3, a4);
194     }
195 root 1.10
196     private:
197    
198     void *self;
199     ptr_type func;
200 root 1.8
201 root 1.12 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 root 1.10 {
204     klass *obj = static_cast<klass *>(self);
205 root 1.12 return (obj->*method) (a1, a2, a3, a4);
206 root 1.10 }
207 root 1.12 };
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 pcg 1.1
214 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
215     void set (K *object)
216 root 1.9 {
217 root 1.10 self = object;
218     func = thunk<K, method>;
219 root 1.9 }
220    
221 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
222 root 1.9 {
223 root 1.10 return func (self, a1, a2, a3, a4, a5);
224 root 1.9 }
225 pcg 1.1
226 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
227 root 1.9 {
228     return call (a1, a2, a3, a4, a5);
229     }
230 root 1.10
231     private:
232    
233     void *self;
234     ptr_type func;
235 root 1.8
236 root 1.12 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 root 1.10 {
239     klass *obj = static_cast<klass *>(self);
240 root 1.12 return (obj->*method) (a1, a2, a3, a4, a5);
241 root 1.10 }
242 root 1.12 };
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 pcg 1.1
249 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
250     void set (K *object)
251 root 1.9 {
252 root 1.10 self = object;
253     func = thunk<K, method>;
254 root 1.9 }
255    
256 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
257 root 1.9 {
258 root 1.10 return func (self, a1, a2, a3, a4, a5, a6);
259 root 1.9 }
260 pcg 1.1
261 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
262 root 1.9 {
263     return call (a1, a2, a3, a4, a5, a6);
264     }
265 root 1.10
266     private:
267 root 1.8
268 root 1.10 void *self;
269     ptr_type func;
270 root 1.8
271 root 1.12 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 root 1.10 {
274     klass *obj = static_cast<klass *>(self);
275 root 1.12 return (obj->*method) (a1, a2, a3, a4, a5, a6);
276 root 1.10 }
277 root 1.12 };
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 pcg 1.1
284 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
285     void set (K *object)
286 root 1.9 {
287 root 1.10 self = object;
288     func = thunk<K, method>;
289 root 1.9 }
290    
291 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
292 root 1.9 {
293 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7);
294 root 1.9 }
295 pcg 1.1
296 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
297 root 1.9 {
298     return call (a1, a2, a3, a4, a5, a6, a7);
299     }
300 root 1.10
301     private:
302    
303     void *self;
304     ptr_type func;
305 root 1.8
306 root 1.12 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 root 1.10 {
309     klass *obj = static_cast<klass *>(self);
310 root 1.12 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
311 root 1.10 }
312 root 1.12 };
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 root 1.8
319 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
320     void set (K *object)
321 root 1.9 {
322 root 1.10 self = object;
323     func = thunk<K, method>;
324 root 1.9 }
325    
326 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
327 root 1.9 {
328 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
329 root 1.9 }
330 root 1.8
331     R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
332 root 1.9 {
333     return call (a1, a2, a3, a4, a5, a6, a7, a8);
334     }
335 root 1.10
336     private:
337    
338     void *self;
339     ptr_type func;
340 root 1.8
341 root 1.12 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 root 1.10 {
344     klass *obj = static_cast<klass *>(self);
345 root 1.12 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
346 root 1.10 }
347 root 1.12 };
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 root 1.8
354 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
355     void set (K *object)
356 root 1.9 {
357 root 1.10 self = object;
358     func = thunk<K, method>;
359 root 1.9 }
360    
361 root 1.10 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
362 root 1.9 {
363 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
364 root 1.9 }
365 root 1.8
366     R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
367 root 1.9 {
368     return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
369     }
370 root 1.10
371     private:
372    
373     void *self;
374     ptr_type func;
375 root 1.8
376 root 1.12 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 root 1.10 {
379     klass *obj = static_cast<klass *>(self);
380 root 1.12 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9);
381 root 1.10 }
382 root 1.12 };
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 root 1.8
389 root 1.10 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
390     void set (K *object)
391 root 1.9 {
392 root 1.10 self = object;
393     func = thunk<K, method>;
394 root 1.9 }
395    
396 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
397 root 1.9 {
398 root 1.10 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
399 root 1.9 }
400 root 1.8
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 root 1.9 {
403     return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
404     }
405 root 1.12
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 root 1.8 };
418    
419    
420 pcg 1.1 #endif