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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines