#!/usr/bin/perl print < class callback$a { struct object { }; void *obj; R (object::*meth)($TYPE); /* a proxy is a kind of recipe on how to call a specific class method */ struct proxy_base { virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) = 0; }; template struct proxy : proxy_base { virtual R call (void *obj, R (object::*meth)($TYPE)$_TYPEARG) { ((reinterpret_cast(obj)) ->* (reinterpret_cast(meth))) ($ARG); } }; proxy_base *prxy; public: template callback$a (O1 *object, R (O2::*method)($TYPE)) { static proxy p; obj = reinterpret_cast(object); meth = reinterpret_cast(method); prxy = &p; } R call($TYPEARG) const { return prxy->call (obj, meth$_ARG); } R operator ()($TYPEARG) const { return call ($ARG); } }; EOF } print <