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.5 by pcg, Thu Mar 3 16:54:34 2005 UTC vs.
Revision 1.16 by root, Sun Nov 18 00:02:56 2018 UTC

1// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it
2// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it
3// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it
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
8/* 1/*
9 callback.h -- C++ callback mechanism 2 * callback.h -- C++ callback mechanism
10 Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de> 3 * Copyright (C) 2003-2018 Marc Lehmann <pcg@goof.com>
11 4 *
12 This file is part of GVPE. 5 * This file is part of GVPE.
13 6 *
14 GVPE is free software; you can redistribute it and/or modify 7 * 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 8 * 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 9 * Free Software Foundation; either version 3 of the License, or (at your
17 (at your option) any later version. 10 * option) any later version.
18 11 *
19 This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful, but
20 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
22 GNU General Public License for more details. 15 * Public License for more details.
23 16 *
24 You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License along
25 along with gvpe; if not, write to the Free Software 18 * with this program; if not, see <http://www.gnu.org/licenses/>.
26 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 *
20 * Additional permission under GNU GPL version 3 section 7
21 *
22 * If you modify this Program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a modified
24 * version of that library), containing parts covered by the terms of the
25 * OpenSSL or SSLeay licenses, the licensors of this Program grant you
26 * additional permission to convey the resulting work. Corresponding
27 * Source for a non-source form of such a combination shall include the
28 * source code for the parts of OpenSSL used as well as that of the
29 * covered work.
27*/ 30*/
28 31
29#ifndef CALLBACK_H__ 32#ifndef CALLBACK_H__
30#define CALLBACK_H__ 33#define CALLBACK_H__
31 34
32template<class R> 35#define CALLBACK_H_VERSION 4
33class callback0 {
34 struct object { };
35 36
36 void *obj; 37template<typename signature>
37 R (object::*meth)(); 38struct callback;
38 39
39 /* a proxy is a kind of recipe on how to call a specific class method */
40 struct proxy_base {
41 virtual R call (void *obj, R (object::*meth)()) = 0;
42 };
43 template<class O1, class O2> 40template<class R, class ...Args>
44 struct proxy : proxy_base { 41struct callback<R (Args...)>
45 virtual R call (void *obj, R (object::*meth)()) 42{
46 { 43 typedef R (*ptr_type)(void *self, Args...);
47 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)()>(meth)))
48 ();
49 }
50 };
51 44
52 proxy_base *prxy; 45 template<class K, R (K::*method)(Args...)>
46 void set (K *object)
47 {
48 self = object;
49 func = thunk<K, method>;
50 }
53 51
54public: 52 R call (Args... args) const
55 template<class O1, class O2>
56 callback0 (O1 *object, R (O2::*method)())
57 { 53 {
58 static proxy<O1,O2> p; 54 return func (self, args...);
59 obj = reinterpret_cast<void *>(object);
60 meth = reinterpret_cast<R (object::*)()>(method);
61 prxy = &p;
62 } 55 }
63 56
64 R call() const 57 R operator ()(Args... args) const
65 { 58 {
66 return prxy->call (obj, meth); 59 return call (args...);
67 } 60 }
68 61
69 R operator ()() const 62private:
70 {
71 return call ();
72 }
73};
74 63
75template<class R, class A1> 64 void *self;
76class callback1 { 65 ptr_type func;
77 struct object { };
78 66
79 void *obj; 67 template<class klass, R (klass::*method)(Args...)>
80 R (object::*meth)(A1); 68 static R thunk (void *self, Args... args)
81 69 {
82 /* a proxy is a kind of recipe on how to call a specific class method */ 70 klass *obj = static_cast<klass *>(self);
83 struct proxy_base { 71 return (obj->*method) (args...);
84 virtual R call (void *obj, R (object::*meth)(A1), A1 a1) = 0;
85 }; 72 }
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
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
108 {
109 return prxy->call (obj, meth, a1);
110 }
111
112 R operator ()(A1 a1) const
113 {
114 return call (a1);
115 }
116};
117
118template<class R, class A1, class A2>
119class callback2 {
120 struct object { };
121
122 void *obj;
123 R (object::*meth)(A1, A2);
124
125 /* a proxy is a kind of recipe on how to call a specific class method */
126 struct proxy_base {
127 virtual R call (void *obj, R (object::*meth)(A1, A2), A1 a1, A2 a2) = 0;
128 };
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
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
151 {
152 return prxy->call (obj, meth, a1, a2);
153 }
154
155 R operator ()(A1 a1, A2 a2) const
156 {
157 return call (a1, a2);
158 }
159};
160
161template<class R, class A1, class A2, class A3>
162class callback3 {
163 struct object { };
164
165 void *obj;
166 R (object::*meth)(A1, A2, A3);
167
168 /* a proxy is a kind of recipe on how to call a specific class method */
169 struct proxy_base {
170 virtual R call (void *obj, R (object::*meth)(A1, A2, A3), A1 a1, A2 a2, A3 a3) = 0;
171 };
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
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
194 {
195 return prxy->call (obj, meth, a1, a2, a3);
196 }
197
198 R operator ()(A1 a1, A2 a2, A3 a3) const
199 {
200 return call (a1, a2, a3);
201 }
202};
203
204template<class R, class A1, class A2, class A3, class A4>
205class callback4 {
206 struct object { };
207
208 void *obj;
209 R (object::*meth)(A1, A2, A3, A4);
210
211 /* a proxy is a kind of recipe on how to call a specific class method */
212 struct proxy_base {
213 virtual R call (void *obj, R (object::*meth)(A1, A2, A3, A4), A1 a1, A2 a2, A3 a3, A4 a4) = 0;
214 };
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
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
237 {
238 return prxy->call (obj, meth, a1, a2, a3, a4);
239 }
240
241 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4) const
242 {
243 return call (a1, a2, a3, a4);
244 }
245};
246
247template<class R, class A1, class A2, class A3, class A4, class A5>
248class callback5 {
249 struct object { };
250
251 void *obj;
252 R (object::*meth)(A1, A2, A3, A4, A5);
253
254 /* a proxy is a kind of recipe on how to call a specific class method */
255 struct proxy_base {
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 };
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
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
280 {
281 return prxy->call (obj, meth, a1, a2, a3, a4, a5);
282 }
283
284 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
285 {
286 return call (a1, a2, a3, a4, a5);
287 }
288};
289
290template<class R, class A1, class A2, class A3, class A4, class A5, class A6>
291class callback6 {
292 struct object { };
293
294 void *obj;
295 R (object::*meth)(A1, A2, A3, A4, A5, A6);
296
297 /* a proxy is a kind of recipe on how to call a specific class method */
298 struct proxy_base {
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 };
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
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
323 {
324 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6);
325 }
326
327 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
328 {
329 return call (a1, a2, a3, a4, a5, a6);
330 }
331};
332
333template<class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
334class callback7 {
335 struct object { };
336
337 void *obj;
338 R (object::*meth)(A1, A2, A3, A4, A5, A6, A7);
339
340 /* a proxy is a kind of recipe on how to call a specific class method */
341 struct proxy_base {
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 };
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
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
366 {
367 return prxy->call (obj, meth, a1, a2, a3, a4, a5, a6, a7);
368 }
369
370 R operator ()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
371 {
372 return call (a1, a2, a3, a4, a5, a6, a7);
373 }
374}; 73};
375 74
376#endif 75#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines