Re: XForms: c++, io_callback and idle_callback

Jacques Tremblay (jackt@gel.ulaval.ca)
Wed, 29 Apr 1998 10:03:22 -0400 (EDT)

# To subscribers of the xforms list from Jacques Tremblay <jackt@gel.ulaval.ca> :

On Wed, 29 Apr 1998, Matthew Flax wrote:

.: Date: Wed, 29 Apr 1998 16:40:03 +1000 (EST)
.: From: Matthew Flax <flatmax@cse.unsw.EDU.AU>
.: Reply-To: xforms@bob.usuf2.usuhs.mil
.: To: xforms@bob.usuf2.usuhs.mil
.: Subject: XForms: c++, io_callback and idle_callback
.:
.: # To subscribers of the xforms list from Matthew Flax <flatmax@cse.unsw.EDU.AU> :
.:
.: I am using xforms in "C++" mode !
.:
.: If I register either an io_callback or an idle_callback, I can not use
.: class member functions.
.:
.: In other words I have to use global callback functions.
.: Does anyone know why ?
.: Could it be due to name mangling ?
.:

Hi,

this is normal because C++ member functions are passed
an implicit pointer (the 'this' pointer). XForms is a C library
and does not pass this pointer to callback functions. However, you
can register a static member function as a callback. Static member
functions are like global functions except that their name is
in the scope of the class. (e.g. MyClass::StaticMemberFunction)
My favorite option is to store the this pointer into the
u_vdata field of XForms objects. Then in the static callback, you
can retrieve the 'this' pointer.

Hope this helps.

Jacques

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/