[PyKDE] Trouble binding code with SIP

Patrick Stinson ajole-1 at gci.net
Thu Oct 16 07:50:01 BST 2003


This may be more of a question for Phil.


a.h
----------------------------------
namespace PK
{
class A {};
}

b.h
------------------------------------
namespace PK
{
class B{};
}

pkmod.sip
-----------------------------------
%Module PK
%Include a.sip
%Include b.sip

a.sip
-------------------------------------
/* same as a.h */

b.sip
-------------------------------------
/* same as b.h */


I'm working on modifying my sip project to include a lot of classes all 
contained in the same C++ namespace. What is the correct way to organize the 
sip files? Do all classes in the namespace have to be declared within the 
namespace in the same sip file? 

Right now I have added the namespace decl and brackets in each class' sip 
file, all of which are included in the module file, just like in PyQt. When 
it's like this, I get a sip parse error on the line including the second file 
with a namespace decl. 

Cheers!

On Monday 13 October 2003 08:30, Aurélien Gâteau wrote:
> Le Lundi 13 Octobre 2003 18:23, Phil Thompson a écrit :
> > That wouldn't make any difference. The %HeaderCode section in a class
> > definition is used to #include all header files needed by that class -
> > normally just the one.
>
> I just tried it again. I made some simplifications, like putting my
> Listener into DolSphinx namespace, so here is the new sip file (only one
> now).
>
> --- dolsphinx.sip ---
> %Module dolsphinx
>
> %Import qtmod.sip
>
> %HeaderCode
> #include <dolsphinx.h>
> #include <dolsphinxlistener.h>
> %End
>
>
> namespace DolSphinx {
>     enum State { Uninitialized, Initializing, Listening, Calibrating,
> Paused };
>
>     class Listener : QObject {
>     public:
>         Listener(QObject* /TransferThis/ = 0);
>         ~Listener();
>
>         void wordConnect(const QString&, SIP_RXOBJ_CON,SIP_SLOT_CON());
>         void wordDisconnect(const QString&, SIP_RXOBJ_CON,SIP_SLOT_CON());
>
>     signals:
>         void wordHeard(const QString&);
>         void stateChanged(DolSphinx::State);
>     };
>
>     /* function snip */
>
>     DolSphinx::Listener* listener();
>     void setListener(DolSphinx::Listener*);
>
>     DolSphinx::State state();
>
>     DolSphinx::State stringToState(const QString&);
>     QString stateToString(DolSphinx::State);
> };
> ---
>
> What is interesting is that it does not fail on
> "stateToString(DolSphinx::State)". Maybe it has something to do with the
> fact that stateChanged is a signal.
>
> The broken file is sipdolsphinxProxydolsphinx.h. It's content is:
>
> --- sipdolsphinxProxydolsphinx.h ---
> // Module proxy signal/slot handler class.
> //
> // Generated by SIP 3.7 (build 102) on Mon Oct 13 18:25:41 2003
>
> #ifndef _dolsphinxPROXY_H
> #define _dolsphinxPROXY_H
>
> #include <sipQt.h>
>
> #include <qobject.h>
> #include <qapplication.h>
> #include <qstring.h>
>
> class sipProxydolsphinx: public sipProxy
> {
>     Q_OBJECT
>
> public:
>     char *getProxySlot(char *);
>
> public slots:
>     void proxySlot(DolSphinx::State); // <- compilation fails here
>     void proxySlot(const QString&);
>     void proxySlot(QObject *);
>     void proxySlot();
> };
>
> #endif
> ---
>
> Aurélien
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde




More information about the PyQt mailing list