[PyKDE] More SIP questions

Phil Thompson phil at river-bank.demon.co.uk
Tue Mar 25 23:59:01 GMT 2003


On Tuesday 25 March 2003 10:03 pm, WELCH,DONALD J (HP-Vancouver,ex1) wrote:
> Greetings,
>
> Thanks again for the quick response to my earlier queries. I have an
> additional point of contention:
>
> Each of these 5 variables and methods in the class are causing me grief.
>
> // channel.h
> class Channel
> {
>     public:
>         static const int MAX_LEN = 4096;
>         static const char DEF_NAME[] = "UNKNOWN";
>
>         Channel & operator=( const Channel & chan );
>
>         virtual ~Channel();
>
>         static void delay( struct timeval value);
>     ...
> };
>
> Tried this:
>
> //channel.sip
> class Channel
> {
> %HeaderCode
> #include "channel.h"
> %End
>
> public:
>     static const MAX_LEN; // Correct?
>     static const char DEF_NAME[]; // Error

Python doesn't have const values. You could define them as variables, and you 
can also provide handwritten code using %VariableCode if you need to fiddle 
with them. To be honest I can't remember the details as PyQt no longer makes 
use of this. Try...

static int MAX_LEN;
%VariableCode
	Replace this when we've worked out what to do.
%End

...and look at the generated code.

>     Channel & operator=( const Channel & ); //Error

Not supported, just comment out.

>     virtual ~Channel(); //Error

Remove the "virtual".

>     static void delay( struct timeval ); //Error

I assume it's complaining about "struct timeval". You need to wrap this as 
well - or use %MappedType to use something like a tuple instead.

Phil




More information about the PyQt mailing list