[PyKDE] SIP questions
Gerard Vermeulen
gvermeul at grenoble.cnrs.fr
Thu May 29 18:21:00 BST 2003
On Thu, 29 May 2003 08:40:21 -0700
Jim Bublitz <jbublitz at nwinternet.com> wrote:
> On Thursday May 29 2003 07:08, 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.
>
> I'll take your word that it works. It may be that sip has changed
> and I'm not aware of it (although I don't think so). It's more
> likely that the dependencies are getting satisfied via some
> feature of the Makefile or sequence of compilation. For example,
> if PyKDE is built using the -c switch to build.py, that doesn't
> guarantee it will build *without* the -c switch, because the way
> the h files are pulled in is different in each case. Similarly,
> if your wrapper h file pulls in all of the other necessary h
> files and in turn the wrapper h file is pulled in by another
> file common to all the cpp files, you won't see a need for a
> header code block in each class. However, generally I believe
> that's still a requirement - it seems to me to be the difference
> between "works sometimes" and "always works".
>
> In general, I still get the best results by adding a %HeaderCode
> block to each class.
>
> Jim
>
PyQwt always worked with %HeaderCode blocks outside the class definition
(my motivation is not to confuse emacs' C++-mode).
A quick look in the PyQwt's generated code shows that all files included
in the %HeaderCode block end up in a file called 'sipqwtDeclqwt.h' and
this file gets included in every generated *.cpp file.
PyQwt does not use the equivalent of a -c switch, but I do not think
that it would make a difference in view of those observations.
Gerard
More information about the PyQt
mailing list