[PyKDE] still a problem with protected static member functions

Gerard Vermeulen gerard.vermeulen at grenoble.cnrs.fr
Sun Mar 5 05:27:06 GMT 2006


Hi Phil,

SIP-4.3 (snapshot-20060304) has still a problem with protected static member
functions in the sense that it does not generate all include statements in
the C++ source files (and maybe a deeper problem -- see end of mail).

The problem occurs with the following hierarchy:

#ifndef S_H
#define S_H

class A
{
public:
    A() {}
    virtual ~A() {}
protected:
    static int bar() { return 3; }
};

class B: public A
{
public:
    B(): A() {}
    virtual ~B() {}
private:
    static int bar(int oops) { return 0; }
};

class C: public A
{
protected:
    C(): A() {}
    virtual ~C() {}
    static int bar(int oops) { return 3*oops; }
};

class D: public C
{
protected:
    D(): C() {}
    virtual ~D() {}
};

class E: public D
{
public:
    E(): D() {}
    virtual ~E() {}
};

#endif // S_H

When I define method code for static int C::bar(int) in the following
SIP specification:
%Module s 0

class A
{
%TypeHeaderCode
#include <s.h>
%End

public:
    A();
    ~A();
protected:
    static int bar();
};

class B: A
{
%TypeHeaderCode
#include <s.h>
%End

public:
    B();
    ~B();
};

class C: A
{
%TypeHeaderCode
#include <s.h>
%End

protected:
    C();
    ~C();
    static int bar(int);
%MethodCode
// dummy method code which breaks compilation
// of classes which are derived a child class
sipRes = sipC::sipProtect_bar(a0);
%End
};

class D: C
{
%TypeHeaderCode
#include <s.h>
%End

protected:
    D();
    ~D();
};

class E: D
{
%TypeHeaderCode
#include <s.h>
%End

public:
    E();
    ~E();
};

// End of SIP file

then I have to patch the source code as follows:

--- s-0.3/sipsE.cpp.fix 2006-03-05 05:44:11.000000000 +0100
+++ s-0.3/sipsE.cpp     2006-03-05 05:44:11.000000000 +0100
@@ -7,6 +7,7 @@
 #include "sipAPIs.h"
 #include "sipsE.h"

+#include "sipsC.h"
 #include "sipsD.h"

because the method code for bar() gets copied in the generated C++ file
for class E.

I think that SIP's resolution of static member functions is still broken.
When SIP is generating the code for class E, it should see that class C
defines a static member function and use that one.  Class D only has a
a static member function by inheritance and its inherited static member
function should not be used in the generated code.

The attached s-0.3.tar.gz demonstrates the problem.  If you give the
s-0.3/configure.py script any commandline argument, it will patch the
output of SIP.

Gerard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s-0.3.tar.gz
Type: application/octet-stream
Size: 1787 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060305/3dd7794e/s-0.3.tar.obj


More information about the PyQt mailing list