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.12 by pcg, Tue Dec 4 15:01:12 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
29#define CALLBACK_H_VERSION 3 39#define CALLBACK_H_VERSION 3
30 40
31template<typename signature> 41template<typename signature>
32struct callback; 42struct callback;
33 43
34#define callback_set(callback,obj,klass,method) callback.set<klass, &klass::method> (obj)
35
36template<class R> 44template<class R>
37struct callback<R ()> 45struct callback<R ()>
38{ 46{
39 typedef R (*ptr_type)(void *self); 47 typedef R (*ptr_type)(void *self);
40 48
41private: 49 template<class K, R (K::*method)()>
42 50 void set (K *object)
43 void *self;
44 ptr_type func;
45
46protected:
47
48 template<typename method>
49 struct thunktype;
50
51 template<class klass>
52 struct thunktype<R (klass::*)>
53 { 51 {
54 typedef klass K; 52 self = object;
53 func = thunk<K, method>;
55 }; 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;
56 70
57 template<class klass, R (klass::*method)()> 71 template<class klass, R (klass::*method)()>
58 static R thunk (void *self) 72 static R thunk (void *self)
59 { 73 {
60 klass *obj = static_cast<klass *>(self); 74 klass *obj = static_cast<klass *>(self);
61 return (obj->*method) (); 75 return (obj->*method) ();
62 } 76 }
63
64public:
65 template<class K, R (K::*method)()>
66 void set (K *object)
67 {
68 self = object;
69 func = thunk<K, method>;
70 }
71
72 R call () const
73 {
74 return func (self);
75 }
76
77 R operator ()() const
78 {
79 return call ();
80 }
81}; 77};
82 78
83template<class R, class A1> 79template<class R, class A1>
84struct callback<R (A1)> 80struct callback<R (A1)>
85{ 81{
86 typedef R (*ptr_type)(void *self, A1); 82 typedef R (*ptr_type)(void *self, A1);
87 83
88private: 84 template<class K, R (K::*method)(A1)>
89 85 void set (K *object)
90 void *self;
91 ptr_type func;
92
93protected:
94
95 template<typename method>
96 struct thunktype;
97
98 template<class klass>
99 struct thunktype<R (klass::*)>
100 { 86 {
101 typedef klass K; 87 self = object;
88 func = thunk<K, method>;
102 }; 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;
103 105
104 template<class klass, R (klass::*method)(A1)> 106 template<class klass, R (klass::*method)(A1)>
105 static R thunk (void *self, A1 a1) 107 static R thunk (void *self, A1 a1)
106 { 108 {
107 klass *obj = static_cast<klass *>(self); 109 klass *obj = static_cast<klass *>(self);
108 return (obj->*method) (a1); 110 return (obj->*method) (a1);
109 } 111 }
110
111public:
112 template<class K, R (K::*method)(A1)>
113 void set (K *object)
114 {
115 self = object;
116 func = thunk<K, method>;
117 }
118
119 R call (A1 a1) const
120 {
121 return func (self, a1);
122 }
123
124 R operator ()(A1 a1) const
125 {
126 return call (a1);
127 }
128}; 112};
129 113
130template<class R, class A1, class A2> 114template<class R, class A1, class A2>
131struct callback<R (A1, A2)> 115struct callback<R (A1, A2)>
132{ 116{
133 typedef R (*ptr_type)(void *self, A1, A2); 117 typedef R (*ptr_type)(void *self, A1, A2);
134 118
135private: 119 template<class K, R (K::*method)(A1, A2)>
136 120 void set (K *object)
137 void *self;
138 ptr_type func;
139
140protected:
141
142 template<typename method>
143 struct thunktype;
144
145 template<class klass>
146 struct thunktype<R (klass::*)>
147 { 121 {
148 typedef klass K; 122 self = object;
123 func = thunk<K, method>;
149 }; 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;
150 140
151 template<class klass, R (klass::*method)(A1, A2)> 141 template<class klass, R (klass::*method)(A1, A2)>
152 static R thunk (void *self, A1 a1, A2 a2) 142 static R thunk (void *self, A1 a1, A2 a2)
153 { 143 {
154 klass *obj = static_cast<klass *>(self); 144 klass *obj = static_cast<klass *>(self);
155 return (obj->*method) (a1, a2); 145 return (obj->*method) (a1, a2);
156 } 146 }
157
158public:
159 template<class K, R (K::*method)(A1, A2)>
160 void set (K *object)
161 {
162 self = object;
163 func = thunk<K, method>;
164 }
165
166 R call (A1 a1, A2 a2) const
167 {
168 return func (self, a1, a2);
169 }
170
171 R operator ()(A1 a1, A2 a2) const
172 {
173 return call (a1, a2);
174 }
175}; 147};
176 148
177template<class R, class A1, class A2, class A3> 149template<class R, class A1, class A2, class A3>
178struct callback<R (A1, A2, A3)> 150struct callback<R (A1, A2, A3)>
179{ 151{
180 typedef R (*ptr_type)(void *self, A1, A2, A3); 152 typedef R (*ptr_type)(void *self, A1, A2, A3);
181 153
182private: 154 template<class K, R (K::*method)(A1, A2, A3)>
183 155 void set (K *object)
184 void *self;
185 ptr_type func;
186
187protected:
188
189 template<typename method>
190 struct thunktype;
191
192 template<class klass>
193 struct thunktype<R (klass::*)>
194 { 156 {
195 typedef klass K; 157 self = object;
158 func = thunk<K, method>;
196 }; 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;
197 175
198 template<class klass, R (klass::*method)(A1, A2, A3)> 176 template<class klass, R (klass::*method)(A1, A2, A3)>
199 static R thunk (void *self, A1 a1, A2 a2, A3 a3) 177 static R thunk (void *self, A1 a1, A2 a2, A3 a3)
200 { 178 {
201 klass *obj = static_cast<klass *>(self); 179 klass *obj = static_cast<klass *>(self);
202 return (obj->*method) (a1, a2, a3); 180 return (obj->*method) (a1, a2, a3);
203 } 181 }
204
205public:
206 template<class K, R (K::*method)(A1, A2, A3)>
207 void set (K *object)
208 {
209 self = object;
210 func = thunk<K, method>;
211 }
212
213 R call (A1 a1, A2 a2, A3 a3) const
214 {
215 return func (self, a1, a2, a3);
216 }
217
218 R operator ()(A1 a1, A2 a2, A3 a3) const
219 {
220 return call (a1, a2, a3);
221 }
222}; 182};
223 183
224template<class R, class A1, class A2, class A3, class A4> 184template<class R, class A1, class A2, class A3, class A4>
225struct callback<R (A1, A2, A3, A4)> 185struct callback<R (A1, A2, A3, A4)>
226{ 186{
227 typedef R (*ptr_type)(void *self, A1, A2, A3, A4); 187 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
228 188
229private: 189 template<class K, R (K::*method)(A1, A2, A3, A4)>
230 190 void set (K *object)
231 void *self;
232 ptr_type func;
233
234protected:
235
236 template<typename method>
237 struct thunktype;
238
239 template<class klass>
240 struct thunktype<R (klass::*)>
241 { 191 {
242 typedef klass K; 192 self = object;
193 func = thunk<K, method>;
243 }; 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;
244 210
245 template<class klass, R (klass::*method)(A1, A2, A3, A4)> 211 template<class klass, R (klass::*method)(A1, A2, A3, A4)>
246 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)
247 { 213 {
248 klass *obj = static_cast<klass *>(self); 214 klass *obj = static_cast<klass *>(self);
249 return (obj->*method) (a1, a2, a3, a4); 215 return (obj->*method) (a1, a2, a3, a4);
250 } 216 }
251
252public:
253 template<class K, R (K::*method)(A1, A2, A3, A4)>
254 void set (K *object)
255 {
256 self = object;
257 func = thunk<K, method>;
258 }
259
260 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
261 {
262 return func (self, a1, a2, a3, a4);
263 }
264
265 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
266 {
267 return call (a1, a2, a3, a4);
268 }
269}; 217};
270 218
271template<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>
272struct callback<R (A1, A2, A3, A4, A5)> 220struct callback<R (A1, A2, A3, A4, A5)>
273{ 221{
274 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5); 222 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
275 223
276private: 224 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
277 225 void set (K *object)
278 void *self;
279 ptr_type func;
280
281protected:
282
283 template<typename method>
284 struct thunktype;
285
286 template<class klass>
287 struct thunktype<R (klass::*)>
288 { 226 {
289 typedef klass K; 227 self = object;
228 func = thunk<K, method>;
290 }; 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;
291 245
292 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)> 246 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)>
293 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)
294 { 248 {
295 klass *obj = static_cast<klass *>(self); 249 klass *obj = static_cast<klass *>(self);
296 return (obj->*method) (a1, a2, a3, a4, a5); 250 return (obj->*method) (a1, a2, a3, a4, a5);
297 } 251 }
298
299public:
300 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
301 void set (K *object)
302 {
303 self = object;
304 func = thunk<K, method>;
305 }
306
307 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
308 {
309 return func (self, a1, a2, a3, a4, a5);
310 }
311
312 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
313 {
314 return call (a1, a2, a3, a4, a5);
315 }
316}; 252};
317 253
318template<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>
319struct callback<R (A1, A2, A3, A4, A5, A6)> 255struct callback<R (A1, A2, A3, A4, A5, A6)>
320{ 256{
321 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);
322 258
323private: 259 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
324 260 void set (K *object)
325 void *self;
326 ptr_type func;
327
328protected:
329
330 template<typename method>
331 struct thunktype;
332
333 template<class klass>
334 struct thunktype<R (klass::*)>
335 { 261 {
336 typedef klass K; 262 self = object;
263 func = thunk<K, method>;
337 }; 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;
338 280
339 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)>
340 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)
341 { 283 {
342 klass *obj = static_cast<klass *>(self); 284 klass *obj = static_cast<klass *>(self);
343 return (obj->*method) (a1, a2, a3, a4, a5, a6); 285 return (obj->*method) (a1, a2, a3, a4, a5, a6);
344 } 286 }
345
346public:
347 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
348 void set (K *object)
349 {
350 self = object;
351 func = thunk<K, method>;
352 }
353
354 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
355 {
356 return func (self, a1, a2, a3, a4, a5, a6);
357 }
358
359 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
360 {
361 return call (a1, a2, a3, a4, a5, a6);
362 }
363}; 287};
364 288
365template<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>
366struct callback<R (A1, A2, A3, A4, A5, A6, A7)> 290struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
367{ 291{
368 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);
369 293
370private: 294 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
371 295 void set (K *object)
372 void *self;
373 ptr_type func;
374
375protected:
376
377 template<typename method>
378 struct thunktype;
379
380 template<class klass>
381 struct thunktype<R (klass::*)>
382 { 296 {
383 typedef klass K; 297 self = object;
298 func = thunk<K, method>;
384 }; 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;
385 315
386 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)>
387 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)
388 { 318 {
389 klass *obj = static_cast<klass *>(self); 319 klass *obj = static_cast<klass *>(self);
390 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7); 320 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
391 } 321 }
392
393public:
394 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
395 void set (K *object)
396 {
397 self = object;
398 func = thunk<K, method>;
399 }
400
401 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
402 {
403 return func (self, a1, a2, a3, a4, a5, a6, a7);
404 }
405
406 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
407 {
408 return call (a1, a2, a3, a4, a5, a6, a7);
409 }
410}; 322};
411 323
412template<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>
413struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)> 325struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)>
414{ 326{
415 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);
416 328
417private: 329 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
418 330 void set (K *object)
419 void *self;
420 ptr_type func;
421
422protected:
423
424 template<typename method>
425 struct thunktype;
426
427 template<class klass>
428 struct thunktype<R (klass::*)>
429 { 331 {
430 typedef klass K; 332 self = object;
333 func = thunk<K, method>;
431 }; 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;
432 350
433 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)>
434 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)
435 { 353 {
436 klass *obj = static_cast<klass *>(self); 354 klass *obj = static_cast<klass *>(self);
437 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8); 355 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
438 } 356 }
439
440public:
441 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
442 void set (K *object)
443 {
444 self = object;
445 func = thunk<K, method>;
446 }
447
448 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
449 {
450 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
451 }
452
453 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
454 {
455 return call (a1, a2, a3, a4, a5, a6, a7, a8);
456 }
457}; 357};
458 358
459template<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>
460struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)> 360struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>
461{ 361{
462 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);
463 363
464private: 364 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
465 365 void set (K *object)
466 void *self;
467 ptr_type func;
468
469protected:
470
471 template<typename method>
472 struct thunktype;
473
474 template<class klass>
475 struct thunktype<R (klass::*)>
476 { 366 {
477 typedef klass K; 367 self = object;
368 func = thunk<K, method>;
478 }; 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;
479 385
480 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)>
481 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)
482 { 388 {
483 klass *obj = static_cast<klass *>(self); 389 klass *obj = static_cast<klass *>(self);
484 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);
485 } 391 }
486
487public:
488 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
489 void set (K *object)
490 {
491 self = object;
492 func = thunk<K, method>;
493 }
494
495 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
496 {
497 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
498 }
499
500 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
501 {
502 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
503 }
504}; 392};
505 393
506template<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>
507struct 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)>
508{ 396{
509 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);
510 398
511private: 399 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
512 400 void set (K *object)
513 void *self;
514 ptr_type func;
515
516protected:
517
518 template<typename method>
519 struct thunktype;
520
521 template<class klass>
522 struct thunktype<R (klass::*)>
523 { 401 {
524 typedef klass K; 402 self = object;
403 func = thunk<K, method>;
525 }; 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;
526 420
527 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)>
528 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)
529 { 423 {
530 klass *obj = static_cast<klass *>(self); 424 klass *obj = static_cast<klass *>(self);
531 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);
532 } 426 }
533
534public:
535 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
536 void set (K *object)
537 {
538 self = object;
539 func = thunk<K, method>;
540 }
541
542 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
543 {
544 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
545 }
546
547 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
548 {
549 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
550 }
551}; 427};
552 428
553 429
554#endif 430#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines