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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines