ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/callback.h
(Generate patch)

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines