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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines