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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines