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.13 by pcg, Tue Dec 4 17:17:19 2007 UTC vs.
Revision 1.15 by pcg, Thu Aug 7 17:54:26 2008 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: callback.pl is part of the GVPE 2// THIS IS A GENERATED FILE: callback.pl is part of the GVPE
3// THIS IS A GENERATED FILE: distribution. 3// THIS IS A GENERATED FILE: distribution.
4 4
5/* 5/*
6 callback.h -- C++ callback mechanism 6 * callback.h -- C++ callback mechanism
7 Copyright (C) 2003-2007 Marc Lehmann <pcg@goof.com> 7 * Copyright (C) 2003-2008 Marc Lehmann <pcg@goof.com>
8 8 *
9 This file is part of GVPE. 9 * This file is part of GVPE.
10 10 *
11 GVPE is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify it
12 it under the terms of the GNU General Public License as published by 12 * under the terms of the GNU General Public License as published by the
13 the Free Software Foundation; either version 2 of the License, or 13 * Free Software Foundation; either version 3 of the License, or (at your
14 (at your option) any later version. 14 * option) any later version.
15 15 *
16 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, but
17 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 GNU General Public License for more details. 19 * Public License for more details.
20 20 *
21 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 along
22 along with gvpe; if not, write to the Free Software 22 * with this program; if not, see <http://www.gnu.org/licenses/>.
23 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 *
24 * Additional permission under GNU GPL version 3 section 7
25 *
26 * If you modify this Program, or any covered work, by linking or
27 * combining it with the OpenSSL project's OpenSSL library (or a modified
28 * version of that library), containing parts covered by the terms of the
29 * OpenSSL or SSLeay licenses, the licensors of this Program grant you
30 * additional permission to convey the resulting work. Corresponding
31 * Source for a non-source form of such a combination shall include the
32 * source code for the parts of OpenSSL used as well as that of the
33 * covered work.
24*/ 34*/
25 35
26#ifndef CALLBACK_H__ 36#ifndef CALLBACK_H__
27#define CALLBACK_H__ 37#define CALLBACK_H__
28 38
34template<class R> 44template<class R>
35struct callback<R ()> 45struct callback<R ()>
36{ 46{
37 typedef R (*ptr_type)(void *self); 47 typedef R (*ptr_type)(void *self);
38 48
39private: 49 template<class K, R (K::*method)()>
40 50 void set (K *object)
41 void *self;
42 ptr_type func;
43
44protected:
45
46 template<typename method>
47 struct thunktype;
48
49 template<class klass>
50 struct thunktype<R (klass::*)>
51 { 51 {
52 typedef klass K; 52 self = object;
53 func = thunk<K, method>;
53 }; 54 }
55
56 R call () const
57 {
58 return func (self);
59 }
60
61 R operator ()() const
62 {
63 return call ();
64 }
65
66private:
67
68 void *self;
69 ptr_type func;
54 70
55 template<class klass, R (klass::*method)()> 71 template<class klass, R (klass::*method)()>
56 static R thunk (void *self) 72 static R thunk (void *self)
57 { 73 {
58 klass *obj = static_cast<klass *>(self); 74 klass *obj = static_cast<klass *>(self);
59 return (obj->*method) (); 75 return (obj->*method) ();
60 } 76 }
61
62public:
63 template<class K, R (K::*method)()>
64 void set (K *object)
65 {
66 self = object;
67 func = thunk<K, method>;
68 }
69
70 R call () const
71 {
72 return func (self);
73 }
74
75 R operator ()() const
76 {
77 return call ();
78 }
79}; 77};
80 78
81template<class R, class A1> 79template<class R, class A1>
82struct callback<R (A1)> 80struct callback<R (A1)>
83{ 81{
84 typedef R (*ptr_type)(void *self, A1); 82 typedef R (*ptr_type)(void *self, A1);
85 83
86private: 84 template<class K, R (K::*method)(A1)>
87 85 void set (K *object)
88 void *self;
89 ptr_type func;
90
91protected:
92
93 template<typename method>
94 struct thunktype;
95
96 template<class klass>
97 struct thunktype<R (klass::*)>
98 { 86 {
99 typedef klass K; 87 self = object;
88 func = thunk<K, method>;
100 }; 89 }
90
91 R call (A1 a1) const
92 {
93 return func (self, a1);
94 }
95
96 R operator ()(A1 a1) const
97 {
98 return call (a1);
99 }
100
101private:
102
103 void *self;
104 ptr_type func;
101 105
102 template<class klass, R (klass::*method)(A1)> 106 template<class klass, R (klass::*method)(A1)>
103 static R thunk (void *self, A1 a1) 107 static R thunk (void *self, A1 a1)
104 { 108 {
105 klass *obj = static_cast<klass *>(self); 109 klass *obj = static_cast<klass *>(self);
106 return (obj->*method) (a1); 110 return (obj->*method) (a1);
107 } 111 }
108
109public:
110 template<class K, R (K::*method)(A1)>
111 void set (K *object)
112 {
113 self = object;
114 func = thunk<K, method>;
115 }
116
117 R call (A1 a1) const
118 {
119 return func (self, a1);
120 }
121
122 R operator ()(A1 a1) const
123 {
124 return call (a1);
125 }
126}; 112};
127 113
128template<class R, class A1, class A2> 114template<class R, class A1, class A2>
129struct callback<R (A1, A2)> 115struct callback<R (A1, A2)>
130{ 116{
131 typedef R (*ptr_type)(void *self, A1, A2); 117 typedef R (*ptr_type)(void *self, A1, A2);
132 118
133private: 119 template<class K, R (K::*method)(A1, A2)>
134 120 void set (K *object)
135 void *self;
136 ptr_type func;
137
138protected:
139
140 template<typename method>
141 struct thunktype;
142
143 template<class klass>
144 struct thunktype<R (klass::*)>
145 { 121 {
146 typedef klass K; 122 self = object;
123 func = thunk<K, method>;
147 }; 124 }
125
126 R call (A1 a1, A2 a2) const
127 {
128 return func (self, a1, a2);
129 }
130
131 R operator ()(A1 a1, A2 a2) const
132 {
133 return call (a1, a2);
134 }
135
136private:
137
138 void *self;
139 ptr_type func;
148 140
149 template<class klass, R (klass::*method)(A1, A2)> 141 template<class klass, R (klass::*method)(A1, A2)>
150 static R thunk (void *self, A1 a1, A2 a2) 142 static R thunk (void *self, A1 a1, A2 a2)
151 { 143 {
152 klass *obj = static_cast<klass *>(self); 144 klass *obj = static_cast<klass *>(self);
153 return (obj->*method) (a1, a2); 145 return (obj->*method) (a1, a2);
154 } 146 }
155
156public:
157 template<class K, R (K::*method)(A1, A2)>
158 void set (K *object)
159 {
160 self = object;
161 func = thunk<K, method>;
162 }
163
164 R call (A1 a1, A2 a2) const
165 {
166 return func (self, a1, a2);
167 }
168
169 R operator ()(A1 a1, A2 a2) const
170 {
171 return call (a1, a2);
172 }
173}; 147};
174 148
175template<class R, class A1, class A2, class A3> 149template<class R, class A1, class A2, class A3>
176struct callback<R (A1, A2, A3)> 150struct callback<R (A1, A2, A3)>
177{ 151{
178 typedef R (*ptr_type)(void *self, A1, A2, A3); 152 typedef R (*ptr_type)(void *self, A1, A2, A3);
179 153
180private: 154 template<class K, R (K::*method)(A1, A2, A3)>
181 155 void set (K *object)
182 void *self;
183 ptr_type func;
184
185protected:
186
187 template<typename method>
188 struct thunktype;
189
190 template<class klass>
191 struct thunktype<R (klass::*)>
192 { 156 {
193 typedef klass K; 157 self = object;
158 func = thunk<K, method>;
194 }; 159 }
160
161 R call (A1 a1, A2 a2, A3 a3) const
162 {
163 return func (self, a1, a2, a3);
164 }
165
166 R operator ()(A1 a1, A2 a2, A3 a3) const
167 {
168 return call (a1, a2, a3);
169 }
170
171private:
172
173 void *self;
174 ptr_type func;
195 175
196 template<class klass, R (klass::*method)(A1, A2, A3)> 176 template<class klass, R (klass::*method)(A1, A2, A3)>
197 static R thunk (void *self, A1 a1, A2 a2, A3 a3) 177 static R thunk (void *self, A1 a1, A2 a2, A3 a3)
198 { 178 {
199 klass *obj = static_cast<klass *>(self); 179 klass *obj = static_cast<klass *>(self);
200 return (obj->*method) (a1, a2, a3); 180 return (obj->*method) (a1, a2, a3);
201 } 181 }
202
203public:
204 template<class K, R (K::*method)(A1, A2, A3)>
205 void set (K *object)
206 {
207 self = object;
208 func = thunk<K, method>;
209 }
210
211 R call (A1 a1, A2 a2, A3 a3) const
212 {
213 return func (self, a1, a2, a3);
214 }
215
216 R operator ()(A1 a1, A2 a2, A3 a3) const
217 {
218 return call (a1, a2, a3);
219 }
220}; 182};
221 183
222template<class R, class A1, class A2, class A3, class A4> 184template<class R, class A1, class A2, class A3, class A4>
223struct callback<R (A1, A2, A3, A4)> 185struct callback<R (A1, A2, A3, A4)>
224{ 186{
225 typedef R (*ptr_type)(void *self, A1, A2, A3, A4); 187 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
226 188
227private: 189 template<class K, R (K::*method)(A1, A2, A3, A4)>
228 190 void set (K *object)
229 void *self;
230 ptr_type func;
231
232protected:
233
234 template<typename method>
235 struct thunktype;
236
237 template<class klass>
238 struct thunktype<R (klass::*)>
239 { 191 {
240 typedef klass K; 192 self = object;
193 func = thunk<K, method>;
241 }; 194 }
195
196 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
197 {
198 return func (self, a1, a2, a3, a4);
199 }
200
201 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
202 {
203 return call (a1, a2, a3, a4);
204 }
205
206private:
207
208 void *self;
209 ptr_type func;
242 210
243 template<class klass, R (klass::*method)(A1, A2, A3, A4)> 211 template<class klass, R (klass::*method)(A1, A2, A3, A4)>
244 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4) 212 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4)
245 { 213 {
246 klass *obj = static_cast<klass *>(self); 214 klass *obj = static_cast<klass *>(self);
247 return (obj->*method) (a1, a2, a3, a4); 215 return (obj->*method) (a1, a2, a3, a4);
248 } 216 }
249
250public:
251 template<class K, R (K::*method)(A1, A2, A3, A4)>
252 void set (K *object)
253 {
254 self = object;
255 func = thunk<K, method>;
256 }
257
258 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
259 {
260 return func (self, a1, a2, a3, a4);
261 }
262
263 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
264 {
265 return call (a1, a2, a3, a4);
266 }
267}; 217};
268 218
269template<class R, class A1, class A2, class A3, class A4, class A5> 219template<class R, class A1, class A2, class A3, class A4, class A5>
270struct callback<R (A1, A2, A3, A4, A5)> 220struct callback<R (A1, A2, A3, A4, A5)>
271{ 221{
272 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5); 222 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
273 223
274private: 224 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
275 225 void set (K *object)
276 void *self;
277 ptr_type func;
278
279protected:
280
281 template<typename method>
282 struct thunktype;
283
284 template<class klass>
285 struct thunktype<R (klass::*)>
286 { 226 {
287 typedef klass K; 227 self = object;
228 func = thunk<K, method>;
288 }; 229 }
230
231 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
232 {
233 return func (self, a1, a2, a3, a4, a5);
234 }
235
236 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
237 {
238 return call (a1, a2, a3, a4, a5);
239 }
240
241private:
242
243 void *self;
244 ptr_type func;
289 245
290 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)> 246 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)>
291 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) 247 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
292 { 248 {
293 klass *obj = static_cast<klass *>(self); 249 klass *obj = static_cast<klass *>(self);
294 return (obj->*method) (a1, a2, a3, a4, a5); 250 return (obj->*method) (a1, a2, a3, a4, a5);
295 } 251 }
296
297public:
298 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
299 void set (K *object)
300 {
301 self = object;
302 func = thunk<K, method>;
303 }
304
305 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
306 {
307 return func (self, a1, a2, a3, a4, a5);
308 }
309
310 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
311 {
312 return call (a1, a2, a3, a4, a5);
313 }
314}; 252};
315 253
316template<class R, class A1, class A2, class A3, class A4, class A5, class A6> 254template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
317struct callback<R (A1, A2, A3, A4, A5, A6)> 255struct callback<R (A1, A2, A3, A4, A5, A6)>
318{ 256{
319 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6); 257 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
320 258
321private: 259 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
322 260 void set (K *object)
323 void *self;
324 ptr_type func;
325
326protected:
327
328 template<typename method>
329 struct thunktype;
330
331 template<class klass>
332 struct thunktype<R (klass::*)>
333 { 261 {
334 typedef klass K; 262 self = object;
263 func = thunk<K, method>;
335 }; 264 }
265
266 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
267 {
268 return func (self, a1, a2, a3, a4, a5, a6);
269 }
270
271 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
272 {
273 return call (a1, a2, a3, a4, a5, a6);
274 }
275
276private:
277
278 void *self;
279 ptr_type func;
336 280
337 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)> 281 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)>
338 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) 282 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
339 { 283 {
340 klass *obj = static_cast<klass *>(self); 284 klass *obj = static_cast<klass *>(self);
341 return (obj->*method) (a1, a2, a3, a4, a5, a6); 285 return (obj->*method) (a1, a2, a3, a4, a5, a6);
342 } 286 }
343
344public:
345 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
346 void set (K *object)
347 {
348 self = object;
349 func = thunk<K, method>;
350 }
351
352 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
353 {
354 return func (self, a1, a2, a3, a4, a5, a6);
355 }
356
357 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
358 {
359 return call (a1, a2, a3, a4, a5, a6);
360 }
361}; 287};
362 288
363template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> 289template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
364struct callback<R (A1, A2, A3, A4, A5, A6, A7)> 290struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
365{ 291{
366 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7); 292 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
367 293
368private: 294 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
369 295 void set (K *object)
370 void *self;
371 ptr_type func;
372
373protected:
374
375 template<typename method>
376 struct thunktype;
377
378 template<class klass>
379 struct thunktype<R (klass::*)>
380 { 296 {
381 typedef klass K; 297 self = object;
298 func = thunk<K, method>;
382 }; 299 }
300
301 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
302 {
303 return func (self, a1, a2, a3, a4, a5, a6, a7);
304 }
305
306 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
307 {
308 return call (a1, a2, a3, a4, a5, a6, a7);
309 }
310
311private:
312
313 void *self;
314 ptr_type func;
383 315
384 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)> 316 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)>
385 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) 317 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
386 { 318 {
387 klass *obj = static_cast<klass *>(self); 319 klass *obj = static_cast<klass *>(self);
388 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7); 320 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
389 } 321 }
390
391public:
392 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
393 void set (K *object)
394 {
395 self = object;
396 func = thunk<K, method>;
397 }
398
399 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
400 {
401 return func (self, a1, a2, a3, a4, a5, a6, a7);
402 }
403
404 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
405 {
406 return call (a1, a2, a3, a4, a5, a6, a7);
407 }
408}; 322};
409 323
410template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> 324template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
411struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)> 325struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)>
412{ 326{
413 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8); 327 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8);
414 328
415private: 329 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
416 330 void set (K *object)
417 void *self;
418 ptr_type func;
419
420protected:
421
422 template<typename method>
423 struct thunktype;
424
425 template<class klass>
426 struct thunktype<R (klass::*)>
427 { 331 {
428 typedef klass K; 332 self = object;
333 func = thunk<K, method>;
429 }; 334 }
335
336 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
337 {
338 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
339 }
340
341 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
342 {
343 return call (a1, a2, a3, a4, a5, a6, a7, a8);
344 }
345
346private:
347
348 void *self;
349 ptr_type func;
430 350
431 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)> 351 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
432 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) 352 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
433 { 353 {
434 klass *obj = static_cast<klass *>(self); 354 klass *obj = static_cast<klass *>(self);
435 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8); 355 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
436 } 356 }
437
438public:
439 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
440 void set (K *object)
441 {
442 self = object;
443 func = thunk<K, method>;
444 }
445
446 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
447 {
448 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
449 }
450
451 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
452 {
453 return call (a1, a2, a3, a4, a5, a6, a7, a8);
454 }
455}; 357};
456 358
457template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> 359template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
458struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)> 360struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>
459{ 361{
460 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9); 362 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9);
461 363
462private: 364 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
463 365 void set (K *object)
464 void *self;
465 ptr_type func;
466
467protected:
468
469 template<typename method>
470 struct thunktype;
471
472 template<class klass>
473 struct thunktype<R (klass::*)>
474 { 366 {
475 typedef klass K; 367 self = object;
368 func = thunk<K, method>;
476 }; 369 }
370
371 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
372 {
373 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
374 }
375
376 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
377 {
378 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
379 }
380
381private:
382
383 void *self;
384 ptr_type func;
477 385
478 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)> 386 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
479 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) 387 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
480 { 388 {
481 klass *obj = static_cast<klass *>(self); 389 klass *obj = static_cast<klass *>(self);
482 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9); 390 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9);
483 } 391 }
484
485public:
486 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
487 void set (K *object)
488 {
489 self = object;
490 func = thunk<K, method>;
491 }
492
493 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
494 {
495 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
496 }
497
498 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
499 {
500 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
501 }
502}; 392};
503 393
504template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> 394template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
505struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> 395struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
506{ 396{
507 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); 397 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
508 398
509private: 399 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
510 400 void set (K *object)
511 void *self;
512 ptr_type func;
513
514protected:
515
516 template<typename method>
517 struct thunktype;
518
519 template<class klass>
520 struct thunktype<R (klass::*)>
521 { 401 {
522 typedef klass K; 402 self = object;
403 func = thunk<K, method>;
523 }; 404 }
405
406 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
407 {
408 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
409 }
410
411 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
412 {
413 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
414 }
415
416private:
417
418 void *self;
419 ptr_type func;
524 420
525 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> 421 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
526 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) 422 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)
527 { 423 {
528 klass *obj = static_cast<klass *>(self); 424 klass *obj = static_cast<klass *>(self);
529 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); 425 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
530 } 426 }
531
532public:
533 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
534 void set (K *object)
535 {
536 self = object;
537 func = thunk<K, method>;
538 }
539
540 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
541 {
542 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
543 }
544
545 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
546 {
547 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
548 }
549}; 427};
550 428
551 429
552#endif 430#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines