… | |
… | |
5 | // THIS IS A GENERATED FILE: callback.pl is part of the GVPE |
5 | // THIS IS A GENERATED FILE: callback.pl is part of the GVPE |
6 | // THIS IS A GENERATED FILE: distribution. |
6 | // THIS IS A GENERATED FILE: distribution. |
7 | |
7 | |
8 | /* |
8 | /* |
9 | callback.h -- C++ callback mechanism |
9 | callback.h -- C++ callback mechanism |
10 | Copyright (C) 2003-2005 Marc Lehmann <pcg\@goof.com> |
10 | Copyright (C) 2003-2006 Marc Lehmann <pcg\@goof.com> |
11 | |
11 | |
12 | This file is part of GVPE. |
12 | This file is part of GVPE. |
13 | |
13 | |
14 | GVPE is free software; you can redistribute it and/or modify |
14 | GVPE is free software; you can redistribute it and/or modify |
15 | it under the terms of the GNU General Public License as published by |
15 | it under the terms of the GNU General Public License as published by |
… | |
… | |
47 | void *obj; |
47 | void *obj; |
48 | R (object::*meth)($TYPE); |
48 | R (object::*meth)($TYPE); |
49 | |
49 | |
50 | /* a proxy is a kind of recipe on how to call a specific class method */ |
50 | /* a proxy is a kind of recipe on how to call a specific class method */ |
51 | struct proxy_base { |
51 | struct proxy_base { |
52 | virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) = 0; |
52 | virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) const = 0; |
53 | }; |
53 | }; |
54 | template<class O1, class O2> |
54 | template<class O1, class O2> |
55 | struct proxy : proxy_base { |
55 | struct proxy : proxy_base { |
56 | virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) |
56 | virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) const |
57 | { |
57 | { |
58 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)($TYPE)>(meth))) |
58 | return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)($TYPE)>(meth))) |
59 | ($ARG); |
59 | ($ARG); |
60 | } |
60 | } |
61 | }; |
61 | }; |
62 | |
62 | |
63 | proxy_base *prxy; |
63 | proxy_base *prxy; |
64 | |
64 | |
65 | public: |
65 | public: |
66 | template<class O1, class O2> |
66 | template<class O1, class O2> |
67 | callback$a (O1 *object, R (O2::*method)($TYPE)) |
67 | explicit callback$a (O1 *object, R (O2::*method)($TYPE)) |
68 | { |
68 | { |
69 | static proxy<O1,O2> p; |
69 | static proxy<O1,O2> p; |
70 | obj = reinterpret_cast<void *>(object); |
70 | obj = reinterpret_cast<void *>(object); |
71 | meth = reinterpret_cast<R (object::*)($TYPE)>(method); |
71 | meth = reinterpret_cast<R (object::*)($TYPE)>(method); |
72 | prxy = &p; |
72 | prxy = &p; |