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.5 by pcg, Thu Mar 3 16:54:34 2005 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-2005 Marc Lehmann <gvpe@schmorp.de> 7 Copyright (C) 2003-2007 Marc Lehmann <pcg@goof.com>
11 8
12 This file is part of GVPE. 9 This file is part of GVPE.
13 10
14 GVPE is free software; you can redistribute it and/or modify 11 GVPE is free software; you can redistribute it and/or modify
15 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
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details. 19 GNU General Public License for more details.
23 20
24 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
25 along with gvpe; if not, write to the Free Software 22 along with gvpe; if not, write to the Free Software
26 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
27*/ 24*/
28 25
29#ifndef CALLBACK_H__ 26#ifndef CALLBACK_H__
30#define CALLBACK_H__ 27#define CALLBACK_H__
31 28
29#define CALLBACK_H_VERSION 3
30
31template<typename signature>
32struct callback;
33
32template<class R> 34template<class R>
33class callback0 { 35struct callback<R ()>
34 struct object { }; 36{
37 typedef R (*ptr_type)(void *self);
35 38
36 void *obj; 39private:
37 R (object::*meth)();
38 40
39 /* a proxy is a kind of recipe on how to call a specific class method */ 41 void *self;
40 struct proxy_base { 42 ptr_type func;
41 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) ();
42 }; 60 }
43 template<class O1, class O2> 61
44 struct proxy : proxy_base { 62public:
45 virtual R call (void *obj, R (object::*meth)()) 63 template<class K, R (K::*method)()>
46 { 64 void set (K *object)
47 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth))) 65 {
48 (); 66 self = object;
49 } 67 func = thunk<K, method>;
50 }; 68 }
51 69
52 proxy_base *prxy;
53
54public:
55 template<class O1, class O2>
56 callback0 (O1 *object, R (O2::*method)())
57 {
58 static proxy<O1,O2> p;
59 obj = reinterpret_cast<void *>(object);
60 meth = reinterpret_cast<R (object::*)()>(method);
61 prxy = &p;
62 }
63
64 R call() const 70 R call () const
65 { 71 {
66 return prxy->call (obj, meth); 72 return func (self);
67 } 73 }
68 74
69 R operator ()() const 75 R operator ()() const
70 { 76 {
71 return call (); 77 return call ();
72 } 78 }
73}; 79};
74 80
75template<class R, class A1> 81template<class R, class A1>
76class callback1 { 82struct callback<R (A1)>
77 struct object { }; 83{
84 typedef R (*ptr_type)(void *self, A1);
78 85
79 void *obj; 86private:
80 R (object::*meth)(A1);
81 87
82 /* a proxy is a kind of recipe on how to call a specific class method */ 88 void *self;
83 struct proxy_base { 89 ptr_type func;
84 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);
85 }; 107 }
86 template<class O1, class O2> 108
87 struct proxy : proxy_base { 109public:
88 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) 110 template<class K, R (K::*method)(A1)>
89 { 111 void set (K *object)
90 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth))) 112 {
91 (a1); 113 self = object;
92 } 114 func = thunk<K, method>;
93 }; 115 }
94 116
95 proxy_base *prxy;
96
97public:
98 template<class O1, class O2>
99 callback1 (O1 *object, R (O2::*method)(A1))
100 {
101 static proxy<O1,O2> p;
102 obj = reinterpret_cast<void *>(object);
103 meth = reinterpret_cast<R (object::*)(A1)>(method);
104 prxy = &p;
105 }
106
107 R call(A1 a1) const 117 R call (A1 a1) const
108 { 118 {
109 return prxy->call (obj, meth, a1); 119 return func (self, a1);
110 } 120 }
111 121
112 R operator ()(A1 a1) const 122 R operator ()(A1 a1) const
113 { 123 {
114 return call (a1); 124 return call (a1);
115 } 125 }
116}; 126};
117 127
118template<class R, class A1, class A2> 128template<class R, class A1, class A2>
119class callback2 { 129struct callback<R (A1, A2)>
120 struct object { }; 130{
131 typedef R (*ptr_type)(void *self, A1, A2);
121 132
122 void *obj; 133private:
123 R (object::*meth)(A1, A2);
124 134
125 /* a proxy is a kind of recipe on how to call a specific class method */ 135 void *self;
126 struct proxy_base { 136 ptr_type func;
127 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);
128 }; 154 }
129 template<class O1, class O2> 155
130 struct proxy : proxy_base { 156public:
131 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) 157 template<class K, R (K::*method)(A1, A2)>
132 { 158 void set (K *object)
133 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth))) 159 {
134 (a1, a2); 160 self = object;
135 } 161 func = thunk<K, method>;
136 }; 162 }
137 163
138 proxy_base *prxy;
139
140public:
141 template<class O1, class O2>
142 callback2 (O1 *object, R (O2::*method)(A1, A2))
143 {
144 static proxy<O1,O2> p;
145 obj = reinterpret_cast<void *>(object);
146 meth = reinterpret_cast<R (object::*)(A1, A2)>(method);
147 prxy = &p;
148 }
149
150 R call(A1 a1, A2 a2) const 164 R call (A1 a1, A2 a2) const
151 { 165 {
152 return prxy->call (obj, meth, a1, a2); 166 return func (self, a1, a2);
153 } 167 }
154 168
155 R operator ()(A1 a1, A2 a2) const 169 R operator ()(A1 a1, A2 a2) const
156 { 170 {
157 return call (a1, a2); 171 return call (a1, a2);
158 } 172 }
159}; 173};
160 174
161template<class R, class A1, class A2, class A3> 175template<class R, class A1, class A2, class A3>
162class callback3 { 176struct callback<R (A1, A2, A3)>
163 struct object { }; 177{
178 typedef R (*ptr_type)(void *self, A1, A2, A3);
164 179
165 void *obj; 180private:
166 R (object::*meth)(A1, A2, A3);
167 181
168 /* a proxy is a kind of recipe on how to call a specific class method */ 182 void *self;
169 struct proxy_base { 183 ptr_type func;
170 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);
171 }; 201 }
172 template<class O1, class O2> 202
173 struct proxy : proxy_base { 203public:
174 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)>
175 { 205 void set (K *object)
176 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth))) 206 {
177 (a1, a2, a3); 207 self = object;
178 } 208 func = thunk<K, method>;
179 }; 209 }
180 210
181 proxy_base *prxy;
182
183public:
184 template<class O1, class O2>
185 callback3 (O1 *object, R (O2::*method)(A1, A2, A3))
186 {
187 static proxy<O1,O2> p;
188 obj = reinterpret_cast<void *>(object);
189 meth = reinterpret_cast<R (object::*)(A1, A2, A3)>(method);
190 prxy = &p;
191 }
192
193 R call(A1 a1, A2 a2, A3 a3) const 211 R call (A1 a1, A2 a2, A3 a3) const
194 { 212 {
195 return prxy->call (obj, meth, a1, a2, a3); 213 return func (self, a1, a2, a3);
196 } 214 }
197 215
198 R operator ()(A1 a1, A2 a2, A3 a3) const 216 R operator ()(A1 a1, A2 a2, A3 a3) const
199 { 217 {
200 return call (a1, a2, a3); 218 return call (a1, a2, a3);
201 } 219 }
202}; 220};
203 221
204template<class R, class A1, class A2, class A3, class A4> 222template<class R, class A1, class A2, class A3, class A4>
205class callback4 { 223struct callback<R (A1, A2, A3, A4)>
206 struct object { }; 224{
225 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
207 226
208 void *obj; 227private:
209 R (object::*meth)(A1, A2, A3, A4);
210 228
211 /* a proxy is a kind of recipe on how to call a specific class method */ 229 void *self;
212 struct proxy_base { 230 ptr_type func;
213 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);
214 }; 248 }
215 template<class O1, class O2> 249
216 struct proxy : proxy_base { 250public:
217 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)>
218 { 252 void set (K *object)
219 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth))) 253 {
220 (a1, a2, a3, a4); 254 self = object;
221 } 255 func = thunk<K, method>;
222 }; 256 }
223 257
224 proxy_base *prxy;
225
226public:
227 template<class O1, class O2>
228 callback4 (O1 *object, R (O2::*method)(A1, A2, A3, A4))
229 {
230 static proxy<O1,O2> p;
231 obj = reinterpret_cast<void *>(object);
232 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4)>(method);
233 prxy = &p;
234 }
235
236 R call(A1 a1, A2 a2, A3 a3, A4 a4) const 258 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
237 { 259 {
238 return prxy->call (obj, meth, a1, a2, a3, a4); 260 return func (self, a1, a2, a3, a4);
239 } 261 }
240 262
241 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const 263 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
242 { 264 {
243 return call (a1, a2, a3, a4); 265 return call (a1, a2, a3, a4);
244 } 266 }
245}; 267};
246 268
247template<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>
248class callback5 { 270struct callback<R (A1, A2, A3, A4, A5)>
249 struct object { }; 271{
272 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
250 273
251 void *obj; 274private:
252 R (object::*meth)(A1, A2, A3, A4, A5);
253 275
254 /* a proxy is a kind of recipe on how to call a specific class method */ 276 void *self;
255 struct proxy_base { 277 ptr_type func;
256 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);
257 }; 295 }
258 template<class O1, class O2> 296
259 struct proxy : proxy_base { 297public:
260 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)>
261 { 299 void set (K *object)
262 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth))) 300 {
263 (a1, a2, a3, a4, a5); 301 self = object;
264 } 302 func = thunk<K, method>;
265 }; 303 }
266 304
267 proxy_base *prxy;
268
269public:
270 template<class O1, class O2>
271 callback5 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5))
272 {
273 static proxy<O1,O2> p;
274 obj = reinterpret_cast<void *>(object);
275 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5)>(method);
276 prxy = &p;
277 }
278
279 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
280 { 306 {
281 return prxy->call (obj, meth, a1, a2, a3, a4, a5); 307 return func (self, a1, a2, a3, a4, a5);
282 } 308 }
283 309
284 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
285 { 311 {
286 return call (a1, a2, a3, a4, a5); 312 return call (a1, a2, a3, a4, a5);
287 } 313 }
288}; 314};
289 315
290template<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>
291class callback6 { 317struct callback<R (A1, A2, A3, A4, A5, A6)>
292 struct object { }; 318{
319 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
293 320
294 void *obj; 321private:
295 R (object::*meth)(A1, A2, A3, A4, A5, A6);
296 322
297 /* a proxy is a kind of recipe on how to call a specific class method */ 323 void *self;
298 struct proxy_base { 324 ptr_type func;
299 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);
300 }; 342 }
301 template<class O1, class O2> 343
302 struct proxy : proxy_base { 344public:
303 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)>
304 { 346 void set (K *object)
305 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth))) 347 {
306 (a1, a2, a3, a4, a5, a6); 348 self = object;
307 } 349 func = thunk<K, method>;
308 }; 350 }
309 351
310 proxy_base *prxy;
311
312public:
313 template<class O1, class O2>
314 callback6 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6))
315 {
316 static proxy<O1,O2> p;
317 obj = reinterpret_cast<void *>(object);
318 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6)>(method);
319 prxy = &p;
320 }
321
322 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
323 { 353 {
324 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6); 354 return func (self, a1, a2, a3, a4, a5, a6);
325 } 355 }
326 356
327 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
328 { 358 {
329 return call (a1, a2, a3, a4, a5, a6); 359 return call (a1, a2, a3, a4, a5, a6);
330 } 360 }
331}; 361};
332 362
333template<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>
334class callback7 { 364struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
335 struct object { }; 365{
366 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
336 367
337 void *obj; 368private:
338 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7);
339 369
340 /* a proxy is a kind of recipe on how to call a specific class method */ 370 void *self;
341 struct proxy_base { 371 ptr_type func;
342 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);
343 }; 389 }
344 template<class O1, class O2> 390
345 struct proxy : proxy_base { 391public:
346 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)>
347 { 393 void set (K *object)
348 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth))) 394 {
349 (a1, a2, a3, a4, a5, a6, a7); 395 self = object;
350 } 396 func = thunk<K, method>;
351 }; 397 }
352 398
353 proxy_base *prxy;
354
355public:
356 template<class O1, class O2>
357 callback7 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7))
358 {
359 static proxy<O1,O2> p;
360 obj = reinterpret_cast<void *>(object);
361 meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7)>(method);
362 prxy = &p;
363 }
364
365 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
366 { 400 {
367 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7); 401 return func (self, a1, a2, a3, a4, a5, a6, a7);
368 } 402 }
369 403
370 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
371 { 405 {
372 return call (a1, a2, a3, a4, a5, a6, a7); 406 return call (a1, a2, a3, a4, a5, a6, a7);
373 } 407 }
374}; 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
375 551
376#endif 552#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines