Thread: [pygccxml-commit] SF.net SVN: pygccxml: [10] pygccxml_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <mb...@us...> - 2006-04-28 07:37:45
|
Revision: 10 Author: mbaas Date: 2006-04-28 00:37:38 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=10&view=rev Log Message: ----------- Deleted some files that are not required for the unittests Removed Paths: ------------- pygccxml_dev/unittests/data/gccxml.xsl pygccxml_dev/unittests/example.py pygccxml_dev/unittests/pygccxml.profile pygccxml_dev/unittests/windows.py Deleted: pygccxml_dev/unittests/data/gccxml.xsl =================================================================== --- pygccxml_dev/unittests/data/gccxml.xsl 2006-04-27 06:18:41 UTC (rev 9) +++ pygccxml_dev/unittests/data/gccxml.xsl 2006-04-28 07:37:38 UTC (rev 10) @@ -1,989 +0,0 @@ -<?xml version="1.0"?> -<xsl:stylesheet - xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" - version = "1.0"> - <xsl:output method="html"/> - - <xsl:template match = "GCC_XML"> - - <!-- =============================================== --> - <table border="0"> - <tr><td>A</td><td ><a href="#TA">Array Types</a></td></tr> - <tr><td>B</td><td ><a href="#TB">Builtins</a></td></tr> - <tr><td>Co</td><td ><a href="#TC">Constructors</a></td></tr> - <tr><td>Cvt</td><td ><a href="#TCT">Converter</a></td></tr> - <tr><td>Q</td><td ><a href="#TQ">Cvq Types</a></td></tr> - <tr><td>Z</td><td ><a href="#TZ">Classes</a></td></tr> - <tr><td>D</td><td ><a href="#TD">Destructors</a></td></tr> - <tr><td>E</td><td ><a href="#TE">Enumerations</a></td></tr> - <tr><td>Fd</td><td ><a href="#TFd">Fields</a></td></tr> - <tr><td>Fu</td><td ><a href="#TF">Functions</a></td></tr> - <tr><td>FT</td><td ><a href="#TFT">Function Types</a></td></tr> - <tr><td>M</td><td ><a href="#TM">Methods</a></td></tr> - <tr><td>MT</td><td ><a href="#TMT">Method Typess</a></td></tr> - <tr><td>N</td><td ><a href="#TN">Namespaces</a></td></tr> - <tr><td>OpM</td><td ><a href="#TOM">Operator Methods</a></td></tr> - <tr><td>OpF</td><td ><a href="#TOF">Operator Functions</a></td></tr> - <tr><td>O</td><td ><a href="#TO">Offset Types</a></td></tr> - <tr><td>P</td><td ><a href="#TP">Pointer Types</a></td></tr> - <tr><td>R</td><td ><a href="#TR">Reference Types</a></td></tr> - <tr><td>S</td><td ><a href="#TS">Structures</a></td></tr> - <tr><td>TT</td><td ><a href="#TT">Typedefs</a></td></tr> - <tr><td>U</td><td ><a href="#TU">Unions</a></td></tr> - <tr><td>V</td><td ><a href="#TV">Variables</a></td></tr> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TB"></a> - <thead> - <tr align="center" colspan="5">Builtin Types</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - </tr> - </thead> - <xsl:apply-templates select="FundamentalType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TN"></a> - <thead> - <tr align="center" colspan="5">Namespaces</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">members</td> - </tr> - </thead> - <xsl:apply-templates select="Namespace"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TZ"></a> - <thead> - <tr align="center" colspan="5">Classes</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">bases</td> - <td align="center">members</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Class"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TS"></a> - <thead> - <tr align="center" colspan="5">Structures</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">bases</td> - <td align="center">members</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Struct"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TU"></a> - <thead> - <tr align="center" colspan="5">Unions</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">bases</td> - <td align="center">members</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Union"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TFd"></a> - <thead> - <tr align="center" colspan="5">Fields</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">type</td> - <td align="center">bits</td> - <td align="center">access</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Field"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TT"></a> - <thead> - <tr align="center" colspan="5">Typedefs</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">type</td> - </tr> - </thead> - <xsl:apply-templates select="Typedef"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TA"></a> - <thead> - <tr align="center" colspan="2">Arrays</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">type</td> - <td align="center">min</td> - <td align="center">max</td> - </tr> - </thead> - <xsl:apply-templates select="ArrayType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - - <!-- =============================================== --> - <table border="1"> - <a name="TP"></a> - <thead> - <tr align="center" colspan="2">Pointers</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">type</td> - </tr> - </thead> - <xsl:apply-templates select="PointerType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TO"></a> - <thead> - <tr align="center" colspan="2">Offset Types</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">basetype</td> - <td align="center">type</td> - </tr> - </thead> - <xsl:apply-templates select="OffsetType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TR"></a> - <thead> - <tr align="center" colspan="2">References</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">type</td> - </tr> - </thead> - <xsl:apply-templates select="ReferenceType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TQ"></a> - <thead> - <tr align="center" colspan="2">CVQ Types</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">type</td> - </tr> - </thead> - <xsl:apply-templates select="CvQualifiedType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TV"></a> - <thead> - <tr align="center" colspan="5">Variables</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">type</td> - <td align="center">access</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Variable"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TM"></a> - <thead> - <tr align="center" colspan="5">Methods</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">returns</td> - <td align="center">throws</td> - <td align="center">arguments</td> - <td align="center">access</td> - <td align="center">static</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Method"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TOM"></a> - <thead> - <tr align="center" colspan="5">Operator Methods</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">returns</td> - <td align="center">throws</td> - <td align="center">arguments</td> - <td align="center">access</td> - <td align="center">static</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="OperatorMethod"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TMT"></a> - <thead> - <tr align="center" colspan="5">Method Types</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">basetype</td> - <td align="center">returns</td> - <td align="center">arguments</td> - <td align="center">const</td> - </tr> - </thead> - <xsl:apply-templates select="MethodType"> - <xsl:sort select="@id"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TCT"></a> - <thead> - <tr align="center" colspan="5">Converters</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">returns</td> - <td align="center">throws</td> - <td align="center">access</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Converter"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TF"></a> - <thead> - <tr align="center" colspan="5">Functions</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">returns</td> - <td align="center">throws</td> - <td align="center">arguments</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Function"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TOF"></a> - <thead> - <tr align="center" colspan="5">Operator Functions</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">returns</td> - <td align="center">throws</td> - <td align="center">arguments</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="OperatorFunction"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TFT"></a> - <thead> - <tr align="center" colspan="5">Function Types</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">returns</td> - <td align="center">arguments</td> - </tr> - </thead> - <xsl:apply-templates select="FunctionType"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TC"></a> - <thead> - <tr align="center" colspan="5">Constructors</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">throws</td> - <td align="center">arguments</td> - <td align="center">access</td> - <td align="center">artificial</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Constructor"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TD"></a> - <thead> - <tr align="center" colspan="5">Destructors</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">throws</td> - <td align="center">access</td> - <td align="center">virtual</td> - <td align="center">artificial</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Destructor"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <a name="TE"></a> - <thead> - <tr align="center" colspan="5">Enumerations</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - <td align="center">context</td> - <td align="center">artificial</td> - <td align="center">file</td> - <td align="center">line</td> - </tr> - </thead> - <xsl:apply-templates select="Enumeration"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - <!-- =============================================== --> - <table border="1"> - <thead> - <tr align="center" colspan="5">File</tr> - <tr> - <td align="center">T</td> - <td align="center">id</td> - <td align="center">name</td> - </tr> - </thead> - <xsl:apply-templates select="File"> - <xsl:sort select="@name"/> - </xsl:apply-templates> - </table><hr/> - - </xsl:template> - - <!-- ====================================================================== --> - <xsl:template match = "Class"> - <tr> - <td>Z</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@bases" /> - </xsl:call-template> - </td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@members" /> - </xsl:call-template> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Struct"> - <tr> - <td>S</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@bases" /> - </xsl:call-template> - </td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@members" /> - </xsl:call-template> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Union"> - <tr> - <td>U</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@bases" /> - </xsl:call-template> - </td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@members" /> - </xsl:call-template> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Namespace"> - <tr> - <td>N</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@members" /> - </xsl:call-template> - </td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Field"> - <tr> - <td>Fd</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - <td><xsl:value-of select="@access"/></td> - <td><xsl:value-of select="@bits"/></td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Typedef"> - <tr> - <td>T</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "ArrayType"> - <tr> - <td>A</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - <td><a name="{@min}"><xsl:value-of select="@min"/></a></td> - <td><a name="{@max}"><xsl:value-of select="@max"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "PointerType"> - <tr> - <td>P</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "OffsetType"> - <tr> - <td>O</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@basetype}"><xsl:value-of select="@basetype"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "ReferenceType"> - <tr> - <td>R</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "CvQualifiedType"> - <tr> - <td>Q</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "FundamentalType"> - <tr> - <td>B</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Variable"> - <tr> - <td>V</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@type}"><xsl:value-of select="@type"/></a></td> - <td><xsl:value-of select="@access"/></td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Method"> - <tr> - <td>M</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:apply-templates select="Argument"/></td> - <td><xsl:value-of select="@access"/></td> - <td> - <xsl:choose> - <xsl:when test="@static='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "MethodType"> - <tr> - <td>MT</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@basetype}"><xsl:value-of select="@basetype"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td><xsl:apply-templates select="Argument"/></td> - <td> - <xsl:choose> - <xsl:when test="@const='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "OperatorMethod"> - <tr> - <td>OpM</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@basetype}"><xsl:value-of select="@basetype"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:apply-templates select="Argument"/></td> - <td><xsl:value-of select="@access"/></td> - <td> - <xsl:choose> - <xsl:when test="@static='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Converter"> - <tr> - <td>Cnv</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:value-of select="@access"/></td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Function"> - <tr> - <td>F</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:apply-templates select="Argument"/></td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "OperatorFunction"> - <tr> - <td>OpF</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:apply-templates select="Argument"/></td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "FunctionType"> - <tr> - <td>FT</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="#{@returns}"><xsl:value-of select="@returns"/></a></td> - <td><xsl:apply-templates select="Argument"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Destructor"> - <tr> - <td>D</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:value-of select="@access"/></td> - <td> - <xsl:choose> - <xsl:when test="@virtual='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - <td> - <xsl:choose> - <xsl:when test="@artificial='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Constructor"> - <tr> - <td>Co</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:call-template name="tokenize"> - <xsl:with-param name="string" select="@throw" /> - </xsl:call-template> - </td> - <td><xsl:apply-templates select="Argument"/></td> - <td><xsl:value-of select="@access"/></td> - <td> - <xsl:choose> - <xsl:when test="@artificial='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Enumeration"> - <tr> - <td>En</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><xsl:value-of select="@name"/></td> - <td><a href="#{@context}"><xsl:value-of select="@context"/></a></td> - <td> - <xsl:choose> - <xsl:when test="@artificial='1'">true</xsl:when> - <xsl:otherwise>false</xsl:otherwise> - </xsl:choose> - </td> - <td><a href="#{@file}"><xsl:value-of select="@file"/></a></td> - <td><xsl:value-of select="@line"/></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "File"> - <tr> - <td>Fd</td> - <td><a name="{@id}"><xsl:value-of select="@id"/></a></td> - <td><a href="{@name}"><xsl:value-of select="@name"/></a></td> - </tr> - </xsl:template> - - <!-- =============================================== --> - <xsl:template match = "Argument"> - <a href="#{@type}"><xsl:value-of select="@type"/></a> - </xsl:template> - - <!--- ========== Tokenizer ================== --> - <xsl:template name="tokenize"> - <xsl:param name="string" select="''" /> - <xsl:param name="delimiters" select="' 	 '" /> - <xsl:choose> - <xsl:when test="not($string)" /> - <xsl:when test="not($delimiters)"> - <xsl:call-template name="_tokenize-characters"> - <xsl:with-param name="string" select="$string" /> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="_tokenize-delimiters"> - <xsl:with-param name="string" select="$string" /> - <xsl:with-param name="delimiters" select="$delimiters" /> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - - <!-- =============================================== --> - <xsl:template name="_tokenize-characters"> - <xsl:param name="string" /> - <xsl:if test="$string"> - <a href="#{$string}"> - <xsl:value-of select="substring($string, 1, 1)" /> - </a> - <xsl:call-template name="_tokenize-characters"> - <xsl:with-param name="string" select="substring($string, 2)" /> - </xsl:call-template> - </xsl:if> - </xsl:template> - - <!-- =============================================== --> - <xsl:template name="_tokenize-delimiters"> - <xsl:param name="string" /> - <xsl:param name="delimiters" /> - <xsl:variable name="delimiter" select="substring($delimiters, 1, 1)" /> - <xsl:choose> - <xsl:when test="not($delimiter)"> - <a href="#{$string}"> - <xsl:value-of select="$string" /> - </a> - </xsl:when> - <xsl:when test="contains($string, $delimiter)"> - <xsl:if test="not(starts-with($string, $delimiter))"> - <xsl:call-template name="_tokenize-delimiters"> - <xsl:with-param name="string" select="substring-before($string, $delimiter)" /> - <xsl:with-param name="delimiters" select="substring($delimiters, 2)" /> - </xsl:call-template> - </xsl:if> - <xsl:call-template name="_tokenize-delimiters"> - <xsl:with-param name="string" select="substring-after($string, $delimiter)" /> - <xsl:with-param name="delimiters" select="$delimiters" /> - </xsl:call-template> - </xsl:when> - - <xsl:when test="starts-with($string, 'private:')"> - <xsl:call-template name="_tokenize-delimiters"> - <xsl:with-param name="string" select="substring($string, 9)" /> - </xsl:call-template> - </xsl:when> - - <xsl:when test="starts-with($string, 'protected:')"> - <xsl:call-template name="_tokenize-delimiters"> - <xsl:with-param name="string" select="substring($string, 11)" /> - </xsl:call-template> - </xsl:when> - - <xsl:otherwise> - <xsl:call-template name="_tokenize-delimiters"> - <xsl:with-param name="string" select="$string" /> - <xsl:with-param name="delimiters" select="substring($delimiters, 2)" /> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - -</xsl:stylesheet> Deleted: pygccxml_dev/unittests/example.py =================================================================== --- pygccxml_dev/unittests/example.py 2006-04-27 06:18:41 UTC (rev 9) +++ pygccxml_dev/unittests/example.py 2006-04-28 07:37:38 UTC (rev 10) @@ -1,143 +0,0 @@ -# Copyright 2004 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import autoconfig -from pygccxml import * - -class printer_t( declarations.decl_visitor_t ): - JUSTIFY = 20 - INTEND_SIZE = 4 - - def __init__( self, level=0 ): - declarations.decl_visitor_t.__init__(self) - self.__inst = None - self.__level = level - - def _get_level(self): - return self.__level - level = property( _get_level ) - - def _get_inst(self): - return self.__inst - def _set_inst(self, inst): - self.__inst = inst - instance = property( _get_inst, _set_inst ) - - def __nice_decl_name( self, inst ): - name = inst.__class__.__name__ - if name.endswith( '_t' ): - name = name[:-len('_t')] - return name.replace( '_', ' ' ) - - def __print_decl_header(self): - header = self.__nice_decl_name( self.__inst ) + ": '%s'" % self.__inst.name - print ' ' * self.level * self.INTEND_SIZE + header.ljust( self.JUSTIFY ) - curr_level = self.level + 1 - if self.__inst.location: - location = 'location: ' - print ' ' * curr_level * self.INTEND_SIZE + location.ljust( self.JUSTIFY ) - curr_level += 1 - file = 'file: ' + "'%s'" % self.__inst.location.file_name - print ' ' * curr_level * self.INTEND_SIZE + file.ljust( self.JUSTIFY ) - line = 'line: ' + "'%s'" % self.__inst.location.line - print ' ' * curr_level * self.INTEND_SIZE + line.ljust( self.JUSTIFY ) - curr_level = self.level + 1 - artificial = 'artificial: ' + "'%s'" % str(self.__inst.is_artificial) - print ' ' * curr_level * self.INTEND_SIZE + artificial.ljust( self.JUSTIFY ) - - def visit_member_function( self ): - self.__print_decl_header() - - def visit_constructor( self ): - self.__print_decl_header() - - def visit_destructor( self ): - self.__print_decl_header() - - def visit_member_operator( self ): - self.__print_decl_header() - - def visit_casting_operator( self ): - self.__print_decl_header() - - def visit_free_function( self ): - self.__print_decl_header() - - def visit_free_operator( self ): - self.__print_decl_header() - - def visit_class_declaration(self ): - self.__print_decl_header() - - def visit_class(self ): - self.__print_decl_header() - curr_level = self.level + 1 - class_type = 'class type: ' + "'%s'" % str(self.__inst.class_type) - print ' ' * curr_level * self.INTEND_SIZE + class_type.ljust( self.JUSTIFY ) - - def print_hierarchy(hierarchy_type, classes, curr_level): - print ' ' * curr_level * self.INTEND_SIZE + hierarchy_type.ljust( self.JUSTIFY ) - curr_level += 1 - for class_ in classes: - class_str = 'class: ' + "'%s'" % str(class_.related_class.decl_string) - print ' ' * curr_level * self.INTEND_SIZE + class_str.ljust( self.JUSTIFY ) - access = 'access: ' + "'%s'" % str(class_.access) - print ' ' * (curr_level + 1)* self.INTEND_SIZE + access.ljust( self.JUSTIFY ) - - if self.__inst.bases: - print_hierarchy( 'base classes: ', self.__inst.bases, curr_level ) - - if self.__inst.derived: - print_hierarchy( 'derived classes: ', self.__inst.derived, curr_level ) - - def print_members(members_type, members, curr_level): - print ' ' * curr_level * self.INTEND_SIZE + members_type.ljust( self.JUSTIFY ) - curr_level += 1 - for member in members: - prn = printer_t( curr_level + 1 ) - prn.instance = member - declarations.apply_visitor( prn, member ) - - print_members( 'public: ', self.__inst.public_members, curr_level ) - print_members( 'protected: ', self.__inst.protected_members, curr_level ) - print_members( 'private: ', self.__inst.private_members, curr_level ) - - def visit_enumeration(self): - self.__print_decl_header() - curr_level = self.level + 1 - print ' ' * curr_level * self.INTEND_SIZE + 'values: '.ljust( self.JUSTIFY ) - curr_level += 1 - for name, value in self.__inst.values.items(): - print ' ' * curr_level * self.INTEND_SIZE, name, ':', value - - def visit_namespace(self ): - self.__print_decl_header() - for decl in self.__inst.declarations: - prn = printer_t( self.level + 1 ) - prn.instance = decl - declarations.apply_visitor( prn, decl ) - - def visit_typedef(self ): - self.__print_decl_header() - curr_level = self.level + 1 - print ' ' * curr_level * self.INTEND_SIZE + 'alias to: ', self.__inst.type.decl_string - - def visit_variable(self ): - self.__print_decl_header() - curr_level = self.level + 1 - print ' ' * curr_level * self.INTEND_SIZE, 'type: ', self.__inst.type.decl_string - print ' ' * curr_level * self.INTEND_SIZE, 'value: ', self.__inst.value - -if __name__ == "__main__": - include_std_header = os.path.join( autoconfig.data_directory, 'include_std.hpp' ) - include_std_header = os.path.join( autoconfig.data_directory, 'include_all.hpp' ) - decls = parser.parse( [include_std_header] ) - prn = printer_t() - for decl in decls: - prn.instance = decl - declarations.apply_visitor( prn, decl ) - Deleted: pygccxml_dev/unittests/pygccxml.profile =================================================================== (Binary files differ) Deleted: pygccxml_dev/unittests/windows.py =================================================================== --- pygccxml_dev/unittests/windows.py 2006-04-27 06:18:41 UTC (rev 9) +++ pygccxml_dev/unittests/windows.py 2006-04-28 07:37:38 UTC (rev 10) @@ -1,33 +0,0 @@ -# Copyright 2004 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import copy -import pickle -import unittest -import tempfile -import autoconfig -from pprint import pformat -from sets import Set as set - -import time -import pygccxml -from pygccxml.utils import * -from pygccxml.parser import * -from pygccxml.declarations import * - -start = time.clock() - -wins = parse( [r"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\windows.h"] ) - -end = time.clock() - -print 'parsing take ', end - start, ' seconds' - -#wins = make_flatten( wins ) -print 'len:', len(wins) -for decl in wins: - print decl.__class__.__name__, decl.name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-05-02 04:15:42
|
Revision: 30 Author: roman_yakovenko Date: 2006-05-01 21:15:28 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=30&view=rev Log Message: ----------- From now it is possible to configure "multi-select" queries to not raise exception, if query returns empty. just pass allow_empty=True as a parameter to the functions Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/namespace.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/unittests/namespace_matcher_tester.py Modified: pygccxml_dev/pygccxml/declarations/namespace.py =================================================================== --- pygccxml_dev/pygccxml/declarations/namespace.py 2006-05-02 04:10:19 UTC (rev 29) +++ pygccxml_dev/pygccxml/declarations/namespace.py 2006-05-02 04:15:28 UTC (rev 30) @@ -63,11 +63,12 @@ , function=function , recursive=recursive ) - def namespaces( self, name=None, function=None, recursive=None ): + def namespaces( self, name=None, function=None, recursive=None, allow_empty=None ): return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function - , recursive=recursive ) + , recursive=recursive + , allow_empty=allow_empty) def free_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] @@ -80,7 +81,7 @@ , header_file=header_file , recursive=recursive ) - def free_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def free_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function @@ -89,7 +90,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def free_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] @@ -103,7 +105,7 @@ , header_file=header_file , recursive=recursive ) - def free_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def free_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=name , symbol=symbol @@ -113,4 +115,7 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive ) \ No newline at end of file + , recursive=recursive + , allow_empty=allow_empty) + + \ No newline at end of file Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2006-05-02 04:10:19 UTC (rev 29) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2006-05-02 04:15:28 UTC (rev 30) @@ -194,7 +194,13 @@ return self.RECURSIVE_DEFAULT else: return keywds[ 'recursive' ] - + + def __findout_allow_empty( self, **keywds ): + if None is keywds[ 'allow_empty' ]: + return self.ALLOW_EMPTY_MDECL_WRAPPER + else: + return keywds[ 'allow_empty' ] + def __findout_decl_type( self, match_class, **keywds ): if keywds.has_key( 'decl_type' ): return keywds['decl_type'] @@ -202,7 +208,10 @@ matcher_args = keywds.copy() del matcher_args['function'] del matcher_args['recursive'] + if matcher_args.has_key('allow_empty'): + del matcher_args['allow_empty'] + matcher = match_class( **matcher_args ) if matcher.decl_type: return matcher.decl_type @@ -212,6 +221,8 @@ matcher_args = keywds.copy() del matcher_args['function'] del matcher_args['recursive'] + if matcher_args.has_key('allow_empty'): + del matcher_args['allow_empty'] matcher = match_class( **matcher_args ) if keywds['function']: @@ -234,11 +245,17 @@ if matcher.is_full_name(): name = matcher.decl_name_only if recursive: - utils.logger.info( 'query has been optimized on type and name' ) - return self._type2name2decls[decl_type][name] + utils.logger.info( 'query has been optimized on type and name' ) + if self._type2name2decls[decl_type].has_key( name ): + return self._type2name2decls[decl_type][name] + else: + return [] else: utils.logger.info( 'non recursive query has been optimized on type and name' ) - return self._type2name2decls_nr[decl_type][name] + if self._type2name2decls_nr[decl_type].has_key( name ): + return self._type2name2decls_nr[decl_type][name] + else: + return [] elif decl_type: if recursive: utils.logger.info( 'query has been optimized on type' ) @@ -273,13 +290,14 @@ matcher = self.__create_matcher( match_class, **norm_keywds ) dtype = self.__findout_decl_type( match_class, **norm_keywds ) recursive_ = self.__findout_recursive( **norm_keywds ) + allow_empty = self.__findout_allow_empty( **norm_keywds ) decls = self.__findout_range( norm_keywds['name'], dtype, recursive_ ) found = matcher_module.matcher.find( matcher, decls, False ) mfound = mdecl_wrapper.mdecl_wrapper_t( found ) utils.logger.info( '%d declaration(s) that match query' % len(mfound) ) utils.logger.info( 'find single query execution - done( %f seconds )' % ( time.clock() - start_time ) ) - if not mfound and not self.ALLOW_EMPTY_MDECL_WRAPPER: + if not mfound and not allow_empty: raise RuntimeError( "Multi declaration query returned 0 declarations." ) return mfound @@ -294,14 +312,15 @@ , header_file=header_file , recursive=recursive) - def decls( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None ): + def decls( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.decl ] , name=name , function=function , decl_type=decl_type , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def class_( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.class_ ] @@ -312,14 +331,15 @@ , header_file=header_file , recursive=recursive) - def classes( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): + def classes( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.class_ ] , name=name , function=function , decl_type=self._impl_decl_types[ scopedef_t.class_ ] , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def variable( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.variable ] @@ -330,14 +350,15 @@ , header_file=header_file , recursive=recursive) - def variables( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ): + def variables( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.variable ] , name=name , function=function , type=type , header_dir=header_dir , header_file=header_file - , recursive=recursive ) + , recursive=recursive + , allow_empty=allow_empty) def calldef( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.calldef ] @@ -350,7 +371,7 @@ , header_file=header_file , recursive=recursive ) - def calldefs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def calldefs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.calldef ] , name=name , function=function @@ -359,7 +380,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.operator ] @@ -373,7 +395,7 @@ , header_file=header_file , recursive=recursive ) - def operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None, recursive=None ): + def operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.operator ] , name=name , symbol=symbol @@ -383,7 +405,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive ) + , recursive=recursive + , allow_empty=allow_empty) def member_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.member_function ] @@ -396,7 +419,7 @@ , header_file=header_file , recursive=recursive ) - def member_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def member_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.member_function ] , name=name , function=function @@ -405,7 +428,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def constructor( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.constructor ] @@ -418,7 +442,7 @@ , header_file=header_file , recursive=recursive ) - def constructors( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def constructors( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.constructor ] , name=name , function=function @@ -427,7 +451,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def member_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.member_operator ] @@ -441,7 +466,7 @@ , header_file=header_file , recursive=recursive ) - def member_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def member_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.member_operator ] , name=name , symbol=symbol @@ -451,7 +476,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive ) + , recursive=recursive + , allow_empty=allow_empty) def casting_operator( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.casting_operator ] @@ -464,7 +490,7 @@ , header_file=header_file , recursive=recursive ) - def casting_operators( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + def casting_operators( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.casting_operator ] , name=name , function=function @@ -473,7 +499,8 @@ , arg_types=arg_types , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) def enumeration( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): return self._find_single( self._impl_matchers[ scopedef_t.enumeration ] @@ -486,13 +513,14 @@ #adding small aliase enum = enumeration - def enumerations( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): + def enumerations( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): return self._find_multiple( self._impl_matchers[ scopedef_t.enumeration ] , name=name , function=function , decl_type=self._impl_decl_types[ scopedef_t.enumeration ] , header_dir=header_dir , header_file=header_file - , recursive=recursive) + , recursive=recursive + , allow_empty=allow_empty) #adding small aliase enums = enumerations \ No newline at end of file Modified: pygccxml_dev/unittests/namespace_matcher_tester.py =================================================================== --- pygccxml_dev/unittests/namespace_matcher_tester.py 2006-05-02 04:10:19 UTC (rev 29) +++ pygccxml_dev/unittests/namespace_matcher_tester.py 2006-05-02 04:15:28 UTC (rev 30) @@ -25,8 +25,13 @@ def test( self ): criteria = declarations.namespace_matcher_t( name='bit_fields' ) x = declarations.matcher.get_single( criteria, self.declarations ) - self.failUnless( str(criteria) == '(decl type==namespace_t) and (name==bit_fields)' ) + self.failUnless( str(criteria) == '(decl type==namespace_t) and (name==bit_fields)' ) + def test_allow_empty( self ): + global_ns = declarations.get_global_namespace( self.declarations ) + global_ns.init_optimizer() + self.failUnless( 0 == len( global_ns.namespaces( 'does not exist', allow_empty=True ) ) ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-05-14 07:32:20
|
Revision: 78 Author: roman_yakovenko Date: 2006-05-14 00:32:12 -0700 (Sun, 14 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=78&view=rev Log Message: ----------- adding test case for demangled property Modified Paths: -------------- pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/demangled_tester.py Added: pygccxml_dev/unittests/demangled_tester.py =================================================================== --- pygccxml_dev/unittests/demangled_tester.py (rev 0) +++ pygccxml_dev/unittests/demangled_tester.py 2006-05-14 07:32:12 UTC (rev 78) @@ -0,0 +1,40 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'demangled.hpp' + self.global_ns = None + + def setUp(self): + if not self.global_ns: + decls = parser.parse( [self.header], self.config ) + self.global_ns = declarations.get_global_namespace( decls ) + self.global_ns.init_optimizer() + + def test( self ): + demangled = self.global_ns.namespace( 'demangled' ) + cls = demangled.class_( 'item_t<3740067437l, 11l, 2147483648l>' ) + self.failUnless( cls._name == 'item_t<0deece66d,11,080000000>' ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() \ No newline at end of file Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-05-14 07:31:46 UTC (rev 77) +++ pygccxml_dev/unittests/test_all.py 2006-05-14 07:32:12 UTC (rev 78) @@ -32,6 +32,7 @@ import cache_enums_tester import decl_printer_tester import typedefs_tester +import demangled_tester def create_suite(): testers = [ @@ -63,6 +64,7 @@ , cache_enums_tester , decl_printer_tester , typedefs_tester + , demangled_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-05-17 05:39:19
|
Revision: 104 Author: roman_yakovenko Date: 2006-05-16 22:39:04 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=104&view=rev Log Message: ----------- rename of class_t.typedefs property to "aliases" adding 2 new select functions: typedef and typedefs Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/parser/patcher.py pygccxml_dev/pygccxml/parser/project_reader.py pygccxml_dev/pygccxml/parser/source_reader.py pygccxml_dev/unittests/typedefs_tester.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-05-17 05:39:04 UTC (rev 104) @@ -196,6 +196,7 @@ impl_decl_types[ scopedef.scopedef_t.calldef ] = calldef_t impl_matchers[ scopedef.scopedef_t.operator ] = operator_matcher_t +impl_decl_types[ scopedef.scopedef_t.operator ] = operator_t impl_matchers[ scopedef.scopedef_t.member_function ] = calldef_matcher_t impl_decl_types[ scopedef.scopedef_t.member_function ] = member_function_t @@ -215,6 +216,10 @@ impl_matchers[ scopedef.scopedef_t.enumeration ] = declaration_matcher_t impl_decl_types[ scopedef.scopedef_t.enumeration ] = enumeration_t +impl_matchers[ scopedef.scopedef_t.typedef ] = declaration_matcher_t +impl_decl_types[ scopedef.scopedef_t.typedef ] = typedef_t + + impl_matchers[ namespace_t.namespace ] = namespace_matcher_t impl_matchers[ namespace_t.free_function ] = calldef_matcher_t Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2006-05-17 05:39:04 UTC (rev 104) @@ -98,7 +98,7 @@ self._public_members = [] self._private_members = [] self._protected_members = [] - self._typedefs = [] + self._aliases = [] def _get_name_impl( self ): if class_t.USE_DEMANGLED_AS_NAME and self.demangled: @@ -221,12 +221,12 @@ protected_members = property( _get_protected_members, _set_protected_members , doc="list of all protected L{members<declaration_t>}" ) - def _get_typedefs(self): - return self._typedefs - def _set_typedefs( self, new_typedefs ): - self._typedefs = new_typedefs - typedefs = property( _get_typedefs, _set_typedefs - , doc="List of aliases/typedefs to this instance") + def _get_aliases(self): + return self._aliases + def _set_aliases( self, new_aliases ): + self._aliases = new_aliases + aliases = property( _get_aliases, _set_aliases + , doc="List of L{aliases<typedef_t>} to this instance") def _get_declarations_impl(self): return self.get_members() Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2006-05-17 05:39:04 UTC (rev 104) @@ -129,8 +129,8 @@ class_type = 'class type: ' + "'%s'" % str(self.__inst.class_type) self.writer( ' ' * curr_level * self.INDENT_SIZE + class_type.ljust( self.JUSTIFY ) + os.linesep ) - if self.__inst.typedefs: - aliases = map( lambda typedef: typedef.name, self.__inst.typedefs ) + if self.__inst.aliases: + aliases = map( lambda typedef: typedef.name, self.__inst.aliases ) msg = 'aliases: ' + `aliases` self.writer( ' ' * curr_level * self.INDENT_SIZE + msg.ljust( self.JUSTIFY ) + os.linesep ) Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2006-05-17 05:39:04 UTC (rev 104) @@ -524,3 +524,23 @@ , allow_empty=allow_empty) #adding small aliase enums = enumerations + + def typedef( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): + """Finds any declaration by criteria. Please see L{scopedef_t} for full explanation.""" + return self._find_single( self._impl_matchers[ scopedef_t.typedef ] + , name=name + , function=function + , decl_type=self._impl_decl_types[ scopedef_t.typedef ] + , header_dir=header_dir + , header_file=header_file + , recursive=recursive) + + def typedefs( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): + return self._find_multiple( self._impl_matchers[ scopedef_t.typedef ] + , name=name + , function=function + , decl_type=self._impl_decl_types[ scopedef_t.typedef ] + , header_dir=header_dir + , header_file=header_file + , recursive=recursive + , allow_empty=allow_empty) \ No newline at end of file Modified: pygccxml_dev/pygccxml/parser/patcher.py =================================================================== --- pygccxml_dev/pygccxml/parser/patcher.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/parser/patcher.py 2006-05-17 05:39:04 UTC (rev 104) @@ -147,7 +147,7 @@ decl = base_type.declaration return decl.name == name \ or ( isinstance( decl, declarations.class_t ) \ - and name in map( lambda typedef: typedef.name, decl.typedefs ) ) + and name in map( lambda typedef: typedef.name, decl.aliases ) ) def __fix_constructor_call( self, func, arg ): call_invocation = declarations.call_invocation @@ -160,7 +160,7 @@ if decl.name != name: #we have some alias to the class relevant_typedefs = filter( lambda typedef: typedef.name == name - , decl.typedefs ) + , decl.aliases ) if 1 == len( relevant_typedefs ): f_q_name = self.__join_names( declarations.full_name( relevant_typedefs[0].parent ) , name ) Modified: pygccxml_dev/pygccxml/parser/project_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-17 05:39:04 UTC (rev 104) @@ -252,7 +252,7 @@ if config.verbose: logger.info( "Relinking declared types ..." ) self._relink_declarated_types( leaved_classes, types ) - source_reader.bind_typedefs( pygccxml.declarations.make_flatten( answer ) ) + source_reader.bind_aliases( pygccxml.declarations.make_flatten( answer ) ) return answer def __parse_all_at_once(self, files): Modified: pygccxml_dev/pygccxml/parser/source_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/source_reader.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/pygccxml/parser/source_reader.py 2006-05-17 05:39:04 UTC (rev 104) @@ -19,7 +19,7 @@ RuntimeError.__init__( self, msg ) -def bind_typedefs( decls ): +def bind_aliases( decls ): """ This function binds between class and it's typedefs. @@ -40,8 +40,8 @@ continue if id( cls_inst ) not in visited: visited.add( id( cls_inst ) ) - del cls_inst.typedefs[:] - cls_inst.typedefs.append( decl ) + del cls_inst.aliases[:] + cls_inst.aliases.append( decl ) class source_reader_t: def __init__( self, config, cache=None, decl_factory=None ): @@ -253,7 +253,7 @@ for decl in decls.itervalues(): linker_.instance = decl apply_visitor( linker_, decl ) - bind_typedefs( decls.itervalues() ) + bind_aliases( decls.itervalues() ) decls = filter( lambda inst: isinstance(inst, declaration_t) and not inst.parent, decls.itervalues() ) #some times gccxml report typedefs defined in no namespace #it happens for example in next situation Modified: pygccxml_dev/unittests/typedefs_tester.py =================================================================== --- pygccxml_dev/unittests/typedefs_tester.py 2006-05-16 19:33:24 UTC (rev 103) +++ pygccxml_dev/unittests/typedefs_tester.py 2006-05-17 05:39:04 UTC (rev 104) @@ -30,8 +30,8 @@ def test( self ): item_cls = self.global_ns.class_( name='item_t' ) self.failUnless( item_cls, "unable to find class 'item_t'" ) - self.failUnless( len( item_cls.typedefs ) == 1 ) - self.failUnless( item_cls.typedefs[0].name == 'Item' ) + self.failUnless( len( item_cls.aliases ) == 1 ) + self.failUnless( item_cls.aliases[0].name == 'Item' ) class tester_prj_t( parser_test_case.parser_test_case_t ): @@ -52,9 +52,9 @@ , type=declarations.class_t , name='item_t' ) self.failUnless( item_cls, "unable to find class 'item_t'" ) - self.failUnless( len( item_cls.typedefs ) == 3 ) + self.failUnless( len( item_cls.aliases ) == 3 ) expected_aliases = set( ['Item', 'Item1', 'Item2' ] ) - real_aliases = set( map( lambda typedef: typedef.name, item_cls.typedefs ) ) + real_aliases = set( map( lambda typedef: typedef.name, item_cls.aliases ) ) self.failUnless( real_aliases == expected_aliases ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-05-25 08:05:21
|
Revision: 164 Author: roman_yakovenko Date: 2006-05-25 01:05:00 -0700 (Thu, 25 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=164&view=rev Log Message: ----------- fixing critical bug with unnamed enums. If you have 2 unnamed enums within same scope, only one enum is reported Modified Paths: -------------- pygccxml_dev/pygccxml/parser/project_reader.py pygccxml_dev/unittests/data/core_cache.hpp pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/data/unnamed_enums_bug1.hpp pygccxml_dev/unittests/data/unnamed_enums_bug2.hpp pygccxml_dev/unittests/unnamed_enums_bug_tester.py Modified: pygccxml_dev/pygccxml/parser/project_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-25 06:54:11 UTC (rev 163) +++ pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-25 08:05:00 UTC (rev 164) @@ -324,7 +324,8 @@ def _join_namespaces( self, nsref ): assert isinstance( nsref, pygccxml.declarations.namespace_t ) ddhash = {} # decl.__class__ : { decl.name : [decls] } double declaration hash - decls = [] + decls = [] + for decl in nsref.declarations: if not ddhash.has_key( decl.__class__ ): ddhash[ decl.__class__ ] = { decl._name : [ decl ] } @@ -339,7 +340,12 @@ if decl not in joined_decls[decl._name]: #functions has overloading decls.append( decl ) - joined_decls[decl._name].append( decl ) + joined_decls[decl._name].append( decl ) + elif isinstance( decl, pygccxml.declarations.enumeration_t ): + #unnamed enums + if not decl.name and decl not in joined_decls[decl._name]: + decls.append( decl ) + joined_decls[decl._name].append( decl ) else: assert 1 == len( joined_decls[ decl._name ] ) if isinstance( decl, pygccxml.declarations.namespace_t ): Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2006-05-25 06:54:11 UTC (rev 163) +++ pygccxml_dev/unittests/data/core_cache.hpp 2006-05-25 08:05:00 UTC (rev 164) @@ -22,3 +22,4 @@ #endif//__core_cache_hpp__ +//touch \ No newline at end of file Added: pygccxml_dev/unittests/data/unnamed_enums_bug1.hpp =================================================================== --- pygccxml_dev/unittests/data/unnamed_enums_bug1.hpp (rev 0) +++ pygccxml_dev/unittests/data/unnamed_enums_bug1.hpp 2006-05-25 08:05:00 UTC (rev 164) @@ -0,0 +1,13 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __unnamed_enums_bug1_hpp__ +#define __unnamed_enums_bug1_hpp__ + +enum{ x1, x2 }; +enum{ y1, y2 }; + + +#endif//__unnamed_enums_bug1_hpp__ Added: pygccxml_dev/unittests/data/unnamed_enums_bug2.hpp =================================================================== --- pygccxml_dev/unittests/data/unnamed_enums_bug2.hpp (rev 0) +++ pygccxml_dev/unittests/data/unnamed_enums_bug2.hpp 2006-05-25 08:05:00 UTC (rev 164) @@ -0,0 +1,11 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __unnamed_enums_bug2_hpp__ +#define __unnamed_enums_bug2_hpp__ + +enum{ z1, z2 }; + +#endif//__unnamed_enums_bug2_hpp__ \ No newline at end of file Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-05-25 06:54:11 UTC (rev 163) +++ pygccxml_dev/unittests/test_all.py 2006-05-25 08:05:00 UTC (rev 164) @@ -32,7 +32,8 @@ import cache_enums_tester import decl_printer_tester import typedefs_tester -import demangled_tester +import demangled_tester +import unnamed_enums_bug_tester def create_suite(): testers = [ @@ -64,7 +65,8 @@ , cache_enums_tester , decl_printer_tester , typedefs_tester - , demangled_tester + , demangled_tester + , unnamed_enums_bug_tester ] main_suite = unittest.TestSuite() Added: pygccxml_dev/unittests/unnamed_enums_bug_tester.py =================================================================== --- pygccxml_dev/unittests/unnamed_enums_bug_tester.py (rev 0) +++ pygccxml_dev/unittests/unnamed_enums_bug_tester.py 2006-05-25 08:05:00 UTC (rev 164) @@ -0,0 +1,95 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class source_reader_tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'unnamed_enums_bug1.hpp' + self.global_ns = None + + def setUp(self): + if not self.global_ns: + reader = parser.source_reader_t( self.config ) + decls = reader.read_file( self.header ) + self.global_ns = declarations.get_global_namespace( decls ) + self.global_ns.init_optimizer() + + def test( self ): + names = [] + enums = self.global_ns.enums() + map( lambda enum: names.extend( enum.values.keys() ), enums ) + self.failUnless( len( names ) == 4 ) + self.failUnless( 'x1' in names ) + self.failUnless( 'x2' in names ) + self.failUnless( 'y1' in names ) + self.failUnless( 'y2' in names ) + +class project_reader_1_tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'unnamed_enums_bug1.hpp' + self.global_ns = None + + def setUp(self): + if not self.global_ns: + decls = parser.parse( [self.header], self.config ) + self.global_ns = declarations.get_global_namespace( decls ) + self.global_ns.init_optimizer() + + def test( self ): + names = [] + enums = self.global_ns.enums() + map( lambda enum: names.extend( enum.values.keys() ), enums ) + self.failUnless( len( names ) == 4 ) + self.failUnless( 'x1' in names ) + self.failUnless( 'x2' in names ) + self.failUnless( 'y1' in names ) + self.failUnless( 'y2' in names ) + +class project_reader_3_tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.headers = ['unnamed_enums_bug1.hpp', 'unnamed_enums_bug2.hpp', 'unnamed_enums_bug1.hpp' ] + self.global_ns = None + + def setUp(self): + if not self.global_ns: + decls = parser.parse( self.headers, self.config ) + self.global_ns = declarations.get_global_namespace( decls ) + self.global_ns.init_optimizer() + + def test( self ): + names = [] + enums = self.global_ns.enums() + map( lambda enum: names.extend( enum.values.keys() ), enums ) + self.failUnless( len( names ) == 6 ) + self.failUnless( 'x1' in names ) + self.failUnless( 'x2' in names ) + self.failUnless( 'y1' in names ) + self.failUnless( 'y2' in names ) + self.failUnless( 'z1' in names ) + self.failUnless( 'z2' in names ) + + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(source_reader_tester_t)) + suite.addTest( unittest.makeSuite(project_reader_1_tester_t)) + suite.addTest( unittest.makeSuite(project_reader_3_tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-06-07 20:10:45
|
Revision: 213 Author: roman_yakovenko Date: 2006-06-05 11:36:16 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=213&view=rev Log Message: ----------- fixing vector traits tester Modified Paths: -------------- pygccxml_dev/unittests/data/vector_traits.hpp pygccxml_dev/unittests/test_all.py pygccxml_dev/unittests/vector_traits_tester.py Modified: pygccxml_dev/unittests/data/vector_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 15:17:25 UTC (rev 212) +++ pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 18:36:16 UTC (rev 213) @@ -49,13 +49,6 @@ container do_nothing(){}; }; - - struct _6_{ - typedef const int value_type; - typedef const std::vector< const int > container; - - container do_nothing(){}; - }; } Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-06-05 15:17:25 UTC (rev 212) +++ pygccxml_dev/unittests/test_all.py 2006-06-05 18:36:16 UTC (rev 213) @@ -34,6 +34,7 @@ import typedefs_tester import demangled_tester import unnamed_enums_bug_tester +import vector_traits_tester def create_suite(): testers = [ @@ -67,6 +68,7 @@ , typedefs_tester , demangled_tester , unnamed_enums_bug_tester + , vector_traits_tester ] main_suite = unittest.TestSuite() Modified: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 15:17:25 UTC (rev 212) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 18:36:16 UTC (rev 213) @@ -45,7 +45,17 @@ continue self.validate_yes( struct.typedef( 'value_type' ) , struct.typedef( 'container' ) ) - + + def test_no( self ): + traits = declarations.vector_traits + no_ns = self.global_ns.namespace( 'no' ) + for struct in no_ns.classes(): + if not struct.name.startswith( '_' ): + continue + if not struct.name.endswith( '_' ): + continue + self.failUnless( not traits.is_vector( struct.typedef( 'container' ) ) ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-06-19 13:24:47
|
Revision: 232 Author: roman_yakovenko Date: 2006-06-19 06:24:30 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=232&view=rev Log Message: ----------- small refactoring to container traits to make it easy to add another container Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/container_traits.py pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/vector_traits_tester.py pyplusplus_dev/pyplusplus/module_creator/types_database.py Modified: pygccxml_dev/pygccxml/declarations/container_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/container_traits.py 2006-06-19 12:30:09 UTC (rev 231) +++ pygccxml_dev/pygccxml/declarations/container_traits.py 2006-06-19 13:24:30 UTC (rev 232) @@ -7,81 +7,49 @@ defines few algorithms, that deals with different properties of std containers """ -#import typedef import calldef import cpptypes -#import variable -#import algorithm import namespace -#import templates -#import enumeration import class_declaration -#from sets import Set as set -#import types as build_in_types import type_traits -def is_defined_in_xxx( xxx, cls ): - if not cls.parent: - return False +class impl_details: + @staticmethod + def get_container_or_none( type, container_name ): + """returns reference to the class declaration or None""" + type = type_traits.remove_alias( type ) + type = type_traits.remove_cv( type ) + + cls = None + if isinstance( type, cpptypes.declarated_t ): + cls = type_traits.remove_alias( type.declaration ) + elif isinstance( type, class_declaration.class_t ): + cls = type + elif isinstance( type, class_declaration.class_declaration_t ): + cls = type + else: + return + + if not cls.name.startswith( container_name + '<' ): + return + + if not type_traits.impl_details.is_defined_in_xxx( 'std', cls ): + return + return cls - if not isinstance( cls.parent, namespace.namespace_t ): - return False +class vector_traits: + CONTAINER_NAME = 'vector' - if xxx != cls.parent.name: - return False - - xxx_ns = cls.parent - if not xxx_ns.parent: - return False - - if not isinstance( xxx_ns.parent, namespace.namespace_t ): - return False - - if '::' != xxx_ns.parent.name: - return False - - global_ns = xxx_ns.parent - return None is global_ns.parent - -class vector_traits: - @staticmethod - def declaration_or_none( type ): - global is_defined_in_std - """returns reference to the class declaration or None""" - type = type_traits.remove_alias( type ) - type = type_traits.remove_cv( type ) - - cls = None - if isinstance( type, cpptypes.declarated_t ): - cls = type_traits.remove_alias( type.declaration ) - elif isinstance( type, class_declaration.class_t ): - cls = type - elif isinstance( type, class_declaration.class_declaration_t ): - cls = type - else: - return - - if not cls.name.startswith( 'vector<' ): - return - - if not is_defined_in_xxx( 'std', cls ): - return - return cls - - @staticmethod def is_vector( type ): """ - Returns True if type represents instantiation of std class vector, - otherwise False. - """ - return not( None is vector_traits.declaration_or_none( type ) ) - + Returns True if type represents instantiation of std class vector, otherwise False.""" + return not( None is impl_details.get_container_or_none( type, vector_traits.CONTAINER_NAME ) ) @staticmethod def class_declaration( type ): """returns reference to the class declaration, """ - cls = vector_traits.declaration_or_none( type ) + cls = impl_details.get_container_or_none( type, vector_traits.CONTAINER_NAME ) if not cls: raise TypeError( 'Type "%s" is not instantiation of std::vector' % type.decl_string ) return cls @@ -93,17 +61,9 @@ if isinstance( cls, class_declaration.class_t ): return type_traits.remove_declarated( cls.typedef( "value_type", recursive=False ).type ) else: - value_type_str = templates.args( cls.name )[0] - if not value_type_str.startswith( '::' ): - value_type_str = '::' + value_type_str - found = cls.top_parent.decls( name=value_type_str - , function=lambda decl: not isinstance( decl, calldef.calldef_t ) - , allow_empty=True ) - if not found: - if cpptypes.FUNDAMENTAL_TYPES.has_key( value_type_str ): - return cpptypes.FUNDAMENTAL_TYPES[value_type_str] - if len( found ) == 1: - return found[0] - else: - raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string ) + value_type_str = templates.args( cls.name )[0] + ref = type_traits.impl_details.find_value_type( cls.top_parent, value_type_str ) + if None is ref: + raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string ) + return ref Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-19 12:30:09 UTC (rev 231) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-19 13:24:30 UTC (rev 232) @@ -753,6 +753,46 @@ global_ns = xxx_ns.parent return None is global_ns.parent + +class impl_details: + @staticmethod + def is_defined_in_xxx( xxx, cls ): + if not cls.parent: + return False + + if not isinstance( cls.parent, namespace.namespace_t ): + return False + + if xxx != cls.parent.name: + return False + + xxx_ns = cls.parent + if not xxx_ns.parent: + return False + + if not isinstance( xxx_ns.parent, namespace.namespace_t ): + return False + + if '::' != xxx_ns.parent.name: + return False + + global_ns = xxx_ns.parent + return None is global_ns.parent + + @staticmethod + def find_value_type( global_ns, value_type_str ): + if not value_type_str.startswith( '::' ): + value_type_str = '::' + value_type_str + found = global_ns.decls( name=value_type_str + , function=lambda decl: not isinstance( decl, calldef.calldef_t ) + , allow_empty=True ) + if not found: + if cpptypes.FUNDAMENTAL_TYPES.has_key( value_type_str ): + return cpptypes.FUNDAMENTAL_TYPES[value_type_str] + if len( found ) == 1: + return found[0] + else: + return None class smart_pointer_traits: @staticmethod @@ -762,7 +802,7 @@ type = remove_declarated( type ) if not isinstance( type, ( class_declaration.class_declaration_t, class_declaration.class_t ) ): return False - if not is_defined_in_xxx( 'boost', type ): + if not impl_details.is_defined_in_xxx( 'boost', type ): return False return type.decl_string.startswith( '::boost::shared_ptr<' ) @@ -779,16 +819,11 @@ raise RuntimeError( "Unable to find out shared_ptr value type. shared_ptr class is: %s" % cls.decl_string ) else: value_type_str = templates.args( cls.name )[0] - found = cls.top_parent.classes( value_type_str, allow_empty=True ) - if not found: - if cpptypes.FUNDAMENTAL_TYPES.has_key( value_type_str ): - return cpptypes.FUNDAMENTAL_TYPES[value_type_str] - if len( found ) == 1: - return found[0] - else: + ref = impl_details.find_value_type( cls.top_parent, value_type_str ) + if None is ref: raise RuntimeError( "Unable to find out shared_ptr value type. shared_ptr class is: %s" % cls.decl_string ) - - + return ref + def is_std_string( type ): decl_strings = [ '::std::basic_string<char,std::char_traits<char>,std::allocator<char> >' Modified: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py 2006-06-19 12:30:09 UTC (rev 231) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-06-19 13:24:30 UTC (rev 232) @@ -27,7 +27,6 @@ def validate_yes( self, value_type, container ): traits = declarations.vector_traits - self.failUnless( traits.declaration_or_none( container ) ) self.failUnless( traits.is_vector( container ) ) self.failUnless( declarations.is_same( value_type, traits.value_type( container ) ) ) Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-19 12:30:09 UTC (rev 231) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-19 13:24:30 UTC (rev 232) @@ -53,18 +53,18 @@ #will return True is type was treated type = declarations.remove_alias( type ) type = declarations.remove_pointer( type ) - type = declarations.remove_reference( type ) - may_be_vector = declarations.vector_traits.declaration_or_none( type ) - if not ( None is may_be_vector ): + type = declarations.remove_reference( type ) + if declarations.vector_traits.is_vector( type ): + vector = declarations.vector_traits.class_declaration( type ) try: - declarations.vector_traits.value_type( may_be_vector ) - self.__used_vectors.add( may_be_vector ) + declarations.vector_traits.value_type( vector ) + self.__used_vectors.add( vector ) return True except RuntimeError, error: msg = 'WARNING: pyplusplus found std::vector instantiation declaration, ' msg = msg + 'but can not find out value type!' msg = msg + os.linesep + 'This class will not be exported!' - msg = msg + os.linesep + 'std::vector instantiation is: ' + may_be_vector.decl_string + msg = msg + os.linesep + 'std::vector instantiation is: ' + vector.decl_string _logging_.logger.warn( msg ) return False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-07-02 17:26:58
|
Revision: 270 Author: roman_yakovenko Date: 2006-07-02 10:26:30 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=270&view=rev Log Message: ----------- integrating cflags patch from Allen Modified Paths: -------------- pygccxml_dev/unittests/autoconfig.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/data/decl_cache_file1.txt pygccxml_dev/unittests/data/decl_cache_file1_duplicate.txt pygccxml_dev/unittests/data/decl_cache_file2.txt pygccxml_dev/unittests/declarations_cache_tester.py Modified: pygccxml_dev/unittests/autoconfig.py =================================================================== --- pygccxml_dev/unittests/autoconfig.py 2006-07-02 17:25:19 UTC (rev 269) +++ pygccxml_dev/unittests/autoconfig.py 2006-07-02 17:26:30 UTC (rev 270) @@ -13,13 +13,14 @@ gccxml_path = '' data_directory = os.path.abspath( os.path.join( os.curdir, 'data' ) ) +build_dir = os.path.abspath( os.path.join( os.curdir, 'temp' ) ) if 'roman' in getpass.getuser(): if sys.platform == 'win32': gccxml_path = 'd:/gccxml_cvs/gccxml-build/bin/release/gccxml.exe' else: gccxml_path = '/home/roman/gccxml-build/bin/gccxml' - + try: import pygccxml print 'unittests will run on INSTALLED version' @@ -73,4 +74,4 @@ #, 'wstring' #] ) #except ImportError: - #pass \ No newline at end of file + #pass Added: pygccxml_dev/unittests/data/decl_cache_file1.txt =================================================================== --- pygccxml_dev/unittests/data/decl_cache_file1.txt (rev 0) +++ pygccxml_dev/unittests/data/decl_cache_file1.txt 2006-07-02 17:26:30 UTC (rev 270) @@ -0,0 +1 @@ +// Line 1: Test file for declaration_cache testing Added: pygccxml_dev/unittests/data/decl_cache_file1_duplicate.txt =================================================================== --- pygccxml_dev/unittests/data/decl_cache_file1_duplicate.txt (rev 0) +++ pygccxml_dev/unittests/data/decl_cache_file1_duplicate.txt 2006-07-02 17:26:30 UTC (rev 270) @@ -0,0 +1 @@ +// Line 1: Test file for declaration_cache testing Added: pygccxml_dev/unittests/data/decl_cache_file2.txt =================================================================== --- pygccxml_dev/unittests/data/decl_cache_file2.txt (rev 0) +++ pygccxml_dev/unittests/data/decl_cache_file2.txt 2006-07-02 17:26:30 UTC (rev 270) @@ -0,0 +1,2 @@ +// Line 1: Test file for declaration_cache testing +// Line 2: Added: pygccxml_dev/unittests/declarations_cache_tester.py =================================================================== --- pygccxml_dev/unittests/declarations_cache_tester.py (rev 0) +++ pygccxml_dev/unittests/declarations_cache_tester.py 2006-07-02 17:26:30 UTC (rev 270) @@ -0,0 +1,153 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os, sys, unittest, os.path +import autoconfig +import pygccxml.parser +from pygccxml.parser.config import config_t +from pygccxml.parser.declarations_cache import * + +class decl_cache_tester(unittest.TestCase): + def __init__(self, *args ): + unittest.TestCase.__init__(self, *args) + if not os.path.exists( autoconfig.build_dir ): + os.makedirs( autoconfig.build_dir ) + + def test_file_signature(self): + file1 = os.path.join(autoconfig.data_directory, 'decl_cache_file1.txt') + file1_dup = os.path.join(autoconfig.data_directory, 'decl_cache_file1_duplicate.txt') + file2 = os.path.join(autoconfig.data_directory, 'decl_cache_file2.txt') + sig1 = file_signature(file1) + sig1_dup = file_signature(file1_dup) + sig2 = file_signature(file2) + self.assert_(sig1 == sig1_dup) + self.assert_(sig1 != sig2) + + def test_config_signature(self): + diff_cfg_list = self.build_differing_cfg_list() + def_cfg = diff_cfg_list[0] + def_sig = configuration_signature(def_cfg) + + # Test changes that should cause sig changes + for cfg in diff_cfg_list[1:]: + self.assert_(configuration_signature(cfg) != def_sig) + + # Test changes that should not cause sig changes + no_changes = def_cfg.clone() + self.assert_(configuration_signature(no_changes) == def_sig) + + #start_decls_changed = def_cfg.clone() + #start_decls_changed.start_with_declarations = "test object" + #self.assert_(configuration_signature(start_decls_changed) == def_sig) + + verbose_changed = def_cfg.clone() + verbose_changed.verbose = True + self.assert_(configuration_signature(verbose_changed) == def_sig) + + ignore_changed = def_cfg.clone() + ignore_changed.ignore_gccxml_output = True + self.assert_(configuration_signature(ignore_changed) == def_sig) + + def test_cache_interface(self): + cache_file = os.path.join(autoconfig.build_dir, 'decl_cache_test.test_cache_read.cache') + file1 = os.path.join(autoconfig.data_directory, 'decl_cache_file1.txt') + file1_dup = os.path.join(autoconfig.data_directory, 'decl_cache_file1_duplicate.txt') + file2 = os.path.join(autoconfig.data_directory, 'decl_cache_file2.txt') + diff_cfg_list = self.build_differing_cfg_list() + def_cfg = diff_cfg_list[0] + + if os.path.exists(cache_file): + os.remove(cache_file) + + cache = file_cache_t(cache_file) + self.assert_(len(cache._file_cache_t__cache) == 0) + + # test creating new entries for differing files + cache.update(file1, def_cfg, 1,[]) + self.assert_(len(cache._file_cache_t__cache) == 1) + cache.update(file1_dup, def_cfg, 2,[]) + self.assert_(len(cache._file_cache_t__cache) == 1) + cache.update(file2, def_cfg, 3,[]) + self.assert_(len(cache._file_cache_t__cache) == 2) + + self.assert_(cache.cached_value(file1,def_cfg) == 2) + self.assert_(cache.cached_value(file2,def_cfg) == 3) + + # Test reading again + cache.flush() + cache = file_cache_t(cache_file) + self.assert_(len(cache._file_cache_t__cache) == 2) + self.assert_(cache.cached_value(file1,def_cfg) == 2) + self.assert_(cache.cached_value(file2,def_cfg) == 3) + + # Test flushing doesn't happen if we don't touch the cache + cache = file_cache_t(cache_file) + self.assert_(cache.cached_value(file1,def_cfg) == 2) # Read from cache + cache.flush() # should not actually flush + cache = file_cache_t(cache_file) + self.assert_(len(cache._file_cache_t__cache) == 2) + + # Test flush culling + cache = file_cache_t(cache_file) + cache.update(file1_dup, def_cfg, 4,[]) # Modify cache + cache.flush() # should cull off one entry + cache = file_cache_t(cache_file) + self.assert_(len(cache._file_cache_t__cache) == 1) + + + def build_differing_cfg_list(self): + """ Return a list of configurations that all differ. """ + cfg_list = [] + def_cfg = config_t("gccxml_path",'.',['tmp'],['sym'],['unsym'], + None,False,False,"") + cfg_list.append(def_cfg) + + # Test changes that should cause sig changes + gccxml_changed = def_cfg.clone() + gccxml_changed.gccxml_path = "other_path" + cfg_list.append(gccxml_changed) + + wd_changed = def_cfg.clone() + wd_changed.working_directory = "other_dir" + cfg_list.append(wd_changed) + + #inc_changed = def_cfg.clone() + #inc_changed.include_paths = ["/var/tmp"] + #self.assert_(configuration_signature(inc_changed) != def_sig) + inc_changed = config_t("gccxml_path",'.',['/var/tmp'],['sym'],['unsym'], + None,False,False,"") + cfg_list.append(inc_changed) + + #def_changed = def_cfg.clone() + #def_changed.define_symbols = ["symbol"] + #self.assert_(configuration_signature(def_changed) != def_sig) + def_changed = config_t("gccxml_path",'.',['/var/tmp'],['new-sym'],['unsym'], + None,False,False,"") + cfg_list.append(def_changed) + + #undef_changed = def_cfg.clone() + #undef_changed.undefine_symbols = ["symbol"] + #self.assert_(configuration_signature(undef_changed) != def_sig) + undef_changed = config_t("gccxml_path",'.',['/var/tmp'],['sym'],['new-unsym'], + None,False,False,"") + cfg_list.append(undef_changed) + + cflags_changed = def_cfg.clone() + cflags_changed.cflags = "new flags" + cfg_list.append(cflags_changed) + + return cfg_list + + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(decl_cache_tester)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-07-02 17:25:19 UTC (rev 269) +++ pygccxml_dev/unittests/test_all.py 2006-07-02 17:26:30 UTC (rev 270) @@ -36,7 +36,7 @@ import unnamed_enums_bug_tester import vector_traits_tester import string_traits_tester - +import declarations_cache_tester def create_suite(): testers = [ @@ -72,6 +72,7 @@ , unnamed_enums_bug_tester , vector_traits_tester , string_traits_tester + , declarations_cache_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-07-05 08:13:06
|
Revision: 273 Author: roman_yakovenko Date: 2006-07-05 01:12:38 -0700 (Wed, 05 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=273&view=rev Log Message: ----------- renaming value_type to element_type and making it to be a property Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/container_traits.py pygccxml_dev/unittests/vector_traits_tester.py pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py pyplusplus_dev/pyplusplus/file_writers/multiple_files.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/pyplusplus/module_creator/types_database.py pyplusplus_dev/unittests/indexing_suites_tester.py Modified: pygccxml_dev/pygccxml/declarations/container_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/container_traits.py 2006-07-04 13:30:48 UTC (rev 272) +++ pygccxml_dev/pygccxml/declarations/container_traits.py 2006-07-05 08:12:38 UTC (rev 273) @@ -1,23 +1,24 @@ -# Copyright 2004 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -""" -defines few algorithms, that deals with different properties of std containers -""" - -import calldef -import cpptypes -import namespace -import templates -import class_declaration -import type_traits - +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +""" +defines few algorithms, that deals with different properties of std containers +""" + +import calldef +import cpptypes +import namespace +import templates +import class_declaration +import type_traits + class container_traits_impl_t: - def __init__( self, container_name, value_type_index ): + def __init__( self, container_name, element_type_index, element_type_typedef ): self.name = container_name - self.value_type_index = value_type_index + self.element_type_index = element_type_index + self.element_type_typedef = element_type_typedef def get_container_or_none( self, type ): """returns reference to the class declaration or None""" @@ -50,22 +51,22 @@ raise TypeError( 'Type "%s" is not instantiation of std::%s' % ( type.decl_string, self.name ) ) return cls - def value_type( self, type ): + def element_type( self, type ): cls = self.class_declaration( type ) if isinstance( cls, class_declaration.class_t ): - value_type = cls.typedef( "value_type", recursive=False ).type + value_type = cls.typedef( self.element_type_typedef, recursive=False ).type return type_traits.remove_declarated( value_type ) else: - value_type_str = templates.args( cls.name )[self.value_type_index] + value_type_str = templates.args( cls.name )[self.element_type_index] ref = type_traits.impl_details.find_value_type( cls.top_parent, value_type_str ) if None is ref: raise RuntimeError( "Unable to find out %s '%s' value type." % ( self.name, cls.decl_string ) ) return ref -def create_traits_class( container_name, value_type_index ): +def create_traits_class( container_name, element_type_index, element_type_typedef ): class xxx_traits: - impl = container_traits_impl_t( container_name, value_type_index ) + impl = container_traits_impl_t( container_name, element_type_index, element_type_typedef ) @staticmethod def is_my_case( type ): @@ -76,34 +77,35 @@ return xxx_traits.impl.class_declaration( type ) @staticmethod - def value_type( type ): - return xxx_traits.impl.value_type( type ) + def element_type( type ): + return xxx_traits.impl.element_type( type ) return xxx_traits -list_traits = create_traits_class( 'list', 0 ) +list_traits = create_traits_class( 'list', 0, 'value_type' ) -deque_traits = create_traits_class( 'deque', 0 ) +deque_traits = create_traits_class( 'deque', 0, 'value_type' ) -queue_traits = create_traits_class( 'queue', 0 ) -priority_queue = create_traits_class( 'priority_queue', 0 ) +queue_traits = create_traits_class( 'queue', 0, 'value_type' ) -vector_traits = create_traits_class( 'vector', 0 ) +priority_queue = create_traits_class( 'priority_queue', 0, 'value_type' ) -stack_traits = create_traits_class( 'stack', 0 ) +vector_traits = create_traits_class( 'vector', 0, 'value_type' ) -map_traits = create_traits_class( 'map', 1 ) -multimap_traits = create_traits_class( 'multimap', 1 ) +stack_traits = create_traits_class( 'stack', 0, 'value_type' ) -hash_map_traits = create_traits_class( 'hash_map', 1 ) -hash_multimap_traits = create_traits_class( 'hash_multimap', 1 ) +map_traits = create_traits_class( 'map', 1, 'mapped_type' ) +multimap_traits = create_traits_class( 'multimap', 1, 'mapped_type' ) -set_traits = create_traits_class( 'set', 0 ) -hash_set_traits = create_traits_class( 'hash_set', 0 ) +hash_map_traits = create_traits_class( 'hash_map', 1, 'mapped_type' ) +hash_multimap_traits = create_traits_class( 'hash_multimap', 1, 'mapped_type' ) -multiset_traits = create_traits_class( 'multiset', 0 ) -hash_multiset_traits = create_traits_class( 'hash_multiset', 0 ) +set_traits = create_traits_class( 'set', 0, 'value_type' ) +hash_set_traits = create_traits_class( 'hash_set', 0, 'value_type' ) +multiset_traits = create_traits_class( 'multiset', 0, 'value_type' ) +hash_multiset_traits = create_traits_class( 'hash_multiset', 0, 'value_type' ) + Modified: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py 2006-07-04 13:30:48 UTC (rev 272) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-07-05 08:12:38 UTC (rev 273) @@ -28,7 +28,7 @@ def validate_yes( self, value_type, container ): traits = declarations.vector_traits self.failUnless( traits.is_my_case( container ) ) - self.failUnless( declarations.is_same( value_type, traits.value_type( container ) ) ) + self.failUnless( declarations.is_same( value_type, traits.element_type( container ) ) ) def test_global_ns( self ): value_type = self.global_ns.class_( '_0_' ) Modified: pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py 2006-07-05 08:12:38 UTC (rev 273) @@ -144,7 +144,7 @@ def is_vector_of_strings( decl ): if not declarations.vector_traits.is_my_case( decl ): return False - return declarations.is_std_string( declarations.vector_traits.value_type(decl) ) + return declarations.is_std_string( declarations.vector_traits.element_type(decl) ) str_vec = mb.class_( is_vector_of_strings ) str_vec.alias = "strings" Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-05 08:12:38 UTC (rev 273) @@ -30,7 +30,6 @@ this class are never created by the user, instead they are returned by the API. """ - def __init__(self): object.__init__(self) self._alias = None @@ -45,9 +44,11 @@ def _get_alias(self): if not self._alias: - if declarations.templates.is_instantiation( self.name ): + if declarations.templates.is_instantiation( self.name ): + container_aliases = [ 'value_type', 'key_type' ] if isinstance( self, declarations.class_t ) \ - and 1 == len( set( map( lambda typedef: typedef.name, self.aliases ) ) ): + and 1 == len( set( map( lambda typedef: typedef.name, self.aliases ) ) ) \ + and self.aliases[0].name not in container_aliases: self._alias = self.aliases[0].name else: self._alias = self._generate_valid_name() Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2006-07-05 08:12:38 UTC (rev 273) @@ -28,17 +28,18 @@ return self.__container_class container_class = property( _get_container_class ) - def value_type(self): - return self.__container_traits.value_type( self.container_class ) + def _get_element_type(self): + return self.__container_traits.element_type( self.container_class ) + element_type = property( _get_element_type ) def _get_no_proxy( self ): if self.__no_proxy is None: - value_type = self.value_type() - if declarations.is_fundamental( value_type ) \ - or declarations.is_enum( value_type ) \ - or declarations.is_std_string( value_type ) \ - or declarations.is_std_wstring( value_type ) \ - or declarations.smart_pointer_traits.is_smart_pointer( value_type ): + element_type = self.element_type + if declarations.is_fundamental( element_type ) \ + or declarations.is_enum( element_type ) \ + or declarations.is_std_string( element_type ) \ + or declarations.is_std_wstring( element_type ) \ + or declarations.smart_pointer_traits.is_smart_pointer( element_type ): self.__no_proxy = True else: self.__no_proxy = False Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2006-07-05 08:12:38 UTC (rev 273) @@ -59,8 +59,9 @@ return self._get_container_traits() container_traits = property( _get_container_traits ) - def value_type( self ): - return self.__container_traits.value_type( self.container_class ) + def _get_element_type(self): + return self.__container_traits.element_type( self.container_class ) + element_type = property( _get_element_type ) def _get_call_policies( self ): #TODO find out call policies @@ -73,7 +74,7 @@ if self._default_applied: return self._default_applied = True - #find out what operators are supported by value_type and + #find out what operators are supported by element_type and #then configure the _disable_[methods|groups] pass Modified: pyplusplus_dev/pyplusplus/file_writers/multiple_files.py =================================================================== --- pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2006-07-05 08:12:38 UTC (rev 273) @@ -86,11 +86,11 @@ return None if not isinstance( code_creator.declaration.indexing_suite, decl_wrappers.indexing_suite2_t ): return None - value_type = code_creator.declaration.indexing_suite.value_type() + element_type = code_creator.declaration.indexing_suite.element_type class_traits = declarations.class_traits - if not class_traits.is_my_case( value_type ): + if not class_traits.is_my_case( element_type ): return None - value_class = class_traits.get_declaration( value_type ) + value_class = class_traits.get_declaration( element_type ) return self.create_value_traits_header_name( value_class ) def create_source( self, file_name, function_name, creators ): Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-07-05 08:12:38 UTC (rev 273) @@ -357,7 +357,7 @@ def _treat_indexing_suite( self ): def create_explanation(cls): msg = '//WARNING: the next line of code will not compile, because "%s" does not have operator== !' - msg = msg % cls.indexing_suite.value_type().decl_string + msg = msg % cls.indexing_suite.element_type.decl_string return code_creators.custom_text_t( msg, False ) def create_cls_cc( cls ): @@ -406,18 +406,18 @@ used_headers.add( isuite[ container_name ] ) cls_creator = create_cls_cc( cls ) - value_type = cls.indexing_suite.value_type() + element_type = cls.indexing_suite.element_type if isuite is isuite1: - if declarations.is_class( value_type ) and not declarations.has_public_equal( value_type ): + if declarations.is_class( element_type ) and not declarations.has_public_equal( element_type ): cls_creator.adopt_creator( create_explanation( cls ) ) cls_creator.adopt_creator( code_creators.indexing_suite1_t(cls) ) else: class_traits = declarations.class_traits - if class_traits.is_my_case( value_type ): - value_cls = class_traits.get_declaration( value_type ) + if class_traits.is_my_case( element_type ): + value_cls = class_traits.get_declaration( element_type ) if not ( value_cls.equality_comparable and value_cls.less_than_comparable ): - value_type_cc = code_creators.value_traits_t( value_cls ) - self.__extmodule.adopt_creator( value_type_cc, self.__extmodule.creators.index( self.__module_body ) ) + element_type_cc = code_creators.value_traits_t( value_cls ) + self.__extmodule.adopt_creator( element_type_cc, self.__extmodule.creators.index( self.__module_body ) ) cls_creator.adopt_creator( code_creators.indexing_suite2_t(cls) ) self.__module_body.adopt_creator( cls_creator ) Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-05 08:12:38 UTC (rev 273) @@ -71,8 +71,7 @@ return False try: - #checking whether value_type could be extracted - container_cls.indexing_suite.value_type() + check_extraction = container_cls.indexing_suite.element_type except RuntimeError, error: msg = 'WARNING: pyplusplus found "%s" instantiation declaration, ' % container_cls.name msg = msg + 'but can not find out value type!' Modified: pyplusplus_dev/unittests/indexing_suites_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites_tester.py 2006-07-04 13:30:48 UTC (rev 272) +++ pyplusplus_dev/unittests/indexing_suites_tester.py 2006-07-05 08:12:38 UTC (rev 273) @@ -24,8 +24,8 @@ def matcher( item, decl ): if not declarations.vector_traits.is_my_case( decl ): return False - value_type = declarations.vector_traits.value_type(decl) - if item is value_type: + element_type = declarations.vector_traits.element_type(decl) + if item is element_type: return True return False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-07-08 18:28:03
|
Revision: 279 Author: roman_yakovenko Date: 2006-07-08 11:27:50 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=279&view=rev Log Message: ----------- updating unittests to new interface of enumeration_t Modified Paths: -------------- pygccxml_dev/unittests/declarations_tester.py pygccxml_dev/unittests/type_traits_tester.py pygccxml_dev/unittests/unnamed_enums_bug_tester.py Modified: pygccxml_dev/unittests/declarations_tester.py =================================================================== --- pygccxml_dev/unittests/declarations_tester.py 2006-07-08 18:26:29 UTC (rev 278) +++ pygccxml_dev/unittests/declarations_tester.py 2006-07-08 18:27:50 UTC (rev 279) @@ -32,8 +32,8 @@ def test_enumeration_t(self): enum = self.global_ns.enum( 'ENumbers' ) - expected_values = dict( zip( [ 'e%d' % index for index in range(10) ] - , [ '%d' % index for index in range(10) ] ) ) + expected_values = zip( [ 'e%d' % index for index in range(10) ] + , [ index for index in range(10) ] ) self.failUnless( expected_values == enum.values , "expected enum values ( '%s' ) and existings ( '%s' ) are different" % \ ( pprint.pformat( expected_values ), pprint.pformat( enum.values ) ) ) Modified: pygccxml_dev/unittests/type_traits_tester.py =================================================================== --- pygccxml_dev/unittests/type_traits_tester.py 2006-07-08 18:26:29 UTC (rev 278) +++ pygccxml_dev/unittests/type_traits_tester.py 2006-07-08 18:27:50 UTC (rev 279) @@ -210,7 +210,7 @@ expected_type = declarations.find_declaration( defs , name='expected' , type=declarations.enumeration_t ) - expected_value = bool( int( expected_type.values['value'] ) ) + expected_value = bool( expected_type.get_name2value_dict()['value'] ) if expected_value != declarations.is_convertible( source_type, target_type ): print decl.name Modified: pygccxml_dev/unittests/unnamed_enums_bug_tester.py =================================================================== --- pygccxml_dev/unittests/unnamed_enums_bug_tester.py 2006-07-08 18:26:29 UTC (rev 278) +++ pygccxml_dev/unittests/unnamed_enums_bug_tester.py 2006-07-08 18:27:50 UTC (rev 279) @@ -26,8 +26,8 @@ def test( self ): names = [] - enums = self.global_ns.enums() - map( lambda enum: names.extend( enum.values.keys() ), enums ) + enums = self.global_ns.enums() + map( lambda enum: names.extend( enum.get_name2value_dict().keys() ), enums ) self.failUnless( len( names ) == 4 ) self.failUnless( 'x1' in names ) self.failUnless( 'x2' in names ) @@ -49,7 +49,7 @@ def test( self ): names = [] enums = self.global_ns.enums() - map( lambda enum: names.extend( enum.values.keys() ), enums ) + map( lambda enum: names.extend( enum.get_name2value_dict().keys() ), enums ) self.failUnless( len( names ) == 4 ) self.failUnless( 'x1' in names ) self.failUnless( 'x2' in names ) @@ -71,7 +71,7 @@ def test( self ): names = [] enums = self.global_ns.enums() - map( lambda enum: names.extend( enum.values.keys() ), enums ) + map( lambda enum: names.extend( enum.get_name2value_dict().keys() ), enums ) self.failUnless( len( names ) == 6 ) self.failUnless( 'x1' in names ) self.failUnless( 'x2' in names ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-07-08 20:28:45
|
Revision: 281 Author: roman_yakovenko Date: 2006-07-08 13:28:29 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=281&view=rev Log Message: ----------- integrating has_public_equal and has_public_less with indexing suite 2. Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/type_traits.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py Added Paths: ----------- pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp pygccxml_dev/unittests/has_binary_operator_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-07-08 18:48:46 UTC (rev 280) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-07-08 20:28:29 UTC (rev 281) @@ -147,6 +147,7 @@ from type_traits import remove_declarated from type_traits import has_destructor +from type_traits import has_public_less from type_traits import has_trivial_copy from type_traits import has_public_equal from type_traits import has_public_assign @@ -154,8 +155,8 @@ from type_traits import has_public_constructor from type_traits import has_trivial_constructor from type_traits import find_trivial_constructor +from type_traits import has_public_binary_operator from type_traits import has_any_non_copyconstructor - from type_traits import smart_pointer_traits Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-07-08 18:48:46 UTC (rev 280) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-07-08 20:28:29 UTC (rev 281) @@ -365,32 +365,40 @@ , type.public_members ) return bool( constructors ) -def has_public_equal( type ): - """returns True if class has public operator==, otherwise False""" +def has_public_binary_operator( type, operator_symbol ): + symbol = operator_symbol not_artificial = lambda decl: decl.is_artificial == False type = remove_alias( type ) type = remove_cv( type ) type = remove_declarated( type ) assert isinstance( type, class_declaration.class_t ) - equals = type.member_operators( function=not_artificial, symbol='==', allow_empty=True, recursive=False ) + equals = type.member_operators( function=not_artificial, symbol=symbol, allow_empty=True, recursive=False ) if equals: return True t = cpptypes.declarated_t( type ) t = cpptypes.const_t( t ) t = cpptypes.reference_t( t ) - equals = type.parent.operators( function=not_artificial, symbol='==', arg_types=[t, None], allow_empty=True, recursive=False ) + equals = type.parent.operators( function=not_artificial, symbol=symbol, arg_types=[t, None], allow_empty=True, recursive=False ) if equals: return True for bi in type.recursive_bases: assert isinstance( bi, class_declaration.hierarchy_info_t ) if bi.access_type != class_declaration.ACCESS_TYPES.PUBLIC: continue - equals = bi.related_class.member_operators( function=not_artificial, symbol='==', allow_empty=True, recursive=False ) + equals = bi.related_class.member_operators( function=not_artificial, symbol=symbol, allow_empty=True, recursive=False ) if equals: return True return False - + +def has_public_equal( type ): + """returns True if class has public operator==, otherwise False""" + return has_public_binary_operator( type, '==' ) + +def has_public_less( type ): + """returns True if class has public operator<, otherwise False""" + return has_public_binary_operator( type, '<' ) + def is_unary_operator( oper ): """returns True if operator is unary operator, otherwise False""" #~ definition: Added: pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp (rev 0) +++ pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp 2006-07-08 20:28:29 UTC (rev 281) @@ -0,0 +1,39 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <string> +#include <vector> + +namespace binary_operator{ +namespace yes{ + typedef std::string yes1; + + inline bool instantiate_templ(){ + return std::string( "1" ) == std::string( "2" ); + } + + struct trivial{ + bool operator==(const trivial& other); + }; + + typedef trivial yes2; + + struct external{ + }; + + bool operator==( const external& left, const external& right ); + + typedef external yes3; +} +namespace no{ + + struct x1{ + private: + bool operator==( const x1& other ); + }; + + typedef x1 no1; +} +} \ No newline at end of file Added: pygccxml_dev/unittests/has_binary_operator_traits_tester.py =================================================================== --- pygccxml_dev/unittests/has_binary_operator_traits_tester.py (rev 0) +++ pygccxml_dev/unittests/has_binary_operator_traits_tester.py 2006-07-08 20:28:29 UTC (rev 281) @@ -0,0 +1,49 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE + global_ns = None + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'has_public_binary_operator_traits.hpp' + self.global_ns = None + + def setUp(self): + if not tester_t.global_ns: + decls = parser.parse( [self.header], self.config ) + tester_t.global_ns = declarations.get_global_namespace( decls ) + self.global_ns = tester_t.global_ns + + def test_yes( self ): + yes_ns = self.global_ns.namespace( 'yes' ) + for typedef in yes_ns.typedefs(): + self.failUnless( declarations.has_public_equal( typedef ) + , "Class '%s' should have public operator==" % typedef.decl_string ) + + def test_no( self ): + no_ns = self.global_ns.namespace( 'no' ) + for typedef in no_ns.typedefs(): + self.failUnless( not declarations.has_public_equal( typedef ) + , "Class '%s' should not have public operator==" % typedef.decl_string ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-07-08 18:48:46 UTC (rev 280) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-07-08 20:28:29 UTC (rev 281) @@ -49,7 +49,6 @@ indexing_suite = property( _get_indexing_suite ) def _get_equality_comparable( self ): - return False if None is self._equality_comparable: self._equality_comparable = declarations.has_public_equal( self ) return self._equality_comparable @@ -60,7 +59,6 @@ equality_comparable = property( _get_equality_comparable, _set_equality_comparable ) def _get_less_than_comparable( self ): - return False if None is self._less_than_comparable: self._less_than_comparable = declarations.has_public_less( self ) return self._less_than_comparable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-08-26 12:14:43
|
Revision: 474 Author: roman_yakovenko Date: 2006-08-26 05:14:17 -0700 (Sat, 26 Aug 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=474&view=rev Log Message: ----------- adding unit tests for gccxml that runs on Linux AMD64 architecture Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/pygccxml/parser/patcher.py pygccxml_dev/pygccxml/utils/__init__.py pygccxml_dev/unittests/data/core_cache.hpp pygccxml_dev/unittests/data/patcher.hpp pygccxml_dev/unittests/patcher_tester.py Added Paths: ----------- pygccxml_dev/unittests/data/patcher_tester_64bit.xml Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-08-26 08:16:46 UTC (rev 473) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-08-26 12:14:17 UTC (rev 474) @@ -28,25 +28,25 @@ import class_declaration import types as build_in_types -def __remove_alias(tp, tp_is_clone): +def __remove_alias(type_): """implementation details""" - #implementation of this function is important - if isinstance( tp, cpptypes.compound_t ): - if not tp_is_clone: - tp = tp.clone() - tp_is_clone = True #copy on first modification - tp.base = __remove_alias( tp.base, tp_is_clone ) - return tp - elif isinstance( tp, typedef.typedef_t ): - return __remove_alias( tp.type, tp_is_clone ) - elif isinstance( tp, cpptypes.declarated_t ) and isinstance( tp.declaration, typedef.typedef_t ): - return __remove_alias( tp.declaration.type, tp_is_clone ) - else: - return tp + if isinstance( type_, typedef.typedef_t ): + return __remove_alias( type_.type ) + if isinstance( type_, cpptypes.declarated_t ) and isinstance( type_.declaration, typedef.typedef_t ): + return __remove_alias( type_.declaration.type ) + if isinstance( type_, cpptypes.compound_t ): + type_.base = __remove_alias( type_.base ) + return type_ + return type_ -def remove_alias(tp): +def remove_alias(type_): """returns type without typedefs""" - return __remove_alias( tp, False ) + if isinstance( type_, cpptypes.type_t ): + return __remove_alias( type_.clone() ) + elif isinstance( type_, typedef.typedef_t ): + return __remove_alias( type_.type.clone() ) + else: + return type_ def create_cv_types( base ): """implementation details""" Modified: pygccxml_dev/pygccxml/parser/patcher.py =================================================================== --- pygccxml_dev/pygccxml/parser/patcher.py 2006-08-26 08:16:46 UTC (rev 473) +++ pygccxml_dev/pygccxml/parser/patcher.py 2006-08-26 12:14:17 UTC (rev 474) @@ -3,6 +3,7 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +from pygccxml import utils from pygccxml import declarations class patcher_base_t(object): @@ -73,9 +74,14 @@ return arg.default_value except: pass - + try: int( arg.default_value, 16 ) + if 64 == utils.get_architecture(): + #on 64 bit architecture, gccxml reports 0fffff, which is valid number + #the problem is that in this case it is so buggy so pygccxml can not fix it + #users will have to fix the default value manually + return arg.default_value default_value = arg.default_value.lower() found_hex = filter( lambda ch: ch in 'abcdef', default_value ) if found_hex and not default_value.startswith( '0x' ): Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2006-08-26 08:16:46 UTC (rev 473) +++ pygccxml_dev/pygccxml/utils/__init__.py 2006-08-26 12:14:17 UTC (rev 474) @@ -80,6 +80,10 @@ return os.path.normpath( os.path.normcase( some_path ) ) def get_architecture(): + """returns computer architecture: 32 or 64. + + The guess is based on maxint. + """ if sys.maxint == 2147483647: return 32 elif sys.maxint == 9223372036854775807: Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2006-08-26 08:16:46 UTC (rev 473) +++ pygccxml_dev/unittests/data/core_cache.hpp 2006-08-26 12:14:17 UTC (rev 474) @@ -22,4 +22,4 @@ #endif//__core_cache_hpp__ -//touch//touch//touch//touch//touch//touch//touch//touch \ No newline at end of file +//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch \ No newline at end of file Modified: pygccxml_dev/unittests/data/patcher.hpp =================================================================== --- pygccxml_dev/unittests/data/patcher.hpp 2006-08-26 08:16:46 UTC (rev 473) +++ pygccxml_dev/unittests/data/patcher.hpp 2006-08-26 12:14:17 UTC (rev 474) @@ -1,53 +1,52 @@ -// Copyright 2004 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef __patcher_hpp__ -#define __patcher_hpp__ - -namespace ns1{ namespace ns2{ - -enum fruit{ apple, orange }; - -} } - -void fix_enum( ns1::ns2::fruit arg=ns1::ns2::apple ); - -typedef unsigned long long ull; -void fix_numeric( ull arg=(ull)-1 ); - -namespace fx{ - enum{ unnamed = 0 }; - void fix_unnamed( int x=unnamed ); -} - -namespace function_call{ - inline int calc( int,int, int){ return 0; } - void fix_function_call( int i=calc( 1,2,3) ); -} - -namespace fundamental{ - enum spam { eggs }; - void fix_fundamental(unsigned int v=eggs); -} - - -namespace typedef_{ - -struct original_name{ - original_name(){} -}; - -typedef original_name alias; - -} - -void typedef__func( const typedef_::alias& position = typedef_::alias() ); - - -/*struct default_arg_t{};*/ -/*default_arg_t create_default_argument();*/ -/*void double_call( default_arg_t x=create_default_argument() );*/ -#endif//__patcher_hpp__ - +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __patcher_hpp__ +#define __patcher_hpp__ + +namespace ns1{ namespace ns2{ + +enum fruit{ apple, orange }; + +} } + +void fix_enum( ns1::ns2::fruit arg=ns1::ns2::apple ); + +typedef unsigned long long ull; +void fix_numeric( ull arg=(ull)-1 ); + +namespace fx{ + enum{ unnamed = 0 }; + void fix_unnamed( int x=unnamed ); +} + +namespace function_call{ + inline int calc( int,int, int){ return 0; } + void fix_function_call( int i=calc( 1,2,3) ); +} + +namespace fundamental{ + enum spam { eggs }; + void fix_fundamental(unsigned int v=eggs); +} + + +namespace typedef_{ + +struct original_name{ + original_name(){} +}; + +typedef original_name alias; + +} + +void typedef__func( const typedef_::alias& position = typedef_::alias() ); + + +/*struct default_arg_t{};*/ +/*default_arg_t create_default_argument();*/ +/*void double_call( default_arg_t x=create_default_argument() );*/ +#endif//__patcher_hpp__ Added: pygccxml_dev/unittests/data/patcher_tester_64bit.xml =================================================================== --- pygccxml_dev/unittests/data/patcher_tester_64bit.xml (rev 0) +++ pygccxml_dev/unittests/data/patcher_tester_64bit.xml 2006-08-26 12:14:17 UTC (rev 474) @@ -0,0 +1,452 @@ +<?xml version="1.0"?> +<GCC_XML cvs_revision="1.113"> + <Namespace id="_1" name="::" members="_3 _4 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 _16 _17 _18 _19 _20 _21 _22 _23 _24 _25 _26 _27 _28 _29 _30 _31 _32 _33 _34 _35 _36 _37 _38 _39 _40 _41 _42 _43 _44 _45 _46 _47 _48 _49 _50 _51 _52 _53 _54 _55 _56 _57 _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 _68 _69 _70 _71 _72 _73 _74 _75 _76 _77 _78 _79 _80 _81 _82 _83 _84 _85 _86 _87 _88 _89 _90 _91 _92 _93 _94 _95 _96 _97 _98 _99 _100 _101 _102 _103 _104 _105 _106 _107 _108 _109 _110 _111 _112 _113 _114 _115 _116 _117 _118 _119 _120 _121 _122 _123 _124 _125 _126 _127 _128 _129 _130 _131 " mangled="_Z2::" demangled="::"/> + <Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std" demangled="std"/> + <Function id="_3" name="typedef__func" returns="_132" context="_1" mangled="_Z13typedef__funcRKN8typedef_13original_nameE" demangled="typedef__func(typedef_::original_name const&)" location="f0:46" file="f0" line="46" extern="1"> + <Argument name="position" type="_133" location="f0:46" file="f0" line="46" default="alias()"/> + </Function> + <Function id="_4" name="fix_numeric" returns="_132" context="_1" mangled="_Z11fix_numericy" demangled="fix_numeric(unsigned long long)" location="f0:18" file="f0" line="18" extern="1"> + <Argument name="arg" type="_6" location="f0:18" file="f0" line="18" default="0ffffffff"/> + </Function> + <FundamentalType id="_5" name="long long unsigned int" size="64" align="64"/> + <Typedef id="_6" name="ull" type="_5" context="_1" location="f0:17" file="f0" line="17"/> + <Function id="_7" name="fix_enum" returns="_132" context="_1" mangled="_Z8fix_enumN3ns13ns25fruitE" demangled="fix_enum(ns1::ns2::fruit)" location="f0:15" file="f0" line="15" extern="1"> + <Argument name="arg" type="_134" location="f0:15" file="f0" line="15" default="apple"/> + </Function> + <Function id="_8" name="__builtin_cpowl" returns="_135" context="_1" location="f1:131" file="f1" line="131" extern="1"> + <Argument type="_135" location="f1:131" file="f1" line="131"/> + <Argument type="_135" location="f1:131" file="f1" line="131"/> + </Function> + <Function id="_9" name="__builtin_cpow" returns="_136" context="_1" location="f1:130" file="f1" line="130" extern="1"> + <Argument type="_136" location="f1:130" file="f1" line="130"/> + <Argument type="_136" location="f1:130" file="f1" line="130"/> + </Function> + <Function id="_10" name="__builtin_cpowf" returns="_137" context="_1" location="f1:129" file="f1" line="129" extern="1"> + <Argument type="_137" location="f1:129" file="f1" line="129"/> + <Argument type="_137" location="f1:129" file="f1" line="129"/> + </Function> + <Function id="_11" name="__builtin_ctanhl" returns="_135" context="_1" location="f1:128" file="f1" line="128" extern="1"> + <Argument type="_135" location="f1:128" file="f1" line="128"/> + </Function> + <Function id="_12" name="__builtin_ctanh" returns="_136" context="_1" location="f1:127" file="f1" line="127" extern="1"> + <Argument type="_136" location="f1:127" file="f1" line="127"/> + </Function> + <Function id="_13" name="__builtin_ctanhf" returns="_137" context="_1" location="f1:126" file="f1" line="126" extern="1"> + <Argument type="_137" location="f1:126" file="f1" line="126"/> + </Function> + <Function id="_14" name="__builtin_ctanl" returns="_135" context="_1" location="f1:125" file="f1" line="125" extern="1"> + <Argument type="_135" location="f1:125" file="f1" line="125"/> + </Function> + <Function id="_15" name="__builtin_ctan" returns="_136" context="_1" location="f1:124" file="f1" line="124" extern="1"> + <Argument type="_136" location="f1:124" file="f1" line="124"/> + </Function> + <Function id="_16" name="__builtin_ctanf" returns="_137" context="_1" location="f1:123" file="f1" line="123" extern="1"> + <Argument type="_137" location="f1:123" file="f1" line="123"/> + </Function> + <Function id="_17" name="__builtin_csqrtl" returns="_135" context="_1" location="f1:122" file="f1" line="122" extern="1"> + <Argument type="_135" location="f1:122" file="f1" line="122"/> + </Function> + <Function id="_18" name="__builtin_csqrt" returns="_136" context="_1" location="f1:121" file="f1" line="121" extern="1"> + <Argument type="_136" location="f1:121" file="f1" line="121"/> + </Function> + <Function id="_19" name="__builtin_csqrtf" returns="_137" context="_1" location="f1:120" file="f1" line="120" extern="1"> + <Argument type="_137" location="f1:120" file="f1" line="120"/> + </Function> + <Function id="_20" name="__builtin_csinhl" returns="_135" context="_1" location="f1:119" file="f1" line="119" extern="1"> + <Argument type="_135" location="f1:119" file="f1" line="119"/> + </Function> + <Function id="_21" name="__builtin_csinh" returns="_136" context="_1" location="f1:118" file="f1" line="118" extern="1"> + <Argument type="_136" location="f1:118" file="f1" line="118"/> + </Function> + <Function id="_22" name="__builtin_csinhf" returns="_137" context="_1" location="f1:117" file="f1" line="117" extern="1"> + <Argument type="_137" location="f1:117" file="f1" line="117"/> + </Function> + <Function id="_23" name="__builtin_csinl" returns="_135" context="_1" location="f1:116" file="f1" line="116" extern="1"> + <Argument type="_135" location="f1:116" file="f1" line="116"/> + </Function> + <Function id="_24" name="__builtin_csin" returns="_136" context="_1" location="f1:115" file="f1" line="115" extern="1"> + <Argument type="_136" location="f1:115" file="f1" line="115"/> + </Function> + <Function id="_25" name="__builtin_csinf" returns="_137" context="_1" location="f1:114" file="f1" line="114" extern="1"> + <Argument type="_137" location="f1:114" file="f1" line="114"/> + </Function> + <Function id="_26" name="__builtin_clogl" returns="_135" context="_1" location="f1:113" file="f1" line="113" extern="1"> + <Argument type="_135" location="f1:113" file="f1" line="113"/> + </Function> + <Function id="_27" name="__builtin_clog" returns="_136" context="_1" location="f1:112" file="f1" line="112" extern="1"> + <Argument type="_136" location="f1:112" file="f1" line="112"/> + </Function> + <Function id="_28" name="__builtin_clogf" returns="_137" context="_1" location="f1:111" file="f1" line="111" extern="1"> + <Argument type="_137" location="f1:111" file="f1" line="111"/> + </Function> + <Function id="_29" name="__builtin_cexpl" returns="_135" context="_1" location="f1:110" file="f1" line="110" extern="1"> + <Argument type="_135" location="f1:110" file="f1" line="110"/> + </Function> + <Function id="_30" name="__builtin_cexp" returns="_136" context="_1" location="f1:109" file="f1" line="109" extern="1"> + <Argument type="_136" location="f1:109" file="f1" line="109"/> + </Function> + <Function id="_31" name="__builtin_cexpf" returns="_137" context="_1" location="f1:108" file="f1" line="108" extern="1"> + <Argument type="_137" location="f1:108" file="f1" line="108"/> + </Function> + <Function id="_32" name="__builtin_ccoshl" returns="_135" context="_1" location="f1:107" file="f1" line="107" extern="1"> + <Argument type="_135" location="f1:107" file="f1" line="107"/> + </Function> + <Function id="_33" name="__builtin_ccosh" returns="_136" context="_1" location="f1:106" file="f1" line="106" extern="1"> + <Argument type="_136" location="f1:106" file="f1" line="106"/> + </Function> + <Function id="_34" name="__builtin_ccoshf" returns="_137" context="_1" location="f1:105" file="f1" line="105" extern="1"> + <Argument type="_137" location="f1:105" file="f1" line="105"/> + </Function> + <Function id="_35" name="__builtin_ccosl" returns="_135" context="_1" location="f1:104" file="f1" line="104" extern="1"> + <Argument type="_135" location="f1:104" file="f1" line="104"/> + </Function> + <Function id="_36" name="__builtin_ccos" returns="_136" context="_1" location="f1:103" file="f1" line="103" extern="1"> + <Argument type="_136" location="f1:103" file="f1" line="103"/> + </Function> + <Function id="_37" name="__builtin_ccosf" returns="_137" context="_1" location="f1:102" file="f1" line="102" extern="1"> + <Argument type="_137" location="f1:102" file="f1" line="102"/> + </Function> + <Function id="_38" name="__builtin_popcountll" returns="_138" context="_1" location="f1:101" file="f1" line="101" extern="1"> + <Argument type="_139" location="f1:101" file="f1" line="101"/> + </Function> + <Function id="_39" name="__builtin_popcountl" returns="_138" context="_1" location="f1:100" file="f1" line="100" extern="1"> + <Argument type="_140" location="f1:100" file="f1" line="100"/> + </Function> + <Function id="_40" name="__builtin_popcount" returns="_138" context="_1" location="f1:99" file="f1" line="99" extern="1"> + <Argument type="_138" location="f1:99" file="f1" line="99"/> + </Function> + <Function id="_41" name="__builtin_ctzll" returns="_138" context="_1" location="f1:98" file="f1" line="98" extern="1"> + <Argument type="_139" location="f1:98" file="f1" line="98"/> + </Function> + <Function id="_42" name="__builtin_ctzl" returns="_138" context="_1" location="f1:97" file="f1" line="97" extern="1"> + <Argument type="_140" location="f1:97" file="f1" line="97"/> + </Function> + <Function id="_43" name="__builtin_ctz" returns="_138" context="_1" location="f1:96" file="f1" line="96" extern="1"> + <Argument type="_138" location="f1:96" file="f1" line="96"/> + </Function> + <Function id="_44" name="__builtin_cargl" returns="_141" context="_1" location="f1:95" file="f1" line="95" extern="1"> + <Argument type="_135" location="f1:95" file="f1" line="95"/> + </Function> + <Function id="_45" name="__builtin_carg" returns="_142" context="_1" location="f1:94" file="f1" line="94" extern="1"> + <Argument type="_136" location="f1:94" file="f1" line="94"/> + </Function> + <Function id="_46" name="__builtin_cargf" returns="_143" context="_1" location="f1:93" file="f1" line="93" extern="1"> + <Argument type="_137" location="f1:93" file="f1" line="93"/> + </Function> + <Function id="_47" name="__builtin_cabsl" returns="_141" context="_1" location="f1:92" file="f1" line="92" extern="1"> + <Argument type="_135" location="f1:92" file="f1" line="92"/> + </Function> + <Function id="_48" name="__builtin_cabs" returns="_142" context="_1" location="f1:91" file="f1" line="91" extern="1"> + <Argument type="_136" location="f1:91" file="f1" line="91"/> + </Function> + <Function id="_49" name="__builtin_cabsf" returns="_143" context="_1" location="f1:90" file="f1" line="90" extern="1"> + <Argument type="_137" location="f1:90" file="f1" line="90"/> + </Function> + <Function id="_50" name="__builtin_tanl" returns="_141" context="_1" location="f1:89" file="f1" line="89" extern="1"> + <Argument type="_141" location="f1:89" file="f1" line="89"/> + </Function> + <Function id="_51" name="__builtin_tanhl" returns="_141" context="_1" location="f1:88" file="f1" line="88" extern="1"> + <Argument type="_141" location="f1:88" file="f1" line="88"/> + </Function> + <Function id="_52" name="__builtin_tanhf" returns="_143" context="_1" location="f1:87" file="f1" line="87" extern="1"> + <Argument type="_143" location="f1:87" file="f1" line="87"/> + </Function> + <Function id="_53" name="__builtin_tanh" returns="_142" context="_1" location="f1:86" file="f1" line="86" extern="1"> + <Argument type="_142" location="f1:86" file="f1" line="86"/> + </Function> + <Function id="_54" name="__builtin_tanf" returns="_143" context="_1" location="f1:85" file="f1" line="85" extern="1"> + <Argument type="_143" location="f1:85" file="f1" line="85"/> + </Function> + <Function id="_55" name="__builtin_tan" returns="_142" context="_1" location="f1:84" file="f1" line="84" extern="1"> + <Argument type="_142" location="f1:84" file="f1" line="84"/> + </Function> + <Function id="_56" name="__builtin_sinhl" returns="_141" context="_1" location="f1:79" file="f1" line="79" extern="1"> + <Argument type="_141" location="f1:79" file="f1" line="79"/> + </Function> + <Function id="_57" name="__builtin_sinhf" returns="_143" context="_1" location="f1:78" file="f1" line="78" extern="1"> + <Argument type="_143" location="f1:78" file="f1" line="78"/> + </Function> + <Function id="_58" name="__builtin_sinh" returns="_142" context="_1" location="f1:77" file="f1" line="77" extern="1"> + <Argument type="_142" location="f1:77" file="f1" line="77"/> + </Function> + <Function id="_59" name="__builtin_powil" returns="_141" context="_1" location="f1:74" file="f1" line="74" extern="1"> + <Argument type="_141" location="f1:74" file="f1" line="74"/> + <Argument type="_138" location="f1:74" file="f1" line="74"/> + </Function> + <Function id="_60" name="__builtin_powif" returns="_143" context="_1" location="f1:73" file="f1" line="73" extern="1"> + <Argument type="_143" location="f1:73" file="f1" line="73"/> + <Argument type="_138" location="f1:73" file="f1" line="73"/> + </Function> + <Function id="_61" name="__builtin_powi" returns="_142" context="_1" location="f1:72" file="f1" line="72" extern="1"> + <Argument type="_142" location="f1:72" file="f1" line="72"/> + <Argument type="_138" location="f1:72" file="f1" line="72"/> + </Function> + <Function id="_62" name="__builtin_powl" returns="_141" context="_1" location="f1:71" file="f1" line="71" extern="1"> + <Argument type="_141" location="f1:71" file="f1" line="71"/> + <Argument type="_141" location="f1:71" file="f1" line="71"/> + </Function> + <Function id="_63" name="__builtin_powf" returns="_143" context="_1" location="f1:70" file="f1" line="70" extern="1"> + <Argument type="_143" location="f1:70" file="f1" line="70"/> + <Argument type="_143" location="f1:70" file="f1" line="70"/> + </Function> + <Function id="_64" name="__builtin_modfl" returns="_141" context="_1" location="f1:69" file="f1" line="69" extern="1"> + <Argument type="_141" location="f1:69" file="f1" line="69"/> + <Argument type="_144" location="f1:69" file="f1" line="69"/> + </Function> + <Function id="_65" name="__builtin_modff" returns="_143" context="_1" location="f1:68" file="f1" line="68" extern="1"> + <Argument type="_143" location="f1:68" file="f1" line="68"/> + <Argument type="_145" location="f1:68" file="f1" line="68"/> + </Function> + <Function id="_66" name="__builtin_log10l" returns="_141" context="_1" location="f1:65" file="f1" line="65" extern="1"> + <Argument type="_141" location="f1:65" file="f1" line="65"/> + </Function> + <Function id="_67" name="__builtin_log10f" returns="_143" context="_1" location="f1:64" file="f1" line="64" extern="1"> + <Argument type="_143" location="f1:64" file="f1" line="64"/> + </Function> + <Function id="_68" name="__builtin_log10" returns="_142" context="_1" location="f1:63" file="f1" line="63" extern="1"> + <Argument type="_142" location="f1:63" file="f1" line="63"/> + </Function> + <Function id="_69" name="__builtin_ldexpl" returns="_141" context="_1" location="f1:61" file="f1" line="61" extern="1"> + <Argument type="_141" location="f1:61" file="f1" line="61"/> + <Argument type="_138" location="f1:61" file="f1" line="61"/> + </Function> + <Function id="_70" name="__builtin_ldexpf" returns="_143" context="_1" location="f1:60" file="f1" line="60" extern="1"> + <Argument type="_143" location="f1:60" file="f1" line="60"/> + <Argument type="_138" location="f1:60" file="f1" line="60"/> + </Function> + <Function id="_71" name="__builtin_ldexp" returns="_142" context="_1" location="f1:59" file="f1" line="59" extern="1"> + <Argument type="_142" location="f1:59" file="f1" line="59"/> + <Argument type="_138" location="f1:59" file="f1" line="59"/> + </Function> + <Function id="_72" name="__builtin_frexpl" returns="_141" context="_1" location="f1:58" file="f1" line="58" extern="1"> + <Argument type="_141" location="f1:58" file="f1" line="58"/> + <Argument type="_146" location="f1:58" file="f1" line="58"/> + </Function> + <Function id="_73" name="__builtin_frexpf" returns="_143" context="_1" location="f1:57" file="f1" line="57" extern="1"> + <Argument type="_143" location="f1:57" file="f1" line="57"/> + <Argument type="_146" location="f1:57" file="f1" line="57"/> + </Function> + <Function id="_74" name="__builtin_frexp" returns="_142" context="_1" location="f1:56" file="f1" line="56" extern="1"> + <Argument type="_142" location="f1:56" file="f1" line="56"/> + <Argument type="_146" location="f1:56" file="f1" line="56"/> + </Function> + <Function id="_75" name="__builtin_fmodl" returns="_141" context="_1" location="f1:55" file="f1" line="55" extern="1"> + <Argument type="_141" location="f1:55" file="f1" line="55"/> + <Argument type="_141" location="f1:55" file="f1" line="55"/> + </Function> + <Function id="_76" name="__builtin_fmodf" returns="_143" context="_1" location="f1:54" file="f1" line="54" extern="1"> + <Argument type="_143" location="f1:54" file="f1" line="54"/> + <Argument type="_143" location="f1:54" file="f1" line="54"/> + </Function> + <Function id="_77" name="__builtin_floorl" returns="_141" context="_1" location="f1:53" file="f1" line="53" extern="1"> + <Argument type="_141" location="f1:53" file="f1" line="53"/> + </Function> + <Function id="_78" name="__builtin_floorf" returns="_143" context="_1" location="f1:52" file="f1" line="52" extern="1"> + <Argument type="_143" location="f1:52" file="f1" line="52"/> + </Function> + <Function id="_79" name="__builtin_floor" returns="_142" context="_1" location="f1:51" file="f1" line="51" extern="1"> + <Argument type="_142" location="f1:51" file="f1" line="51"/> + </Function> + <Function id="_80" name="__builtin_coshl" returns="_141" context="_1" location="f1:43" file="f1" line="43" extern="1"> + <Argument type="_141" location="f1:43" file="f1" line="43"/> + </Function> + <Function id="_81" name="__builtin_coshf" returns="_143" context="_1" location="f1:42" file="f1" line="42" extern="1"> + <Argument type="_143" location="f1:42" file="f1" line="42"/> + </Function> + <Function id="_82" name="__builtin_cosh" returns="_142" context="_1" location="f1:41" file="f1" line="41" extern="1"> + <Argument type="_142" location="f1:41" file="f1" line="41"/> + </Function> + <Function id="_83" name="__builtin_ceill" returns="_141" context="_1" location="f1:38" file="f1" line="38" extern="1"> + <Argument type="_141" location="f1:38" file="f1" line="38"/> + </Function> + <Function id="_84" name="__builtin_ceilf" returns="_143" context="_1" location="f1:37" file="f1" line="37" extern="1"> + <Argument type="_143" location="f1:37" file="f1" line="37"/> + </Function> + <Function id="_85" name="__builtin_ceil" returns="_142" context="_1" location="f1:36" file="f1" line="36" extern="1"> + <Argument type="_142" location="f1:36" file="f1" line="36"/> + </Function> + <Function id="_86" name="__builtin_atanl" returns="_141" context="_1" location="f1:35" file="f1" line="35" extern="1"> + <Argument type="_141" location="f1:35" file="f1" line="35"/> + </Function> + <Function id="_87" name="__builtin_atanf" returns="_143" context="_1" location="f1:34" file="f1" line="34" extern="1"> + <Argument type="_143" location="f1:34" file="f1" line="34"/> + </Function> + <Function id="_88" name="__builtin_atan2l" returns="_141" context="_1" location="f1:33" file="f1" line="33" extern="1"> + <Argument type="_141" location="f1:33" file="f1" line="33"/> + <Argument type="_141" location="f1:33" file="f1" line="33"/> + </Function> + <Function id="_89" name="__builtin_atan2f" returns="_143" context="_1" location="f1:32" file="f1" line="32" extern="1"> + <Argument type="_143" location="f1:32" file="f1" line="32"/> + <Argument type="_143" location="f1:32" file="f1" line="32"/> + </Function> + <Function id="_90" name="__builtin_atan2" returns="_142" context="_1" location="f1:31" file="f1" line="31" extern="1"> + <Argument type="_142" location="f1:31" file="f1" line="31"/> + <Argument type="_142" location="f1:31" file="f1" line="31"/> + </Function> + <Function id="_91" name="__builtin_atan" returns="_142" context="_1" location="f1:30" file="f1" line="30" extern="1"> + <Argument type="_142" location="f1:30" file="f1" line="30"/> + </Function> + <Function id="_92" name="__builtin_asinl" returns="_141" context="_1" location="f1:29" file="f1" line="29" extern="1"> + <Argument type="_141" location="f1:29" file="f1" line="29"/> + </Function> + <Function id="_93" name="__builtin_asinf" returns="_143" context="_1" location="f1:28" file="f1" line="28" extern="1"> + <Argument type="_143" location="f1:28" file="f1" line="28"/> + </Function> + <Function id="_94" name="__builtin_asin" returns="_142" context="_1" location="f1:27" file="f1" line="27" extern="1"> + <Argument type="_142" location="f1:27" file="f1" line="27"/> + </Function> + <Function id="_95" name="__builtin_acosl" returns="_141" context="_1" location="f1:26" file="f1" line="26" extern="1"> + <Argument type="_141" location="f1:26" file="f1" line="26"/> + </Function> + <Function id="_96" name="__builtin_acosf" returns="_143" context="_1" location="f1:25" file="f1" line="25" extern="1"> + <Argument type="_143" location="f1:25" file="f1" line="25"/> + </Function> + <Function id="_97" name="__builtin_acos" returns="_142" context="_1" location="f1:24" file="f1" line="24" extern="1"> + <Argument type="_142" location="f1:24" file="f1" line="24"/> + </Function> + <Function id="_98" name="__builtin_expect" returns="_140" context="_1" location="f1:16" file="f1" line="16" extern="1"> + <Argument name="EXP" type="_140" location="f1:16" file="f1" line="16"/> + <Argument name="C" type="_140" location="f1:16" file="f1" line="16"/> + </Function> + <Function id="_99" name="__builtin_prefetch" returns="_132" context="_1" location="f1:17" file="f1" line="17" extern="1"> + <Argument name="ADDR" type="_147" location="f1:17" file="f1" line="17"/> + <Ellipsis/> + </Function> + <Function id="_100" name="__builtin_return" returns="_132" context="_1" location="f1:13" file="f1" line="13" extern="1" attributes="nothrow noreturn"> + <Argument name="RESULT" type="_148" location="f1:13" file="f1" line="13"/> + </Function> + <Function id="_101" name="__builtin_return_address" returns="_148" context="_1" location="f1:14" file="f1" line="14" extern="1"> + <Argument name="LEVEL" type="_149" location="f1:14" file="f1" line="14"/> + </Function> + <Function id="_102" name="__builtin_frame_address" returns="_148" context="_1" location="f1:15" file="f1" line="15" extern="1"> + <Argument name="LEVEL" type="_149" location="f1:15" file="f1" line="15"/> + </Function> + <Function id="_103" name="__builtin_nansl" returns="_141" context="_1" mangled="nansl" demangled="__int128" location="f1:23" file="f1" line="23" extern="1" attributes="nothrow const"> + <Argument name="str" type="_150" location="f1:23" file="f1" line="23"/> + </Function> + <Function id="_104" name="__builtin_nansf" returns="_143" context="_1" mangled="nansf" demangled="__int128" location="f1:22" file="f1" line="22" extern="1" attributes="nothrow const"> + <Argument name="str" type="_150" location="f1:22" file="f1" line="22"/> + </Function> + <Function id="_105" name="__builtin_nans" returns="_142" context="_1" mangled="nans" demangled="__int128" location="f1:21" file="f1" line="21" extern="1" attributes="nothrow const"> + <Argument name="str" type="_150" location="f1:21" file="f1" line="21"/> + </Function> + <Function id="_106" name="__builtin_infl" returns="_141" context="_1" location="f1:20" file="f1" line="20" extern="1" attributes="nothrow const"/> + <Function id="_107" name="__builtin_inff" returns="_143" context="_1" location="f1:19" file="f1" line="19" extern="1" attributes="nothrow const"/> + <Function id="_108" name="__builtin_inf" returns="_142" context="_1" location="f1:18" file="f1" line="18" extern="1" attributes="nothrow const"/> + <Function id="_109" name="__builtin_logl" returns="_141" context="_1" mangled="logl" demangled="long" location="f1:67" file="f1" line="67" extern="1" attributes="nothrow"> + <Argument type="_141" location="f1:67" file="f1" line="67"/> + </Function> + <Function id="_110" name="__builtin_expl" returns="_141" context="_1" mangled="expl" demangled="long double" location="f1:47" file="f1" line="47" extern="1" attributes="nothrow"> + <Argument type="_141" location="f1:47" file="f1" line="47"/> + </Function> + <Function id="_111" name="__builtin_cosl" returns="_141" context="_1" mangled="cosl" demangled="char" location="f1:44" file="f1" line="44" extern="1" attributes="nothrow pure"> + <Argument type="_141" location="f1:44" file="f1" line="44"/> + </Function> + <Function id="_112" name="__builtin_sinl" returns="_141" context="_1" mangled="sinl" demangled="short" location="f1:80" file="f1" line="80" extern="1" attributes="nothrow pure"> + <Argument type="_141" location="f1:80" file="f1" line="80"/> + </Function> + <Function id="_113" name="__builtin_sqrtl" returns="_141" context="_1" mangled="sqrtl" demangled="short" location="f1:83" file="f1" line="83" extern="1" attributes="nothrow"> + <Argument type="_141" location="f1:83" file="f1" line="83"/> + </Function> + <Function id="_114" name="__builtin_logf" returns="_143" context="_1" mangled="logf" demangled="long" location="f1:66" file="f1" line="66" extern="1" attributes="nothrow"> + <Argument type="_143" location="f1:66" file="f1" line="66"/> + </Function> + <Function id="_115" name="__builtin_expf" returns="_143" context="_1" mangled="expf" demangled="long double" location="f1:46" file="f1" line="46" extern="1" attributes="nothrow"> + <Argument type="_143" location="f1:46" file="f1" line="46"/> + </Function> + <Function id="_116" name="__builtin_cosf" returns="_143" context="_1" mangled="cosf" demangled="char" location="f1:40" file="f1" line="40" extern="1" attributes="nothrow pure"> + <Argument type="_143" location="f1:40" file="f1" line="40"/> + </Function> + <Function id="_117" name="__builtin_sinf" returns="_143" context="_1" mangled="sinf" demangled="short" location="f1:76" file="f1" line="76" extern="1" attributes="nothrow pure"> + <Argument type="_143" location="f1:76" file="f1" line="76"/> + </Function> + <Function id="_118" name="__builtin_sqrtf" returns="_143" context="_1" mangled="sqrtf" demangled="short" location="f1:82" file="f1" line="82" extern="1" attributes="nothrow"> + <Argument type="_143" location="f1:82" file="f1" line="82"/> + </Function> + <Function id="_119" name="__builtin_log" returns="_142" context="_1" mangled="log" demangled="long" location="f1:62" file="f1" line="62" extern="1" attributes="nothrow"> + <Argument type="_142" location="f1:62" file="f1" line="62"/> + </Function> + <Function id="_120" name="__builtin_exp" returns="_142" context="_1" mangled="exp" demangled="long double" location="f1:45" file="f1" line="45" extern="1" attributes="nothrow"> + <Argument type="_142" location="f1:45" file="f1" line="45"/> + </Function> + <Function id="_121" name="__builtin_cos" returns="_142" context="_1" mangled="cos" demangled="char" location="f1:39" file="f1" line="39" extern="1" attributes="nothrow pure"> + <Argument type="_142" location="f1:39" file="f1" line="39"/> + </Function> + <Function id="_122" name="__builtin_sin" returns="_142" context="_1" mangled="sin" demangled="short" location="f1:75" file="f1" line="75" extern="1" attributes="nothrow pure"> + <Argument type="_142" location="f1:75" file="f1" line="75"/> + </Function> + <Function id="_123" name="__builtin_sqrt" returns="_142" context="_1" mangled="sqrt" demangled="short" location="f1:81" file="f1" line="81" extern="1" attributes="nothrow"> + <Argument type="_142" location="f1:81" file="f1" line="81"/> + </Function> + <Function id="_124" name="__builtin_fabsl" returns="_141" context="_1" location="f1:50" file="f1" line="50" extern="1" attributes="nothrow const"> + <Argument type="_141" location="f1:50" file="f1" line="50"/> + </Function> + <Function id="_125" name="__builtin_fabsf" returns="_143" context="_1" location="f1:49" file="f1" line="49" extern="1" attributes="nothrow const"> + <Argument type="_143" location="f1:49" file="f1" line="49"/> + </Function> + <Function id="_126" name="__builtin_fabs" returns="_142" context="_1" location="f1:48" file="f1" line="48" extern="1" attributes="nothrow const"> + <Argument type="_142" location="f1:48" file="f1" line="48"/> + </Function> + <Namespace id="_127" name="typedef_" context="_1" members="_152 _151 " mangled="_Z8typedef_" demangled="typedef_"/> + <Namespace id="_128" name="fundamental" context="_1" members="_153 _154 " mangled="_Z11fundamental" demangled="fundamental"/> + <Namespace id="_129" name="function_call" context="_1" members="_155 _156 " mangled="_Z13function_call" demangled="function_call"/> + <Namespace id="_130" name="fx" context="_1" members="_157 _158 " mangled="_Z2fx" demangled="fx"/> + <Namespace id="_131" name="ns1" context="_1" members="_159 " mangled="_Z3ns1" demangled="ns1"/> + <FundamentalType id="_132" name="void" align="8"/> + <ReferenceType id="_133" type="_152c" size="64" align="64"/> + <Enumeration id="_134" name="fruit" context="_159" location="f0:11" file="f0" line="11" artificial="1" size="32" align="32"> + <EnumValue name="apple" init="0"/> + <EnumValue name="orange" init="1"/> + </Enumeration> + <FundamentalType id="_135" name="complex long double" size="256" align="128"/> + <FundamentalType id="_136" name="complex double" size="128" align="64"/> + <FundamentalType id="_137" name="complex float" size="64" align="32"/> + <FundamentalType id="_138" name="int" size="32" align="32"/> + <FundamentalType id="_139" name="long long int" size="64" align="64"/> + <FundamentalType id="_140" name="long int" size="64" align="64"/> + <FundamentalType id="_141" name="long double" size="128" align="128"/> + <FundamentalType id="_142" name="double" size="64" align="64"/> + <FundamentalType id="_143" name="float" size="32" align="32"/> + <PointerType id="_144" type="_141" size="64" align="64"/> + <PointerType id="_145" type="_143" size="64" align="64"/> + <PointerType id="_146" type="_138" size="64" align="64"/> + <PointerType id="_147" type="_132c" size="64" align="64"/> + <PointerType id="_148" type="_132" size="64" align="64"/> + <FundamentalType id="_149" name="unsigned int" size="32" align="32"/> + <PointerType id="_150" type="_162c" size="64" align="64"/> + <Struct id="_151" name="original_name" context="_127" mangled="N8typedef_13original_nameE" demangled="typedef_::original_name" location="f0:38" file="f0" line="38" artificial="1" size="8" align="8" members="_164 _165 " bases=""/> + <Typedef id="_152" name="alias" type="_151" context="_127" location="f0:42" file="f0" line="42"/> + <Function id="_153" name="fix_fundamental" returns="_132" context="_128" mangled="_ZN11fundamental15fix_fundamentalEj" demangled="fundamental::fix_fundamental(unsigned)" location="f0:32" file="f0" line="32" extern="1"> + <Argument name="v" type="_149" location="f0:32" file="f0" line="32" default="eggs"/> + </Function> + <Enumeration id="_154" name="spam" context="_128" location="f0:31" file="f0" line="31" artificial="1" size="32" align="32"> + <EnumValue name="eggs" init="0"/> + </Enumeration> + <Function id="_155" name="fix_function_call" returns="_132" context="_129" mangled="_ZN13function_call17fix_function_callEi" demangled="function_call::fix_function_call(int)" location="f0:27" file="f0" line="27" extern="1"> + <Argument name="i" type="_138" location="f0:27" file="f0" line="27" default="function_call::calc(int, int, int)(1, 2, 3)"/> + </Function> + <Function id="_156" name="calc" returns="_138" context="_129" mangled="_ZN13function_call4calcEiii" demangled="function_call::calc(int, int, int)" location="f0:26" file="f0" line="26" endline="26" inline="1"> + <Argument type="_138" location="f0:26" file="f0" line="26"/> + <Argument type="_138" location="f0:26" file="f0" line="26"/> + <Argument type="_138" location="f0:26" file="f0" line="26"/> + </Function> + <Function id="_157" name="fix_unnamed" returns="_132" context="_130" mangled="_ZN2fx11fix_unnamedEi" demangled="fx::fix_unnamed(int)" location="f0:22" file="f0" line="22" extern="1"> + <Argument name="x" type="_138" location="f0:22" file="f0" line="22" default="unnamed"/> + </Function> + <Enumeration id="_158" name="._0" context="_130" location="f0:21" file="f0" line="21" artificial="1" size="32" align="32"> + <EnumValue name="unnamed" init="0"/> + </Enumeration> + <Namespace id="_159" name="ns2" context="_131" members="_134 " mangled="_ZN3ns13ns2E" demangled="ns1::ns2"/> + <Constructor id="_164" name="original_name" artificial="1" throw="" context="_151" access="public" mangled="_ZN8typedef_13original_nameC1ERKS0_ *INTERNAL* " demangled="typedef_::original_name::original_name(typedef_::original_name const&)" location="f0:38" file="f0" line="38" inline="1"> + <Argument name="_ctor_arg" type="_166" location="f0:38" file="f0" line="38"/> + </Constructor> + <Constructor id="_165" name="original_name" explicit="1" context="_151" access="public" mangled="_ZN8typedef_13original_nameC1Ev *INTERNAL* " demangled="typedef_::original_name::original_name()" location="f0:39" file="f0" line="39" endline="39" inline="1"/> + <ReferenceType id="_166" type="_151c" size="64" align="64"/> + <FundamentalType id="_162" name="char" size="8" align="8"/> + <CvQualifiedType id="_162c" type="_162" const="1"/> + <CvQualifiedType id="_132c" type="_132" const="1"/> + <CvQualifiedType id="_151c" type="_151" const="1"/> + <CvQualifiedType id="_152c" type="_152" const="1"/> + <File id="f0" name="/home/gotti/pygccxml-0.8.1/unittests/data/patcher.hpp"/> + <File id="f1" name="/usr/local/share/gccxml-0.7/GCC/4.1/gccxml_builtins.h"/> +</GCC_XML> Modified: pygccxml_dev/unittests/patcher_tester.py =================================================================== --- pygccxml_dev/unittests/patcher_tester.py 2006-08-26 08:16:46 UTC (rev 473) +++ pygccxml_dev/unittests/patcher_tester.py 2006-08-26 12:14:17 UTC (rev 474) @@ -3,6 +3,7 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +import os import unittest import autoconfig import parser_test_case @@ -11,20 +12,26 @@ from pygccxml import parser from pygccxml import declarations -class tester_t( parser_test_case.parser_test_case_t ): +class tester_impl_t( parser_test_case.parser_test_case_t ): decls = None - def __init__(self, *args): + def __init__(self, architecture, *args): parser_test_case.parser_test_case_t.__init__(self, *args) + self.architecture = architecture self.__decls = None def setUp( self ): - if tester_t.decls is None: - reader = parser.source_reader_t( self.config ) - tester_t.decls = reader.read_file( 'patcher.hpp' ) - self.__decls = tester_t.decls - + reader = parser.source_reader_t( self.config ) + if 32 == self.architecture: + self.__decls = reader.read_file( 'patcher.hpp' ) + else: + original_get_architecture = utils.get_architecture + utils.get_architecture = lambda: 64 + self.__decls = reader.read_xml_file( + os.path.join( autoconfig.data_directory, 'patcher_tester_64bit.xml' ) ) + utils.get_architecture = original_get_architecture + def test_enum_patcher(self): fix_enum = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_enum' ) self.failUnless( fix_enum, "Free function fix_enum has not been found." ) @@ -35,8 +42,11 @@ def test_numeric_patcher(self): fix_numeric = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_numeric' ) self.failUnless( fix_numeric, "Free function fix_numeric has not been found." ) - self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffff" ) - + if 32 == self.architecture: + self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffff" ) + else: + self.failUnless( fix_numeric.arguments[0].default_value == u"0ffffffff" ) + def test_unnamed_enum_patcher(self): fix_unnamed = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_unnamed' ) self.failUnless( fix_unnamed, "Free function fix_unnamed has not been found." ) @@ -57,9 +67,18 @@ self.failUnless( typedef__func, "Free function typedef__func has not been found." ) self.failUnless( typedef__func.arguments[0].default_value == u"::typedef_::alias( )" ) +class tester_32_t( tester_impl_t ): + def __init__(self, *args): + tester_impl_t.__init__(self, 32, *args) + +class tester_64_t( tester_impl_t ): + def __init__(self, *args): + tester_impl_t.__init__(self, 64, *args) + def create_suite(): suite = unittest.TestSuite() - suite.addTest( unittest.makeSuite(tester_t)) + suite.addTest( unittest.makeSuite(tester_32_t)) + suite.addTest( unittest.makeSuite(tester_64_t)) return suite def run_suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-08-30 05:18:22
|
Revision: 492 Author: roman_yakovenko Date: 2006-08-29 22:18:13 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=492&view=rev Log Message: ----------- small improvement for getting function overloads Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/unittests/core_tester.py Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2006-08-29 14:07:44 UTC (rev 491) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2006-08-30 05:18:13 UTC (rev 492) @@ -156,16 +156,12 @@ if not self.parent: return [] # finding all functions with the same name - overloaded_funcs \ - = algorithm.find_all_declarations( self.parent.declarations - , type=calldef_t - , name=self.name - , recursive=False ) - if not overloaded_funcs: - return overloaded_funcs - overloaded_funcs_ids = map( id, overloaded_funcs ) - index = overloaded_funcs_ids.index( id( self ) ) - return overloaded_funcs[:index] + overloaded_funcs[index+1:] + return self.parent.calldefs( + name=self.name + , function=lambda decl: not (decl is self ) + , allow_empty=True + , recursive=False ) + overloads = property( _get_overloads , doc="""A list of overloaded "callables" (i.e. other callables with the same name within the same scope. @type: list of L{calldef_t}""" ) Modified: pygccxml_dev/unittests/core_tester.py =================================================================== --- pygccxml_dev/unittests/core_tester.py 2006-08-29 14:07:44 UTC (rev 491) +++ pygccxml_dev/unittests/core_tester.py 2006-08-30 05:18:13 UTC (rev 492) @@ -36,9 +36,9 @@ , 'core_overloads_1.hpp' , 'core_overloads_2.hpp' , 'abstract_classes.hpp' - ] + ] self.global_ns = None - + def setUp(self): if not core_t.global_ns: decls = parse( self.test_files, self.config, self.COMPILATION_MODE ) @@ -50,7 +50,7 @@ def test_top_parent(self): enum = self.global_ns.enum( '::ns::ns32::E33' ) self.failUnless( self.global_ns is enum.top_parent ) - + #tests namespaces join functionality. described in gccxml.py def test_nss_join(self): #list of all namespaces @@ -114,7 +114,7 @@ self.failUnless( nested_enum1 is nested_enum2 , "enum accessed through access definition('%s') and through declarations('%s') are different enums or instances." \ %( nested_enum1.name, nested_enum2.name ) ) - + #check whether we meaning same class instance self.failUnless( class_inst is nested_enum1.parent is nested_enum2.parent , 'There are 2 or more instances of ns namespace.' ) @@ -124,7 +124,7 @@ core_membership = self.global_ns.namespace( 'membership' ) self._test_ns_membership( self.global_ns, 'EGlobal' ) self._test_ns_membership( core_membership.namespace('enums_ns'), 'EWithin' ) - self._test_ns_membership( core_membership.namespace( '' ), 'EWithinUnnamed' ) + self._test_ns_membership( core_membership.namespace( '' ), 'EWithinUnnamed' ) class_nested_enums = core_membership.class_( 'class_for_nested_enums_t' ) self._test_class_membership( class_nested_enums, 'ENestedPublic', ACCESS_TYPES.PUBLIC ) self._test_class_membership( class_nested_enums, 'ENestedProtected', ACCESS_TYPES.PROTECTED ) @@ -193,28 +193,28 @@ % (typedef.type.decl_string, fundamental_type.decl_string) ) def test_compound_types(self): - typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_const_int' ) + typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_const_int' ) self._test_type_composition( typedef_inst.type, const_t, int_t ) - typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_pointer_int' ) + typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_pointer_int' ) self._test_type_composition( typedef_inst.type, pointer_t, int_t ) - typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_reference_int' ) + typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_reference_int' ) self._test_type_composition( typedef_inst.type, reference_t, int_t ) - typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_const_unsigned_int_const_pointer' ) + typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_const_unsigned_int_const_pointer' ) self._test_type_composition( typedef_inst.type, const_t, pointer_t ) self._test_type_composition( typedef_inst.type.base, pointer_t, const_t ) self._test_type_composition( typedef_inst.type.base.base, const_t, unsigned_int_t ) - typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_volatile_int' ) + typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_volatile_int' ) self._test_type_composition( typedef_inst.type, volatile_t, int_t ) - var_inst = self.global_ns.variable( 'array255' ) + var_inst = self.global_ns.variable( 'array255' ) self._test_type_composition( var_inst.type, array_t, int_t ) - typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_EFavoriteDrinks' ) + typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_EFavoriteDrinks' ) self.failUnless( isinstance( typedef_inst.type, declarated_t ) , " typedef to enum should be 'declarated_t' instead of '%s'" % typedef_inst.type.__class__.__name__ ) enum_declaration = self.global_ns.enum( 'EFavoriteDrinks' ) @@ -223,7 +223,7 @@ % ( typedef_inst.type.declaration.name, enum_declaration.name ) ) def test_free_function_type(self): - function_ptr = self.global_ns.decl( decl_type=typedef_t, name='function_ptr' ) + function_ptr = self.global_ns.decl( decl_type=typedef_t, name='function_ptr' ) self._test_type_composition( function_ptr.type, pointer_t, free_function_type_t ) function_type = function_ptr.type.base self.failUnless( isinstance( function_type.return_type, int_t ) @@ -240,7 +240,7 @@ %( 'double_t', function_type.arguments_types[0].__class__.__name__ ) ) def test_member_function_type(self): - function_ptr = self.global_ns.decl( decl_type=typedef_t, name='member_function_ptr_t') + function_ptr = self.global_ns.decl( decl_type=typedef_t, name='member_function_ptr_t') self._test_type_composition( function_ptr.type, pointer_t, member_function_type_t ) function_type = function_ptr.type.base @@ -262,7 +262,7 @@ %( 'double_t', function_type.arguments_types[0].__class__.__name__ ) ) def test_member_variable_type(self): - mv = self.global_ns.decl( decl_type=typedef_t, name='member_variable_ptr_t') + mv = self.global_ns.decl( decl_type=typedef_t, name='member_variable_ptr_t') self._test_type_composition( mv.type, pointer_t, member_variable_type_t ) members_pointers = self.global_ns.class_( 'members_pointers_t' ) @@ -282,7 +282,7 @@ % ( 4, len(do_nothings) ) ) for index, do_nothing in enumerate(do_nothings): others = do_nothings[:index] + do_nothings[index+1:] - self.failUnless( do_nothing.overloads == others + self.failUnless( set( do_nothing.overloads ) == set( others ) , "there is a difference between expected function overloads and existing ones." ) def test_abstract_classes(self): @@ -320,7 +320,7 @@ core_t.__init__(self, *args) def create_suite(): - suite = unittest.TestSuite() + suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(core_all_at_once_t)) suite.addTest( unittest.makeSuite(core_all_at_once_no_opt_t)) suite.addTest( unittest.makeSuite(core_file_by_file_t)) @@ -342,4 +342,4 @@ ##~ statistics = hotshot.stats.load( statistics_file ) ##~ statistics.strip_dirs() ##~ statistics.sort_stats( 'time', 'calls' ) -##~ statistics.print_stats( 678 ) \ No newline at end of file +##~ statistics.print_stats( 678 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-02-17 11:53:01
|
Revision: 910 http://svn.sourceforge.net/pygccxml/?rev=910&view=rev Author: roman_yakovenko Date: 2007-02-17 03:53:00 -0800 (Sat, 17 Feb 2007) Log Message: ----------- fixing few regression failures, caused by some changes in gccxml Modified Paths: -------------- pygccxml_dev/unittests/data/patcher.hpp pygccxml_dev/unittests/demangled_tester.py Modified: pygccxml_dev/unittests/data/patcher.hpp =================================================================== --- pygccxml_dev/unittests/data/patcher.hpp 2007-02-16 21:59:29 UTC (rev 909) +++ pygccxml_dev/unittests/data/patcher.hpp 2007-02-17 11:53:00 UTC (rev 910) @@ -6,6 +6,7 @@ #ifndef __patcher_hpp__ #define __patcher_hpp__ +#include <string> #include <vector> namespace ns1{ namespace ns2{ Modified: pygccxml_dev/unittests/demangled_tester.py =================================================================== --- pygccxml_dev/unittests/demangled_tester.py 2007-02-16 21:59:29 UTC (rev 909) +++ pygccxml_dev/unittests/demangled_tester.py 2007-02-17 11:53:00 UTC (rev 910) @@ -36,7 +36,7 @@ demangled = self.global_ns.namespace( 'demangled' ) if 32 == self.architecture: cls = demangled.class_( 'item_t<3740067437l, 11l, 2147483648l>' ) - self.failUnless( cls._name == 'item_t<0deece66d,11,080000000>' ) + self.failUnless( cls._name == 'item_t<0x0deece66d,11,0x080000000>' ) else: cls = demangled.class_( "item_t<25214903917l, 11l, 2147483648l>" ) self.failUnless( cls._name == 'item_t<25214903917,11,2147483648>' ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-02-24 18:37:52
|
Revision: 922 http://svn.sourceforge.net/pygccxml/?rev=922&view=rev Author: roman_yakovenko Date: 2007-02-24 10:37:52 -0800 (Sat, 24 Feb 2007) Log Message: ----------- adding new test case for free functions name mangling Modified Paths: -------------- pygccxml_dev/unittests/data/demangled.hpp pygccxml_dev/unittests/demangled_tester.py Modified: pygccxml_dev/unittests/data/demangled.hpp =================================================================== --- pygccxml_dev/unittests/data/demangled.hpp 2007-02-23 18:21:40 UTC (rev 921) +++ pygccxml_dev/unittests/data/demangled.hpp 2007-02-24 18:37:52 UTC (rev 922) @@ -24,4 +24,6 @@ } +void set_a(); + #endif//__demangled_hpp \ No newline at end of file Modified: pygccxml_dev/unittests/demangled_tester.py =================================================================== --- pygccxml_dev/unittests/demangled_tester.py 2007-02-23 18:21:40 UTC (rev 921) +++ pygccxml_dev/unittests/demangled_tester.py 2007-02-24 18:37:52 UTC (rev 922) @@ -41,6 +41,12 @@ cls = demangled.class_( "item_t<25214903917l, 11l, 2147483648l>" ) self.failUnless( cls._name == 'item_t<25214903917,11,2147483648>' ) + def test_free_function( self ): + f = self.global_ns.free_functions('set_a', allow_empty=True) + if not f: + return + f = f[0] + self.failUnless( f.mangled ) class tester_32_t( tester_impl_t ): def __init__(self, *args): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-06-24 04:28:31
|
Revision: 1077 http://svn.sourceforge.net/pygccxml/?rev=1077&view=rev Author: roman_yakovenko Date: 2007-06-23 21:28:27 -0700 (Sat, 23 Jun 2007) Log Message: ----------- committing attributes_tester.py Added Paths: ----------- pygccxml_dev/unittests/attributes_tester.py pygccxml_dev/unittests/data/attributes.hpp Added: pygccxml_dev/unittests/attributes_tester.py =================================================================== --- pygccxml_dev/unittests/attributes_tester.py (rev 0) +++ pygccxml_dev/unittests/attributes_tester.py 2007-06-24 04:28:27 UTC (rev 1077) @@ -0,0 +1,43 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + global_ns = None + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'attributes.hpp' + + def setUp(self): + if not tester_t.global_ns: + decls = parser.parse( [self.header], self.config ) + tester_t.global_ns = declarations.get_global_namespace( decls ) + tester_t.global_ns.init_optimizer() + + def test( self ): + numeric = self.global_ns.class_( 'numeric_t' ) + self.failUnless( None is numeric.attributes ) + do_nothing = numeric.mem_fun( 'do_nothing' ) + self.failUnless( "gccxml(no throw)" == do_nothing.attributes ) + arg = do_nothing.arguments[0] + self.failUnless( "gccxml(out)" == arg.attributes ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Added: pygccxml_dev/unittests/data/attributes.hpp =================================================================== --- pygccxml_dev/unittests/data/attributes.hpp (rev 0) +++ pygccxml_dev/unittests/data/attributes.hpp 2007-06-24 04:28:27 UTC (rev 1077) @@ -0,0 +1,24 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __atributes_hpp__ +#define __atributes_hpp__ + +#define _out_ __attribute( (gccxml( "out" ) ) ) +#define _sealed_ __attribute( (gccxml( "sealed" ) ) ) +#define _no_throw_ __attribute( (gccxml( "no throw" ) ) ) + +namespace attributes{ + +_sealed_ struct numeric_t{ + + _no_throw_ void do_nothing( _out_ int& x ){} + +}; + +} + +#endif//__atributes_hpp__ + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-11-07 21:24:53
|
Revision: 1129 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1129&view=rev Author: roman_yakovenko Date: 2007-11-07 13:24:58 -0800 (Wed, 07 Nov 2007) Log Message: ----------- testing GCCXML 0.9 related changes Modified Paths: -------------- pygccxml_dev/unittests/autoconfig.py pygccxml_dev/unittests/cache_enums_tester.py pygccxml_dev/unittests/data/core_cache.hpp pygccxml_dev/unittests/data/type_traits.hpp pygccxml_dev/unittests/declarations_tester.py pygccxml_dev/unittests/demangled_tester.py pygccxml_dev/unittests/patcher_tester.py Modified: pygccxml_dev/unittests/autoconfig.py =================================================================== --- pygccxml_dev/unittests/autoconfig.py 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/autoconfig.py 2007-11-07 21:24:58 UTC (rev 1129) @@ -11,17 +11,18 @@ #import pychecker.checker compiler = None -gccxml_path = '' data_directory = os.path.abspath( os.path.join( os.curdir, 'data' ) ) build_dir = os.path.abspath( os.path.join( os.curdir, 'temp' ) ) -if 'roman' in getpass.getuser(): - if sys.platform == 'win32': - compiler = 'msvc71' - gccxml_path = r'D:/dev/gccxml/gccxml.exe' - else: - gccxml_path = '/home/roman/gccxml/bin/gccxml' +gccxml_07_path = os.path.abspath( os.path.join( '..', '..', 'gccxml_bin', 'v07', sys.platform, 'bin' ) ) +gccxml_09_path = os.path.abspath( os.path.join( '..', '..', 'gccxml_bin', 'v09', sys.platform, 'bin' ) ) +gccxml_path = gccxml_09_path +gccxml_version = '__GCCXML_09__' + +if sys.platform == 'win32': + compiler = 'msvc71' + try: import pygccxml print 'unittests will run on INSTALLED version' @@ -35,6 +36,7 @@ class cxx_parsers_cfg: gccxml = pygccxml.parser.gccxml_configuration_t( gccxml_path=gccxml_path , working_directory=data_directory + , define_symbols=[ gccxml_version ] , compiler=compiler ) synopsis = pygccxml.parser.synopsis_configuration_t( working_directory=data_directory ) Modified: pygccxml_dev/unittests/cache_enums_tester.py =================================================================== --- pygccxml_dev/unittests/cache_enums_tester.py 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/cache_enums_tester.py 2007-11-07 21:24:58 UTC (rev 1129) @@ -38,8 +38,9 @@ color2 = declarations.matcher.get_single( enum_matcher, decls2 ) self.failUnless( color1.values == color2.values ) -class synopsis_tester_t( tester_impl_t ): - CXX_PARSER_CFG = autoconfig.cxx_parsers_cfg.synopsis +#there is no progress with this parser +#class synopsis_tester_t( tester_impl_t ): +# CXX_PARSER_CFG = autoconfig.cxx_parsers_cfg.synopsis class gccxml_tester_t( tester_impl_t ): CXX_PARSER_CFG = autoconfig.cxx_parsers_cfg.gccxml @@ -47,7 +48,7 @@ def create_suite(): suite = unittest.TestSuite() - suite.addTest( unittest.makeSuite(synopsis_tester_t)) + #suite.addTest( unittest.makeSuite(synopsis_tester_t)) suite.addTest( unittest.makeSuite(gccxml_tester_t)) return suite Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/data/core_cache.hpp 2007-11-07 21:24:58 UTC (rev 1129) @@ -22,4 +22,4 @@ #endif//__core_cache_hpp__ -//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch \ No newline at end of file +//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch \ No newline at end of file Modified: pygccxml_dev/unittests/data/type_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/type_traits.hpp 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/data/type_traits.hpp 2007-11-07 21:24:58 UTC (rev 1129) @@ -1,3 +1,4 @@ + // Copyright 2004 Roman Yakovenko. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -79,10 +80,16 @@ namespace yes{ typedef detail::x x; +#ifdef __GCCXML_09__ + typedef detail::y_type y_type; +#endif//__GCCXML_09__ + } namespace no{ typedef std::string string_type; +#ifdef __GCCXML_07__ typedef detail::y_type y_type; +#endif//__GCCXML_07__ } } Modified: pygccxml_dev/unittests/declarations_tester.py =================================================================== --- pygccxml_dev/unittests/declarations_tester.py 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/declarations_tester.py 2007-11-07 21:24:58 UTC (rev 1129) @@ -47,9 +47,16 @@ def test_variables(self): variables = self.global_ns.namespace( 'variables' ) initialized = self.global_ns.variable( name='initialized' ) - self.failUnless( initialized.value == '10122004' + + expected_value = None + if '0.9' in initialized.compiler: + expected_value = '10122004ul' + else: + expected_value = '10122004' + + self.failUnless( initialized.value == expected_value , "there is a difference between expected value( %s ) and real value(%s) of 'initialized' variable" \ - % ( '10122004', initialized.value ) ) + % ( expected_value, initialized.value ) ) self._test_type_composition( initialized.type, const_t, long_unsigned_int_t ) static_var = initialized = self.global_ns.variable( name='static_var' ) @@ -173,4 +180,4 @@ unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": - run_suite() \ No newline at end of file + run_suite() Modified: pygccxml_dev/unittests/demangled_tester.py =================================================================== --- pygccxml_dev/unittests/demangled_tester.py 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/demangled_tester.py 2007-11-07 21:24:58 UTC (rev 1129) @@ -35,8 +35,12 @@ def test( self ): demangled = self.global_ns.namespace( 'demangled' ) if 32 == self.architecture: - cls = demangled.class_( 'item_t<3740067437l, 11l, 2147483648l>' ) - self.failUnless( cls._name == 'item_t<0x0deece66d,11,0x080000000>' ) + if '0.9' in demangled.compiler: + cls = demangled.class_( 'item_t<3740067437ul, 11ul, 2147483648ul>' ) + self.failUnless( cls._name == 'item_t<-554899859ul,11ul,-2147483648ul>' ) + else: + cls = demangled.class_( 'item_t<3740067437l, 11l, 2147483648l>' ) + self.failUnless( cls._name == 'item_t<0x0deece66d,11,0x080000000>' ) else: cls = demangled.class_( "item_t<25214903917l, 11l, 2147483648l>" ) self.failUnless( cls._name == 'item_t<25214903917,11,2147483648>' ) @@ -67,4 +71,4 @@ unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": - run_suite() \ No newline at end of file + run_suite() Modified: pygccxml_dev/unittests/patcher_tester.py =================================================================== --- pygccxml_dev/unittests/patcher_tester.py 2007-11-07 21:24:10 UTC (rev 1128) +++ pygccxml_dev/unittests/patcher_tester.py 2007-11-07 21:24:58 UTC (rev 1129) @@ -27,7 +27,10 @@ def test_numeric_patcher(self): fix_numeric = self.global_ns.free_fun( 'fix_numeric' ) if 32 == self.architecture: - self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffff" ) + if '0.9' in fix_numeric.compiler: + self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffffu" ) + else: + self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffff" ) else: self.failUnless( fix_numeric.arguments[0].default_value == u"0ffffffff" ) @@ -37,7 +40,10 @@ def test_function_call_patcher(self): fix_function_call = self.global_ns.free_fun( 'fix_function_call' ) - self.failUnless( fix_function_call.arguments[0].default_value == u"function_call::calc( 1, 2, 3 )" ) + if '0.9' in fix_function_call.compiler: + self.failUnless( fix_function_call.arguments[0].default_value == u"function_call::calc(1, 2, 3)" ) + else: + self.failUnless( fix_function_call.arguments[0].default_value == u"function_call::calc( 1, 2, 3 )" ) def test_fundamental_patcher(self): fcall = self.global_ns.free_fun( 'fix_fundamental' ) @@ -45,13 +51,21 @@ def test_constructor_patcher(self): typedef__func = self.global_ns.free_fun( 'typedef__func' ) - self.failUnless( typedef__func.arguments[0].default_value == u"::typedef_::alias( )" ) + if '0.9' in typedef__func.compiler: + self.failUnless( typedef__func.arguments[0].default_value == u"typedef_::original_name()" ) + else: + self.failUnless( typedef__func.arguments[0].default_value == u"::typedef_::alias( )" ) if 32 == self.architecture: clone_tree = self.global_ns.free_fun( 'clone_tree' ) - default_values = [ - 'vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >()' - , 'vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >((&allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >()))' - ] + default_values = [] + if '0.9' in clone_tree.compiler: + default_values = [ + ] + else: + default_values = [ + 'vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >()' + , 'vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >((&allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >()))' + ] self.failUnless( clone_tree.arguments[0].default_value in default_values) class tester_32_t( tester_impl_t ): @@ -59,7 +73,6 @@ def __init__(self, *args): tester_impl_t.__init__(self, 32, *args) - def setUp( self ): if not tester_32_t.global_ns: reader = parser.source_reader_t( self.config ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-11-22 21:56:21
|
Revision: 1171 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1171&view=rev Author: roman_yakovenko Date: 2007-11-22 13:56:26 -0800 (Thu, 22 Nov 2007) Log Message: ----------- adding new better(user supplied) unittest for copy constructor related type traits Added Paths: ----------- pygccxml_dev/unittests/copy_constructor_tester.py pygccxml_dev/unittests/data/ogre1.4.xml.bz2 Added: pygccxml_dev/unittests/copy_constructor_tester.py =================================================================== --- pygccxml_dev/unittests/copy_constructor_tester.py (rev 0) +++ pygccxml_dev/unittests/copy_constructor_tester.py 2007-11-22 21:56:26 UTC (rev 1171) @@ -0,0 +1,46 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.global_ns = None + + def setUp(self): + if not self.global_ns: + xml_file = os.path.join( autoconfig.data_directory, 'ogre1.4.xml' ) + reader = parser.source_reader_t( autoconfig.cxx_parsers_cfg.gccxml ) + self.global_ns = declarations.get_global_namespace( reader.read_xml_file(xml_file) ) + self.global_ns.init_optimizer() + + def test( self ): + for x in self.global_ns.typedefs( 'SettingsMultiMap' ): + self.failUnless( not declarations.is_noncopyable( x ) ) + + for x in self.global_ns.typedefs( 'SettingsIterator' ): + self.failUnless( not declarations.is_noncopyable( x ) ) + + for x in self.global_ns.typedefs( 'SectionIterator' ): + self.failUnless( not declarations.is_noncopyable( x ) ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Added: pygccxml_dev/unittests/data/ogre1.4.xml.bz2 =================================================================== (Binary files differ) Property changes on: pygccxml_dev/unittests/data/ogre1.4.xml.bz2 ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-05-23 18:39:31
|
Revision: 154 Author: roman_yakovenko Date: 2006-05-23 11:38:46 -0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=154&view=rev Log Message: ----------- adding java fundamental types Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/unittests/core_tester.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-05-23 14:37:46 UTC (rev 153) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-05-23 18:38:46 UTC (rev 154) @@ -54,7 +54,19 @@ from cpptypes import member_variable_type_t from cpptypes import declarated_t from cpptypes import type_qualifiers_t +#java types +from cpptypes import java_fundamental_t +from cpptypes import jbyte_t +from cpptypes import jshort_t +from cpptypes import jint_t +from cpptypes import jlong_t +from cpptypes import jfloat_t +from cpptypes import jdouble_t +from cpptypes import jchar_t +from cpptypes import jboolean_t + + from variable import variable_t from algorithm import full_name Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2006-05-23 14:37:46 UTC (rev 153) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2006-05-23 18:38:46 UTC (rev 154) @@ -89,7 +89,11 @@ def _clone_impl( self ): return self - + +class java_fundamental_t( fundamental_t ): + def __init__( self, name ): + fundamental_t.__init__( self, name ) + class void_t( fundamental_t ): CPPNAME = 'void' def __init__( self ): @@ -185,6 +189,48 @@ def __init__( self ): fundamental_t.__init__( self, complex_float_t.CPPNAME ) +class jbyte_t( java_fundamental_t ): + JNAME = 'jbyte' + def __init__( self ): + java_fundamental_t.__init__( self, jbyte_t.JNAME ) + +class jshort_t( java_fundamental_t ): + JNAME = 'jshort' + def __init__( self ): + java_fundamental_t.__init__( self, jshort_t.JNAME ) + +class jint_t( java_fundamental_t ): + JNAME = 'jint' + def __init__( self ): + java_fundamental_t.__init__( self, jint_t.JNAME ) + +class jlong_t( java_fundamental_t ): + JNAME = 'jlong' + def __init__( self ): + java_fundamental_t.__init__( self, jlong_t.JNAME ) + +class jfloat_t( java_fundamental_t ): + JNAME = 'jfloat' + def __init__( self ): + java_fundamental_t.__init__( self, jfloat_t.JNAME ) + + +class jdouble_t( java_fundamental_t ): + JNAME = 'jdouble' + def __init__( self ): + java_fundamental_t.__init__( self, jdouble_t.JNAME ) + + +class jchar_t( java_fundamental_t ): + JNAME = 'jchar' + def __init__( self ): + java_fundamental_t.__init__( self, jchar_t.JNAME ) + +class jboolean_t( java_fundamental_t ): + JNAME = 'jboolean' + def __init__( self ): + java_fundamental_t.__init__( self, jboolean_t.JNAME ) + FUNDAMENTAL_TYPES = { void_t.CPPNAME : void_t() , char_t.CPPNAME : char_t() @@ -208,6 +254,24 @@ , complex_long_double_t.CPPNAME : complex_long_double_t() , complex_double_t.CPPNAME : complex_double_t() , complex_float_t.CPPNAME : complex_float_t() + ##adding java types + , jbyte_t.JNAME : jbyte_t() + , jshort_t.JNAME : jshort_t() + , jint_t.JNAME : jint_t() + , jlong_t.JNAME : jlong_t() + , jfloat_t.JNAME : jfloat_t() + , jdouble_t.JNAME : jdouble_t() + , jchar_t.JNAME : jchar_t() + , jboolean_t.JNAME : jboolean_t() + , '__java_byte' : jbyte_t() + , '__java_short' : jshort_t() + , '__java_int' : jint_t() + , '__java_long' : jlong_t() + , '__java_float' : jfloat_t() + , '__java_double' : jdouble_t() + , '__java_char' : jchar_t() + , '__java_boolean' : jboolean_t() + } ################################################################################ Modified: pygccxml_dev/unittests/core_tester.py =================================================================== --- pygccxml_dev/unittests/core_tester.py 2006-05-23 14:37:46 UTC (rev 153) +++ pygccxml_dev/unittests/core_tester.py 2006-05-23 18:38:46 UTC (rev 154) @@ -184,6 +184,8 @@ for fundamental_type_name, fundamental_type in FUNDAMENTAL_TYPES.iteritems(): if 'complex' in fundamental_type_name: continue #I check this in an other tester + if isinstance( fundamental_type, java_fundamental_t ): + continue #I don't check this at all typedef_name = 'typedef_' + fundamental_type_name.replace( ' ', '_' ) typedef = self.global_ns.decl( decl_type=typedef_t, name=typedef_name ) self.failUnless( typedef, "unable to find typedef to build-in type '%s'" % fundamental_type_name ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-06-07 20:10:19
|
Revision: 210 Author: roman_yakovenko Date: 2006-06-05 07:09:20 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=210&view=rev Log Message: ----------- adding is_vector type traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/type_traits.py Added Paths: ----------- pygccxml_dev/unittests/data/unnamed_classes.hpp pygccxml_dev/unittests/data/vector_traits.hpp pygccxml_dev/unittests/unnamed_classes_tester.py pygccxml_dev/unittests/vector_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-06-05 09:35:05 UTC (rev 209) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-06-05 14:09:20 UTC (rev 210) @@ -142,6 +142,8 @@ from type_traits import find_trivial_constructor from type_traits import has_any_non_copyconstructor +from type_traits import vector_traits + import templates import call_invocation Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 09:35:05 UTC (rev 209) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 14:09:20 UTC (rev 210) @@ -20,6 +20,7 @@ import cpptypes import variable import algorithm +import namespace import enumeration import class_declaration from sets import Set as set @@ -721,14 +722,84 @@ return True return __is_noncopyable_single( class_ ) + + +def is_defined_in_std( cls ): + if not cls.parent: + return False + if not isinstance( cls.parent, namespace.namespace_t ): + return False + if 'std' != cls.parent.name: + return False + + std = cls.parent + if not std.parent: + return False + if not isinstance( std.parent, namespace.namespace_t ): + return False + if '::' != std.parent.name: + return False + global_ns = std.parent + return None is global_ns.parent + +class vector_traits: + + @staticmethod + def declaration_or_none( type ): + global is_defined_in_std + """returns reference to the class declaration or None""" + type = remove_alias( type ) + type = remove_cv( type ) + if not isinstance( type, cpptypes.declarated_t ): + return + + cls = remove_alias( type.declaration ) + if not isinstance( cls, ( class_declaration.class_t, class_declaration.class_declaration_t ) ): + return + + if not cls.name.startswith( 'vector<' ): + return + + if not is_defined_in_std( cls ): + return + return cls + + @staticmethod + def is_vector( type ): + """ + Returns True if type represents instantiation of std class vector, + otherwise False. + """ + return not( None is vector_traits.declaration_or_none( type ) ) + + @staticmethod + def class_declaration( type ): + """returns reference to the class declaration, """ + cls = vector_traits.declaration_or_none( type ) + if not cls: + raise TypeError( 'Type "%s" is not instantiation ov std::vector' % type.decl_string ) + return cls + @staticmethod + def value_type( type ): + """returns reference to value_type of the vector""" + cls = vector_traits.class_declaration( type ) + if isinstance( cls, class_declaration.class_t ): + return cls.typedef( "value_type" ).type + else: + + + + + + \ No newline at end of file Added: pygccxml_dev/unittests/data/unnamed_classes.hpp =================================================================== --- pygccxml_dev/unittests/data/unnamed_classes.hpp (rev 0) +++ pygccxml_dev/unittests/data/unnamed_classes.hpp 2006-06-05 14:09:20 UTC (rev 210) @@ -0,0 +1,51 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __unnamed_classes_hpp__ +#define __unnamed_classes_hpp__ + +namespace unnamed{ + +struct S1{ + struct S2{ + union Flags{ + struct{ + unsigned int hasItemIdList : 1; + unsigned int pointsToFileOrDir : 1; + unsigned int hasDescription : 1; + unsigned int hasRelativePath : 1; + unsigned int hasWorkingDir : 1; + unsigned int hasCmdLineArgs : 1; + unsigned int hasCustomIcon : 1; + unsigned int useWorkingDir : 1; // Seems to need to be set to enable working dir + unsigned int unused : 24; + }; + unsigned int raw; + } flags; + + union FileAttribs{ + struct{ + unsigned int isReadOnly : 1; + unsigned int isHidden : 1; + unsigned int isSystem : 1; + unsigned int isVolumeLabel : 1; + unsigned int isDir : 1; + unsigned int isModified : 1; // =archive bit set, ie; is a file normally + unsigned int isEncrypted : 1; + unsigned int isNormal : 1; // Doesn't seem to get set + unsigned int isTemporary : 1; + unsigned int isSparse : 1; + unsigned int hasReparsePoint : 1; + unsigned int isCompressed : 1; + unsigned int isOffline : 1; + unsigned int unused : 19; + }; + unsigned int raw; + } fileattribs; // in GetFileAttributes() format + } header; +}; + +} // namespace +#endif//__unnamed_classes_hpp__ Added: pygccxml_dev/unittests/data/vector_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/vector_traits.hpp (rev 0) +++ pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 14:09:20 UTC (rev 210) @@ -0,0 +1,59 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <string> +#include <vector> + +struct _0_{}; +typedef std::vector< _0_ > container; + +namespace vector_traits{ +namespace yes{ + struct _1_{ + typedef int value_type; + typedef std::vector< int > container; + }; + + struct _2_{ + typedef _0_ value_type; + typedef std::vector< _0_ > container; + }; + + struct _3_{ + typedef std::string value_type; + typedef std::vector< std::string > container; + }; + + struct _4_{ + typedef std::vector<int> value_type; + typedef std::vector< std::vector<int> > container; + }; + + struct _5_{ + typedef int value_type; + typedef const std::vector< int > container; + }; + + struct _6_{ + typedef const int value_type; + typedef const std::vector< const int > container; + }; + +} + +namespace no{ + struct _1_{ + template< class T > + struct vector{}; + + typedef vector<int> container; + }; + + struct _2_{ + typedef const std::vector< const int >& container; + }; +} + +} \ No newline at end of file Added: pygccxml_dev/unittests/unnamed_classes_tester.py =================================================================== --- pygccxml_dev/unittests/unnamed_classes_tester.py (rev 0) +++ pygccxml_dev/unittests/unnamed_classes_tester.py 2006-06-05 14:09:20 UTC (rev 210) @@ -0,0 +1,40 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'unnamed_classes.hpp' + self.global_ns = None + + def setUp(self): + if not self.global_ns: + decls = parser.parse( [self.header], self.config ) + self.global_ns = declarations.get_global_namespace( decls ) + self.global_ns.init_optimizer() + + def test( self ): + #bf_x = self.global_ns.variable( 'x' ) + #self.failUnless( bf_x.bits == 1 ) + pass + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() \ No newline at end of file Added: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py (rev 0) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 14:09:20 UTC (rev 210) @@ -0,0 +1,48 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE + global_ns = None + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'vector_traits.hpp' + self.global_ns = None + + def setUp(self): + if not tester_t.global_ns: + decls = parser.parse( [self.header], self.config ) + tester_t.global_ns = declarations.get_global_namespace( decls ) + self.global_ns = tester_t.global_ns + + def validate_yes( self, value_type, container ): + traits = declarations.vector_traits + self.failUnless( traits.declaration_or_none( container ) ) + self.failUnless( traits.is_vector( container ) ) + self.failUnless( declarations.is_same( value_type, traits.value_type( container ) ) ) + + def test_global_ns( self ): + value_type = self.global_ns.class_( '_0_' ) + container = self.global_ns.typedef( 'container', recursive=False ) + self.validate_yes( value_type, container ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-06-07 20:11:10
|
Revision: 212 Author: roman_yakovenko Date: 2006-06-05 08:17:25 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=212&view=rev Log Message: ----------- some fixes for vector_traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/data/vector_traits.hpp pygccxml_dev/unittests/vector_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 15:16:30 UTC (rev 211) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 15:17:25 UTC (rev 212) @@ -21,6 +21,7 @@ import variable import algorithm import namespace +import templates import enumeration import class_declaration from sets import Set as set @@ -210,11 +211,17 @@ return type else: return nake_type.base - + +def remove_declarated( type ): + type = remove_alias( type ) + if isinstance( type, cpptypes.declarated_t ): + type = type.declaration + return type + def is_same(type1, type2): """returns True if type1 and type2 are same types""" - nake_type1 = remove_alias( type1 ) - nake_type2 = remove_alias( type2 ) + nake_type1 = remove_declarated( type1 ) + nake_type2 = remove_declarated( type2 ) return nake_type1 == nake_type2 def is_volatile(type): @@ -793,7 +800,15 @@ if isinstance( cls, class_declaration.class_t ): return cls.typedef( "value_type" ).type else: - + value_type_str = templates.args( cls.name )[0] + found = cls.top_parent.classes( value_type_str, allow_empty=True ) + if not found: + if cpptypes.FUNDAMENTAL_TYPES.has_key( value_type_str ): + return cpptypes.FUNDAMENTAL_TYPES[value_type_str] + if len( found ) == 1: + return found[0] + else: + raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string ) Modified: pygccxml_dev/unittests/data/vector_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 15:16:30 UTC (rev 211) +++ pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 15:17:25 UTC (rev 212) @@ -6,39 +6,55 @@ #include <string> #include <vector> + + struct _0_{}; + typedef std::vector< _0_ > container; + namespace vector_traits{ namespace yes{ struct _1_{ typedef int value_type; typedef std::vector< int > container; + + container do_nothing(){}; }; struct _2_{ typedef _0_ value_type; typedef std::vector< _0_ > container; + + container do_nothing(){}; }; struct _3_{ typedef std::string value_type; typedef std::vector< std::string > container; + + container do_nothing(){}; }; struct _4_{ typedef std::vector<int> value_type; typedef std::vector< std::vector<int> > container; + + container do_nothing(){}; }; struct _5_{ typedef int value_type; typedef const std::vector< int > container; + + container do_nothing(){}; }; struct _6_{ typedef const int value_type; typedef const std::vector< const int > container; + + container do_nothing(){}; }; } Modified: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 15:16:30 UTC (rev 211) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 15:17:25 UTC (rev 212) @@ -35,6 +35,16 @@ value_type = self.global_ns.class_( '_0_' ) container = self.global_ns.typedef( 'container', recursive=False ) self.validate_yes( value_type, container ) + + def test_yes( self ): + yes_ns = self.global_ns.namespace( 'yes' ) + for struct in yes_ns.classes(): + if not struct.name.startswith( '_' ): + continue + if not struct.name.endswith( '_' ): + continue + self.validate_yes( struct.typedef( 'value_type' ) + , struct.typedef( 'container' ) ) def create_suite(): suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-06-08 10:42:51
|
Revision: 217 Author: roman_yakovenko Date: 2006-06-08 00:02:03 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=217&view=rev Log Message: ----------- adding is_std_[w]string traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/data/string_traits.hpp pygccxml_dev/unittests/string_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-06-08 05:52:33 UTC (rev 216) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-06-08 07:02:03 UTC (rev 217) @@ -119,6 +119,8 @@ from type_traits import is_base_and_derived from type_traits import is_convertible from type_traits import is_noncopyable +from type_traits import is_std_string +from type_traits import is_std_wstring from type_traits import is_unary_operator from type_traits import is_binary_operator @@ -142,8 +144,11 @@ from type_traits import find_trivial_constructor from type_traits import has_any_non_copyconstructor -from type_traits import vector_traits +from type_traits import vector_traits +from type_traits import smart_pointer_traits + + import templates import call_invocation Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-08 05:52:33 UTC (rev 216) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-08 07:02:03 UTC (rev 217) @@ -790,7 +790,7 @@ """returns reference to the class declaration, """ cls = vector_traits.declaration_or_none( type ) if not cls: - raise TypeError( 'Type "%s" is not instantiation ov std::vector' % type.decl_string ) + raise TypeError( 'Type "%s" is not instantiation of std::vector' % type.decl_string ) return cls @staticmethod @@ -809,14 +809,36 @@ return found[0] else: raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string ) - -def is_smart_pointer( type ): - type = remove_alias( type ) - type = remove_cv( type ) - if not is_defined_in_xxx( 'boost', type ): - return False - return type.decl_string.startswith( '::boost::shared_ptr<' ) - + +class smart_pointer_traits: + @staticmethod + def is_smart_pointer( type ): + type = remove_alias( type ) + type = remove_cv( type ) + if not is_defined_in_xxx( 'boost', type ): + return False + return type.decl_string.startswith( '::boost::shared_ptr<' ) + + @staticmethod + def value_type( type ): + if not smart_pointer_traits.is_smart_pointer( type ): + raise TypeError( 'Type "%s" is not instantiation of boost::shared_ptr' % type.decl_string ) + type = remove_alias( type ) + cls = remove_cv( type ) + if isinstance( cls, class_declaration.class_t ): + return cls.typedef( "value_type" ).type + else: + value_type_str = templates.args( cls.name )[0] + found = cls.top_parent.classes( value_type_str, allow_empty=True ) + if not found: + if cpptypes.FUNDAMENTAL_TYPES.has_key( value_type_str ): + return cpptypes.FUNDAMENTAL_TYPES[value_type_str] + if len( found ) == 1: + return found[0] + else: + raise RuntimeError( "Unable to find out shared_ptr value type. shared_ptr class is: %s" % cls.decl_string ) + + def is_std_string( type ): decl_strings = [ '::std::basic_string<char,std::char_traits<char>,std::allocator<char> >' Added: pygccxml_dev/unittests/data/string_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/string_traits.hpp (rev 0) +++ pygccxml_dev/unittests/data/string_traits.hpp 2006-06-08 07:02:03 UTC (rev 217) @@ -0,0 +1,32 @@ +// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <string> + +namespace string_traits{ +namespace yes{ + typedef std::string x1; + typedef const std::string x2; +} + +namespace no{ + typedef int x1; + typedef std::string& x2; +} + +} + +namespace wstring_traits{ +namespace yes{ + typedef std::wstring x1; + typedef const std::wstring x2; +} + +namespace no{ + typedef int x1; + typedef std::wstring& x2; +} + +} \ No newline at end of file Added: pygccxml_dev/unittests/string_traits_tester.py =================================================================== --- pygccxml_dev/unittests/string_traits_tester.py (rev 0) +++ pygccxml_dev/unittests/string_traits_tester.py 2006-06-08 07:02:03 UTC (rev 217) @@ -0,0 +1,55 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +class tester_t( parser_test_case.parser_test_case_t ): + COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE + global_ns = None + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.header = 'string_traits.hpp' + self.global_ns = None + + def setUp(self): + if not tester_t.global_ns: + decls = parser.parse( [self.header], self.config ) + tester_t.global_ns = declarations.get_global_namespace( decls ) + self.global_ns = tester_t.global_ns + + def validate_yes( self, ns, controller ): + for typedef in ns.typedefs(): + self.failUnless( controller( typedef.type ) ) + + def validate_no( self, ns, controller ): + for typedef in ns.typedefs(): + self.failUnless( not controller( typedef.type ) ) + + def test_string( self ): + string_traits = self.global_ns.namespace( 'string_traits' ) + self.validate_yes( string_traits.namespace( 'yes' ), declarations.is_std_string ) + self.validate_no( string_traits.namespace( 'no' ), declarations.is_std_string ) + + def test_wstring( self ): + wstring_traits = self.global_ns.namespace( 'wstring_traits' ) + self.validate_yes( wstring_traits.namespace( 'yes' ), declarations.is_std_wstring ) + self.validate_no( wstring_traits.namespace( 'no' ), declarations.is_std_wstring ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() \ No newline at end of file Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-06-08 05:52:33 UTC (rev 216) +++ pygccxml_dev/unittests/test_all.py 2006-06-08 07:02:03 UTC (rev 217) @@ -35,6 +35,8 @@ import demangled_tester import unnamed_enums_bug_tester import vector_traits_tester +import string_traits_tester + def create_suite(): testers = [ @@ -68,7 +70,8 @@ , typedefs_tester , demangled_tester , unnamed_enums_bug_tester - , vector_traits_tester + , vector_traits_tester + , string_traits_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-06-19 14:31:48
|
Revision: 233 Author: roman_yakovenko Date: 2006-06-19 07:31:22 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=233&view=rev Log Message: ----------- big refactoring to container traits to make it easy to add another container Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/container_traits.py pygccxml_dev/unittests/vector_traits_tester.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/module_creator/types_database.py pyplusplus_dev/unittests/indexing_suites_tester.py Modified: pygccxml_dev/pygccxml/declarations/container_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/container_traits.py 2006-06-19 13:24:30 UTC (rev 232) +++ pygccxml_dev/pygccxml/declarations/container_traits.py 2006-06-19 14:31:22 UTC (rev 233) @@ -12,10 +12,13 @@ import namespace import class_declaration import type_traits + +class container_traits_impl_t: + def __init__( self, container_name, value_type_index ): + self.name = container_name + self.value_type_index = value_type_index -class impl_details: - @staticmethod - def get_container_or_none( type, container_name ): + def get_container_or_none( self, type ): """returns reference to the class declaration or None""" type = type_traits.remove_alias( type ) type = type_traits.remove_cv( type ) @@ -30,40 +33,55 @@ else: return - if not cls.name.startswith( container_name + '<' ): + if not cls.name.startswith( self.name + '<' ): return if not type_traits.impl_details.is_defined_in_xxx( 'std', cls ): return return cls - -class vector_traits: - CONTAINER_NAME = 'vector' - - @staticmethod - def is_vector( type ): - """ - Returns True if type represents instantiation of std class vector, otherwise False.""" - return not( None is impl_details.get_container_or_none( type, vector_traits.CONTAINER_NAME ) ) - - @staticmethod - def class_declaration( type ): - """returns reference to the class declaration, """ - cls = impl_details.get_container_or_none( type, vector_traits.CONTAINER_NAME ) - if not cls: - raise TypeError( 'Type "%s" is not instantiation of std::vector' % type.decl_string ) - return cls - - @staticmethod - def value_type( type ): - """returns reference to value_type of the vector""" - cls = vector_traits.class_declaration( type ) - if isinstance( cls, class_declaration.class_t ): - return type_traits.remove_declarated( cls.typedef( "value_type", recursive=False ).type ) - else: - value_type_str = templates.args( cls.name )[0] + + def is_my_case( self, type ): + return bool( self.get_container_or_none( type ) ) + + def class_declaration( self, type ): + cls = self.get_container_or_none( type ) + if not cls: + raise TypeError( 'Type "%s" is not instantiation of std::%s' % ( type.decl_string, self.name ) ) + return cls + + def value_type( self, type ): + cls = self.class_declaration( type ) + if isinstance( cls, class_declaration.class_t ): + value_type = cls.typedef( "value_type", recursive=False ).type + return type_traits.remove_declarated( value_type ) + else: + value_type_str = templates.args( cls.name )[self.value_type_index] ref = type_traits.impl_details.find_value_type( cls.top_parent, value_type_str ) - if None is ref: - raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string ) - return ref + if None is ref: + raise RuntimeError( "Unable to find out %s '%s' value type." + % ( self.name, cls.decl_string ) ) + return ref +def create_traits_class( container_name, value_type_index ): + class xxx_traits: + impl = container_traits_impl_t( container_name, value_type_index ) + + @staticmethod + def is_my_case( type ): + return xxx_traits.impl.is_my_case( type ) + + @staticmethod + def class_declaration( type ): + return xxx_traits.impl.class_declaration( type ) + + @staticmethod + def value_type( type ): + return xxx_traits.impl.value_type( type ) + + return xxx_traits + +vector_traits = create_traits_class( 'vector', 0 ) +map_traits = create_traits_class( 'map', 1 ) +multimap_traits = create_traits_class( 'multimap', 1 ) +hash_map_traits = create_traits_class( 'hash_map', 1 ) +hash_multimap_traits = create_traits_class( 'hash_multimap', 1 ) \ No newline at end of file Modified: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py 2006-06-19 13:24:30 UTC (rev 232) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-06-19 14:31:22 UTC (rev 233) @@ -27,7 +27,7 @@ def validate_yes( self, value_type, container ): traits = declarations.vector_traits - self.failUnless( traits.is_vector( container ) ) + self.failUnless( traits.is_my_case( container ) ) self.failUnless( declarations.is_same( value_type, traits.value_type( container ) ) ) def test_global_ns( self ): @@ -53,7 +53,7 @@ continue if not struct.name.endswith( '_' ): continue - self.failUnless( not traits.is_vector( struct.typedef( 'container' ) ) ) + self.failUnless( not traits.is_my_case( struct.typedef( 'container' ) ) ) def create_suite(): suite = unittest.TestSuite() Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-06-19 13:24:30 UTC (rev 232) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-06-19 14:31:22 UTC (rev 233) @@ -11,7 +11,7 @@ def guess_indexing_suite( class_ ): - if declarations.vector_traits.is_vector( class_ ): + if declarations.vector_traits.is_my_case( class_ ): return container_suites.vector_suite_t( class_ ) #this will only be exported if indexing suite is not None and only when needed Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-19 13:24:30 UTC (rev 232) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-19 14:31:22 UTC (rev 233) @@ -54,7 +54,7 @@ type = declarations.remove_alias( type ) type = declarations.remove_pointer( type ) type = declarations.remove_reference( type ) - if declarations.vector_traits.is_vector( type ): + if declarations.vector_traits.is_my_case( type ): vector = declarations.vector_traits.class_declaration( type ) try: declarations.vector_traits.value_type( vector ) Modified: pyplusplus_dev/unittests/indexing_suites_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites_tester.py 2006-06-19 13:24:30 UTC (rev 232) +++ pyplusplus_dev/unittests/indexing_suites_tester.py 2006-06-19 14:31:22 UTC (rev 233) @@ -22,7 +22,7 @@ @staticmethod def matcher( item, decl ): - if not declarations.vector_traits.is_vector( decl ): + if not declarations.vector_traits.is_my_case( decl ): return False value_type = declarations.vector_traits.value_type(decl) if item is value_type: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-07-09 05:31:36
|
Revision: 284 Author: roman_yakovenko Date: 2006-07-08 22:31:25 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=284&view=rev Log Message: ----------- fixing has_binary_operator type traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/data/core_cache.hpp pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp pygccxml_dev/unittests/test_all.py Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-07-09 05:31:25 UTC (rev 284) @@ -14,7 +14,8 @@ Those functions are very valuable for code generation. Almost all functions within this module works on L{type_t} class hierarchy and\\or L{class_t}. """ - + +import filters import typedef import calldef import cpptypes @@ -366,28 +367,44 @@ return bool( constructors ) def has_public_binary_operator( type, operator_symbol ): - symbol = operator_symbol not_artificial = lambda decl: decl.is_artificial == False type = remove_alias( type ) type = remove_cv( type ) type = remove_declarated( type ) - assert isinstance( type, class_declaration.class_t ) - equals = type.member_operators( function=not_artificial, symbol=symbol, allow_empty=True, recursive=False ) - if equals: + assert isinstance( type, class_declaration.class_t ) + + if is_std_string( type ) or is_std_wstring( type ): + #In some case compare operators of std::basic_string are not instantiated + return True + + operators = type.member_operators( function=filters.custom_matcher_t( not_artificial ) \ + & filters.access_type_matcher_t( 'public' ) + , symbol=operator_symbol + , allow_empty=True + , recursive=False ) + if operators: return True t = cpptypes.declarated_t( type ) t = cpptypes.const_t( t ) t = cpptypes.reference_t( t ) - equals = type.parent.operators( function=not_artificial, symbol=symbol, arg_types=[t, None], allow_empty=True, recursive=False ) - if equals: + operators = type.top_parent.operators( function=not_artificial + , arg_types=[t, None] + , symbol=operator_symbol + , allow_empty=True + , recursive=True ) + if operators: return True for bi in type.recursive_bases: assert isinstance( bi, class_declaration.hierarchy_info_t ) if bi.access_type != class_declaration.ACCESS_TYPES.PUBLIC: continue - equals = bi.related_class.member_operators( function=not_artificial, symbol=symbol, allow_empty=True, recursive=False ) - if equals: + operators = bi.related_class.member_operators( function=filters.custom_matcher_t( not_artificial ) \ + & filters.access_type_matcher_t( 'public' ) + , symbol=operator_symbol + , allow_empty=True + , recursive=False ) + if operators: return True return False Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/unittests/data/core_cache.hpp 2006-07-09 05:31:25 UTC (rev 284) @@ -22,4 +22,4 @@ #endif//__core_cache_hpp__ -//touch//touch//touch \ No newline at end of file +//touch//touch//touch//touch \ No newline at end of file Modified: pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp 2006-07-09 05:31:25 UTC (rev 284) @@ -10,10 +10,6 @@ namespace yes{ typedef std::string yes1; - inline bool instantiate_templ(){ - return std::string( "1" ) == std::string( "2" ); - } - struct trivial{ bool operator==(const trivial& other); }; Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/unittests/test_all.py 2006-07-09 05:31:25 UTC (rev 284) @@ -37,6 +37,7 @@ import vector_traits_tester import string_traits_tester import declarations_cache_tester +import has_binary_operator_traits_tester def create_suite(): testers = [ @@ -72,7 +73,8 @@ , unnamed_enums_bug_tester , vector_traits_tester , string_traits_tester - , declarations_cache_tester + , declarations_cache_tester + , has_binary_operator_traits_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-07-10 12:33:57
|
Revision: 289 Author: roman_yakovenko Date: 2006-07-10 05:33:25 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=289&view=rev Log Message: ----------- adding different loggers for different functionality removing verbose flag Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/parser/config.py pygccxml_dev/pygccxml/parser/declarations_cache.py pygccxml_dev/pygccxml/parser/project_reader.py pygccxml_dev/pygccxml/parser/scanner.py pygccxml_dev/pygccxml/parser/source_reader.py pygccxml_dev/pygccxml/utils/__init__.py pygccxml_dev/unittests/declarations_cache_tester.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/module_builder/__init__.py pyplusplus_dev/pyplusplus/module_builder/builder.py Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2006-07-10 12:33:25 UTC (rev 289) @@ -75,7 +75,11 @@ self._type2decls_nr = {} self._type2name2decls_nr = {} self._all_decls = None - + + def _get_logger( self ): + return utils.loggers.queries_engine + _logger = property( _get_logger ) + def _get__cmp__scope_items(self): raise NotImplementedError() @@ -148,7 +152,7 @@ Those hashtables allows to search declaration very quick. """ if self.name == '::': - utils.logger.debug( "preparing data structures for query optimizer - started" ) + self._logger.debug( "preparing data structures for query optimizer - started" ) start_time = time.clock() self.clear_optimizer() @@ -178,7 +182,7 @@ map( lambda decl: decl.init_optimizer() , filter( lambda decl: isinstance( decl, scopedef_t ), self.declarations ) ) if self.name == '::': - utils.logger.debug( "preparing data structures for query optimizer - done( %f seconds ). " + self._logger.debug( "preparing data structures for query optimizer - done( %f seconds ). " % ( time.clock() - start_time ) ) self._optimized = True @@ -226,15 +230,15 @@ matcher = match_class( **matcher_args ) if keywds['function']: - utils.logger.debug( 'running query: %s and <user defined function>' % str( matcher ) ) + self._logger.debug( 'running query: %s and <user defined function>' % str( matcher ) ) return lambda decl: matcher( decl ) and keywds['function'](decl) else: - utils.logger.debug( 'running query: %s' % str( matcher ) ) + self._logger.debug( 'running query: %s' % str( matcher ) ) return matcher def __findout_range( self, name, decl_type, recursive ): if not self._optimized: - utils.logger.debug( 'running non optimized query - optimization has not been done' ) + self._logger.debug( 'running non optimized query - optimization has not been done' ) decls = self.declarations if recursive: decls = algorithm.make_flatten( self.declarations ) @@ -245,34 +249,34 @@ if matcher.is_full_name(): name = matcher.decl_name_only if recursive: - utils.logger.debug( 'query has been optimized on type and name' ) + self._logger.debug( 'query has been optimized on type and name' ) if self._type2name2decls[decl_type].has_key( name ): return self._type2name2decls[decl_type][name] else: return [] else: - utils.logger.debug( 'non recursive query has been optimized on type and name' ) + self._logger.debug( 'non recursive query has been optimized on type and name' ) if self._type2name2decls_nr[decl_type].has_key( name ): return self._type2name2decls_nr[decl_type][name] else: return [] elif decl_type: if recursive: - utils.logger.debug( 'query has been optimized on type' ) + self._logger.debug( 'query has been optimized on type' ) return self._type2decls[ decl_type ] else: - utils.logger.debug( 'non recursive query has been optimized on type' ) + self._logger.debug( 'non recursive query has been optimized on type' ) return self._type2decls_nr[ decl_type ] else: if recursive: - utils.logger.debug( 'query has not been optimized ( hint: query does not contain type and/or name )' ) + self._logger.debug( 'query has not been optimized ( hint: query does not contain type and/or name )' ) return self._all_decls else: - utils.logger.debug( 'non recursive query has not been optimized ( hint: query does not contain type and/or name )' ) + self._logger.debug( 'non recursive query has not been optimized ( hint: query does not contain type and/or name )' ) return self.declarations def _find_single( self, match_class, **keywds ): - utils.logger.debug( 'find single query execution - started' ) + self._logger.debug( 'find single query execution - started' ) start_time = time.clock() norm_keywds = self.__normalize_args( **keywds ) matcher = self.__create_matcher( match_class, **norm_keywds ) @@ -280,11 +284,11 @@ recursive_ = self.__findout_recursive( **norm_keywds ) decls = self.__findout_range( norm_keywds['name'], dtype, recursive_ ) found = matcher_module.matcher.get_single( matcher, decls, False ) - utils.logger.debug( 'find single query execution - done( %f seconds )' % ( time.clock() - start_time ) ) + self._logger.debug( 'find single query execution - done( %f seconds )' % ( time.clock() - start_time ) ) return found def _find_multiple( self, match_class, **keywds ): - utils.logger.debug( 'find all query execution - started' ) + self._logger.debug( 'find all query execution - started' ) start_time = time.clock() norm_keywds = self.__normalize_args( **keywds ) matcher = self.__create_matcher( match_class, **norm_keywds ) @@ -294,8 +298,8 @@ decls = self.__findout_range( norm_keywds['name'], dtype, recursive_ ) found = matcher_module.matcher.find( matcher, decls, False ) mfound = mdecl_wrapper.mdecl_wrapper_t( found ) - utils.logger.debug( '%d declaration(s) that match query' % len(mfound) ) - utils.logger.debug( 'find single query execution - done( %f seconds )' + self._logger.debug( '%d declaration(s) that match query' % len(mfound) ) + self._logger.debug( 'find single query execution - done( %f seconds )' % ( time.clock() - start_time ) ) if not mfound and not allow_empty: raise RuntimeError( "Multi declaration query returned 0 declarations." ) Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/parser/config.py 2006-07-10 12:33:25 UTC (rev 289) @@ -27,7 +27,6 @@ , define_symbols=None , undefine_symbols=None , start_with_declarations=None - , verbose=False , ignore_gccxml_output=False , cflags=""): """Constructor. @@ -52,7 +51,6 @@ start_with_declarations = [] self.__start_with_declarations = start_with_declarations - self.__verbose = verbose self.__ignore_gccxml_output = ignore_gccxml_output self.__cflags = cflags @@ -63,7 +61,6 @@ , define_symbols=self.__define_symbols[:] , undefine_symbols=self.__undefine_symbols[:] , start_with_declarations=self.__start_with_declarations[:] - , verbose=self.verbose , ignore_gccxml_output=self.ignore_gccxml_output , cflags=self.cflags) @@ -95,12 +92,6 @@ return self.__start_with_declarations start_with_declarations = property( __get_start_with_declarations ) - def __get_verbose(self): - return self.__verbose - def __set_verbose(self, val=True): - self.__verbose = val - verbose = property( __get_verbose, __set_verbose ) - def __get_ignore_gccxml_output(self): return self.__ignore_gccxml_output def __set_ignore_gccxml_output(self, val=True): Modified: pygccxml_dev/pygccxml/parser/declarations_cache.py =================================================================== --- pygccxml_dev/pygccxml/parser/declarations_cache.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/parser/declarations_cache.py 2006-07-10 12:33:25 UTC (rev 289) @@ -8,7 +8,7 @@ import md5 import time import cPickle -from pygccxml.utils import logger +from pygccxml import utils def file_signature( filename ): @@ -44,9 +44,11 @@ sig.update(str(u)) return sig.hexdigest() -class cache_base_t( object ): +class cache_base_t( object ): + logger = utils.loggers.declarations_cache + def __init__( self ): - object.__init__(self) + object.__init__(self) def flush(self): """ Flush (write out) the cache to disk if needed. """ @@ -146,7 +148,7 @@ """ @param name: name of the cache file. """ - cache_base_t.__init__( self ) + cache_base_t.__init__( self ) self.__name = name # Name of cache file self.__cache = self.__load( self.__name ) # Map record_key to record_t self.__needs_flushed = not bool( self.__cache ) # If empty then we need to flush @@ -163,15 +165,16 @@ return {} cache_file_obj = file( file_name, 'rb' ) try: - logger.info( "Loading cache file ..." ) + file_cache_t.logger.info( 'Loading cache file "%s".' % file_name ) start_time = time.clock() cache = cPickle.load( cache_file_obj ) - logger.info( "Cache file has been loaded in %.1f secs"%( time.clock() - start_time ) ) - logger.info( "Found cache in file: [%s] entries: %s" - % ( file_name, len( cache.keys() ) ) ) - except Exception: + file_cache_t.logger.debug( "Cache file has been loaded in %.1f secs"%( time.clock() - start_time ) ) + file_cache_t.logger.debug( "Found cache in file: [%s] entries: %s" + % ( file_name, len( cache.keys() ) ) ) + except Exception, error: + file_cache_t.logger.exception( "Error occured while reading cache file: %s", error ) cache_file_obj.close() - logger.info( "Invalid cache file: [%s] Regenerating." % file_name ) + file_cache_t.logger.info( "Invalid cache file: [%s] Regenerating." % file_name ) file(file_name, 'w+b').close() # Create empty file cache = {} # Empty cache return cache @@ -180,7 +183,7 @@ def flush(self): # If not marked as needing flushed, then return immediately if not self.__needs_flushed: - logger.info("Cache did not change, ignoring flush.") + self.logger.debug("Cache did not change, ignoring flush.") return # Remove entries that did not get a cache hit @@ -190,7 +193,7 @@ num_removed += 1 del self.__cache[key] if num_removed > 0: - logger.info( "There are %s removed entries from cache." % num_removed ) + self.logger.debug( "There are %s removed entries from cache." % num_removed ) # Save out the cache to disk cache_file = file( self.__name, 'w+b' ) cPickle.dump( self.__cache, cache_file, cPickle.HIGHEST_PROTOCOL ) Modified: pygccxml_dev/pygccxml/parser/project_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/project_reader.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/parser/project_reader.py 2006-07-10 12:33:25 UTC (rev 289) @@ -9,7 +9,7 @@ import source_reader import declarations_cache import pygccxml.declarations -from pygccxml.utils import logger +from pygccxml import utils class COMPILATION_MODE: ALL_AT_ONCE = 'all at once' @@ -179,7 +179,9 @@ self.__decl_factory = decl_factory if not decl_factory: self.__decl_factory = pygccxml.declarations.decl_factory_t() - + + self.logger = utils.loggers.gccxml + def get_os_file_names( files ): """Returns a list of OS file names @@ -219,14 +221,13 @@ "Unable to parse files using ALL_AT_ONCE mode. " , "There is some file configuration that is not file. " , "pygccxml.parser.project_reader_t switches to FILE_BY_FILE mode." ]) - logger.info( msg ) + self.logger.warning( msg ) return self.__parse_file_by_file(files) def __parse_file_by_file(self, files): namespaces = [] config = self.__config.clone() - if config.verbose: - logger.info( "Reading project files: file by file" ) + self.logger.debug( "Reading project files: file by file" ) for prj_file in files: reader = None header = None @@ -259,35 +260,28 @@ else: decls = reader.read_string( header ) namespaces.append( decls ) - if config.verbose: - logger.info( "Flushing cache... " ) + self.logger.debug( "Flushing cache... " ) start_time = time.clock() self.__dcache.flush() - if config.verbose: - logger.info( "Cache has been flushed in %.1f secs" - % ( time.clock() - start_time ) ) + self.logger.debug( "Cache has been flushed in %.1f secs" % ( time.clock() - start_time ) ) answer = [] - if config.verbose: - logger.info( "Joining namespaces ..." ) + self.logger.debug( "Joining namespaces ..." ) for file_nss in namespaces: answer = self._join_top_namespaces( answer, file_nss ) - if config.verbose: - logger.info( "Joining declarations ..." ) + self.logger.debug( "Joining declarations ..." ) for ns in answer: if isinstance( ns, pygccxml.declarations.namespace_t ): self._join_declarations( ns ) leaved_classes = self._join_class_hierarchy( answer ) types = self.__declarated_types(answer) - if config.verbose: - logger.info( "Relinking declared types ..." ) + self.logger.debug( "Relinking declared types ..." ) self._relink_declarated_types( leaved_classes, types ) source_reader.bind_aliases( pygccxml.declarations.make_flatten( answer ) ) return answer def __parse_all_at_once(self, files): config = self.__config.clone() - if config.verbose: - logger.info( "Reading project files: all at once" ) + self.logger.debug( "Reading project files: all at once" ) header_content = [] for header in files: if isinstance( header, file_configuration_t ): @@ -430,18 +424,16 @@ key = create_key(decl_wrapper_type.declaration) if leaved_classes.has_key( key ): decl_wrapper_type.declaration = leaved_classes[ create_key(decl_wrapper_type.declaration) ] - else: + else: + if decl_wrapper_type.declaration._name.startswith( '__vmi_class_type_info_pseudo' ): + continue msg = [] msg.append( "Unable to find out actual class definition: '%s'." % decl_wrapper_type.declaration._name ) msg.append( "Class definition has been changed from one compilation to an other." ) msg.append( "Why did it happen to me? Here is a short list of reasons: " ) msg.append( " 1. There are different preprocessor definitions applied on same file during compilation" ) - msg.append( " 2. GCC implementation details. Diamand class hierarchy will reproduce this behavior." ) - msg.append( " If name starts with '__vmi_class_type_info_pseudo' you can ignore this message." ) - msg.append( " 3. Bug in pygccxml." ) - logger.error( os.linesep.join(msg) ) - #'__vmi_class_type_info_pseudo1' - + msg.append( " 2. Bug in pygccxml." ) + self.logger.error( os.linesep.join(msg) ) def _join_declarations( self, declref ): self._join_namespaces( declref ) Modified: pygccxml_dev/pygccxml/parser/scanner.py =================================================================== --- pygccxml_dev/pygccxml/parser/scanner.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/parser/scanner.py 2006-07-10 12:33:25 UTC (rev 289) @@ -10,7 +10,7 @@ import warnings import xml.sax.handler from pygccxml.declarations import * -from pygccxml.utils import logger +from pygccxml import utils ##convention #XML_NN - XML Node Name @@ -75,7 +75,8 @@ class scanner_t( xml.sax.handler.ContentHandler ): def __init__(self, gccxml_file, decl_factory, *args ): - xml.sax.handler.ContentHandler.__init__(self, *args ) + xml.sax.handler.ContentHandler.__init__(self, *args ) + self.logger = utils.loggers.gccxml self.gccxml_file = gccxml_file #defining parsing tables self.__readers = { @@ -191,12 +192,12 @@ elif isinstance( obj, types.StringTypes ): self.__files[ attrs[XML_AN_ID] ] = obj else: - logger.warning( 'Unknown object type has been found.' - + ' Please report this bug to pygccxml development team.' ) + self.logger.warning( 'Unknown object type has been found.' + + ' Please report this bug to pygccxml development team.' ) except Exception, error: msg = 'error occured, while parsing element with name "%s" and attrs "%s".' msg = msg + os.linesep + 'Error: %s.' % str( error ) - logger.error( msg % ( name, pprint.pformat( attrs.keys() ) ) ) + self.logger.error( msg % ( name, pprint.pformat( attrs.keys() ) ) ) raise def endElement(self, name): Modified: pygccxml_dev/pygccxml/parser/source_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/source_reader.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/parser/source_reader.py 2006-07-10 12:33:25 UTC (rev 289) @@ -12,7 +12,7 @@ import declarations_cache import patcher from pygccxml.declarations import * -from pygccxml.utils import logger +from pygccxml import utils class gccxml_runtime_error_t( RuntimeError ): def __init__( self, msg ): @@ -72,7 +72,8 @@ @param decl_factory: declarations factory, if not given default declarations factory L{decl_factory_t} will be used - """ + """ + self.logger = utils.loggers.gccxml self.__search_directories = [] self.__config = config self.__search_directories.append( config.working_directory ) @@ -145,7 +146,7 @@ cmd_line = ' '.join(cmd) if 'win32' in sys.platform : cmd_line = '"%s"' % cmd_line - logger.debug( 'gccxml cmd: %s' % cmd_line ) + self.logger.info( 'gccxml cmd: %s' % cmd_line ) return cmd_line def create_xml_file( self, header, destination=None ): @@ -174,8 +175,6 @@ if not os.path.isabs( ffname ): ffname = self.__file_full_name(header) command_line = self.__create_command_line( ffname, gccxml_file ) - if self.__config.verbose: - logger.info( " Command line for GCC-XML: %s" % command_line ) input_, output = os.popen4( command_line ) input_.close() gccxml_reports = [] @@ -231,19 +230,15 @@ gccxml_file = '' try: ffname = self.__file_full_name(source_file) - if self.__config.verbose: - logger.info( "Reading source file: [%s]." % ffname ) + self.logger.debug( "Reading source file: [%s]." % ffname ) declarations = self.__dcache.cached_value( ffname, self.__config ) if not declarations: - if self.__config.verbose: - logger.info( "File has not been found in cache, parsing..." ) + self.logger.debug( "File has not been found in cache, parsing..." ) gccxml_file = self.create_xml_file( ffname ) declarations, files = self.__parse_gccxml_created_file( gccxml_file ) self.__dcache.update( ffname, self.__config, declarations, files ) else: - if self.__config.verbose: - logger.info( "File has not been changed, reading declarations from cache." ) - + self.logger.debug( "File has not been changed, reading declarations from cache." ) except Exception, error: if gccxml_file: pygccxml.utils.remove_file_no_raise( gccxml_file ) @@ -261,8 +256,7 @@ @return: declarations tree """ - if self.__config.verbose: - logger.info( "Reading xml file: [%s]" % gccxml_created_file ) + self.logger.debug( "Reading xml file: [%s]" % gccxml_created_file ) declarations, files = self.__parse_gccxml_created_file( gccxml_created_file ) return declarations Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/pygccxml/utils/__init__.py 2006-07-10 12:33:25 UTC (rev 289) @@ -7,14 +7,22 @@ import sys import logging import tempfile + +def _create_logger_( name ): + logger = logging.getLogger('name') + __handler = logging.StreamHandler(sys.stdout) + __handler.setFormatter( logging.Formatter( '%(levelname)s %(message)s' ) ) + logger.addHandler(__handler) + logger.setLevel(logging.INFO) + return logger + +class loggers: + root = _create_logger_( 'pygccxml' ) + gccxml = _create_logger_( 'pygccxml.gccxml' ) + queries_engine = _create_logger_( 'pygccxml.queries_engine' ) + declarations_cache = _create_logger_( 'pygccxml.declarations_cache' ) + all = [ root, gccxml, queries_engine, declarations_cache ] - -logger = logging.getLogger('pygccxml') -__handler = logging.StreamHandler(sys.stdout) -__handler.setFormatter( logging.Formatter('%(message)s') ) -logger.addHandler(__handler) -logger.setLevel(logging.DEBUG) - def remove_file_no_raise(file_name ): try: if os.path.exists(file_name): Modified: pygccxml_dev/unittests/declarations_cache_tester.py =================================================================== --- pygccxml_dev/unittests/declarations_cache_tester.py 2006-07-09 19:53:40 UTC (rev 288) +++ pygccxml_dev/unittests/declarations_cache_tester.py 2006-07-10 12:33:25 UTC (rev 289) @@ -41,11 +41,7 @@ #start_decls_changed = def_cfg.clone() #start_decls_changed.start_with_declarations = "test object" #self.assert_(configuration_signature(start_decls_changed) == def_sig) - - verbose_changed = def_cfg.clone() - verbose_changed.verbose = True - self.assert_(configuration_signature(verbose_changed) == def_sig) - + ignore_changed = def_cfg.clone() ignore_changed.ignore_gccxml_output = True self.assert_(configuration_signature(ignore_changed) == def_sig) @@ -101,7 +97,7 @@ """ Return a list of configurations that all differ. """ cfg_list = [] def_cfg = config_t("gccxml_path",'.',['tmp'],['sym'],['unsym'], - None,False,False,"") + None,False,"") cfg_list.append(def_cfg) # Test changes that should cause sig changes @@ -117,21 +113,21 @@ #inc_changed.include_paths = ["/var/tmp"] #self.assert_(configuration_signature(inc_changed) != def_sig) inc_changed = config_t("gccxml_path",'.',['/var/tmp'],['sym'],['unsym'], - None,False,False,"") + None,False,"") cfg_list.append(inc_changed) #def_changed = def_cfg.clone() #def_changed.define_symbols = ["symbol"] #self.assert_(configuration_signature(def_changed) != def_sig) def_changed = config_t("gccxml_path",'.',['/var/tmp'],['new-sym'],['unsym'], - None,False,False,"") + None,False,"") cfg_list.append(def_changed) #undef_changed = def_cfg.clone() #undef_changed.undefine_symbols = ["symbol"] #self.assert_(configuration_signature(undef_changed) != def_sig) undef_changed = config_t("gccxml_path",'.',['/var/tmp'],['sym'],['new-unsym'], - None,False,False,"") + None,False,"") cfg_list.append(undef_changed) cflags_changed = def_cfg.clone() Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-07-09 19:53:40 UTC (rev 288) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-07-10 12:33:25 UTC (rev 289) @@ -172,7 +172,8 @@ def _exportable_impl( self ): if not self.name: - return 'pyplusplus can not expose unnamed classes.' + return 'pyplusplus can not expose unnamed classes.' + #it is possible to do so, but not for unnamed classes defined under namespace. if isinstance( self.parent, declarations.namespace_t ): return '' if not self in self.parent.public_members: Modified: pyplusplus_dev/pyplusplus/module_builder/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/__init__.py 2006-07-09 19:53:40 UTC (rev 288) +++ pyplusplus_dev/pyplusplus/module_builder/__init__.py 2006-07-10 12:33:25 UTC (rev 289) @@ -50,6 +50,7 @@ from pygccxml import utils as __pygccxml_utils from pyplusplus import _logging_ as __pyplusplus_logging -def set_logger_level( level ): - __pygccxml_utils.logger.setLevel( level ) +def set_logger_level( level ): + for l in __pygccxml_utils.loggers.all: + l.setLevel( level ) __pyplusplus_logging.logger.setLevel( level ) \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/builder.py 2006-07-09 19:53:40 UTC (rev 288) +++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2006-07-10 12:33:25 UTC (rev 289) @@ -62,7 +62,6 @@ , define_symbols=define_symbols , undefine_symbols=undefine_symbols , start_with_declarations=start_with_declarations - , verbose=compilation_verbose , ignore_gccxml_output=ignore_gccxml_output) #may be in future I will add those directories to user_defined_directories This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |