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.6 by pcg, Tue Apr 26 00:55:55 2005 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 Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de> 7 * Copyright (C) 2003-2008 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 * This program is free software; you can redistribute it and/or modify it
15 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
16 the Free Software Foundation; either version 2 of the License, or 13 * Free Software Foundation; either version 3 of the License, or (at your
17 (at your option) any later version. 14 * option) any later version.
18 15 *
19 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
20 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
22 GNU General Public License for more details. 19 * 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 along
25 along with gvpe; if not, write to the Free Software 22 * with this program; if not, see <http://www.gnu.org/licenses/>.
26 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
27*/ 34*/
28 35
29#ifndef CALLBACK_H__ 36#ifndef CALLBACK_H__
30#define CALLBACK_H__ 37#define CALLBACK_H__
31 38
39#define CALLBACK_H_VERSION 3
40
41template<typename signature>
42struct callback;
43
32template<class R> 44template<class R>
33class callback0 { 45struct callback<R ()>
34 struct object { }; 46{
47 typedef R (*ptr_type)(void *self);
35 48
36 void *obj; 49 template<class K, R (K::*method)()>
37 R (object::*meth)(); 50 void set (K *object)
38 51 {
39 /* a proxy is a kind of recipe on how to call a specific class method */ 52 self = object;
40 struct proxy_base { 53 func = thunk<K, method>;
41 virtual R call (void *obj, R (object::*meth)()) = 0;
42 }; 54 }
43 template<class O1, class O2>
44 struct proxy : proxy_base {
45 virtual R call (void *obj, R (object::*meth)())
46 {
47 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth)))
48 ();
49 }
50 };
51 55
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 56 R call () const
65 { 57 {
66 return prxy->call (obj, meth); 58 return func (self);
67 } 59 }
68 60
69 R operator ()() const 61 R operator ()() const
70 { 62 {
71 return call (); 63 return call ();
72 } 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 }
73}; 77};
74 78
75template<class R, class A1> 79template<class R, class A1>
76class callback1 { 80struct callback<R (A1)>
77 struct object { }; 81{
82 typedef R (*ptr_type)(void *self, A1);
78 83
79 void *obj; 84 template<class K, R (K::*method)(A1)>
80 R (object::*meth)(A1); 85 void set (K *object)
81 86 {
82 /* a proxy is a kind of recipe on how to call a specific class method */ 87 self = object;
83 struct proxy_base { 88 func = thunk<K, method>;
84 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) = 0;
85 }; 89 }
86 template<class O1, class O2>
87 struct proxy : proxy_base {
88 virtual R call (void *obj, R (object::*meth)(A1), A1 a1)
89 {
90 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth)))
91 (a1);
92 }
93 };
94 90
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 91 R call (A1 a1) const
108 { 92 {
109 return prxy->call (obj, meth, a1); 93 return func (self, a1);
110 } 94 }
111 95
112 R operator ()(A1 a1) const 96 R operator ()(A1 a1) const
113 { 97 {
114 return call (a1); 98 return call (a1);
115 } 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 }
116}; 112};
117 113
118template<class R, class A1, class A2> 114template<class R, class A1, class A2>
119class callback2 { 115struct callback<R (A1, A2)>
120 struct object { }; 116{
117 typedef R (*ptr_type)(void *self, A1, A2);
121 118
122 void *obj; 119 template<class K, R (K::*method)(A1, A2)>
123 R (object::*meth)(A1, A2); 120 void set (K *object)
124 121 {
125 /* a proxy is a kind of recipe on how to call a specific class method */ 122 self = object;
126 struct proxy_base { 123 func = thunk<K, method>;
127 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) = 0;
128 }; 124 }
129 template<class O1, class O2>
130 struct proxy : proxy_base {
131 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2)
132 {
133 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth)))
134 (a1, a2);
135 }
136 };
137 125
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 126 R call (A1 a1, A2 a2) const
151 { 127 {
152 return prxy->call (obj, meth, a1, a2); 128 return func (self, a1, a2);
153 } 129 }
154 130
155 R operator ()(A1 a1, A2 a2) const 131 R operator ()(A1 a1, A2 a2) const
156 { 132 {
157 return call (a1, a2); 133 return call (a1, a2);
158 } 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 }
159}; 147};
160 148
161template<class R, class A1, class A2, class A3> 149template<class R, class A1, class A2, class A3>
162class callback3 { 150struct callback<R (A1, A2, A3)>
163 struct object { }; 151{
152 typedef R (*ptr_type)(void *self, A1, A2, A3);
164 153
165 void *obj; 154 template<class K, R (K::*method)(A1, A2, A3)>
166 R (object::*meth)(A1, A2, A3); 155 void set (K *object)
167 156 {
168 /* a proxy is a kind of recipe on how to call a specific class method */ 157 self = object;
169 struct proxy_base { 158 func = thunk<K, method>;
170 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) = 0;
171 }; 159 }
172 template<class O1, class O2>
173 struct proxy : proxy_base {
174 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3)
175 {
176 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth)))
177 (a1, a2, a3);
178 }
179 };
180 160
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 161 R call (A1 a1, A2 a2, A3 a3) const
194 { 162 {
195 return prxy->call (obj, meth, a1, a2, a3); 163 return func (self, a1, a2, a3);
196 } 164 }
197 165
198 R operator ()(A1 a1, A2 a2, A3 a3) const 166 R operator ()(A1 a1, A2 a2, A3 a3) const
199 { 167 {
200 return call (a1, a2, a3); 168 return call (a1, a2, a3);
201 } 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 }
202}; 182};
203 183
204template<class R, class A1, class A2, class A3, class A4> 184template<class R, class A1, class A2, class A3, class A4>
205class callback4 { 185struct callback<R (A1, A2, A3, A4)>
206 struct object { }; 186{
187 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
207 188
208 void *obj; 189 template<class K, R (K::*method)(A1, A2, A3, A4)>
209 R (object::*meth)(A1, A2, A3, A4); 190 void set (K *object)
210 191 {
211 /* a proxy is a kind of recipe on how to call a specific class method */ 192 self = object;
212 struct proxy_base { 193 func = thunk<K, method>;
213 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) = 0;
214 }; 194 }
215 template<class O1, class O2>
216 struct proxy : proxy_base {
217 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4)
218 {
219 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth)))
220 (a1, a2, a3, a4);
221 }
222 };
223 195
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 196 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
237 { 197 {
238 return prxy->call (obj, meth, a1, a2, a3, a4); 198 return func (self, a1, a2, a3, a4);
239 } 199 }
240 200
241 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const 201 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
242 { 202 {
243 return call (a1, a2, a3, a4); 203 return call (a1, a2, a3, a4);
244 } 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 }
245}; 217};
246 218
247template<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>
248class callback5 { 220struct callback<R (A1, A2, A3, A4, A5)>
249 struct object { }; 221{
222 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
250 223
251 void *obj; 224 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
252 R (object::*meth)(A1, A2, A3, A4, A5); 225 void set (K *object)
253 226 {
254 /* a proxy is a kind of recipe on how to call a specific class method */ 227 self = object;
255 struct proxy_base { 228 func = thunk<K, method>;
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;
257 }; 229 }
258 template<class O1, class O2>
259 struct proxy : proxy_base {
260 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
261 {
262 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth)))
263 (a1, a2, a3, a4, a5);
264 }
265 };
266 230
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 231 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
280 { 232 {
281 return prxy->call (obj, meth, a1, a2, a3, a4, a5); 233 return func (self, a1, a2, a3, a4, a5);
282 } 234 }
283 235
284 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
285 { 237 {
286 return call (a1, a2, a3, a4, a5); 238 return call (a1, a2, a3, a4, a5);
287 } 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 }
288}; 252};
289 253
290template<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>
291class callback6 { 255struct callback<R (A1, A2, A3, A4, A5, A6)>
292 struct object { }; 256{
257 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
293 258
294 void *obj; 259 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
295 R (object::*meth)(A1, A2, A3, A4, A5, A6); 260 void set (K *object)
296 261 {
297 /* a proxy is a kind of recipe on how to call a specific class method */ 262 self = object;
298 struct proxy_base { 263 func = thunk<K, method>;
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;
300 }; 264 }
301 template<class O1, class O2>
302 struct proxy : proxy_base {
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)
304 {
305 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth)))
306 (a1, a2, a3, a4, a5, a6);
307 }
308 };
309 265
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 266 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
323 { 267 {
324 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6); 268 return func (self, a1, a2, a3, a4, a5, a6);
325 } 269 }
326 270
327 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
328 { 272 {
329 return call (a1, a2, a3, a4, a5, a6); 273 return call (a1, a2, a3, a4, a5, a6);
330 } 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 }
331}; 287};
332 288
333template<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>
334class callback7 { 290struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
335 struct object { }; 291{
292 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
336 293
337 void *obj; 294 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
338 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7); 295 void set (K *object)
339 296 {
340 /* a proxy is a kind of recipe on how to call a specific class method */ 297 self = object;
341 struct proxy_base { 298 func = thunk<K, method>;
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;
343 }; 299 }
344 template<class O1, class O2>
345 struct proxy : proxy_base {
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)
347 {
348 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth)))
349 (a1, a2, a3, a4, a5, a6, a7);
350 }
351 };
352 300
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 301 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
366 { 302 {
367 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7); 303 return func (self, a1, a2, a3, a4, a5, a6, a7);
368 } 304 }
369 305
370 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
371 { 307 {
372 return call (a1, a2, a3, a4, a5, a6, a7); 308 return call (a1, a2, a3, a4, a5, a6, a7);
373 } 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 }
374}; 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
375 429
376#endif 430#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines