ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/callback.h
Revision: 1.6
Committed: Tue Apr 26 00:55:55 2005 UTC (19 years, 1 month ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.5: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

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