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.12 by pcg, Tue Dec 4 17:17:19 2007 UTC vs.
Revision 1.13 by pcg, Wed Dec 5 18:19:50 2007 UTC

54template<class R$CLASS> 54template<class R$CLASS>
55struct callback<R ($TYPE)> 55struct callback<R ($TYPE)>
56{ 56{
57 typedef R (*ptr_type)(void *self$_TYPE); 57 typedef R (*ptr_type)(void *self$_TYPE);
58 58
59private:
60
61 void *self;
62 ptr_type func;
63
64protected:
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
82public:
83 template<class K, R (K::*method)($TYPE)> 59 template<class K, R (K::*method)($TYPE)>
84 void set (K *object) 60 void set (K *object)
85 { 61 {
86 self = object; 62 self = object;
87 func = thunk<K, method>; 63 func = thunk<K, method>;
94 70
95 R operator ()($TYPEARG) const 71 R operator ()($TYPEARG) const
96 { 72 {
97 return call ($ARG); 73 return call ($ARG);
98 } 74 }
75
76private:
77
78 void *self;
79 ptr_type func;
80
81 template<class klass, R (klass::*method)($TYPE)>
82 static R thunk (void *self$_TYPEARG)
83 {
84 klass *obj = static_cast<klass *>(self);
85 return (obj->*method) ($ARG);
86 }
99}; 87};
100 88
101EOF 89EOF
102} 90}
103 91

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines