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.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
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;
33
34#define callback_set(callback,obj,klass,method) callback.set<klass, &klass::method> (obj)
28 35
29template<class R> 36template<class R>
30class callback0 { 37struct callback<R ()>
31 struct object { }; 38{
39 typedef R (*ptr_type)(void *self);
32 40
33 void *obj; 41private:
34 R (object::*meth)();
35 42
36 /* a proxy is a kind of recipe on how to call a specific class method */ 43 void *self;
37 struct proxy_base { 44 ptr_type func;
38 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) ();
39 }; 62 }
40 template<class O1, class O2> 63
41 struct proxy : proxy_base { 64public:
42 virtual R call (void *obj, R (object::*meth)()) 65 template<class K, R (K::*method)()>
43 { 66 void set (K *object)
44 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth))) 67 {
45 (); 68 self = object;
46 } 69 func = thunk<K, method>;
47 }; 70 }
48 71
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 72 R call () const
62 { 73 {
63 return prxy->call (obj, meth); 74 return func (self);
64 } 75 }
65 76
66 R operator ()() const 77 R operator ()() const
67 { 78 {
68 return call (); 79 return call ();
69 } 80 }
70}; 81};
71 82
72template<class R, class A1> 83template<class R, class A1>
73class callback1 { 84struct callback<R (A1)>
74 struct object { }; 85{
86 typedef R (*ptr_type)(void *self, A1);
75 87
76 void *obj; 88private:
77 R (object::*meth)(A1);
78 89
79 /* a proxy is a kind of recipe on how to call a specific class method */ 90 void *self;
80 struct proxy_base { 91 ptr_type func;
81 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);
82 }; 109 }
83 template<class O1, class O2> 110
84 struct proxy : proxy_base { 111public:
85 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) 112 template<class K, R (K::*method)(A1)>
86 { 113 void set (K *object)
87 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth))) 114 {
88 (a1); 115 self = object;
89 } 116 func = thunk<K, method>;
90 }; 117 }
91 118
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 119 R call (A1 a1) const
105 { 120 {
106 return prxy->call (obj, meth, a1); 121 return func (self, a1);
107 } 122 }
108 123
109 R operator ()(A1 a1) const 124 R operator ()(A1 a1) const
110 { 125 {
111 return call (a1); 126 return call (a1);
112 } 127 }
113}; 128};
114 129
115template<class R, class A1, class A2> 130template<class R, class A1, class A2>
116class callback2 { 131struct callback<R (A1, A2)>
117 struct object { }; 132{
133 typedef R (*ptr_type)(void *self, A1, A2);
118 134
119 void *obj; 135private:
120 R (object::*meth)(A1, A2);
121 136
122 /* a proxy is a kind of recipe on how to call a specific class method */ 137 void *self;
123 struct proxy_base { 138 ptr_type func;
124 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);
125 }; 156 }
126 template<class O1, class O2> 157
127 struct proxy : proxy_base { 158public:
128 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) 159 template<class K, R (K::*method)(A1, A2)>
129 { 160 void set (K *object)
130 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth))) 161 {
131 (a1, a2); 162 self = object;
132 } 163 func = thunk<K, method>;
133 }; 164 }
134 165
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 166 R call (A1 a1, A2 a2) const
148 { 167 {
149 return prxy->call (obj, meth, a1, a2); 168 return func (self, a1, a2);
150 } 169 }
151 170
152 R operator ()(A1 a1, A2 a2) const 171 R operator ()(A1 a1, A2 a2) const
153 { 172 {
154 return call (a1, a2); 173 return call (a1, a2);
155 } 174 }
156}; 175};
157 176
158template<class R, class A1, class A2, class A3> 177template<class R, class A1, class A2, class A3>
159class callback3 { 178struct callback<R (A1, A2, A3)>
160 struct object { }; 179{
180 typedef R (*ptr_type)(void *self, A1, A2, A3);
161 181
162 void *obj; 182private:
163 R (object::*meth)(A1, A2, A3);
164 183
165 /* a proxy is a kind of recipe on how to call a specific class method */ 184 void *self;
166 struct proxy_base { 185 ptr_type func;
167 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);
168 }; 203 }
169 template<class O1, class O2> 204
170 struct proxy : proxy_base { 205public:
171 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)>
172 { 207 void set (K *object)
173 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth))) 208 {
174 (a1, a2, a3); 209 self = object;
175 } 210 func = thunk<K, method>;
176 }; 211 }
177 212
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 213 R call (A1 a1, A2 a2, A3 a3) const
191 { 214 {
192 return prxy->call (obj, meth, a1, a2, a3); 215 return func (self, a1, a2, a3);
193 } 216 }
194 217
195 R operator ()(A1 a1, A2 a2, A3 a3) const 218 R operator ()(A1 a1, A2 a2, A3 a3) const
196 { 219 {
197 return call (a1, a2, a3); 220 return call (a1, a2, a3);
198 } 221 }
199}; 222};
200 223
201template<class R, class A1, class A2, class A3, class A4> 224template<class R, class A1, class A2, class A3, class A4>
202class callback4 { 225struct callback<R (A1, A2, A3, A4)>
203 struct object { }; 226{
227 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
204 228
205 void *obj; 229private:
206 R (object::*meth)(A1, A2, A3, A4);
207 230
208 /* a proxy is a kind of recipe on how to call a specific class method */ 231 void *self;
209 struct proxy_base { 232 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; 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);
211 }; 250 }
212 template<class O1, class O2> 251
213 struct proxy : proxy_base { 252public:
214 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)>
215 { 254 void set (K *object)
216 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth))) 255 {
217 (a1, a2, a3, a4); 256 self = object;
218 } 257 func = thunk<K, method>;
219 }; 258 }
220 259
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 260 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
234 { 261 {
235 return prxy->call (obj, meth, a1, a2, a3, a4); 262 return func (self, a1, a2, a3, a4);
236 } 263 }
237 264
238 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const 265 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
239 { 266 {
240 return call (a1, a2, a3, a4); 267 return call (a1, a2, a3, a4);
241 } 268 }
242}; 269};
243 270
244template<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>
245class callback5 { 272struct callback<R (A1, A2, A3, A4, A5)>
246 struct object { }; 273{
274 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
247 275
248 void *obj; 276private:
249 R (object::*meth)(A1, A2, A3, A4, A5);
250 277
251 /* a proxy is a kind of recipe on how to call a specific class method */ 278 void *self;
252 struct proxy_base { 279 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; 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);
254 }; 297 }
255 template<class O1, class O2> 298
256 struct proxy : proxy_base { 299public:
257 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)>
258 { 301 void set (K *object)
259 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth))) 302 {
260 (a1, a2, a3, a4, a5); 303 self = object;
261 } 304 func = thunk<K, method>;
262 }; 305 }
263 306
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 307 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
277 { 308 {
278 return prxy->call (obj, meth, a1, a2, a3, a4, a5); 309 return func (self, a1, a2, a3, a4, a5);
279 } 310 }
280 311
281 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
282 { 313 {
283 return call (a1, a2, a3, a4, a5); 314 return call (a1, a2, a3, a4, a5);
284 } 315 }
285}; 316};
286 317
287template<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>
288class callback6 { 319struct callback<R (A1, A2, A3, A4, A5, A6)>
289 struct object { }; 320{
321 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
290 322
291 void *obj; 323private:
292 R (object::*meth)(A1, A2, A3, A4, A5, A6);
293 324
294 /* a proxy is a kind of recipe on how to call a specific class method */ 325 void *self;
295 struct proxy_base { 326 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; 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);
297 }; 344 }
298 template<class O1, class O2> 345
299 struct proxy : proxy_base { 346public:
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) 347 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
301 { 348 void set (K *object)
302 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth))) 349 {
303 (a1, a2, a3, a4, a5, a6); 350 self = object;
304 } 351 func = thunk<K, method>;
305 }; 352 }
306 353
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 354 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
320 { 355 {
321 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6); 356 return func (self, a1, a2, a3, a4, a5, a6);
322 } 357 }
323 358
324 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
325 { 360 {
326 return call (a1, a2, a3, a4, a5, a6); 361 return call (a1, a2, a3, a4, a5, a6);
327 } 362 }
328}; 363};
329 364
330template<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>
331class callback7 { 366struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
332 struct object { }; 367{
368 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
333 369
334 void *obj; 370private:
335 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7);
336 371
337 /* a proxy is a kind of recipe on how to call a specific class method */ 372 void *self;
338 struct proxy_base { 373 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; 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);
340 }; 391 }
341 template<class O1, class O2> 392
342 struct proxy : proxy_base { 393public:
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) 394 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
344 { 395 void set (K *object)
345 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth))) 396 {
346 (a1, a2, a3, a4, a5, a6, a7); 397 self = object;
347 } 398 func = thunk<K, method>;
348 }; 399 }
349 400
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 401 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
363 { 402 {
364 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7); 403 return func (self, a1, a2, a3, a4, a5, a6, a7);
365 } 404 }
366 405
367 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
368 { 407 {
369 return call (a1, a2, a3, a4, a5, a6, a7); 408 return call (a1, a2, a3, a4, a5, a6, a7);
370 } 409 }
371}; 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
372 553
373#endif 554#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines