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

Comparing rxvt-unicode/src/callback.h (file contents):
Revision 1.10 by root, Tue Dec 4 14:50:40 2007 UTC vs.
Revision 1.14 by root, Thu May 22 18:54:32 2014 UTC

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-2007 Marc Lehmann <schmorp@schmorp.de>
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 GVPE is free software; you can redistribute it and/or modify
12 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
13 the Free Software Foundation; either version 2 of the License, or 13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version. 14 (at your 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,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 but 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
29#define CALLBACK_H_VERSION 3 29#define CALLBACK_H_VERSION 3
30 30
31template<typename signature> 31template<typename signature>
32struct callback; 32struct callback;
33 33
34#define callback_set(callback,obj,klass,method) callback.set<klass, &klass::method> (obj)
35
36template<class R> 34template<class R>
37struct callback<R ()> 35struct callback<R ()>
38{ 36{
39 typedef R (*ptr_type)(void *self); 37 typedef R (*ptr_type)(void *self);
40 38
41private: 39 template<class K, R (K::*method)()>
42 40 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 { 41 {
54 typedef klass K; 42 self = object;
43 func = thunk<K, method>;
55 }; 44 }
45
46 R call () const
47 {
48 return func (self);
49 }
50
51 R operator ()() const
52 {
53 return call ();
54 }
55
56private:
57
58 void *self;
59 ptr_type func;
56 60
57 template<class klass, R (klass::*method)()> 61 template<class klass, R (klass::*method)()>
58 static R thunk (void *self) 62 static R thunk (void *self)
59 { 63 {
60 klass *obj = static_cast<klass *>(self); 64 klass *obj = static_cast<klass *>(self);
61 return (obj->*method) (); 65 return (obj->*method) ();
62 } 66 }
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}; 67};
82 68
83template<class R, class A1> 69template<class R, class A1>
84struct callback<R (A1)> 70struct callback<R (A1)>
85{ 71{
86 typedef R (*ptr_type)(void *self, A1); 72 typedef R (*ptr_type)(void *self, A1);
87 73
88private: 74 template<class K, R (K::*method)(A1)>
89 75 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 { 76 {
101 typedef klass K; 77 self = object;
78 func = thunk<K, method>;
102 }; 79 }
80
81 R call (A1 a1) const
82 {
83 return func (self, a1);
84 }
85
86 R operator ()(A1 a1) const
87 {
88 return call (a1);
89 }
90
91private:
92
93 void *self;
94 ptr_type func;
103 95
104 template<class klass, R (klass::*method)(A1)> 96 template<class klass, R (klass::*method)(A1)>
105 static R thunk (void *self, A1 a1) 97 static R thunk (void *self, A1 a1)
106 { 98 {
107 klass *obj = static_cast<klass *>(self); 99 klass *obj = static_cast<klass *>(self);
108 return (obj->*method) (a1); 100 return (obj->*method) (a1);
109 } 101 }
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}; 102};
129 103
130template<class R, class A1, class A2> 104template<class R, class A1, class A2>
131struct callback<R (A1, A2)> 105struct callback<R (A1, A2)>
132{ 106{
133 typedef R (*ptr_type)(void *self, A1, A2); 107 typedef R (*ptr_type)(void *self, A1, A2);
134 108
135private: 109 template<class K, R (K::*method)(A1, A2)>
136 110 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 { 111 {
148 typedef klass K; 112 self = object;
113 func = thunk<K, method>;
149 }; 114 }
115
116 R call (A1 a1, A2 a2) const
117 {
118 return func (self, a1, a2);
119 }
120
121 R operator ()(A1 a1, A2 a2) const
122 {
123 return call (a1, a2);
124 }
125
126private:
127
128 void *self;
129 ptr_type func;
150 130
151 template<class klass, R (klass::*method)(A1, A2)> 131 template<class klass, R (klass::*method)(A1, A2)>
152 static R thunk (void *self, A1 a1, A2 a2) 132 static R thunk (void *self, A1 a1, A2 a2)
153 { 133 {
154 klass *obj = static_cast<klass *>(self); 134 klass *obj = static_cast<klass *>(self);
155 return (obj->*method) (a1, a2); 135 return (obj->*method) (a1, a2);
156 } 136 }
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}; 137};
176 138
177template<class R, class A1, class A2, class A3> 139template<class R, class A1, class A2, class A3>
178struct callback<R (A1, A2, A3)> 140struct callback<R (A1, A2, A3)>
179{ 141{
180 typedef R (*ptr_type)(void *self, A1, A2, A3); 142 typedef R (*ptr_type)(void *self, A1, A2, A3);
181 143
182private: 144 template<class K, R (K::*method)(A1, A2, A3)>
183 145 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 { 146 {
195 typedef klass K; 147 self = object;
148 func = thunk<K, method>;
196 }; 149 }
150
151 R call (A1 a1, A2 a2, A3 a3) const
152 {
153 return func (self, a1, a2, a3);
154 }
155
156 R operator ()(A1 a1, A2 a2, A3 a3) const
157 {
158 return call (a1, a2, a3);
159 }
160
161private:
162
163 void *self;
164 ptr_type func;
197 165
198 template<class klass, R (klass::*method)(A1, A2, A3)> 166 template<class klass, R (klass::*method)(A1, A2, A3)>
199 static R thunk (void *self, A1 a1, A2 a2, A3 a3) 167 static R thunk (void *self, A1 a1, A2 a2, A3 a3)
200 { 168 {
201 klass *obj = static_cast<klass *>(self); 169 klass *obj = static_cast<klass *>(self);
202 return (obj->*method) (a1, a2, a3); 170 return (obj->*method) (a1, a2, a3);
203 } 171 }
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}; 172};
223 173
224template<class R, class A1, class A2, class A3, class A4> 174template<class R, class A1, class A2, class A3, class A4>
225struct callback<R (A1, A2, A3, A4)> 175struct callback<R (A1, A2, A3, A4)>
226{ 176{
227 typedef R (*ptr_type)(void *self, A1, A2, A3, A4); 177 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
228 178
229private: 179 template<class K, R (K::*method)(A1, A2, A3, A4)>
230 180 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 { 181 {
242 typedef klass K; 182 self = object;
183 func = thunk<K, method>;
243 }; 184 }
185
186 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
187 {
188 return func (self, a1, a2, a3, a4);
189 }
190
191 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
192 {
193 return call (a1, a2, a3, a4);
194 }
195
196private:
197
198 void *self;
199 ptr_type func;
244 200
245 template<class klass, R (klass::*method)(A1, A2, A3, A4)> 201 template<class klass, R (klass::*method)(A1, A2, A3, A4)>
246 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4) 202 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4)
247 { 203 {
248 klass *obj = static_cast<klass *>(self); 204 klass *obj = static_cast<klass *>(self);
249 return (obj->*method) (a1, a2, a3, a4); 205 return (obj->*method) (a1, a2, a3, a4);
250 } 206 }
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}; 207};
270 208
271template<class R, class A1, class A2, class A3, class A4, class A5> 209template<class R, class A1, class A2, class A3, class A4, class A5>
272struct callback<R (A1, A2, A3, A4, A5)> 210struct callback<R (A1, A2, A3, A4, A5)>
273{ 211{
274 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5); 212 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
275 213
276private: 214 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
277 215 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 { 216 {
289 typedef klass K; 217 self = object;
218 func = thunk<K, method>;
290 }; 219 }
220
221 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
222 {
223 return func (self, a1, a2, a3, a4, a5);
224 }
225
226 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
227 {
228 return call (a1, a2, a3, a4, a5);
229 }
230
231private:
232
233 void *self;
234 ptr_type func;
291 235
292 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)> 236 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) 237 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
294 { 238 {
295 klass *obj = static_cast<klass *>(self); 239 klass *obj = static_cast<klass *>(self);
296 return (obj->*method) (a1, a2, a3, a4, a5); 240 return (obj->*method) (a1, a2, a3, a4, a5);
297 } 241 }
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}; 242};
317 243
318template<class R, class A1, class A2, class A3, class A4, class A5, class A6> 244template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
319struct callback<R (A1, A2, A3, A4, A5, A6)> 245struct callback<R (A1, A2, A3, A4, A5, A6)>
320{ 246{
321 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6); 247 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
322 248
323private: 249 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
324 250 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 { 251 {
336 typedef klass K; 252 self = object;
253 func = thunk<K, method>;
337 }; 254 }
255
256 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
257 {
258 return func (self, a1, a2, a3, a4, a5, a6);
259 }
260
261 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
262 {
263 return call (a1, a2, a3, a4, a5, a6);
264 }
265
266private:
267
268 void *self;
269 ptr_type func;
338 270
339 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)> 271 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) 272 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
341 { 273 {
342 klass *obj = static_cast<klass *>(self); 274 klass *obj = static_cast<klass *>(self);
343 return (obj->*method) (a1, a2, a3, a4, a5, a6); 275 return (obj->*method) (a1, a2, a3, a4, a5, a6);
344 } 276 }
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}; 277};
364 278
365template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> 279template<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)> 280struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
367{ 281{
368 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7); 282 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
369 283
370private: 284 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
371 285 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 { 286 {
383 typedef klass K; 287 self = object;
288 func = thunk<K, method>;
384 }; 289 }
290
291 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
292 {
293 return func (self, a1, a2, a3, a4, a5, a6, a7);
294 }
295
296 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
297 {
298 return call (a1, a2, a3, a4, a5, a6, a7);
299 }
300
301private:
302
303 void *self;
304 ptr_type func;
385 305
386 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)> 306 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) 307 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
388 { 308 {
389 klass *obj = static_cast<klass *>(self); 309 klass *obj = static_cast<klass *>(self);
390 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7); 310 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
391 } 311 }
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}; 312};
411 313
412template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> 314template<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)> 315struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)>
414{ 316{
415 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8); 317 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8);
416 318
417private: 319 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
418 320 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 { 321 {
430 typedef klass K; 322 self = object;
323 func = thunk<K, method>;
431 }; 324 }
325
326 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
327 {
328 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
329 }
330
331 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
332 {
333 return call (a1, a2, a3, a4, a5, a6, a7, a8);
334 }
335
336private:
337
338 void *self;
339 ptr_type func;
432 340
433 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)> 341 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) 342 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
435 { 343 {
436 klass *obj = static_cast<klass *>(self); 344 klass *obj = static_cast<klass *>(self);
437 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8); 345 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
438 } 346 }
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}; 347};
458 348
459template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> 349template<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)> 350struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>
461{ 351{
462 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9); 352 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9);
463 353
464private: 354 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
465 355 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 { 356 {
477 typedef klass K; 357 self = object;
358 func = thunk<K, method>;
478 }; 359 }
360
361 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
362 {
363 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
364 }
365
366 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
367 {
368 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
369 }
370
371private:
372
373 void *self;
374 ptr_type func;
479 375
480 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)> 376 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) 377 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
482 { 378 {
483 klass *obj = static_cast<klass *>(self); 379 klass *obj = static_cast<klass *>(self);
484 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9); 380 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9);
485 } 381 }
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}; 382};
505 383
506template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> 384template<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)> 385struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
508{ 386{
509 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); 387 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
510 388
511private: 389 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
512 390 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 { 391 {
524 typedef klass K; 392 self = object;
393 func = thunk<K, method>;
525 }; 394 }
395
396 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
397 {
398 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
399 }
400
401 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
402 {
403 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
404 }
405
406private:
407
408 void *self;
409 ptr_type func;
526 410
527 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> 411 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) 412 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 { 413 {
530 klass *obj = static_cast<klass *>(self); 414 klass *obj = static_cast<klass *>(self);
531 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); 415 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
532 } 416 }
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}; 417};
552 418
553 419
554#endif 420#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines