ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/callback.pl
(Generate patch)

Comparing gvpe/src/callback.pl (file contents):
Revision 1.4 by pcg, Thu Mar 3 16:54:34 2005 UTC vs.
Revision 1.8 by pcg, Sat Jan 14 11:21:12 2006 UTC

1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3print <<EOF; 3print <<EOF;
4// 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 5// THIS IS A GENERATED FILE: callback.pl is part of the GVPE
6// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it 6// THIS IS A GENERATED FILE: distribution.
7// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it
8// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it
9// THIS IS A GENERATED FILE, RUN callback.pl to regenerate it
10 7
11/* 8/*
12 callback.h -- C++ callback mechanism 9 callback.h -- C++ callback mechanism
13 Copyright (C) 2003 Marc Lehmann <pcg\@goof.com> 10 Copyright (C) 2003-2006 Marc Lehmann <pcg\@goof.com>
14 11
15 This file is part of GVPE. 12 This file is part of GVPE.
16 13
17 GVPE is free software; you can redistribute it and/or modify 14 GVPE is free software; you can redistribute it and/or modify
18 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
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details. 22 GNU General Public License for more details.
26 23
27 You should have received a copy of the GNU General Public License 24 You should have received a copy of the GNU General Public License
28 along with gvpe; if not, write to the Free Software 25 along with gvpe; if not, write to the Free Software
29 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30*/ 27*/
31 28
32#ifndef CALLBACK_H__ 29#ifndef CALLBACK_H__
33#define CALLBACK_H__ 30#define CALLBACK_H__
34 31
50 void *obj; 47 void *obj;
51 R (object::*meth)($TYPE); 48 R (object::*meth)($TYPE);
52 49
53 /* 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 */
54 struct proxy_base { 51 struct proxy_base {
55 virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) = 0; 52 virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) const = 0;
56 }; 53 };
57 template<class O1, class O2> 54 template<class O1, class O2>
58 struct proxy : proxy_base { 55 struct proxy : proxy_base {
59 virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) 56 virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) const
60 { 57 {
61 ((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)($TYPE)>(meth))) 58 return (R)((reinterpret_cast<O1 *>(obj)) ->* (reinterpret_cast<R (O2::*)($TYPE)>(meth)))
62 ($ARG); 59 ($ARG);
63 } 60 }
64 }; 61 };
65 62
66 proxy_base *prxy; 63 proxy_base *prxy;
67 64
68public: 65public:
69 template<class O1, class O2> 66 template<class O1, class O2>
70 callback$a (O1 *object, R (O2::*method)($TYPE)) 67 explicit callback$a (O1 *object, R (O2::*method)($TYPE))
71 { 68 {
72 static proxy<O1,O2> p; 69 static proxy<O1,O2> p;
73 obj = reinterpret_cast<void *>(object); 70 obj = reinterpret_cast<void *>(object);
74 meth = reinterpret_cast<R (object::*)($TYPE)>(method); 71 meth = reinterpret_cast<R (object::*)($TYPE)>(method);
75 prxy = &p; 72 prxy = &p;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines