[pygccxml-commit] SF.net SVN: pygccxml: [142] pygccxml_dev/pygccxml/parser
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-05-20 20:25:30
|
Revision: 142 Author: roman_yakovenko Date: 2006-05-20 13:25:22 -0700 (Sat, 20 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=142&view=rev Log Message: ----------- adding doc strings Modified Paths: -------------- pygccxml_dev/pygccxml/parser/config.py pygccxml_dev/pygccxml/parser/project_reader.py pygccxml_dev/pygccxml/parser/source_reader.py Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2006-05-18 15:11:59 UTC (rev 141) +++ pygccxml_dev/pygccxml/parser/config.py 2006-05-20 20:25:22 UTC (rev 142) @@ -10,7 +10,15 @@ """Configuration object to collect parameters for invoking gccxml. This class serves as a container for the parameters that can be used - to customize the call to gccxml. + to customize the call to gccxml. This class also allows users to work with + relative files paths. In this case files are searched in the following order: + + 1. current directory + + 2. working directory + + 3. additional include paths specified by the user + """ def __init__( self , gccxml_path='' Modified: pygccxml_dev/pygccxml/parser/project_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-18 15:11:59 UTC (rev 141) +++ pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-20 20:25:22 UTC (rev 142) @@ -16,9 +16,10 @@ FILE_BY_FILE = 'file by file' -#TODO: rework next explanation to something useful. -""" -file_configuration_t is rather cool feature. When you create module_builder_t +class file_configuration_t( object ): + """ + file_configuration_t class is cool feature. When you want to parse C++ code + from different sources at once, you should use this class. class instance you should pass list of files. This list can contain string( == file paths ) and/or instances of file_configuration_t class. file_configuration_t is class with fat interface. @@ -60,7 +61,7 @@ , .... ) """ -class file_configuration_t( object ): + class CONTENT_TYPE: STANDARD_SOURCE_FILE = 'standard source file' CACHED_SOURCE_FILE = 'cached source file' Modified: pygccxml_dev/pygccxml/parser/source_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/source_reader.py 2006-05-18 15:11:59 UTC (rev 141) +++ pygccxml_dev/pygccxml/parser/source_reader.py 2006-05-20 20:25:22 UTC (rev 142) @@ -44,7 +44,35 @@ cls_inst.aliases.append( decl ) class source_reader_t: + """ + This class reads C++ source code and returns declarations tree. + + This class is the only class that have an intime knowledge about GCC-XML. + It has only one responsibility: it calls GCC-XML with a source file specified + by user and creates declarations tree. The implementation of this class is split + to 2 classes: + + 1. L{scanner_t} - this class scans the "XML" file, generated by GCC-XML and + creates `pygccxml`_ declarations and types classes. After the xml file has + been processed declarations and type class instances keeps references to + each other using GCC-XML generated id's. + + 2. L{linker_t} - this class contains logic for replacing GCC-XML generated + ids with references to declarations or type class instances. + """ def __init__( self, config, cache=None, decl_factory=None ): + """ + @param config: instance of L{config_t} class, that contains GCC-XML + configuration + @type config: L{config_t} + + @param cache: reference to cache object, that will be updated after + file has been parsed. + @param cache: instance of class, that derives from {cache_base_t} + + @param decl_factory: declarations factory, if not given default + declarations factory L{decl_factory_t} will be used + """ self.__search_directories = [] self.__config = config self.__search_directories.append( config.working_directory ) @@ -118,6 +146,20 @@ return cmd_line def create_xml_file( self, header, destination=None ): + """ + This function will return the file name of the file, created by GCC-XML + for "header" file. If destination_file_path is not None, then this file + path will be used and returned. + + @param header: path to source file, that should be parsed + @type header: str + + @param destination: if given, will be used as target file/path for + GCC-XML generated file. + @type destination: str + + @return: path to GCC-XML generated file + """ gccxml_file = destination # If file specified, remove it to start else create new file name if gccxml_file: @@ -155,6 +197,17 @@ return gccxml_file def create_xml_file_from_string( self, content, destination=None ): + """ + Creates XML file from text. + + @param content: C++ source code + @type content: str + + @param destination: file name for GCC-XML generated file + @type destination: str + + @return: returns file name of GCC-XML generated file + """ header_file = pygccxml.utils.create_temp_file_name( suffix='.h' ) gccxml_file = None try: @@ -167,6 +220,12 @@ return gccxml_file def read_file(self, source_file): + """ + Reads C++ source file and returns declarations tree + + @param source_file: path to C++ source file + @type source_file: str + """ declarations, types = None, None gccxml_file = '' try: @@ -193,6 +252,14 @@ return declarations def read_xml_file(self, gccxml_created_file): + """ + Reads GCC-XML generated XML file. + + @param gccxml_created_file: path to GCC-XML generated file + @type gccxml_created_file: str + + @return: declarations tree + """ if self.__config.verbose: logger.info( "Reading xml file: [%s]" % gccxml_created_file ) @@ -200,6 +267,10 @@ return declarations def read_string(self, content): + """ + Reads Python string, that contains valid C++ code, and returns + declarations tree. + """ header_file = pygccxml.utils.create_temp_file_name( suffix='.h' ) header_file_obj = file(header_file, 'w+') header_file_obj.write( content ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |