[PyKDE] Trouble binding code with SIP

Phil Thompson phil at riverbankcomputing.co.uk
Mon Oct 13 11:42:00 BST 2003


On Monday 13 October 2003 10:27 am, Aurélien Gâteau wrote:
> Hello list
>
> I'm experimenting trouble binding some code with SIP. The original C++
> header code is composed of one namespace (DolSphinx) and a class
> (DolSphinxListener). Here are some interesting excerpts:
>
> --- dolsphinx.h ---
> class DolSphinxListener;
>
> namespace DolSphinx {
>     enum State {Uninitialized, Initializing, Listening, Calibrating,
> Paused};
>
>     /* Snipped some functions */
>
>     DolSphinxListener* listener();
>     void setListener(DolSphinxListener*);
>
>     State state();
>
>     State stringToState(const QString&);
>     QString stateToString(State);
> }
> ---
>
> The DolSphinxListener class:
>
> --- dolsphinxlistener.h ---
> class DolSphinxListener : public QObject {
> Q_OBJECT
> public:
>     /* Snipped some functions */
>
> signals:
>     void wordHeard(const QString&);
>     void stateChanged(DolSphinx::State);
> /* snip */
> };
> ---
>
> I wrote the following files to bind them:
>
> --- dolsphinx.sip ---
> %Module dolsphinx
>
> %Import qtmod.sip
>
> %HeaderCode
> #include <dolsphinx.h>
> %End
>
> %Include dolsphinxlistener.sip
>
> namespace DolSphinx {
>     enum State {Uninitialized, Initializing, Listening, Calibrating, Paused
> };
>
>     DolSphinxListener* listener();
>     void setListener(DolSphinxListener*);
>
>     DolSphinx::State state();
>
>     DolSphinx::State stringToState(const QString&);
>     QString stateToString(DolSphinx::State);
> };
> /* Snipped Makefile code */
> ---
>
> --- dolsphinxlistener.h ---
> class DolSphinxListener : QObject
> {
> %HeaderCode
> #include <dolsphinxlistener.h>
> %End
> public:
>
> signals:
>     void wordHeard(const QString&);
>     void stateChanged(DolSphinx::State);
> };
> ---
>
> Sip	(3.7) generates correctly the C++ files, but compiling the generated
> files fails with this error:
> sipdolsphinxProxydolsphinx.h:22: `DolSphinx' was not declared in this scope
>
> The offending line is:
> void proxySlot(DolSphinx::State);
>
> If I manually add a '#include <dolsphinx.h>' in this file, it works, but I
> don't know how to tell sip to add this include itself. Does anyone got an
> idea?

In the %HeaderCode section of the DolSphinxListener class?

Having to do this implies that dolsphinxlistener.h doesn't (but should IMHO) 
#include the file itself.

Phil




More information about the PyQt mailing list