ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/callback.h
(Generate patch)

Comparing gvpe/src/callback.h (file contents):
Revision 1.1 by pcg, Wed Apr 2 03:06:22 2003 UTC vs.
Revision 1.5 by pcg, Thu Mar 3 16:54:34 2005 UTC

1// 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
1/* 8/*
2 callback.h -- C++ callback mechanism 9 callback.h -- C++ callback mechanism
10 Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de>
3 11
12 This file is part of GVPE.
13
4 This program is free software; you can redistribute it and/or modify 14 GVPE is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 15 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or 16 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 17 (at your option) any later version.
8 18
9 This program is distributed in the hope that it will be useful, 19 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 22 GNU General Public License for more details.
13 23
14 You should have received a copy of the GNU General Public License 24 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 25 along with gvpe; if not, write to the Free Software
16 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 27*/
18 28
19#ifndef VPE_CALLBACK_H__ 29#ifndef CALLBACK_H__
20#define VPE_CALLBACK_H__ 30#define CALLBACK_H__
21 31
32template<class R>
33class 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
54public:
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
22template<class R, class A> 75template<class R, class A1>
23class callback { 76class callback1 {
24 struct object { }; 77 struct object { };
25 78
26 void *obj; 79 void *obj;
27 R (object::*meth)(A arg); 80 R (object::*meth)(A1);
28 81
29 // a proxy is a kind of recipe on how to call a specific class method 82 /* a proxy is a kind of recipe on how to call a specific class method */
30 struct proxy_base { 83 struct proxy_base {
31 virtual R call (void *obj, R (object::*meth)(A), A arg) = 0; 84 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) = 0;
32 }; 85 };
33 template<class O1, class O2> 86 template<class O1, class O2>
34 struct proxy : proxy_base { 87 struct proxy : proxy_base {
35 virtual R call (void *obj, R (object::*meth)(A), A arg) 88 virtual R call (void *obj, R (object::*meth)(A1), A1 a1)
36 { 89 {
37 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A)>(meth))) 90 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth)))
38 (arg); 91 (a1);
39 } 92 }
40 }; 93 };
41 94
42 proxy_base *prxy; 95 proxy_base *prxy;
43 96
44public: 97public:
45 template<class O1, class O2> 98 template<class O1, class O2>
46 callback (O1 *object, R (O2::*method)(A)) 99 callback1 (O1 *object, R (O2::*method)(A1))
47 { 100 {
48 static proxy<O1,O2> p; 101 static proxy<O1,O2> p;
49 obj = reinterpret_cast<void *>(object); 102 obj = reinterpret_cast<void *>(object);
50 meth = reinterpret_cast<R (object::*)(A)>(method); 103 meth = reinterpret_cast<R (object::*)(A1)>(method);
51 prxy = &p; 104 prxy = &p;
52 } 105 }
53 106
54 R call(A arg) const 107 R call(A1 a1) const
55 { 108 {
56 return prxy->call (obj, meth, arg); 109 return prxy->call (obj, meth, a1);
57 } 110 }
58 111
59 R operator ()(A arg) const 112 R operator ()(A1 a1) const
60 { 113 {
61 return call (arg); 114 return call (a1);
115 }
116};
117
118template<class R, class A1, class A2>
119class 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
140public:
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
161template<class R, class A1, class A2, class A3>
162class 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
183public:
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
204template<class R, class A1, class A2, class A3, class A4>
205class 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
226public:
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
247template<class R, class A1, class A2, class A3, class A4, class A5>
248class 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
269public:
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
290template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
291class 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
312public:
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
333template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
334class 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
355public:
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);
62 } 373 }
63}; 374};
64 375
65#endif 376#endif
66

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines