[pygccxml-commit] source/pygccxml/declarations declaration.py,1.19,1.20
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <mb...@us...> - 2006-03-22 10:37:50
|
Update of /cvsroot/pygccxml/source/pygccxml/declarations In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32651 Modified Files: declaration.py Log Message: Added a default __str__() method for all declarations which is used in case there is no more specific version in a derived class Index: declaration.py =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/declaration.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** declaration.py 8 Mar 2006 08:46:10 -0000 1.19 --- declaration.py 22 Mar 2006 10:37:47 -0000 1.20 *************** *** 79,82 **** --- 79,102 ---- self._mangled = mangled + def __str__(self): + """Default __str__ method. + + This version just returns the decl_string and the class. + Derived classes may override this method to provide more detailed + information. + + A __str__ method for a declaration should always provide enough + information so that it uniquely identifies the declaration and + the user is able to find the declaration in his source code. + """ + name = self.decl_string + if name[:2]=="::": + name = name[2:] + # Append the declaration class + cls = self.__class__.__name__ + if cls[-2:]=="_t": + cls = cls[:-2] + return "%s [%s]"%(name, cls) + def _sorted_list( some_list ): some_list.sort() |