On Saturday 09 September 2006 12:44 am, David Boddie wrote: > On Friday 08 September 2006 05:07:49 +0100 (BST), jim j wrote: > > I have a problem while compiling the following code. > > the code is given below: > > > > %Module pyMyTimer > > > > typedef void (*TIMERFP)(long); > > > > struct _time > > { > > %TypeHeaderCode > > #include <mytimer.h> > > %End > > > > long expiryTime; > > TIMERFP pRoutine; > > long param; > > }; > > > > %ModuleHeaderCode > > #include<cTimer.h> > > %End > > > > int myTimerStart(_time* , long , TIMERFP , long ); > > long myTimerStop(_time* ); > > > > I'm geting the following error , > > sip: _time::pRoutine has an unsupported type. > > > > please ,help me to solve the problem... how will i deleare the Function > > pointer in a sip file? and howl will i use that as parameter in a > > function? > > I thought this would be fairly easy, but I think you will have to try the > approach described in this message: > > http://mats.gmd.de/pipermail/pykde/2003-May/005309.html > > To summarise: you probably need to write a wrapper for Python callback > objects and create a C/C++ callback function that you register with the > myTimerStart() function. This C/C++ callback function is used as a proxy > for Python callbacks. I think you might need to write some %MethodCode > for the myTimerStart() function as well.
That's the correct way of doing it and should work in this case so long as the C++ callback can use it's argument to correctly identify the correct Python callable to call. There isn't enough information in the above to say whether or not this is the case. > Alternatively, you might be able to just define TIMERFP as a mapped type, > using something like this: > > typedef void (*TIMERFP)(long); > %MappedType TIMERFP > { > %TypeHeaderCode > #include <mytimer.h> > %End > > %ConvertFromTypeCode > > // Code to convert a C++ function pointer to a Python callable. > // Perhaps this would be used by a C++ proxy function to find a > // suitable Python callable to return. > > %End > > %ConvertToTypeCode > > // Code to convert a Python callable into a suitable C++ function > // pointer. Perhaps the pointer to an existing C++ proxy function > // could be returned. > > %End > }; > > All of the above is speculative. I haven't tried to do this with SIP, and I > couldn't find any existing examples except some on the web with really old > SIP syntax. I hope it helps you get started, anyway. This won't help because it wouldn't be possible to implement the %ConvertFromTypeCode without additional information. Phil _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde