[PyQt] Getting around Circualr references in SIP modules

Nate Reid gnatty7 at hotmail.com
Thu Dec 9 23:38:16 GMT 2010




> Date: Thu, 9 Dec 2010 22:33:26 +0000
> From: phil at riverbankcomputing.com
> To: gnatty7 at hotmail.com
> CC: pyqt at riverbankcomputing.com
> Subject: Re: [PyQt] Getting around Circualr references in SIP modules
> 
> On Thu, 9 Dec 2010 14:17:31 -0800, Nate Reid <gnatty7 at hotmail.com> wrote:
> > I am wrapping a set of components that are generally independent of each
> > other, but not always.
> > 
> > For example, I have
> > ///////
> > // foo module
> > %Module foo
> > %Import common.sip // Need to get a Blah
> > %Include SomeClass.sip
> > 
> > Blah* getTheBlah();
> > %MethodCode
> >     sipRes = ...
> > %End
> > 
> > ///////
> > // SomeClass.sip
> > class SomeClass
> > {
> > %TypeHeaderCode
> > ...
> >     
> > };
> > 
> > ///////
> > // common.sip
> > %Module common
> > %Import foo // Need SomeClass
> > class Blah{
> > ...
> >     SomeClass* getVal();
> > };
> > 
> > 
> > So, common and foo are different modules but they use classes from each
> > other's modules.  How do I get around this problem?  Is there something
> I
> > can do with ConsolidatedModule, or what not to still et these modules be
> > build and installed independently but get around this circular reference
> /
> > Import issue?
> 
> They probably all need to be part of the same module, but you could try
> playing with the /External/ class annotation.
> 
> Phil

However, namespaces seem to make things difficult:

////////////////////////////
// SomeClass.sip
namespace myns {
class 
SomeClass
{
%TypeHeaderCode
#include <path/to/myns/SomeClass.h>
...
};
};

///////
// common.sip
%Module common
%Import foo // Need SomeClass
namespace myns {
    class SomeClass /External/;
};

class Blah{
 ...
myns::SomeClass* getVal();
};

I get a SIP  error:
sip: /path/to/common.sip:#  External classes/structs can only be declared in the global scope


So, when I change common.sip to:
 class myns::SomeClass /External/;

I get:
sip: /path/to/common.sip:# The struct/class has already been defined

Still possible to use External?

-Nate


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101209/ffc75a06/attachment.html>


More information about the PyQt mailing list