[PyQt] Order of %Import vs. %Include directives affects generated output with respect to namespaces?

Nate Reid gnatty7 at hotmail.com
Tue Nov 16 21:57:02 GMT 2010


This is using sip 4.10


// Example module that produces erroneous output

%Module example


%Import mapped_types.sip // A separately compiled module with some mapped types


%Import some_module.sip // This is before the %Includes


%Include file.sip // A wrapped class that uses a wrapped class in some_module under the 'myns' namespace

%Include ...

...



If I change the order of the directives to the following:

// "Correct" example that produces functional  output but  requires reording
 of the Imports

%Module example

%Import mapped_types.sip

%Include file.sip 

%Include ...

...

%Import some_module.sip // This is now after the %Include(s)

...



The output changes with respect to the namespace definitions in the sipClassTypeDef struct defnitions

The first produces something like this is the
// sip_examplemyns.cpp
sipClassTypeDef sipTypeDef__example_myns = {
    {
        -1,
        0,
        0,
        SIP_TYPE_NAMESPACE,
        sipNameNr_myns,
        {0}
    },
    {
        -1,
        {2, 0, 0},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    },
    0,


While the second one with the reordering of the %Import produces:
// sip_examplemyns.cpp

...

sipClassTypeDef sipTypeDef__example_myns = {

    {

        -1,

        0,

        0,

        SIP_TYPE_NAMESPACE,

        sipNameNr_myns,

        {0}

    },

    {

        sipNameNr_myns, // Difference!

        {0, 0, 1},                // Difference!

        0, 0,

        0, 0,

        0, 0,

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

    },


When I load the module in python for the first example above, the namespace 'class' isn't there:
e.g.
>>> import example
>>> example.myns # doesn't exist

Whereas the second version with the %Import some_module after the the %Includes gives me
>>> import example
>>> examp.myns # exists

Is this some sort of bug in sip that's been fixed in a newer version of SIP?  I tried to create a full example that shows this problem but I was hoping that this information is enough to help explain what was going on.

Thanks!
-Nate
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101116/a5d51ebc/attachment-0001.html>


More information about the PyQt mailing list