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: callback.pl is part of the GVPE |
2 | // THIS IS A GENERATED FILE: callback.pl is part of the GVPE |
3 | // THIS IS A GENERATED FILE: distribution. |
3 | // THIS IS A GENERATED FILE: distribution. |
4 | |
4 | |
5 | /* |
5 | /* |
6 | callback.h -- C++ callback mechanism |
6 | * callback.h -- C++ callback mechanism |
7 | Copyright (C) 2003-2006 Marc Lehmann <pcg@goof.com> |
7 | * Copyright (C) 2003-2008 Marc Lehmann <pcg@goof.com> |
8 | |
8 | * |
9 | This file is part of GVPE. |
9 | * This file is part of GVPE. |
10 | |
10 | * |
11 | 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 |
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 gvpe; if not, write to the Free Software |
22 | * with this program; if not, see <http://www.gnu.org/licenses/>. |
23 | 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. |
24 | */ |
34 | */ |
25 | |
35 | |
26 | #ifndef CALLBACK_H__ |
36 | #ifndef CALLBACK_H__ |
27 | #define CALLBACK_H__ |
37 | #define CALLBACK_H__ |
28 | |
38 | |
29 | #define CALLBACK_H_VERSION 2 |
39 | #define CALLBACK_H_VERSION 3 |
30 | |
40 | |
31 | template<class signature> |
41 | template<typename signature> |
32 | struct callback_funtype_trait; |
|
|
33 | |
|
|
34 | template<int arity, class signature> |
|
|
35 | struct callback_get_impl; |
42 | struct callback; |
36 | |
43 | |
37 | template<class R> |
44 | template<class R> |
38 | class callback0 |
45 | struct callback<R ()> |
39 | { |
46 | { |
40 | struct object { }; |
47 | typedef R (*ptr_type)(void *self); |
41 | |
48 | |
42 | typedef R (object::*ptr_type)(); |
49 | template<class K, R (K::*method)()> |
43 | |
50 | void set (K *object) |
44 | void *obj; |
51 | { |
45 | R (object::*meth)(); |
52 | self = object; |
46 | |
53 | func = thunk<K, method>; |
47 | /* a proxy is a kind of recipe on how to call a specific class method */ |
|
|
48 | struct proxy_base { |
|
|
49 | virtual R call (void *obj, R (object::*meth)()) const = 0; |
|
|
50 | }; |
54 | } |
51 | template<class O1, class O2> |
|
|
52 | struct proxy : proxy_base { |
|
|
53 | virtual R call (void *obj, R (object::*meth)()) const |
|
|
54 | { |
|
|
55 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth))) |
|
|
56 | (); |
|
|
57 | } |
|
|
58 | }; |
|
|
59 | |
55 | |
60 | proxy_base *prxy; |
|
|
61 | |
|
|
62 | public: |
|
|
63 | template<class O1, class O2> |
|
|
64 | explicit callback0 (O1 *object, R (O2::*method)()) |
|
|
65 | { |
|
|
66 | static proxy<O1,O2> p; |
|
|
67 | obj = reinterpret_cast<void *>(object); |
|
|
68 | meth = reinterpret_cast<R (object::*)()>(method); |
|
|
69 | prxy = &p; |
|
|
70 | } |
|
|
71 | |
|
|
72 | R call() const |
56 | R call () const |
73 | { |
57 | { |
74 | return prxy->call (obj, meth); |
58 | return func (self); |
75 | } |
59 | } |
76 | |
60 | |
77 | R operator ()() const |
61 | R operator ()() const |
78 | { |
62 | { |
79 | return call (); |
63 | return call (); |
80 | } |
|
|
81 | }; |
|
|
82 | |
|
|
83 | template<class R> |
|
|
84 | struct callback_funtype_trait0 |
|
|
85 | { |
|
|
86 | static const int arity = 0; |
|
|
87 | typedef R type (void); |
|
|
88 | typedef R result_type; |
|
|
89 | |
64 | } |
90 | }; |
|
|
91 | |
65 | |
92 | template<class R> |
66 | private: |
93 | struct callback_funtype_trait<R ()> : callback_funtype_trait0<R> |
|
|
94 | { |
|
|
95 | }; |
|
|
96 | |
67 | |
97 | template<class signature> |
68 | void *self; |
98 | struct callback_get_impl<0, signature> |
69 | ptr_type func; |
99 | { |
70 | |
100 | typedef callback_funtype_trait<signature> T; |
71 | template<class klass, R (klass::*method)()> |
101 | typedef callback0<typename T::result_type> type; |
72 | static R thunk (void *self) |
|
|
73 | { |
|
|
74 | klass *obj = static_cast<klass *>(self); |
|
|
75 | return (obj->*method) (); |
|
|
76 | } |
102 | }; |
77 | }; |
103 | |
78 | |
104 | template<class R, class A1> |
79 | template<class R, class A1> |
105 | class callback1 |
80 | struct callback<R (A1)> |
106 | { |
81 | { |
107 | struct object { }; |
82 | typedef R (*ptr_type)(void *self, A1); |
108 | |
83 | |
109 | typedef R (object::*ptr_type)(A1); |
84 | template<class K, R (K::*method)(A1)> |
110 | |
85 | void set (K *object) |
111 | void *obj; |
86 | { |
112 | R (object::*meth)(A1); |
87 | self = object; |
113 | |
88 | func = thunk<K, method>; |
114 | /* a proxy is a kind of recipe on how to call a specific class method */ |
|
|
115 | struct proxy_base { |
|
|
116 | virtual R call (void *obj, R (object::*meth)(A1), A1 a1) const = 0; |
|
|
117 | }; |
89 | } |
118 | template<class O1, class O2> |
|
|
119 | struct proxy : proxy_base { |
|
|
120 | virtual R call (void *obj, R (object::*meth)(A1), A1 a1) const |
|
|
121 | { |
|
|
122 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1)>(meth))) |
|
|
123 | (a1); |
|
|
124 | } |
|
|
125 | }; |
|
|
126 | |
90 | |
127 | proxy_base *prxy; |
|
|
128 | |
|
|
129 | public: |
|
|
130 | template<class O1, class O2> |
|
|
131 | explicit callback1 (O1 *object, R (O2::*method)(A1)) |
|
|
132 | { |
|
|
133 | static proxy<O1,O2> p; |
|
|
134 | obj = reinterpret_cast<void *>(object); |
|
|
135 | meth = reinterpret_cast<R (object::*)(A1)>(method); |
|
|
136 | prxy = &p; |
|
|
137 | } |
|
|
138 | |
|
|
139 | R call(A1 a1) const |
91 | R call (A1 a1) const |
140 | { |
92 | { |
141 | return prxy->call (obj, meth, a1); |
93 | return func (self, a1); |
142 | } |
94 | } |
143 | |
95 | |
144 | R operator ()(A1 a1) const |
96 | R operator ()(A1 a1) const |
145 | { |
97 | { |
146 | return call (a1); |
98 | return call (a1); |
147 | } |
99 | } |
148 | }; |
|
|
149 | |
100 | |
150 | template<class R, class A1> |
101 | private: |
151 | struct callback_funtype_trait1 |
|
|
152 | { |
|
|
153 | static const int arity = 1; |
|
|
154 | typedef R type (A1); |
|
|
155 | typedef R result_type; |
|
|
156 | typedef A1 arg1_type; |
|
|
157 | }; |
|
|
158 | |
102 | |
159 | template<class R, class A1> |
103 | void *self; |
160 | struct callback_funtype_trait<R (A1)> : callback_funtype_trait1<R, A1> |
104 | ptr_type func; |
161 | { |
|
|
162 | }; |
|
|
163 | |
105 | |
164 | template<class signature> |
106 | template<class klass, R (klass::*method)(A1)> |
165 | struct callback_get_impl<1, signature> |
107 | static R thunk (void *self, A1 a1) |
166 | { |
108 | { |
167 | typedef callback_funtype_trait<signature> T; |
109 | klass *obj = static_cast<klass *>(self); |
168 | typedef callback1<typename T::result_type, typename T::arg1_type> type; |
110 | return (obj->*method) (a1); |
|
|
111 | } |
169 | }; |
112 | }; |
170 | |
113 | |
171 | template<class R, class A1, class A2> |
114 | template<class R, class A1, class A2> |
172 | class callback2 |
115 | struct callback<R (A1, A2)> |
173 | { |
116 | { |
174 | struct object { }; |
|
|
175 | |
|
|
176 | typedef R (object::*ptr_type)(A1, A2); |
117 | typedef R (*ptr_type)(void *self, A1, A2); |
177 | |
118 | |
178 | void *obj; |
119 | template<class K, R (K::*method)(A1, A2)> |
179 | R (object::*meth)(A1, A2); |
120 | void set (K *object) |
180 | |
121 | { |
181 | /* a proxy is a kind of recipe on how to call a specific class method */ |
122 | self = object; |
182 | struct proxy_base { |
123 | func = thunk<K, method>; |
183 | virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) const = 0; |
|
|
184 | }; |
124 | } |
185 | template<class O1, class O2> |
|
|
186 | struct proxy : proxy_base { |
|
|
187 | virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) const |
|
|
188 | { |
|
|
189 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2)>(meth))) |
|
|
190 | (a1, a2); |
|
|
191 | } |
|
|
192 | }; |
|
|
193 | |
125 | |
194 | proxy_base *prxy; |
|
|
195 | |
|
|
196 | public: |
|
|
197 | template<class O1, class O2> |
|
|
198 | explicit callback2 (O1 *object, R (O2::*method)(A1, A2)) |
|
|
199 | { |
|
|
200 | static proxy<O1,O2> p; |
|
|
201 | obj = reinterpret_cast<void *>(object); |
|
|
202 | meth = reinterpret_cast<R (object::*)(A1, A2)>(method); |
|
|
203 | prxy = &p; |
|
|
204 | } |
|
|
205 | |
|
|
206 | R call(A1 a1, A2 a2) const |
126 | R call (A1 a1, A2 a2) const |
207 | { |
127 | { |
208 | return prxy->call (obj, meth, a1, a2); |
128 | return func (self, a1, a2); |
209 | } |
129 | } |
210 | |
130 | |
211 | R operator ()(A1 a1, A2 a2) const |
131 | R operator ()(A1 a1, A2 a2) const |
212 | { |
132 | { |
213 | return call (a1, a2); |
133 | return call (a1, a2); |
214 | } |
134 | } |
215 | }; |
|
|
216 | |
135 | |
217 | template<class R, class A1, class A2> |
136 | private: |
218 | struct callback_funtype_trait2 |
|
|
219 | { |
|
|
220 | static const int arity = 2; |
|
|
221 | typedef R type (A1, A2); |
|
|
222 | typedef R result_type; |
|
|
223 | typedef A1 arg1_type; typedef A2 arg2_type; |
|
|
224 | }; |
|
|
225 | |
137 | |
226 | template<class R, class A1, class A2> |
138 | void *self; |
227 | struct callback_funtype_trait<R (A1, A2)> : callback_funtype_trait2<R, A1, A2> |
139 | ptr_type func; |
228 | { |
|
|
229 | }; |
|
|
230 | |
140 | |
231 | template<class signature> |
141 | template<class klass, R (klass::*method)(A1, A2)> |
232 | struct callback_get_impl<2, signature> |
142 | static R thunk (void *self, A1 a1, A2 a2) |
233 | { |
143 | { |
234 | typedef callback_funtype_trait<signature> T; |
144 | klass *obj = static_cast<klass *>(self); |
235 | typedef callback2<typename T::result_type, typename T::arg1_type, typename T::arg2_type> type; |
145 | return (obj->*method) (a1, a2); |
|
|
146 | } |
236 | }; |
147 | }; |
237 | |
148 | |
238 | template<class R, class A1, class A2, class A3> |
149 | template<class R, class A1, class A2, class A3> |
239 | class callback3 |
150 | struct callback<R (A1, A2, A3)> |
240 | { |
151 | { |
241 | struct object { }; |
|
|
242 | |
|
|
243 | typedef R (object::*ptr_type)(A1, A2, A3); |
152 | typedef R (*ptr_type)(void *self, A1, A2, A3); |
244 | |
153 | |
245 | void *obj; |
154 | template<class K, R (K::*method)(A1, A2, A3)> |
246 | R (object::*meth)(A1, A2, A3); |
155 | void set (K *object) |
247 | |
156 | { |
248 | /* a proxy is a kind of recipe on how to call a specific class method */ |
157 | self = object; |
249 | struct proxy_base { |
158 | func = thunk<K, method>; |
250 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) const = 0; |
|
|
251 | }; |
159 | } |
252 | template<class O1, class O2> |
|
|
253 | struct proxy : proxy_base { |
|
|
254 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) const |
|
|
255 | { |
|
|
256 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3)>(meth))) |
|
|
257 | (a1, a2, a3); |
|
|
258 | } |
|
|
259 | }; |
|
|
260 | |
160 | |
261 | proxy_base *prxy; |
|
|
262 | |
|
|
263 | public: |
|
|
264 | template<class O1, class O2> |
|
|
265 | explicit callback3 (O1 *object, R (O2::*method)(A1, A2, A3)) |
|
|
266 | { |
|
|
267 | static proxy<O1,O2> p; |
|
|
268 | obj = reinterpret_cast<void *>(object); |
|
|
269 | meth = reinterpret_cast<R (object::*)(A1, A2, A3)>(method); |
|
|
270 | prxy = &p; |
|
|
271 | } |
|
|
272 | |
|
|
273 | R call(A1 a1, A2 a2, A3 a3) const |
161 | R call (A1 a1, A2 a2, A3 a3) const |
274 | { |
162 | { |
275 | return prxy->call (obj, meth, a1, a2, a3); |
163 | return func (self, a1, a2, a3); |
276 | } |
164 | } |
277 | |
165 | |
278 | R operator ()(A1 a1, A2 a2, A3 a3) const |
166 | R operator ()(A1 a1, A2 a2, A3 a3) const |
279 | { |
167 | { |
280 | return call (a1, a2, a3); |
168 | return call (a1, a2, a3); |
281 | } |
169 | } |
282 | }; |
|
|
283 | |
170 | |
284 | template<class R, class A1, class A2, class A3> |
171 | private: |
285 | struct callback_funtype_trait3 |
|
|
286 | { |
|
|
287 | static const int arity = 3; |
|
|
288 | typedef R type (A1, A2, A3); |
|
|
289 | typedef R result_type; |
|
|
290 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; |
|
|
291 | }; |
|
|
292 | |
172 | |
293 | template<class R, class A1, class A2, class A3> |
173 | void *self; |
294 | struct callback_funtype_trait<R (A1, A2, A3)> : callback_funtype_trait3<R, A1, A2, A3> |
174 | ptr_type func; |
295 | { |
|
|
296 | }; |
|
|
297 | |
175 | |
298 | template<class signature> |
176 | template<class klass, R (klass::*method)(A1, A2, A3)> |
299 | struct callback_get_impl<3, signature> |
177 | static R thunk (void *self, A1 a1, A2 a2, A3 a3) |
300 | { |
178 | { |
301 | typedef callback_funtype_trait<signature> T; |
179 | klass *obj = static_cast<klass *>(self); |
302 | typedef callback3<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type> type; |
180 | return (obj->*method) (a1, a2, a3); |
|
|
181 | } |
303 | }; |
182 | }; |
304 | |
183 | |
305 | template<class R, class A1, class A2, class A3, class A4> |
184 | template<class R, class A1, class A2, class A3, class A4> |
306 | class callback4 |
185 | struct callback<R (A1, A2, A3, A4)> |
307 | { |
186 | { |
308 | struct object { }; |
|
|
309 | |
|
|
310 | typedef R (object::*ptr_type)(A1, A2, A3, A4); |
187 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4); |
311 | |
188 | |
312 | void *obj; |
189 | template<class K, R (K::*method)(A1, A2, A3, A4)> |
313 | R (object::*meth)(A1, A2, A3, A4); |
190 | void set (K *object) |
314 | |
191 | { |
315 | /* a proxy is a kind of recipe on how to call a specific class method */ |
192 | self = object; |
316 | struct proxy_base { |
193 | func = thunk<K, method>; |
317 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) const = 0; |
|
|
318 | }; |
194 | } |
319 | template<class O1, class O2> |
|
|
320 | struct proxy : proxy_base { |
|
|
321 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) const |
|
|
322 | { |
|
|
323 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4)>(meth))) |
|
|
324 | (a1, a2, a3, a4); |
|
|
325 | } |
|
|
326 | }; |
|
|
327 | |
195 | |
328 | proxy_base *prxy; |
|
|
329 | |
|
|
330 | public: |
|
|
331 | template<class O1, class O2> |
|
|
332 | explicit callback4 (O1 *object, R (O2::*method)(A1, A2, A3, A4)) |
|
|
333 | { |
|
|
334 | static proxy<O1,O2> p; |
|
|
335 | obj = reinterpret_cast<void *>(object); |
|
|
336 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4)>(method); |
|
|
337 | prxy = &p; |
|
|
338 | } |
|
|
339 | |
|
|
340 | R call(A1 a1, A2 a2, A3 a3, A4 a4) const |
196 | R call (A1 a1, A2 a2, A3 a3, A4 a4) const |
341 | { |
197 | { |
342 | return prxy->call (obj, meth, a1, a2, a3, a4); |
198 | return func (self, a1, a2, a3, a4); |
343 | } |
199 | } |
344 | |
200 | |
345 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const |
201 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const |
346 | { |
202 | { |
347 | return call (a1, a2, a3, a4); |
203 | return call (a1, a2, a3, a4); |
348 | } |
204 | } |
349 | }; |
|
|
350 | |
205 | |
351 | template<class R, class A1, class A2, class A3, class A4> |
206 | private: |
352 | struct callback_funtype_trait4 |
|
|
353 | { |
|
|
354 | static const int arity = 4; |
|
|
355 | typedef R type (A1, A2, A3, A4); |
|
|
356 | typedef R result_type; |
|
|
357 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; |
|
|
358 | }; |
|
|
359 | |
207 | |
360 | template<class R, class A1, class A2, class A3, class A4> |
208 | void *self; |
361 | struct callback_funtype_trait<R (A1, A2, A3, A4)> : callback_funtype_trait4<R, A1, A2, A3, A4> |
209 | ptr_type func; |
362 | { |
|
|
363 | }; |
|
|
364 | |
210 | |
365 | template<class signature> |
211 | template<class klass, R (klass::*method)(A1, A2, A3, A4)> |
366 | struct callback_get_impl<4, signature> |
212 | static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4) |
367 | { |
213 | { |
368 | typedef callback_funtype_trait<signature> T; |
214 | klass *obj = static_cast<klass *>(self); |
369 | typedef callback4<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type> type; |
215 | return (obj->*method) (a1, a2, a3, a4); |
|
|
216 | } |
370 | }; |
217 | }; |
371 | |
218 | |
372 | template<class R, class A1, class A2, class A3, class A4, class A5> |
219 | template<class R, class A1, class A2, class A3, class A4, class A5> |
373 | class callback5 |
220 | struct callback<R (A1, A2, A3, A4, A5)> |
374 | { |
221 | { |
375 | struct object { }; |
|
|
376 | |
|
|
377 | typedef R (object::*ptr_type)(A1, A2, A3, A4, A5); |
222 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5); |
378 | |
223 | |
379 | void *obj; |
224 | template<class K, R (K::*method)(A1, A2, A3, A4, A5)> |
380 | R (object::*meth)(A1, A2, A3, A4, A5); |
225 | void set (K *object) |
381 | |
226 | { |
382 | /* a proxy is a kind of recipe on how to call a specific class method */ |
227 | self = object; |
383 | struct proxy_base { |
228 | func = thunk<K, method>; |
384 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const = 0; |
|
|
385 | }; |
229 | } |
386 | template<class O1, class O2> |
|
|
387 | struct proxy : proxy_base { |
|
|
388 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const |
|
|
389 | { |
|
|
390 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5)>(meth))) |
|
|
391 | (a1, a2, a3, a4, a5); |
|
|
392 | } |
|
|
393 | }; |
|
|
394 | |
230 | |
395 | proxy_base *prxy; |
|
|
396 | |
|
|
397 | public: |
|
|
398 | template<class O1, class O2> |
|
|
399 | explicit callback5 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5)) |
|
|
400 | { |
|
|
401 | static proxy<O1,O2> p; |
|
|
402 | obj = reinterpret_cast<void *>(object); |
|
|
403 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5)>(method); |
|
|
404 | prxy = &p; |
|
|
405 | } |
|
|
406 | |
|
|
407 | 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 |
408 | { |
232 | { |
409 | return prxy->call (obj, meth, a1, a2, a3, a4, a5); |
233 | return func (self, a1, a2, a3, a4, a5); |
410 | } |
234 | } |
411 | |
235 | |
412 | 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 |
413 | { |
237 | { |
414 | return call (a1, a2, a3, a4, a5); |
238 | return call (a1, a2, a3, a4, a5); |
415 | } |
239 | } |
416 | }; |
|
|
417 | |
240 | |
418 | template<class R, class A1, class A2, class A3, class A4, class A5> |
241 | private: |
419 | struct callback_funtype_trait5 |
|
|
420 | { |
|
|
421 | static const int arity = 5; |
|
|
422 | typedef R type (A1, A2, A3, A4, A5); |
|
|
423 | typedef R result_type; |
|
|
424 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; |
|
|
425 | }; |
|
|
426 | |
242 | |
427 | template<class R, class A1, class A2, class A3, class A4, class A5> |
243 | void *self; |
428 | struct callback_funtype_trait<R (A1, A2, A3, A4, A5)> : callback_funtype_trait5<R, A1, A2, A3, A4, A5> |
244 | ptr_type func; |
429 | { |
|
|
430 | }; |
|
|
431 | |
245 | |
432 | template<class signature> |
246 | template<class klass, R (klass::*method)(A1, A2, A3, A4, A5)> |
433 | struct callback_get_impl<5, signature> |
247 | static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) |
434 | { |
248 | { |
435 | typedef callback_funtype_trait<signature> T; |
249 | klass *obj = static_cast<klass *>(self); |
436 | typedef callback5<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type> type; |
250 | return (obj->*method) (a1, a2, a3, a4, a5); |
|
|
251 | } |
437 | }; |
252 | }; |
438 | |
253 | |
439 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6> |
254 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6> |
440 | class callback6 |
255 | struct callback<R (A1, A2, A3, A4, A5, A6)> |
441 | { |
256 | { |
442 | struct object { }; |
|
|
443 | |
|
|
444 | typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6); |
257 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6); |
445 | |
258 | |
446 | void *obj; |
259 | template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6)> |
447 | R (object::*meth)(A1, A2, A3, A4, A5, A6); |
260 | void set (K *object) |
448 | |
261 | { |
449 | /* a proxy is a kind of recipe on how to call a specific class method */ |
262 | self = object; |
450 | struct proxy_base { |
263 | func = thunk<K, method>; |
451 | 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) const = 0; |
|
|
452 | }; |
264 | } |
453 | template<class O1, class O2> |
|
|
454 | struct proxy : proxy_base { |
|
|
455 | 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) const |
|
|
456 | { |
|
|
457 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6)>(meth))) |
|
|
458 | (a1, a2, a3, a4, a5, a6); |
|
|
459 | } |
|
|
460 | }; |
|
|
461 | |
265 | |
462 | proxy_base *prxy; |
|
|
463 | |
|
|
464 | public: |
|
|
465 | template<class O1, class O2> |
|
|
466 | explicit callback6 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6)) |
|
|
467 | { |
|
|
468 | static proxy<O1,O2> p; |
|
|
469 | obj = reinterpret_cast<void *>(object); |
|
|
470 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6)>(method); |
|
|
471 | prxy = &p; |
|
|
472 | } |
|
|
473 | |
|
|
474 | 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 |
475 | { |
267 | { |
476 | return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6); |
268 | return func (self, a1, a2, a3, a4, a5, a6); |
477 | } |
269 | } |
478 | |
270 | |
479 | 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 |
480 | { |
272 | { |
481 | return call (a1, a2, a3, a4, a5, a6); |
273 | return call (a1, a2, a3, a4, a5, a6); |
482 | } |
274 | } |
483 | }; |
|
|
484 | |
275 | |
485 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6> |
276 | private: |
486 | struct callback_funtype_trait6 |
|
|
487 | { |
|
|
488 | static const int arity = 6; |
|
|
489 | typedef R type (A1, A2, A3, A4, A5, A6); |
|
|
490 | typedef R result_type; |
|
|
491 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; |
|
|
492 | }; |
|
|
493 | |
277 | |
494 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6> |
278 | void *self; |
495 | struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6)> : callback_funtype_trait6<R, A1, A2, A3, A4, A5, A6> |
279 | ptr_type func; |
496 | { |
|
|
497 | }; |
|
|
498 | |
280 | |
499 | template<class signature> |
281 | template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6)> |
500 | struct callback_get_impl<6, signature> |
282 | static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) |
501 | { |
283 | { |
502 | typedef callback_funtype_trait<signature> T; |
284 | klass *obj = static_cast<klass *>(self); |
503 | typedef callback6<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type> type; |
285 | return (obj->*method) (a1, a2, a3, a4, a5, a6); |
|
|
286 | } |
504 | }; |
287 | }; |
505 | |
288 | |
506 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> |
289 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> |
507 | class callback7 |
290 | struct callback<R (A1, A2, A3, A4, A5, A6, A7)> |
508 | { |
291 | { |
509 | struct object { }; |
|
|
510 | |
|
|
511 | typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7); |
292 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7); |
512 | |
293 | |
513 | void *obj; |
294 | template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7)> |
514 | R (object::*meth)(A1, A2, A3, A4, A5, A6, A7); |
295 | void set (K *object) |
515 | |
296 | { |
516 | /* a proxy is a kind of recipe on how to call a specific class method */ |
297 | self = object; |
517 | struct proxy_base { |
298 | func = thunk<K, method>; |
518 | 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) const = 0; |
|
|
519 | }; |
299 | } |
520 | template<class O1, class O2> |
|
|
521 | struct proxy : proxy_base { |
|
|
522 | 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) const |
|
|
523 | { |
|
|
524 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7)>(meth))) |
|
|
525 | (a1, a2, a3, a4, a5, a6, a7); |
|
|
526 | } |
|
|
527 | }; |
|
|
528 | |
300 | |
529 | proxy_base *prxy; |
|
|
530 | |
|
|
531 | public: |
|
|
532 | template<class O1, class O2> |
|
|
533 | explicit callback7 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7)) |
|
|
534 | { |
|
|
535 | static proxy<O1,O2> p; |
|
|
536 | obj = reinterpret_cast<void *>(object); |
|
|
537 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7)>(method); |
|
|
538 | prxy = &p; |
|
|
539 | } |
|
|
540 | |
|
|
541 | 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 |
542 | { |
302 | { |
543 | return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7); |
303 | return func (self, a1, a2, a3, a4, a5, a6, a7); |
544 | } |
304 | } |
545 | |
305 | |
546 | 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 |
547 | { |
307 | { |
548 | return call (a1, a2, a3, a4, a5, a6, a7); |
308 | return call (a1, a2, a3, a4, a5, a6, a7); |
549 | } |
309 | } |
550 | }; |
|
|
551 | |
310 | |
552 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> |
311 | private: |
553 | struct callback_funtype_trait7 |
|
|
554 | { |
|
|
555 | static const int arity = 7; |
|
|
556 | typedef R type (A1, A2, A3, A4, A5, A6, A7); |
|
|
557 | typedef R result_type; |
|
|
558 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; |
|
|
559 | }; |
|
|
560 | |
312 | |
561 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> |
313 | void *self; |
562 | struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7)> : callback_funtype_trait7<R, A1, A2, A3, A4, A5, A6, A7> |
314 | ptr_type func; |
563 | { |
|
|
564 | }; |
|
|
565 | |
315 | |
566 | template<class signature> |
316 | template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7)> |
567 | struct callback_get_impl<7, signature> |
317 | static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) |
568 | { |
318 | { |
569 | typedef callback_funtype_trait<signature> T; |
319 | klass *obj = static_cast<klass *>(self); |
570 | typedef callback7<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type> type; |
320 | return (obj->*method) (a1, a2, a3, a4, a5, a6, a7); |
|
|
321 | } |
571 | }; |
322 | }; |
572 | |
323 | |
573 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> |
324 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> |
574 | class callback8 |
325 | struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8)> |
575 | { |
326 | { |
576 | struct object { }; |
|
|
577 | |
|
|
578 | typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7, A8); |
327 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8); |
579 | |
328 | |
580 | void *obj; |
|
|
581 | R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8); |
329 | template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8)> |
582 | |
330 | void set (K *object) |
583 | /* a proxy is a kind of recipe on how to call a specific class method */ |
331 | { |
584 | struct proxy_base { |
332 | self = object; |
585 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const = 0; |
333 | func = thunk<K, method>; |
586 | }; |
334 | } |
587 | template<class O1, class O2> |
|
|
588 | struct proxy : proxy_base { |
|
|
589 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const |
|
|
590 | { |
|
|
591 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7, A8)>(meth))) |
|
|
592 | (a1, a2, a3, a4, a5, a6, a7, a8); |
|
|
593 | } |
|
|
594 | }; |
|
|
595 | |
335 | |
596 | proxy_base *prxy; |
|
|
597 | |
|
|
598 | public: |
|
|
599 | template<class O1, class O2> |
|
|
600 | explicit callback8 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7, A8)) |
|
|
601 | { |
|
|
602 | static proxy<O1,O2> p; |
|
|
603 | obj = reinterpret_cast<void *>(object); |
|
|
604 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7, A8)>(method); |
|
|
605 | prxy = &p; |
|
|
606 | } |
|
|
607 | |
|
|
608 | R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const |
336 | R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const |
609 | { |
337 | { |
610 | return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7, a8); |
338 | return func (self, a1, a2, a3, a4, a5, a6, a7, a8); |
611 | } |
339 | } |
612 | |
340 | |
613 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const |
341 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const |
614 | { |
342 | { |
615 | return call (a1, a2, a3, a4, a5, a6, a7, a8); |
343 | return call (a1, a2, a3, a4, a5, a6, a7, a8); |
616 | } |
344 | } |
617 | }; |
|
|
618 | |
345 | |
619 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> |
346 | private: |
620 | struct callback_funtype_trait8 |
|
|
621 | { |
|
|
622 | static const int arity = 8; |
|
|
623 | typedef R type (A1, A2, A3, A4, A5, A6, A7, A8); |
|
|
624 | typedef R result_type; |
|
|
625 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; typedef A8 arg8_type; |
|
|
626 | }; |
|
|
627 | |
347 | |
628 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> |
348 | void *self; |
629 | struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7, A8)> : callback_funtype_trait8<R, A1, A2, A3, A4, A5, A6, A7, A8> |
349 | ptr_type func; |
630 | { |
|
|
631 | }; |
|
|
632 | |
350 | |
633 | template<class signature> |
351 | template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8)> |
634 | struct callback_get_impl<8, signature> |
352 | static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) |
635 | { |
353 | { |
636 | typedef callback_funtype_trait<signature> T; |
354 | klass *obj = static_cast<klass *>(self); |
637 | typedef callback8<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type, typename T::arg8_type> type; |
355 | return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8); |
|
|
356 | } |
638 | }; |
357 | }; |
639 | |
358 | |
640 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> |
359 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> |
641 | class callback9 |
360 | struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)> |
642 | { |
361 | { |
643 | struct object { }; |
|
|
644 | |
|
|
645 | typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7, A8, A9); |
362 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9); |
646 | |
363 | |
647 | void *obj; |
|
|
648 | R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9); |
364 | template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)> |
649 | |
365 | void set (K *object) |
650 | /* a proxy is a kind of recipe on how to call a specific class method */ |
366 | { |
651 | struct proxy_base { |
367 | self = object; |
652 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const = 0; |
368 | func = thunk<K, method>; |
653 | }; |
369 | } |
654 | template<class O1, class O2> |
|
|
655 | struct proxy : proxy_base { |
|
|
656 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const |
|
|
657 | { |
|
|
658 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>(meth))) |
|
|
659 | (a1, a2, a3, a4, a5, a6, a7, a8, a9); |
|
|
660 | } |
|
|
661 | }; |
|
|
662 | |
370 | |
663 | proxy_base *prxy; |
|
|
664 | |
|
|
665 | public: |
|
|
666 | template<class O1, class O2> |
|
|
667 | explicit callback9 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) |
|
|
668 | { |
|
|
669 | static proxy<O1,O2> p; |
|
|
670 | obj = reinterpret_cast<void *>(object); |
|
|
671 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)>(method); |
|
|
672 | prxy = &p; |
|
|
673 | } |
|
|
674 | |
|
|
675 | R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const |
371 | R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const |
676 | { |
372 | { |
677 | return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
373 | return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
678 | } |
374 | } |
679 | |
375 | |
680 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const |
376 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) const |
681 | { |
377 | { |
682 | return call (a1, a2, a3, a4, a5, a6, a7, a8, a9); |
378 | return call (a1, a2, a3, a4, a5, a6, a7, a8, a9); |
683 | } |
379 | } |
684 | }; |
|
|
685 | |
380 | |
686 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> |
381 | private: |
687 | struct callback_funtype_trait9 |
|
|
688 | { |
|
|
689 | static const int arity = 9; |
|
|
690 | typedef R type (A1, A2, A3, A4, A5, A6, A7, A8, A9); |
|
|
691 | typedef R result_type; |
|
|
692 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; typedef A8 arg8_type; typedef A9 arg9_type; |
|
|
693 | }; |
|
|
694 | |
382 | |
695 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> |
383 | void *self; |
696 | struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7, A8, A9)> : callback_funtype_trait9<R, A1, A2, A3, A4, A5, A6, A7, A8, A9> |
384 | ptr_type func; |
697 | { |
|
|
698 | }; |
|
|
699 | |
385 | |
700 | template<class signature> |
386 | template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)> |
701 | struct callback_get_impl<9, signature> |
387 | static R thunk (void *self, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) |
702 | { |
388 | { |
703 | typedef callback_funtype_trait<signature> T; |
389 | klass *obj = static_cast<klass *>(self); |
704 | typedef callback9<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type, typename T::arg8_type, typename T::arg9_type> type; |
390 | return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9); |
|
|
391 | } |
705 | }; |
392 | }; |
706 | |
393 | |
707 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> |
394 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> |
708 | class callback10 |
395 | struct callback<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> |
709 | { |
396 | { |
710 | struct object { }; |
|
|
711 | |
|
|
712 | typedef R (object::*ptr_type)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); |
397 | typedef R (*ptr_type)(void *self, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); |
713 | |
398 | |
714 | void *obj; |
|
|
715 | R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); |
399 | template<class K, R (K::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> |
716 | |
400 | void set (K *object) |
717 | /* a proxy is a kind of recipe on how to call a specific class method */ |
401 | { |
718 | struct proxy_base { |
402 | self = object; |
719 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const = 0; |
403 | func = thunk<K, method>; |
720 | }; |
404 | } |
721 | template<class O1, class O2> |
|
|
722 | struct proxy : proxy_base { |
|
|
723 | virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const |
|
|
724 | { |
|
|
725 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>(meth))) |
|
|
726 | (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
|
|
727 | } |
|
|
728 | }; |
|
|
729 | |
405 | |
730 | proxy_base *prxy; |
|
|
731 | |
|
|
732 | public: |
|
|
733 | template<class O1, class O2> |
|
|
734 | explicit callback10 (O1 *object, R (O2::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) |
|
|
735 | { |
|
|
736 | static proxy<O1,O2> p; |
|
|
737 | obj = reinterpret_cast<void *>(object); |
|
|
738 | meth = reinterpret_cast<R (object::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>(method); |
|
|
739 | prxy = &p; |
|
|
740 | } |
|
|
741 | |
|
|
742 | R call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const |
406 | R call (A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const |
743 | { |
407 | { |
744 | return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
408 | return func (self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
745 | } |
409 | } |
746 | |
410 | |
747 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const |
411 | R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) const |
748 | { |
412 | { |
749 | return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
413 | return call (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
750 | } |
414 | } |
751 | }; |
|
|
752 | |
415 | |
753 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> |
416 | private: |
754 | struct callback_funtype_trait10 |
|
|
755 | { |
|
|
756 | static const int arity = 10; |
|
|
757 | typedef R type (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); |
|
|
758 | typedef R result_type; |
|
|
759 | typedef A1 arg1_type; typedef A2 arg2_type; typedef A3 arg3_type; typedef A4 arg4_type; typedef A5 arg5_type; typedef A6 arg6_type; typedef A7 arg7_type; typedef A8 arg8_type; typedef A9 arg9_type; typedef A10 arg10_type; |
|
|
760 | }; |
|
|
761 | |
417 | |
762 | template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> |
418 | void *self; |
763 | struct callback_funtype_trait<R (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : callback_funtype_trait10<R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> |
419 | ptr_type func; |
764 | { |
|
|
765 | }; |
|
|
766 | |
420 | |
767 | template<class signature> |
421 | template<class klass, R (klass::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> |
768 | struct callback_get_impl<10, signature> |
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) |
769 | { |
|
|
770 | typedef callback_funtype_trait<signature> T; |
|
|
771 | typedef callback10<typename T::result_type, typename T::arg1_type, typename T::arg2_type, typename T::arg3_type, typename T::arg4_type, typename T::arg5_type, typename T::arg6_type, typename T::arg7_type, typename T::arg8_type, typename T::arg9_type, typename T::arg10_type> type; |
|
|
772 | }; |
|
|
773 | |
|
|
774 | |
|
|
775 | template<class signature> |
|
|
776 | struct callback : callback_get_impl<callback_funtype_trait<signature>::arity, signature>::type |
|
|
777 | { |
|
|
778 | typedef typename callback_get_impl<callback_funtype_trait<signature>::arity, signature>::type base_type; |
|
|
779 | |
|
|
780 | template<class O, class M> |
|
|
781 | explicit callback (O object, M method) |
|
|
782 | : base_type (object, method) |
|
|
783 | { |
423 | { |
|
|
424 | klass *obj = static_cast<klass *>(self); |
|
|
425 | return (obj->*method) (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
784 | } |
426 | } |
785 | }; |
427 | }; |
|
|
428 | |
786 | |
429 | |
787 | #endif |
430 | #endif |