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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines