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.3 by pcg, Thu Oct 16 02:41:21 2003 UTC vs.
Revision 1.10 by pcg, Wed May 31 00:31:47 2006 UTC

1// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it 1// THIS IS A GENERATED FILE: RUN callback.pl to regenerate it
2// 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, RUN callback.pl to regenerate it 3// THIS IS A GENERATED FILE: distribution.
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 4
8/* 5/*
9 callback.h -- C++ callback mechanism 6 callback.h -- C++ callback mechanism
10 Copyright (C) 2003 Marc Lehmann <pcg@goof.com> 7 Copyright (C) 2003-2006 Marc Lehmann <pcg@goof.com>
11 8
9 This file is part of GVPE.
10
12 This program is free software; you can redistribute it and/or modify 11 GVPE is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 12 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or 13 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version. 14 (at your option) any later version.
16 15
17 This program is distributed in the hope that it will be useful, 16 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details. 19 GNU General Public License for more details.
21 20
22 You should have received a copy of the GNU General Public License 21 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software 22 along with gvpe; if not, write to the Free Software
24 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25*/ 24*/
26 25
27#ifndef VPE_CALLBACK_H__ 26#ifndef CALLBACK_H__
28#define VPE_CALLBACK_H__ 27#define CALLBACK_H__
28
29#define CALLBACK_H_VERSION 2
30
31template<class signature>
32struct callback_funtype_trait;
33
34template<int arity, class signature>
35struct callback_get_impl;
29 36
30template<class R> 37template<class R>
31class callback0 { 38class callback0
39{
32 struct object { }; 40 struct object { };
41
42 typedef R (object::*ptr_type)();
33 43
34 void *obj; 44 void *obj;
35 R (object::*meth)(); 45 R (object::*meth)();
36 46
37 /* a proxy is a kind of recipe on how to call a specific class method */ 47 /* a proxy is a kind of recipe on how to call a specific class method */
38 struct proxy_base { 48 struct proxy_base {
39 virtual R call (void *obj, R (object::*meth)()) = 0; 49 virtual R call (void *obj, R (object::*meth)()) const = 0;
40 }; 50 };
41 template<class O1, class O2> 51 template<class O1, class O2>
42 struct proxy : proxy_base { 52 struct proxy : proxy_base {
43 virtual R call (void *obj, R (object::*meth)()) 53 virtual R call (void *obj, R (object::*meth)()) const
44 { 54 {
45 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth))) 55 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth)))
46 (); 56 ();
47 } 57 }
48 }; 58 };
49 59
50 proxy_base *prxy; 60 proxy_base *prxy;
51 61
52public: 62public:
53 template<class O1, class O2> 63 template<class O1, class O2>
54 callback0 (O1 *object, R (O2::*method)()) 64 explicit callback0 (O1 *object, R (O2::*method)())
55 { 65 {
56 static proxy<O1,O2> p; 66 static proxy<O1,O2> p;
57 obj = reinterpret_cast<void *>(object); 67 obj = reinterpret_cast<void *>(object);
58 meth = reinterpret_cast<R (object::*)()>(method); 68 meth = reinterpret_cast<R (object::*)()>(method);
59 prxy = &p; 69 prxy = &p;
68 { 78 {
69 return call (); 79 return call ();
70 } 80 }
71}; 81};
72 82
83template<class R>
84struct callback_funtype_trait0
85{
86 static const int arity = 0;
87 typedef R type (void);
88 typedef R result_type;
89
90};
91
92template<class R>
93struct callback_funtype_trait<R ()> : callback_funtype_trait0<R>
94{
95};
96
97template<class signature>
98struct callback_get_impl<0, signature>
99{
100 typedef callback_funtype_trait<signature> T;
101 typedef callback0<typename T::result_type> type;
102};
103
73template<class R, class A1> 104template<class R, class A1>
74class callback1 { 105class callback1
106{
75 struct object { }; 107 struct object { };
108
109 typedef R (object::*ptr_type)(A1);
76 110
77 void *obj; 111 void *obj;
78 R (object::*meth)(A1); 112 R (object::*meth)(A1);
79 113
80 /* a proxy is a kind of recipe on how to call a specific class method */ 114 /* a proxy is a kind of recipe on how to call a specific class method */
81 struct proxy_base { 115 struct proxy_base {
82 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) = 0; 116 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) const = 0;
83 }; 117 };
84 template<class O1, class O2> 118 template<class O1, class O2>
85 struct proxy : proxy_base { 119 struct proxy : proxy_base {
86 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) 120 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) const
87 { 121 {
88 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth))) 122 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth)))
89 (a1); 123 (a1);
90 } 124 }
91 }; 125 };
92 126
93 proxy_base *prxy; 127 proxy_base *prxy;
94 128
95public: 129public:
96 template<class O1, class O2> 130 template<class O1, class O2>
97 callback1 (O1 *object, R (O2::*method)(A1)) 131 explicit callback1 (O1 *object, R (O2::*method)(A1))
98 { 132 {
99 static proxy<O1,O2> p; 133 static proxy<O1,O2> p;
100 obj = reinterpret_cast<void *>(object); 134 obj = reinterpret_cast<void *>(object);
101 meth = reinterpret_cast<R (object::*)(A1)>(method); 135 meth = reinterpret_cast<R (object::*)(A1)>(method);
102 prxy = &p; 136 prxy = &p;
111 { 145 {
112 return call (a1); 146 return call (a1);
113 } 147 }
114}; 148};
115 149
150template<class R, class A1>
151struct callback_funtype_trait1
152{
153 static const int arity = 1;
154 typedef R type (A1);
155 typedef R result_type;
156 typedef A1 arg1_type;
157};
158
159template<class R, class A1>
160struct callback_funtype_trait<R (A1)> : callback_funtype_trait1<R, A1>
161{
162};
163
164template<class signature>
165struct callback_get_impl<1, signature>
166{
167 typedef callback_funtype_trait<signature> T;
168 typedef callback1<typename T::result_type, typename T::arg1_type> type;
169};
170
116template<class R, class A1, class A2> 171template<class R, class A1, class A2>
117class callback2 { 172class callback2
173{
118 struct object { }; 174 struct object { };
175
176 typedef R (object::*ptr_type)(A1, A2);
119 177
120 void *obj; 178 void *obj;
121 R (object::*meth)(A1, A2); 179 R (object::*meth)(A1, A2);
122 180
123 /* a proxy is a kind of recipe on how to call a specific class method */ 181 /* a proxy is a kind of recipe on how to call a specific class method */
124 struct proxy_base { 182 struct proxy_base {
125 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) = 0; 183 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) const = 0;
126 }; 184 };
127 template<class O1, class O2> 185 template<class O1, class O2>
128 struct proxy : proxy_base { 186 struct proxy : proxy_base {
129 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) 187 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) const
130 { 188 {
131 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth))) 189 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth)))
132 (a1, a2); 190 (a1, a2);
133 } 191 }
134 }; 192 };
135 193
136 proxy_base *prxy; 194 proxy_base *prxy;
137 195
138public: 196public:
139 template<class O1, class O2> 197 template<class O1, class O2>
140 callback2 (O1 *object, R (O2::*method)(A1, A2)) 198 explicit callback2 (O1 *object, R (O2::*method)(A1, A2))
141 { 199 {
142 static proxy<O1,O2> p; 200 static proxy<O1,O2> p;
143 obj = reinterpret_cast<void *>(object); 201 obj = reinterpret_cast<void *>(object);
144 meth = reinterpret_cast<R (object::*)(A1, A2)>(method); 202 meth = reinterpret_cast<R (object::*)(A1, A2)>(method);
145 prxy = &p; 203 prxy = &p;
154 { 212 {
155 return call (a1, a2); 213 return call (a1, a2);
156 } 214 }
157}; 215};
158 216
217template<class R, class A1, class A2>
218struct callback_funtype_trait2
219{
220 static const int arity = 2;
221 typedef R type (A1, A2);
222 typedef R result_type;
223 typedef A1 arg1_type; typedef A2 arg2_type;
224};
225
226template<class R, class A1, class A2>
227struct callback_funtype_trait<R (A1, A2)> : callback_funtype_trait2<R, A1, A2>
228{
229};
230
231template<class signature>
232struct callback_get_impl<2, signature>
233{
234 typedef callback_funtype_trait<signature> T;
235 typedef callback2<typename T::result_type, typename T::arg1_type, typename T::arg2_type> type;
236};
237
159template<class R, class A1, class A2, class A3> 238template<class R, class A1, class A2, class A3>
160class callback3 { 239class callback3
240{
161 struct object { }; 241 struct object { };
242
243 typedef R (object::*ptr_type)(A1, A2, A3);
162 244
163 void *obj; 245 void *obj;
164 R (object::*meth)(A1, A2, A3); 246 R (object::*meth)(A1, A2, A3);
165 247
166 /* a proxy is a kind of recipe on how to call a specific class method */ 248 /* a proxy is a kind of recipe on how to call a specific class method */
167 struct proxy_base { 249 struct proxy_base {
168 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) = 0; 250 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) const = 0;
169 }; 251 };
170 template<class O1, class O2> 252 template<class O1, class O2>
171 struct proxy : proxy_base { 253 struct proxy : proxy_base {
172 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) 254 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) const
173 { 255 {
174 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth))) 256 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth)))
175 (a1, a2, a3); 257 (a1, a2, a3);
176 } 258 }
177 }; 259 };
178 260
179 proxy_base *prxy; 261 proxy_base *prxy;
180 262
181public: 263public:
182 template<class O1, class O2> 264 template<class O1, class O2>
183 callback3 (O1 *object, R (O2::*method)(A1, A2, A3)) 265 explicit callback3 (O1 *object, R (O2::*method)(A1, A2, A3))
184 { 266 {
185 static proxy<O1,O2> p; 267 static proxy<O1,O2> p;
186 obj = reinterpret_cast<void *>(object); 268 obj = reinterpret_cast<void *>(object);
187 meth = reinterpret_cast<R (object::*)(A1, A2, A3)>(method); 269 meth = reinterpret_cast<R (object::*)(A1, A2, A3)>(method);
188 prxy = &p; 270 prxy = &p;
197 { 279 {
198 return call (a1, a2, a3); 280 return call (a1, a2, a3);
199 } 281 }
200}; 282};
201 283
284template<class R, class A1, class A2, class A3>
285struct callback_funtype_trait3
286{
287 static const int arity = 3;
288 typedef R type (A1, A2, A3);
289 typedef R result_type;
290 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type;
291};
292
293template<class R, class A1, class A2, class A3>
294struct callback_funtype_trait<R (A1, A2, A3)> : callback_funtype_trait3<R, A1, A2, A3>
295{
296};
297
298template<class signature>
299struct callback_get_impl<3, signature>
300{
301 typedef callback_funtype_trait<signature> T;
302 typedef callback3<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type> type;
303};
304
202template<class R, class A1, class A2, class A3, class A4> 305template<class R, class A1, class A2, class A3, class A4>
203class callback4 { 306class callback4
307{
204 struct object { }; 308 struct object { };
309
310 typedef R (object::*ptr_type)(A1, A2, A3, A4);
205 311
206 void *obj; 312 void *obj;
207 R (object::*meth)(A1, A2, A3, A4); 313 R (object::*meth)(A1, A2, A3, A4);
208 314
209 /* a proxy is a kind of recipe on how to call a specific class method */ 315 /* a proxy is a kind of recipe on how to call a specific class method */
210 struct proxy_base { 316 struct proxy_base {
211 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) = 0; 317 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) const = 0;
212 }; 318 };
213 template<class O1, class O2> 319 template<class O1, class O2>
214 struct proxy : proxy_base { 320 struct proxy : proxy_base {
215 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) 321 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) const
216 { 322 {
217 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth))) 323 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth)))
218 (a1, a2, a3, a4); 324 (a1, a2, a3, a4);
219 } 325 }
220 }; 326 };
221 327
222 proxy_base *prxy; 328 proxy_base *prxy;
223 329
224public: 330public:
225 template<class O1, class O2> 331 template<class O1, class O2>
226 callback4 (O1 *object, R (O2::*method)(A1, A2, A3, A4)) 332 explicit callback4 (O1 *object, R (O2::*method)(A1, A2, A3, A4))
227 { 333 {
228 static proxy<O1,O2> p; 334 static proxy<O1,O2> p;
229 obj = reinterpret_cast<void *>(object); 335 obj = reinterpret_cast<void *>(object);
230 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4)>(method); 336 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4)>(method);
231 prxy = &p; 337 prxy = &p;
240 { 346 {
241 return call (a1, a2, a3, a4); 347 return call (a1, a2, a3, a4);
242 } 348 }
243}; 349};
244 350
351template<class R, class A1, class A2, class A3, class A4>
352struct callback_funtype_trait4
353{
354 static const int arity = 4;
355 typedef R type (A1, A2, A3, A4);
356 typedef R result_type;
357 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type;
358};
359
360template<class R, class A1, class A2, class A3, class A4>
361struct callback_funtype_trait<R (A1, A2, A3, A4)> : callback_funtype_trait4<R, A1, A2, A3, A4>
362{
363};
364
365template<class signature>
366struct callback_get_impl<4, signature>
367{
368 typedef callback_funtype_trait<signature> T;
369 typedef callback4<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type> type;
370};
371
245template<class R, class A1, class A2, class A3, class A4, class A5> 372template<class R, class A1, class A2, class A3, class A4, class A5>
246class callback5 { 373class callback5
374{
247 struct object { }; 375 struct object { };
376
377 typedef R (object::*ptr_type)(A1, A2, A3, A4, A5);
248 378
249 void *obj; 379 void *obj;
250 R (object::*meth)(A1, A2, A3, A4, A5); 380 R (object::*meth)(A1, A2, A3, A4, A5);
251 381
252 /* a proxy is a kind of recipe on how to call a specific class method */ 382 /* a proxy is a kind of recipe on how to call a specific class method */
253 struct proxy_base { 383 struct proxy_base {
254 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) = 0; 384 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;
255 }; 385 };
256 template<class O1, class O2> 386 template<class O1, class O2>
257 struct proxy : proxy_base { 387 struct proxy : proxy_base {
258 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) 388 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
259 { 389 {
260 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth))) 390 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth)))
261 (a1, a2, a3, a4, a5); 391 (a1, a2, a3, a4, a5);
262 } 392 }
263 }; 393 };
264 394
265 proxy_base *prxy; 395 proxy_base *prxy;
266 396
267public: 397public:
268 template<class O1, class O2> 398 template<class O1, class O2>
269 callback5 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5)) 399 explicit callback5 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5))
270 { 400 {
271 static proxy<O1,O2> p; 401 static proxy<O1,O2> p;
272 obj = reinterpret_cast<void *>(object); 402 obj = reinterpret_cast<void *>(object);
273 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5)>(method); 403 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5)>(method);
274 prxy = &p; 404 prxy = &p;
283 { 413 {
284 return call (a1, a2, a3, a4, a5); 414 return call (a1, a2, a3, a4, a5);
285 } 415 }
286}; 416};
287 417
418template<class R, class A1, class A2, class A3, class A4, class A5>
419struct callback_funtype_trait5
420{
421 static const int arity = 5;
422 typedef R type (A1, A2, A3, A4, A5);
423 typedef R result_type;
424 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type;
425};
426
427template<class R, class A1, class A2, class A3, class A4, class A5>
428struct callback_funtype_trait<R (A1, A2, A3, A4, A5)> : callback_funtype_trait5<R, A1, A2, A3, A4, A5>
429{
430};
431
432template<class signature>
433struct callback_get_impl<5, signature>
434{
435 typedef callback_funtype_trait<signature> T;
436 typedef callback5<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type> type;
437};
438
288template<class R, class A1, class A2, class A3, class A4, class A5, class A6> 439template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
289class callback6 { 440class callback6
441{
290 struct object { }; 442 struct object { };
443
444 typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6);
291 445
292 void *obj; 446 void *obj;
293 R (object::*meth)(A1, A2, A3, A4, A5, A6); 447 R (object::*meth)(A1, A2, A3, A4, A5, A6);
294 448
295 /* a proxy is a kind of recipe on how to call a specific class method */ 449 /* a proxy is a kind of recipe on how to call a specific class method */
296 struct proxy_base { 450 struct proxy_base {
297 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; 451 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;
298 }; 452 };
299 template<class O1, class O2> 453 template<class O1, class O2>
300 struct proxy : proxy_base { 454 struct proxy : proxy_base {
301 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) 455 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
302 { 456 {
303 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth))) 457 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth)))
304 (a1, a2, a3, a4, a5, a6); 458 (a1, a2, a3, a4, a5, a6);
305 } 459 }
306 }; 460 };
307 461
308 proxy_base *prxy; 462 proxy_base *prxy;
309 463
310public: 464public:
311 template<class O1, class O2> 465 template<class O1, class O2>
312 callback6 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6)) 466 explicit callback6 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6))
313 { 467 {
314 static proxy<O1,O2> p; 468 static proxy<O1,O2> p;
315 obj = reinterpret_cast<void *>(object); 469 obj = reinterpret_cast<void *>(object);
316 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6)>(method); 470 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6)>(method);
317 prxy = &p; 471 prxy = &p;
326 { 480 {
327 return call (a1, a2, a3, a4, a5, a6); 481 return call (a1, a2, a3, a4, a5, a6);
328 } 482 }
329}; 483};
330 484
485template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
486struct callback_funtype_trait6
487{
488 static const int arity = 6;
489 typedef R type (A1, A2, A3, A4, A5, A6);
490 typedef R result_type;
491 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type;
492};
493
494template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
495struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6)> : callback_funtype_trait6<R, A1, A2, A3, A4, A5, A6>
496{
497};
498
499template<class signature>
500struct callback_get_impl<6, signature>
501{
502 typedef callback_funtype_trait<signature> T;
503 typedef callback6<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type> type;
504};
505
331template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> 506template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
332class callback7 { 507class callback7
508{
333 struct object { }; 509 struct object { };
510
511 typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7);
334 512
335 void *obj; 513 void *obj;
336 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7); 514 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7);
337 515
338 /* a proxy is a kind of recipe on how to call a specific class method */ 516 /* a proxy is a kind of recipe on how to call a specific class method */
339 struct proxy_base { 517 struct proxy_base {
340 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; 518 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;
341 }; 519 };
342 template<class O1, class O2> 520 template<class O1, class O2>
343 struct proxy : proxy_base { 521 struct proxy : proxy_base {
344 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) 522 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
345 { 523 {
346 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth))) 524 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth)))
347 (a1, a2, a3, a4, a5, a6, a7); 525 (a1, a2, a3, a4, a5, a6, a7);
348 } 526 }
349 }; 527 };
350 528
351 proxy_base *prxy; 529 proxy_base *prxy;
352 530
353public: 531public:
354 template<class O1, class O2> 532 template<class O1, class O2>
355 callback7 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7)) 533 explicit callback7 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7))
356 { 534 {
357 static proxy<O1,O2> p; 535 static proxy<O1,O2> p;
358 obj = reinterpret_cast<void *>(object); 536 obj = reinterpret_cast<void *>(object);
359 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7)>(method); 537 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7)>(method);
360 prxy = &p; 538 prxy = &p;
369 { 547 {
370 return call (a1, a2, a3, a4, a5, a6, a7); 548 return call (a1, a2, a3, a4, a5, a6, a7);
371 } 549 }
372}; 550};
373 551
552template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
553struct callback_funtype_trait7
554{
555 static const int arity = 7;
556 typedef R type (A1, A2, A3, A4, A5, A6, A7);
557 typedef R result_type;
558 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type;
559};
560
561template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
562struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7)> : callback_funtype_trait7<R, A1, A2, A3, A4, A5, A6, A7>
563{
564};
565
566template<class signature>
567struct callback_get_impl<7, signature>
568{
569 typedef callback_funtype_trait<signature> T;
570 typedef callback7<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type> type;
571};
572
573template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
574class callback8
575{
576 struct object { };
577
578 typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7, A8);
579
580 void *obj;
581 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8);
582
583 /* a proxy is a kind of recipe on how to call a specific class method */
584 struct proxy_base {
585 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const = 0;
586 };
587 template<class O1, class O2>
588 struct proxy : proxy_base {
589 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
590 {
591 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7, A8)>(meth)))
592 (a1, a2, a3, a4, a5, a6, a7, a8);
593 }
594 };
595
596 proxy_base *prxy;
597
598public:
599 template<class O1, class O2>
600 explicit callback8 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7, A8))
601 {
602 static proxy<O1,O2> p;
603 obj = reinterpret_cast<void *>(object);
604 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7, A8)>(method);
605 prxy = &p;
606 }
607
608 R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
609 {
610 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7, a8);
611 }
612
613 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
614 {
615 return call (a1, a2, a3, a4, a5, a6, a7, a8);
616 }
617};
618
619template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
620struct callback_funtype_trait8
621{
622 static const int arity = 8;
623 typedef R type (A1, A2, A3, A4, A5, A6, A7, A8);
624 typedef R result_type;
625 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; typedef A8 arg8_type;
626};
627
628template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
629struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7, A8)> : callback_funtype_trait8<R, A1, A2, A3, A4, A5, A6, A7, A8>
630{
631};
632
633template<class signature>
634struct callback_get_impl<8, signature>
635{
636 typedef callback_funtype_trait<signature> T;
637 typedef callback8<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type, typename T::arg8_type> type;
638};
639
640template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
641class callback9
642{
643 struct object { };
644
645 typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7, A8, A9);
646
647 void *obj;
648 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9);
649
650 /* a proxy is a kind of recipe on how to call a specific class method */
651 struct proxy_base {
652 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const = 0;
653 };
654 template<class O1, class O2>
655 struct proxy : proxy_base {
656 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
657 {
658 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>(meth)))
659 (a1, a2, a3, a4, a5, a6, a7, a8, a9);
660 }
661 };
662
663 proxy_base *prxy;
664
665public:
666 template<class O1, class O2>
667 explicit callback9 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9))
668 {
669 static proxy<O1,O2> p;
670 obj = reinterpret_cast<void *>(object);
671 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>(method);
672 prxy = &p;
673 }
674
675 R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
676 {
677 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7, a8, a9);
678 }
679
680 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
681 {
682 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
683 }
684};
685
686template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
687struct callback_funtype_trait9
688{
689 static const int arity = 9;
690 typedef R type (A1, A2, A3, A4, A5, A6, A7, A8, A9);
691 typedef R result_type;
692 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; typedef A8 arg8_type; typedef A9 arg9_type;
693};
694
695template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
696struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)> : callback_funtype_trait9<R, A1, A2, A3, A4, A5, A6, A7, A8, A9>
697{
698};
699
700template<class signature>
701struct callback_get_impl<9, signature>
702{
703 typedef callback_funtype_trait<signature> T;
704 typedef callback9<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type, typename T::arg8_type, typename T::arg9_type> type;
705};
706
707template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
708class callback10
709{
710 struct object { };
711
712 typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
713
714 void *obj;
715 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
716
717 /* a proxy is a kind of recipe on how to call a specific class method */
718 struct proxy_base {
719 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const = 0;
720 };
721 template<class O1, class O2>
722 struct proxy : proxy_base {
723 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
724 {
725 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>(meth)))
726 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
727 }
728 };
729
730 proxy_base *prxy;
731
732public:
733 template<class O1, class O2>
734 explicit callback10 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10))
735 {
736 static proxy<O1,O2> p;
737 obj = reinterpret_cast<void *>(object);
738 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>(method);
739 prxy = &p;
740 }
741
742 R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
743 {
744 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
745 }
746
747 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
748 {
749 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
750 }
751};
752
753template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
754struct callback_funtype_trait10
755{
756 static const int arity = 10;
757 typedef R type (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
758 typedef R result_type;
759 typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; typedef A8 arg8_type; typedef A9 arg9_type; typedef A10 arg10_type;
760};
761
762template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
763struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : callback_funtype_trait10<R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>
764{
765};
766
767template<class signature>
768struct callback_get_impl<10, signature>
769{
770 typedef callback_funtype_trait<signature> T;
771 typedef callback10<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type, typename T::arg8_type, typename T::arg9_type, typename T::arg10_type> type;
772};
773
774
775template<class signature>
776struct callback : callback_get_impl<callback_funtype_trait<signature>::arity, signature>::type
777{
778 typedef typename callback_get_impl<callback_funtype_trait<signature>::arity, signature>::type base_type;
779
780 template<class O, class M>
781 explicit callback (O object, M method)
782 : base_type (object, method)
783 {
784 }
785};
786
374#endif 787#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines