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.1 by pcg, Wed Apr 2 05:14:59 2003 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
10 Copyright (C) 2003-2006 Marc Lehmann <pcg\@goof.com>
13 11
12 This file is part of GVPE.
13
14 This program 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
16 the Free Software Foundation; either version 2 of the License, or 16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version. 17 (at your option) any later version.
18 18
19 This program is distributed in the hope that it will be useful, 19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details. 22 GNU General Public License for more details.
23 23
24 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
25 along with this program; if not, write to the Free Software 25 along with gvpe; if not, write to the Free Software
26 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
27*/ 27*/
28 28
29#ifndef VPE_CALLBACK_H__ 29#ifndef CALLBACK_H__
30#define VPE_CALLBACK_H__ 30#define CALLBACK_H__
31 31
32EOF 32EOF
33 33
34for my $a (0..7) { 34for my $a (0..7) {
35 my $CLASS = join "", map ", class A$_", 1..$a; 35 my $CLASS = join "", map ", class A$_", 1..$a;
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 ((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
65public: 65public:
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines