ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/callback.h
Revision: 1.7
Committed: Sat Jan 14 11:21:08 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-7_3a, rel-7_3, rel-7_2, rel-7_1, rel-7_7, rel-7_6, rel-7_5, rel-7_4
Changes since 1.6: +25 -25 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.7 Copyright (C) 2003-2006 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     template<class R>
30     class callback0 {
31     struct object { };
32    
33     void *obj;
34 root 1.5 R (object::*meth)();
35 pcg 1.1
36     /* a proxy is a kind of recipe on how to call a specific class method */
37     struct proxy_base {
38 root 1.7 virtual R call (void *obj, R (object::*meth)()) const = 0;
39 pcg 1.1 };
40     template<class O1, class O2>
41     struct proxy : proxy_base {
42 root 1.7 virtual R call (void *obj, R (object::*meth)()) const
43 pcg 1.1 {
44 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth)))
45 pcg 1.1 ();
46     }
47     };
48    
49     proxy_base *prxy;
50    
51     public:
52     template<class O1, class O2>
53 root 1.7 explicit callback0 (O1 *object, R (O2::*method)())
54 pcg 1.1 {
55     static proxy<O1,O2> p;
56 root 1.5 obj = reinterpret_cast<void *>(object);
57     meth = reinterpret_cast<R (object::*)()>(method);
58 pcg 1.1 prxy = &p;
59     }
60    
61 root 1.5 R call() const
62 pcg 1.1 {
63     return prxy->call (obj, meth);
64     }
65    
66 root 1.5 R operator ()() const
67 pcg 1.1 {
68     return call ();
69     }
70     };
71    
72     template<class R, class A1>
73     class callback1 {
74     struct object { };
75    
76     void *obj;
77 root 1.5 R (object::*meth)(A1);
78 pcg 1.1
79     /* a proxy is a kind of recipe on how to call a specific class method */
80     struct proxy_base {
81 root 1.7 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) const = 0;
82 pcg 1.1 };
83     template<class O1, class O2>
84     struct proxy : proxy_base {
85 root 1.7 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) const
86 pcg 1.1 {
87 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth)))
88 pcg 1.1 (a1);
89     }
90     };
91    
92     proxy_base *prxy;
93    
94     public:
95     template<class O1, class O2>
96 root 1.7 explicit callback1 (O1 *object, R (O2::*method)(A1))
97 pcg 1.1 {
98     static proxy<O1,O2> p;
99 root 1.5 obj = reinterpret_cast<void *>(object);
100     meth = reinterpret_cast<R (object::*)(A1)>(method);
101 pcg 1.1 prxy = &p;
102     }
103    
104 root 1.5 R call(A1 a1) const
105 pcg 1.1 {
106     return prxy->call (obj, meth, a1);
107     }
108    
109 root 1.5 R operator ()(A1 a1) const
110 pcg 1.1 {
111     return call (a1);
112     }
113     };
114    
115     template<class R, class A1, class A2>
116     class callback2 {
117     struct object { };
118    
119     void *obj;
120 root 1.5 R (object::*meth)(A1, A2);
121 pcg 1.1
122     /* a proxy is a kind of recipe on how to call a specific class method */
123     struct proxy_base {
124 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) const = 0;
125 pcg 1.1 };
126     template<class O1, class O2>
127     struct proxy : proxy_base {
128 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) const
129 pcg 1.1 {
130 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth)))
131 pcg 1.1 (a1, a2);
132     }
133     };
134    
135     proxy_base *prxy;
136    
137     public:
138     template<class O1, class O2>
139 root 1.7 explicit callback2 (O1 *object, R (O2::*method)(A1, A2))
140 pcg 1.1 {
141     static proxy<O1,O2> p;
142 root 1.5 obj = reinterpret_cast<void *>(object);
143     meth = reinterpret_cast<R (object::*)(A1, A2)>(method);
144 pcg 1.1 prxy = &p;
145     }
146    
147 root 1.5 R call(A1 a1, A2 a2) const
148 pcg 1.1 {
149     return prxy->call (obj, meth, a1, a2);
150     }
151    
152 root 1.5 R operator ()(A1 a1, A2 a2) const
153 pcg 1.1 {
154     return call (a1, a2);
155     }
156     };
157    
158     template<class R, class A1, class A2, class A3>
159     class callback3 {
160     struct object { };
161    
162     void *obj;
163 root 1.5 R (object::*meth)(A1, A2, A3);
164 pcg 1.1
165     /* a proxy is a kind of recipe on how to call a specific class method */
166     struct proxy_base {
167 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) const = 0;
168 pcg 1.1 };
169     template<class O1, class O2>
170     struct proxy : proxy_base {
171 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) const
172 pcg 1.1 {
173 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth)))
174 pcg 1.1 (a1, a2, a3);
175     }
176     };
177    
178     proxy_base *prxy;
179    
180     public:
181     template<class O1, class O2>
182 root 1.7 explicit callback3 (O1 *object, R (O2::*method)(A1, A2, A3))
183 pcg 1.1 {
184     static proxy<O1,O2> p;
185 root 1.5 obj = reinterpret_cast<void *>(object);
186     meth = reinterpret_cast<R (object::*)(A1, A2, A3)>(method);
187 pcg 1.1 prxy = &p;
188     }
189    
190 root 1.5 R call(A1 a1, A2 a2, A3 a3) const
191 pcg 1.1 {
192     return prxy->call (obj, meth, a1, a2, a3);
193     }
194    
195 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3) const
196 pcg 1.1 {
197     return call (a1, a2, a3);
198     }
199     };
200    
201     template<class R, class A1, class A2, class A3, class A4>
202     class callback4 {
203     struct object { };
204    
205     void *obj;
206 root 1.5 R (object::*meth)(A1, A2, A3, A4);
207 pcg 1.1
208     /* a proxy is a kind of recipe on how to call a specific class method */
209     struct proxy_base {
210 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) const = 0;
211 pcg 1.1 };
212     template<class O1, class O2>
213     struct proxy : proxy_base {
214 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) const
215 pcg 1.1 {
216 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth)))
217 pcg 1.1 (a1, a2, a3, a4);
218     }
219     };
220    
221     proxy_base *prxy;
222    
223     public:
224     template<class O1, class O2>
225 root 1.7 explicit callback4 (O1 *object, R (O2::*method)(A1, A2, A3, A4))
226 pcg 1.1 {
227     static proxy<O1,O2> p;
228 root 1.5 obj = reinterpret_cast<void *>(object);
229     meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4)>(method);
230 pcg 1.1 prxy = &p;
231     }
232    
233 root 1.5 R call(A1 a1, A2 a2, A3 a3, A4 a4) const
234 pcg 1.1 {
235     return prxy->call (obj, meth, a1, a2, a3, a4);
236     }
237    
238 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
239 pcg 1.1 {
240     return call (a1, a2, a3, a4);
241     }
242     };
243    
244     template<class R, class A1, class A2, class A3, class A4, class A5>
245     class callback5 {
246     struct object { };
247    
248     void *obj;
249 root 1.5 R (object::*meth)(A1, A2, A3, A4, A5);
250 pcg 1.1
251     /* a proxy is a kind of recipe on how to call a specific class method */
252     struct proxy_base {
253 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const = 0;
254 pcg 1.1 };
255     template<class O1, class O2>
256     struct proxy : proxy_base {
257 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
258 pcg 1.1 {
259 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth)))
260 pcg 1.1 (a1, a2, a3, a4, a5);
261     }
262     };
263    
264     proxy_base *prxy;
265    
266     public:
267     template<class O1, class O2>
268 root 1.7 explicit callback5 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5))
269 pcg 1.1 {
270     static proxy<O1,O2> p;
271 root 1.5 obj = reinterpret_cast<void *>(object);
272     meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5)>(method);
273 pcg 1.1 prxy = &p;
274     }
275    
276 root 1.5 R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
277 pcg 1.1 {
278     return prxy->call (obj, meth, a1, a2, a3, a4, a5);
279     }
280    
281 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
282 pcg 1.1 {
283     return call (a1, a2, a3, a4, a5);
284     }
285     };
286    
287     template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
288     class callback6 {
289     struct object { };
290    
291     void *obj;
292 root 1.5 R (object::*meth)(A1, A2, A3, A4, A5, A6);
293 pcg 1.1
294     /* a proxy is a kind of recipe on how to call a specific class method */
295     struct proxy_base {
296 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const = 0;
297 pcg 1.1 };
298     template<class O1, class O2>
299     struct proxy : proxy_base {
300 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
301 pcg 1.1 {
302 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth)))
303 pcg 1.1 (a1, a2, a3, a4, a5, a6);
304     }
305     };
306    
307     proxy_base *prxy;
308    
309     public:
310     template<class O1, class O2>
311 root 1.7 explicit callback6 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6))
312 pcg 1.1 {
313     static proxy<O1,O2> p;
314 root 1.5 obj = reinterpret_cast<void *>(object);
315     meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6)>(method);
316 pcg 1.1 prxy = &p;
317     }
318    
319 root 1.5 R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
320 pcg 1.1 {
321     return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6);
322     }
323    
324 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
325 pcg 1.1 {
326     return call (a1, a2, a3, a4, a5, a6);
327     }
328     };
329    
330     template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
331     class callback7 {
332     struct object { };
333    
334     void *obj;
335 root 1.5 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7);
336 pcg 1.1
337     /* a proxy is a kind of recipe on how to call a specific class method */
338     struct proxy_base {
339 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const = 0;
340 pcg 1.1 };
341     template<class O1, class O2>
342     struct proxy : proxy_base {
343 root 1.7 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
344 pcg 1.1 {
345 root 1.6 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth)))
346 pcg 1.1 (a1, a2, a3, a4, a5, a6, a7);
347     }
348     };
349    
350     proxy_base *prxy;
351    
352     public:
353     template<class O1, class O2>
354 root 1.7 explicit callback7 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7))
355 pcg 1.1 {
356     static proxy<O1,O2> p;
357 root 1.5 obj = reinterpret_cast<void *>(object);
358     meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7)>(method);
359 pcg 1.1 prxy = &p;
360     }
361    
362 root 1.5 R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
363 pcg 1.1 {
364     return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7);
365     }
366    
367 root 1.5 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
368 pcg 1.1 {
369     return call (a1, a2, a3, a4, a5, a6, a7);
370     }
371     };
372    
373     #endif