[PyKDE] SIP questions

Phil Thompson phil at riverbankcomputing.co.uk
Thu May 29 20:12:01 BST 2003


On Thursday 29 May 2003 3:08 pm, Jonathan Gardner wrote:
> On Tuesday 25 March 2003 14:05, Jim Bublitz wrote:
> > sip still generates one cpp/h file pair per class, but how you
> > distribute classes over sip files makes no difference to anything.
> > Every class needs a %HeaderCode block though, no matter how you
> > arrange things.
>
> I hate to disagree with you, Jim, and I know I am probably the one who is
> wrong here, but I've found that at least for 3.5, this isn't true. Here is
> what I have in my sip file for PostgeSQL:
>
> %HeaderCode
> #include "libpq-fe++.h" // My C++ wrapper around libpq-fe.h
> %End
>
> class result {
> 	...
> };
>
> class Conn {
> 	...
> };
>
> Everything seems to work okay, even though I only have one %HeaderCode
> block and it is outside the classes.
>
> Correct me if I am wrong.

There is a header file for each class and a global header file. A class header 
file will include the global header file.

The global %HeaderCode goes in the global header file. The class %HeaderCode 
goes in the class header file.

What you've done is the right thing to do if the API you are wrapping is 
defined in a single header file. Jim's is the right approach when an API is 
defined over class specific header files - as in PyQt and PyKDE.

Phil




More information about the PyQt mailing list