
c++ class-method & Tcl_CreateCommand
Peter Schartner <pschartn>,
In a message on 2 Mar 1996 12:58:19 GMT, wrote :
PS> Is there a way to use a class-method as the function-parameter of
PS> Tcl_CreateCommand ? At the time I use a workaround. I create the command with a
PS> normal c-function and this c-function calls the method of the object.
It is never possible to use a normal class method as a passed function (to be
called back later). You *can* use a *static" class method, but you still have
to pass the instance pointer as the client data and call a normal class method
from the static method. This is true not only for Tcl_CreateCommand(), but
for Motif, Xaw, or Xt callback routines too. The simplest hack is to put the
Tcl_CreateCommand() calls in a Xxx_Init() function, use some static c functions
to call the proper member methods. I do this in both the Tcl/Tk interfaces for
my Home Librarian and Role Playing Database packages. The source is available
for both on ftp://sunsite.unc.edu/pub/Linux and mirrors. Visit my virtual
storefront for details (second url in my .sig).
--
\/
http://www.*-*-*.com/ ~heller ||FidoNet: 1:321/153
http://www.*-*-*.com/ ;/\