<div dir="ltr"><br><br><div class="gmail_quote">On Mon, Nov 29, 2010 at 8:36 AM, Davidson, Josh <span dir="ltr">&lt;<a href="mailto:josh.davidson@lmco.com">josh.davidson@lmco.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;m wondering if this behavior is correct when using pygccxml.  Consider the following two sets of simple class definitions:<br>
<br>
-------------- SET 1 ----------------------<br>
class inner {<br>
protected:<br>
    unsigned a;<br>
    unsigned b;<br>
    unsigned c;<br>
};<br>
<br>
class Cool {<br>
public:<br>
    Cool(){}<br>
<br>
protected:<br>
    int x;<br>
    int y;<br>
    int z;<br>
<br>
    inner i;<br>
};<br>
<br>
-------------- SET 2 ----------------------<br>
class Cool {<br>
public:<br>
    Cool();<br>
<br>
protected:<br>
    class inner {<br>
    protected:<br>
        unsigned a;<br>
        unsigned b;<br>
        unsigned c;<br>
    };<br>
<br>
    int x;<br>
    int y;<br>
    int z;<br>
<br>
    inner i;<br>
};<br>
<br>
-------------- END ----------------------<br>
<br>
So you&#39;ll notice that the only difference between 1 &amp; 2 is that 2, defines &quot;inner&quot; 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&#39;s variables like so:<br>

<br>
for var in classType.variables():<br>
  print &quot;var&quot;, <a href="http://var.name" target="_blank">var.name</a>, var.type<br>
<br>
This is what I get:<br>
<br>
SET 1<br>
var x int<br>
var y int<br>
var z int<br>
var i inner<br>
<br>
SET 2<br>
var x int<br>
var y int<br>
var z int<br>
var i Cool::inner<br>
var a unsigned int<br>
var b unsigned int<br>
var c unsigned int<br>
<br>
<br>
As you can see, when I is an inner class, the inner class&#39;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?<br>
<br></blockquote><div><br></div><div>This is the current package behavior. Another interesting use case, you can bring, is based classes. You will not see the variables from the base classes.</div><div><br></div><div>Take a look on this document: <a href="http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pygccxml_dev/docs/query_interface.rest?revision=1727&amp;view=markup">http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pygccxml_dev/docs/query_interface.rest?revision=1727&amp;view=markup</a> and then on pygccxml/declarations/scopedef.py - variables method. </div>
<div><br></div><div><br></div><div>In your case, it is very simple to get the desired variables:</div><div><br></div><div>class_vars = classType.variables( lambda var: var.parent is classType )</div><div><br></div><div><br>
</div><div>HTH</div><div><br></div></div></div>