… | |
… | |
6 | // THIS IS A GENERATED FILE: RUN callback.pl to regenerate it |
6 | // THIS IS A GENERATED FILE: RUN callback.pl to regenerate it |
7 | // THIS IS A GENERATED FILE: callback.pl is part of the GVPE |
7 | // THIS IS A GENERATED FILE: callback.pl is part of the GVPE |
8 | // THIS IS A GENERATED FILE: distribution. |
8 | // THIS IS A GENERATED FILE: distribution. |
9 | |
9 | |
10 | /* |
10 | /* |
11 | callback.h -- C++ callback mechanism |
11 | * callback.h -- C++ callback mechanism |
12 | Copyright (C) 2003-2007 Marc Lehmann <pcg\@goof.com> |
12 | * Copyright (C) 2003-2008 Marc Lehmann <pcg\@goof.com> |
13 | |
13 | * |
14 | This file is part of GVPE. |
14 | * This file is part of GVPE. |
15 | |
15 | * |
16 | GVPE is free software; you can redistribute it and/or modify |
16 | * This program is free software; you can redistribute it and/or modify it |
17 | it under the terms of the GNU General Public License as published by |
17 | * under the terms of the GNU General Public License as published by the |
18 | the Free Software Foundation; either version 2 of the License, or |
18 | * Free Software Foundation; either version 3 of the License, or (at your |
19 | (at your option) any later version. |
19 | * option) any later version. |
20 | |
20 | * |
21 | This program is distributed in the hope that it will be useful, |
21 | * This program is distributed in the hope that it will be useful, but |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
24 | GNU General Public License for more details. |
24 | * Public License for more details. |
25 | |
25 | * |
26 | You should have received a copy of the GNU General Public License |
26 | * You should have received a copy of the GNU General Public License along |
27 | along with gvpe; if not, write to the Free Software |
27 | * with this program; if not, see <http://www.gnu.org/licenses/>. |
28 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
28 | * |
|
|
29 | * Additional permission under GNU GPL version 3 section 7 |
|
|
30 | * |
|
|
31 | * If you modify this Program, or any covered work, by linking or |
|
|
32 | * combining it with the OpenSSL project's OpenSSL library (or a modified |
|
|
33 | * version of that library), containing parts covered by the terms of the |
|
|
34 | * OpenSSL or SSLeay licenses, the licensors of this Program grant you |
|
|
35 | * additional permission to convey the resulting work. Corresponding |
|
|
36 | * Source for a non-source form of such a combination shall include the |
|
|
37 | * source code for the parts of OpenSSL used as well as that of the |
|
|
38 | * covered work. |
29 | */ |
39 | */ |
30 | |
40 | |
31 | #ifndef CALLBACK_H__ |
41 | #ifndef CALLBACK_H__ |
32 | #define CALLBACK_H__ |
42 | #define CALLBACK_H__ |
33 | |
43 | |
… | |
… | |
54 | template<class R$CLASS> |
64 | template<class R$CLASS> |
55 | struct callback<R ($TYPE)> |
65 | struct callback<R ($TYPE)> |
56 | { |
66 | { |
57 | typedef R (*ptr_type)(void *self$_TYPE); |
67 | typedef R (*ptr_type)(void *self$_TYPE); |
58 | |
68 | |
59 | private: |
|
|
60 | |
|
|
61 | void *self; |
|
|
62 | ptr_type func; |
|
|
63 | |
|
|
64 | protected: |
|
|
65 | |
|
|
66 | template<typename method> |
|
|
67 | struct thunktype; |
|
|
68 | |
|
|
69 | template<class klass> |
|
|
70 | struct thunktype<R (klass::*)> |
|
|
71 | { |
|
|
72 | typedef klass K; |
|
|
73 | }; |
|
|
74 | |
|
|
75 | template<class klass, R (klass::*method)($TYPE)> |
|
|
76 | static R thunk (void *self$_TYPEARG) |
|
|
77 | { |
|
|
78 | klass *obj = static_cast<klass *>(self); |
|
|
79 | return (obj->*method) ($ARG); |
|
|
80 | } |
|
|
81 | |
|
|
82 | public: |
|
|
83 | template<class K, R (K::*method)($TYPE)> |
69 | template<class K, R (K::*method)($TYPE)> |
84 | void set (K *object) |
70 | void set (K *object) |
85 | { |
71 | { |
86 | self = object; |
72 | self = object; |
87 | func = thunk<K, method>; |
73 | func = thunk<K, method>; |
… | |
… | |
94 | |
80 | |
95 | R operator ()($TYPEARG) const |
81 | R operator ()($TYPEARG) const |
96 | { |
82 | { |
97 | return call ($ARG); |
83 | return call ($ARG); |
98 | } |
84 | } |
|
|
85 | |
|
|
86 | private: |
|
|
87 | |
|
|
88 | void *self; |
|
|
89 | ptr_type func; |
|
|
90 | |
|
|
91 | template<class klass, R (klass::*method)($TYPE)> |
|
|
92 | static R thunk (void *self$_TYPEARG) |
|
|
93 | { |
|
|
94 | klass *obj = static_cast<klass *>(self); |
|
|
95 | return (obj->*method) ($ARG); |
|
|
96 | } |
99 | }; |
97 | }; |
100 | |
98 | |
101 | EOF |
99 | EOF |
102 | } |
100 | } |
103 | |
101 | |