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.14 by pcg, Wed Dec 5 18:19:50 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;
28 33
29template<class R> 34template<class R>
30class callback0 { 35struct callback<R ()>
31 struct object { }; 36{
37 typedef R (*ptr_type)(void *self);
32 38
33 void *obj; 39 template<class K, R (K::*method)()>
34 R (object::*meth)(); 40 void set (K *object)
35 41 {
36 /* a proxy is a kind of recipe on how to call a specific class method */ 42 self = object;
37 struct proxy_base { 43 func = thunk<K, method>;
38 virtual R call (void *obj, R (object::*meth)()) = 0;
39 }; 44 }
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 45
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 46 R call () const
62 { 47 {
63 return prxy->call (obj, meth); 48 return func (self);
64 } 49 }
65 50
66 R operator ()() const 51 R operator ()() const
67 { 52 {
68 return call (); 53 return call ();
69 } 54 }
55
56private:
57
58 void *self;
59 ptr_type func;
60
61 template<class klass, R (klass::*method)()>
62 static R thunk (void *self)
63 {
64 klass *obj = static_cast<klass *>(self);
65 return (obj->*method) ();
66 }
70}; 67};
71 68
72template<class R, class A1> 69template<class R, class A1>
73class callback1 { 70struct callback<R (A1)>
74 struct object { }; 71{
72 typedef R (*ptr_type)(void *self, A1);
75 73
76 void *obj; 74 template<class K, R (K::*method)(A1)>
77 R (object::*meth)(A1); 75 void set (K *object)
78 76 {
79 /* a proxy is a kind of recipe on how to call a specific class method */ 77 self = object;
80 struct proxy_base { 78 func = thunk<K, method>;
81 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) = 0;
82 }; 79 }
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 80
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 81 R call (A1 a1) const
105 { 82 {
106 return prxy->call (obj, meth, a1); 83 return func (self, a1);
107 } 84 }
108 85
109 R operator ()(A1 a1) const 86 R operator ()(A1 a1) const
110 { 87 {
111 return call (a1); 88 return call (a1);
112 } 89 }
90
91private:
92
93 void *self;
94 ptr_type func;
95
96 template<class klass, R (klass::*method)(A1)>
97 static R thunk (void *self, A1 a1)
98 {
99 klass *obj = static_cast<klass *>(self);
100 return (obj->*method) (a1);
101 }
113}; 102};
114 103
115template<class R, class A1, class A2> 104template<class R, class A1, class A2>
116class callback2 { 105struct callback<R (A1, A2)>
117 struct object { }; 106{
107 typedef R (*ptr_type)(void *self, A1, A2);
118 108
119 void *obj; 109 template<class K, R (K::*method)(A1, A2)>
120 R (object::*meth)(A1, A2); 110 void set (K *object)
121 111 {
122 /* a proxy is a kind of recipe on how to call a specific class method */ 112 self = object;
123 struct proxy_base { 113 func = thunk<K, method>;
124 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) = 0;
125 }; 114 }
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 115
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 116 R call (A1 a1, A2 a2) const
148 { 117 {
149 return prxy->call (obj, meth, a1, a2); 118 return func (self, a1, a2);
150 } 119 }
151 120
152 R operator ()(A1 a1, A2 a2) const 121 R operator ()(A1 a1, A2 a2) const
153 { 122 {
154 return call (a1, a2); 123 return call (a1, a2);
155 } 124 }
125
126private:
127
128 void *self;
129 ptr_type func;
130
131 template<class klass, R (klass::*method)(A1, A2)>
132 static R thunk (void *self, A1 a1, A2 a2)
133 {
134 klass *obj = static_cast<klass *>(self);
135 return (obj->*method) (a1, a2);
136 }
156}; 137};
157 138
158template<class R, class A1, class A2, class A3> 139template<class R, class A1, class A2, class A3>
159class callback3 { 140struct callback<R (A1, A2, A3)>
160 struct object { }; 141{
142 typedef R (*ptr_type)(void *self, A1, A2, A3);
161 143
162 void *obj; 144 template<class K, R (K::*method)(A1, A2, A3)>
163 R (object::*meth)(A1, A2, A3); 145 void set (K *object)
164 146 {
165 /* a proxy is a kind of recipe on how to call a specific class method */ 147 self = object;
166 struct proxy_base { 148 func = thunk<K, method>;
167 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) = 0;
168 }; 149 }
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 150
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 151 R call (A1 a1, A2 a2, A3 a3) const
191 { 152 {
192 return prxy->call (obj, meth, a1, a2, a3); 153 return func (self, a1, a2, a3);
193 } 154 }
194 155
195 R operator ()(A1 a1, A2 a2, A3 a3) const 156 R operator ()(A1 a1, A2 a2, A3 a3) const
196 { 157 {
197 return call (a1, a2, a3); 158 return call (a1, a2, a3);
198 } 159 }
160
161private:
162
163 void *self;
164 ptr_type func;
165
166 template<class klass, R (klass::*method)(A1, A2, A3)>
167 static R thunk (void *self, A1 a1, A2 a2, A3 a3)
168 {
169 klass *obj = static_cast<klass *>(self);
170 return (obj->*method) (a1, a2, a3);
171 }
199}; 172};
200 173
201template<class R, class A1, class A2, class A3, class A4> 174template<class R, class A1, class A2, class A3, class A4>
202class callback4 { 175struct callback<R (A1, A2, A3, A4)>
203 struct object { }; 176{
177 typedef R (*ptr_type)(void *self, A1, A2, A3, A4);
204 178
205 void *obj; 179 template<class K, R (K::*method)(A1, A2, A3, A4)>
206 R (object::*meth)(A1, A2, A3, A4); 180 void set (K *object)
207 181 {
208 /* a proxy is a kind of recipe on how to call a specific class method */ 182 self = object;
209 struct proxy_base { 183 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 }; 184 }
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 185
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 186 R call (A1 a1, A2 a2, A3 a3, A4 a4) const
234 { 187 {
235 return prxy->call (obj, meth, a1, a2, a3, a4); 188 return func (self, a1, a2, a3, a4);
236 } 189 }
237 190
238 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const 191 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
239 { 192 {
240 return call (a1, a2, a3, a4); 193 return call (a1, a2, a3, a4);
241 } 194 }
195
196private:
197
198 void *self;
199 ptr_type func;
200
201 template<class klass, R (klass::*method)(A1, A2, A3, A4)>
202 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4)
203 {
204 klass *obj = static_cast<klass *>(self);
205 return (obj->*method) (a1, a2, a3, a4);
206 }
242}; 207};
243 208
244template<class R, class A1, class A2, class A3, class A4, class A5> 209template<class R, class A1, class A2, class A3, class A4, class A5>
245class callback5 { 210struct callback<R (A1, A2, A3, A4, A5)>
246 struct object { }; 211{
212 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5);
247 213
248 void *obj; 214 template<class K, R (K::*method)(A1, A2, A3, A4, A5)>
249 R (object::*meth)(A1, A2, A3, A4, A5); 215 void set (K *object)
250 216 {
251 /* a proxy is a kind of recipe on how to call a specific class method */ 217 self = object;
252 struct proxy_base { 218 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 }; 219 }
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 220
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 221 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
277 { 222 {
278 return prxy->call (obj, meth, a1, a2, a3, a4, a5); 223 return func (self, a1, a2, a3, a4, a5);
279 } 224 }
280 225
281 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const 226 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
282 { 227 {
283 return call (a1, a2, a3, a4, a5); 228 return call (a1, a2, a3, a4, a5);
284 } 229 }
230
231private:
232
233 void *self;
234 ptr_type func;
235
236 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)>
237 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
238 {
239 klass *obj = static_cast<klass *>(self);
240 return (obj->*method) (a1, a2, a3, a4, a5);
241 }
285}; 242};
286 243
287template<class R, class A1, class A2, class A3, class A4, class A5, class A6> 244template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
288class callback6 { 245struct callback<R (A1, A2, A3, A4, A5, A6)>
289 struct object { }; 246{
247 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6);
290 248
291 void *obj; 249 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)>
292 R (object::*meth)(A1, A2, A3, A4, A5, A6); 250 void set (K *object)
293 251 {
294 /* a proxy is a kind of recipe on how to call a specific class method */ 252 self = object;
295 struct proxy_base { 253 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 }; 254 }
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 255
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 256 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
320 { 257 {
321 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6); 258 return func (self, a1, a2, a3, a4, a5, a6);
322 } 259 }
323 260
324 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const 261 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
325 { 262 {
326 return call (a1, a2, a3, a4, a5, a6); 263 return call (a1, a2, a3, a4, a5, a6);
327 } 264 }
265
266private:
267
268 void *self;
269 ptr_type func;
270
271 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)>
272 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
273 {
274 klass *obj = static_cast<klass *>(self);
275 return (obj->*method) (a1, a2, a3, a4, a5, a6);
276 }
328}; 277};
329 278
330template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> 279template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
331class callback7 { 280struct callback<R (A1, A2, A3, A4, A5, A6, A7)>
332 struct object { }; 281{
282 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7);
333 283
334 void *obj; 284 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)>
335 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7); 285 void set (K *object)
336 286 {
337 /* a proxy is a kind of recipe on how to call a specific class method */ 287 self = object;
338 struct proxy_base { 288 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 }; 289 }
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 290
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 291 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
363 { 292 {
364 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7); 293 return func (self, a1, a2, a3, a4, a5, a6, a7);
365 } 294 }
366 295
367 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const 296 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
368 { 297 {
369 return call (a1, a2, a3, a4, a5, a6, a7); 298 return call (a1, a2, a3, a4, a5, a6, a7);
370 } 299 }
300
301private:
302
303 void *self;
304 ptr_type func;
305
306 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)>
307 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
308 {
309 klass *obj = static_cast<klass *>(self);
310 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7);
311 }
371}; 312};
313
314template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
315struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)>
316{
317 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8);
318
319 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
320 void set (K *object)
321 {
322 self = object;
323 func = thunk<K, method>;
324 }
325
326 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
327 {
328 return func (self, a1, a2, a3, a4, a5, a6, a7, a8);
329 }
330
331 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
332 {
333 return call (a1, a2, a3, a4, a5, a6, a7, a8);
334 }
335
336private:
337
338 void *self;
339 ptr_type func;
340
341 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)>
342 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
343 {
344 klass *obj = static_cast<klass *>(self);
345 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8);
346 }
347};
348
349template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
350struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)>
351{
352 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9);
353
354 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
355 void set (K *object)
356 {
357 self = object;
358 func = thunk<K, method>;
359 }
360
361 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
362 {
363 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9);
364 }
365
366 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const
367 {
368 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9);
369 }
370
371private:
372
373 void *self;
374 ptr_type func;
375
376 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
377 static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
378 {
379 klass *obj = static_cast<klass *>(self);
380 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9);
381 }
382};
383
384template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
385struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
386{
387 typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
388
389 template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
390 void set (K *object)
391 {
392 self = object;
393 func = thunk<K, method>;
394 }
395
396 R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
397 {
398 return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
399 }
400
401 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const
402 {
403 return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
404 }
405
406private:
407
408 void *self;
409 ptr_type func;
410
411 template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
412 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)
413 {
414 klass *obj = static_cast<klass *>(self);
415 return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
416 }
417};
418
372 419
373#endif 420#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines