[C++-sig] pygccxml and inner classes

Davidson, Josh josh.davidson at lmco.com
Mon Nov 29 07:36:21 CET 2010


I'm wondering if this behavior is correct when using pygccxml.  Consider the following two sets of simple class definitions:

-------------- SET 1 ----------------------
class inner {
protected:
    unsigned a;
    unsigned b;
    unsigned c;
};

class Cool {
public:
    Cool(){}

protected:
    int x;
    int y;
    int z;

    inner i;
};

-------------- SET 2 ----------------------
class Cool {
public:
    Cool();

protected:
    class inner {
    protected:
        unsigned a;
        unsigned b;
        unsigned c;
    };

    int x;
    int y;
    int z;

    inner i;
};

-------------- END ----------------------

So you'll notice that the only difference between 1 & 2 is that 2, defines "inner" as an inner class.  Now, if I parse a header file containing those classes, obtain a reference to the pygccxml for class Cool and print it's variables like so:

for var in classType.variables():
  print "var", var.name, var.type

This is what I get:

SET 1
var x int
var y int
var z int
var i inner

SET 2
var x int
var y int
var z int
var i Cool::inner
var a unsigned int
var b unsigned int
var c unsigned int


As you can see, when I is an inner class, the inner class's members show up in the parent class in addition to the inner class itself.  Is this behavior correct?  In SET 2, I would not expect to see a, b, and c show up as members of class Cool.  If this behavior is correct, is there a way to filter out those members that belong to the inner class?




More information about the Cplusplus-sig mailing list