Thread: [pygccxml-commit] SF.net SVN: pygccxml:[1641] pygccxml_dev (Page 2)
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-01-29 23:22:38
|
Revision: 1641 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1641&view=rev Author: roman_yakovenko Date: 2009-01-29 22:14:51 +0000 (Thu, 29 Jan 2009) Log Message: ----------- sphinx Modified Paths: -------------- pydsc_dev/pydsc.py pygccxml_dev/docs/apidocs/api.rest pygccxml_dev/docs/apidocs/binary_parsers.rest pygccxml_dev/docs/apidocs/declarations.rest pygccxml_dev/docs/apidocs/parser.rest pygccxml_dev/docs/apidocs/utils.rest pygccxml_dev/docs/pygccxml.rest pygccxml_dev/pygccxml/parser/__init__.py Removed Paths: ------------- pygccxml_dev/docs/apidocs/modules.txt Modified: pydsc_dev/pydsc.py =================================================================== --- pydsc_dev/pydsc.py 2009-01-29 19:49:51 UTC (rev 1640) +++ pydsc_dev/pydsc.py 2009-01-29 22:14:51 UTC (rev 1641) @@ -65,9 +65,7 @@ def contains_parent_dir( path, dirs ): """ returns true if one of the directories is root directory for the `path`, false otherwise - - :parameters: - - `path` - a path + @param path: path @type path: str Modified: pygccxml_dev/docs/apidocs/api.rest =================================================================== --- pygccxml_dev/docs/apidocs/api.rest 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/apidocs/api.rest 2009-01-29 22:14:51 UTC (rev 1641) @@ -1,14 +1,13 @@ -============ -pygccxml API -============ +=== +API +=== -Modules: --------- +`pygccxml` consists from 4 sub packages .. toctree:: :maxdepth: 4 - binary_parsers - declarations - parser - utils + declarations - contains classes, which describe C++ declarations <declarations> + parser - contains classes, which parse GCC-XML generated file <parser> + binary_parsers - contains classes, which extract some information from `.dll`, `.map`, `.so` files <binary_parsers> + utils - few useful utilities <utils> Modified: pygccxml_dev/docs/apidocs/binary_parsers.rest =================================================================== --- pygccxml_dev/docs/apidocs/binary_parsers.rest 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/apidocs/binary_parsers.rest 2009-01-29 22:14:51 UTC (rev 1641) @@ -1,11 +1,11 @@ -=========================== -pygccxml.binary_parsers API -=========================== +=============================== +pygccxml.binary_parsers package +=============================== This page contains the `pygccxml.binary_parsers` package API documentation. The :mod:`pygccxml.binary_parsers` package ------------------------------------------- +----------------------------------------------------------- .. automodule:: pygccxml.binary_parsers :members: @@ -13,27 +13,11 @@ :show-inheritance: -The :mod:`pygccxml.binary_parsers.get_dll_exported_symbols` module ------------------------------------------------------------------- +The :mod:`parsers <pygccxml.binary_parsers.parsers>` module +----------------------------------------------------------- -.. automodule:: pygccxml.binary_parsers.get_dll_exported_symbols - :members: - :undoc-members: - :show-inheritance: - -The :mod:`pygccxml.binary_parsers.parsers` module -------------------------------------------------- - .. automodule:: pygccxml.binary_parsers.parsers :members: :undoc-members: :show-inheritance: -The :mod:`pygccxml.binary_parsers.undname` module -------------------------------------------------- - -.. automodule:: pygccxml.binary_parsers.undname - :members: - :undoc-members: - :show-inheritance: - Modified: pygccxml_dev/docs/apidocs/declarations.rest =================================================================== --- pygccxml_dev/docs/apidocs/declarations.rest 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/apidocs/declarations.rest 2009-01-29 22:14:51 UTC (rev 1641) @@ -1,8 +1,18 @@ -..\Pygccxml_Dev\Pygccxml\Declarations Documentation -=================================================== +============================= +pygccxml.declarations package +============================= -This page contains the ..\Pygccxml_Dev\Pygccxml\Declarations Package documentation. +This page contains the `pygccxml.declarations` package API documentation. +The :mod:`pygccxml.declarations` package +---------------------------------------- + +.. automodule:: pygccxml.declarations + :members: + :undoc-members: + :show-inheritance: + + The :mod:`pygccxml.declarations.algorithm` module ------------------------------------------------- Deleted: pygccxml_dev/docs/apidocs/modules.txt =================================================================== --- pygccxml_dev/docs/apidocs/modules.txt 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/apidocs/modules.txt 2009-01-29 22:14:51 UTC (rev 1641) @@ -1,16 +0,0 @@ -Miville Modules Documentation -============================= - -This page contains the Miville Modules documentation. - -Modules: --------- - -.. toctree:: - :maxdepth: 4 - - __init__ - binary_parsers - declarations - parser - utils Modified: pygccxml_dev/docs/apidocs/parser.rest =================================================================== --- pygccxml_dev/docs/apidocs/parser.rest 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/apidocs/parser.rest 2009-01-29 22:14:51 UTC (rev 1641) @@ -1,84 +1,85 @@ -..\Pygccxml_Dev\Pygccxml\Parser Documentation -============================================= +======================= +pygccxml.parser package +======================= -This page contains the ..\Pygccxml_Dev\Pygccxml\Parser Package documentation. +This page contains the `pygccxml.parser` package API documentation. -The :mod:`parser.config` Modules --------------------------------- +The :mod:`pygccxml.parser` Package +---------------------------------------------------------- -.. automodule:: parser.config +.. automodule:: pygccxml.parser :members: :undoc-members: :show-inheritance: -The :mod:`parser.declarations_cache` Modules --------------------------------------------- +The :mod:`pygccxml.parser.config` module +---------------------------------------- -.. automodule:: parser.declarations_cache +.. automodule:: pygccxml.parser.config :members: :undoc-members: :show-inheritance: -The :mod:`parser.directory_cache` Modules ------------------------------------------ +The :mod:`pygccxml.parser.declarations_cache` module +---------------------------------------------------- -.. automodule:: parser.directory_cache +.. automodule:: pygccxml.parser.declarations_cache :members: :undoc-members: :show-inheritance: -The :mod:`parser.etree_scanner` Modules ---------------------------------------- +The :mod:`pygccxml.parser.directory_cache` module +------------------------------------------------- -.. automodule:: parser.etree_scanner +.. automodule:: pygccxml.parser.directory_cache :members: :undoc-members: :show-inheritance: -The :mod:`parser.linker` Modules --------------------------------- +The :mod:`pygccxml.parser.etree_scanner` module +----------------------------------------------- -.. automodule:: parser.linker +.. automodule:: pygccxml.parser.etree_scanner :members: :undoc-members: :show-inheritance: -The :mod:`parser.patcher` Modules ---------------------------------- +The :mod:`pygccxml.parser.linker` module +---------------------------------------- -.. automodule:: parser.patcher +.. automodule:: pygccxml.parser.linker :members: :undoc-members: :show-inheritance: -The :mod:`parser.project_reader` Modules ----------------------------------------- +The :mod:`pygccxml.parser.patcher` module +----------------------------------------- -.. automodule:: parser.project_reader +.. automodule:: pygccxml.parser.patcher :members: :undoc-members: :show-inheritance: -The :mod:`parser.scanner` Modules ---------------------------------- +The :mod:`pygccxml.parser.project_reader` module +------------------------------------------------ -.. automodule:: parser.scanner +.. automodule:: pygccxml.parser.project_reader :members: :undoc-members: :show-inheritance: -The :mod:`parser.source_reader` Modules ---------------------------------------- +The :mod:`pygccxml.parser.scanner` module +----------------------------------------- -.. automodule:: parser.source_reader +.. automodule:: pygccxml.parser.scanner :members: :undoc-members: :show-inheritance: -The :mod:`..\pygccxml_dev\pygccxml\parser` Package --------------------------------------------------- +The :mod:`pygccxml.parser.source_reader` module +----------------------------------------------- -.. automodule:: ..\pygccxml_dev\pygccxml\parser +.. automodule:: pygccxml.parser.source_reader :members: :undoc-members: :show-inheritance: Modified: pygccxml_dev/docs/apidocs/utils.rest =================================================================== --- pygccxml_dev/docs/apidocs/utils.rest 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/apidocs/utils.rest 2009-01-29 22:14:51 UTC (rev 1641) @@ -1,20 +1,23 @@ -..\Pygccxml_Dev\Pygccxml\Utils Documentation -============================================ +====================== +pygccxml.utils package +====================== -This page contains the ..\Pygccxml_Dev\Pygccxml\Utils Package documentation. +This page contains the `pygccxml.utils` package API documentation. -The :mod:`utils.fs_utils` Modules +The :mod:`pygccxml.utils` package --------------------------------- -.. automodule:: pygccxml.utils.fs_utils +.. automodule:: pygccxml.utils :members: :undoc-members: :show-inheritance: -The :mod:`..\pygccxml_dev\pygccxml\utils` Package -------------------------------------------------- -.. automodule:: pygccxml.utils + +The :mod:`utils.fs_utils` module +--------------------------------- + +.. automodule:: pygccxml.utils.fs_utils :members: :undoc-members: :show-inheritance: Modified: pygccxml_dev/docs/pygccxml.rest =================================================================== --- pygccxml_dev/docs/pygccxml.rest 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/docs/pygccxml.rest 2009-01-29 22:14:51 UTC (rev 1641) @@ -111,7 +111,7 @@ ---------------- `pygccxml`_ comes with comprehensive unit tests. They are executed on Windows XP -and `Ubuntu`_ Linux operating system. In most cases Python 2.5 and 2.6 are used. +and `Ubuntu`_ Linux operating systems. In most cases Python 2.5 and 2.6 are used. I still maintain backward compatibility to Python 2.4. All in all, `pygccxml` has more than 230 tests. @@ -120,7 +120,6 @@ ------------------------------- .. toctree:: - :maxdepth: 2 example/example.rest download.rest Modified: pygccxml_dev/pygccxml/parser/__init__.py =================================================================== --- pygccxml_dev/pygccxml/parser/__init__.py 2009-01-29 19:49:51 UTC (rev 1640) +++ pygccxml_dev/pygccxml/parser/__init__.py 2009-01-29 22:14:51 UTC (rev 1641) @@ -34,7 +34,8 @@ , config=None , compilation_mode=COMPILATION_MODE.FILE_BY_FILE , cache=None ): - """Parse header files. + """ + Parse header files. @param files: The header files that should be parsed @type files: list of str @@ -46,7 +47,6 @@ @type cache: L{cache_base_t} or str @returns: Declarations """ - if not config: config = config_t() parser = project_reader_t( config=config, cache=cache ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-04 16:32:10
|
Revision: 1658 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1658&view=rev Author: roman_yakovenko Date: 2009-02-04 16:32:04 +0000 (Wed, 04 Feb 2009) Log Message: ----------- sphinx Modified Paths: -------------- pydsc_dev/pydsc.py pydsc_dev/unittests/tester.py pydsc_dev/unittests/to_be_tested.py pygccxml_dev/pygccxml/__init__.py pygccxml_dev/pygccxml/declarations/algorithm.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/enumeration.py pygccxml_dev/pygccxml/declarations/matcher.py pygccxml_dev/pygccxml/declarations/matchers.py pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py pygccxml_dev/pygccxml/declarations/namespace.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/declarations/templates.py pygccxml_dev/pygccxml/utils/__init__.py pygccxml_dev/unittests/autoconfig.py Modified: pydsc_dev/pydsc.py =================================================================== --- pydsc_dev/pydsc.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pydsc_dev/pydsc.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -22,8 +22,8 @@ __license__ = 'Boost Software License <http://boost.org/more/license_info.html>' #license import os +import re import sys -import pdb import pprint import inspect import __builtin__ @@ -33,59 +33,38 @@ """return os.path.normcase( os.path.normpath( some_path ) )""" return os.path.normcase( os.path.normpath( some_path ) ) -class filter_by_path_t: +def contains_parent_dir( path, dirs ): """ - Utility class, should not be used directly. - """ + returns true if one of the directories is root directory for the `path`, false otherwise - class FILTER_TYPE: - """ - defines few filter constants + :param path: path to be checked + :type path: str - - *INCLUDE* - - *EXCLUDE* - """ - INCLUDE = 'include' - EXCLUDE = 'exclude' + :param dirs: list of directories and\\or files + :type dirs: [ str ] - def __init__( self, what, ftype ): - """ - :parameters: - - `what` - could be file or directory name, or list of them - - `ftype` - one of the :const:`FILTER_TYPE` constants - """ - self.what = what - if None is self.what: - self.what = [] - elif isinstance( self.what, str ): - self.what = [self.what] - self.what = map( normalize_path, self.what ) - self.ftype = ftype + :rtype: bool + """ + #precondition: dirs and fpath should be normalize_path'ed before calling this function + return bool( filter( lambda dir: path.startswith( dir ), dirs ) ) - @staticmethod - def contains_parent_dir( path, dirs ): - """ - returns true if one of the directories is root directory for the `path`, false otherwise +def is_identifier( word ): + """ + returns `True` is the word represents an identifier, constructed from two or more words, `False` otherwise. - :param path: path - :type path: str + This function is used to filter out some errors, reported by spell checker. + """ + if not word: + return False + if '_' in word: + return True + rest_of_word = word[1:] + for ch in rest_of_word: + if ch == ch.upper(): + return True + return False - :param dirs: list of directories and\\or files - :type dirs: [ str ] - :rtype: bool - """ - #precondition: dirs and fpath should be normalize_path'ed before calling this function - return bool( filter( lambda dir: path.startswith( dir ), dirs ) ) - - def check( self, source_file ): - """returns True if source_file should be checked, False otherwise""" - source_file = normalize_path( source_file ) - if source_file in self.what or self.contains_parent_dir( source_file, self.what ): - return self.ftype == self.FILTER_TYPE.INCLUDE - else: - return self.ftype == self.FILTER_TYPE.EXCLUDE - class checker_t( object ): """ Applies spell check process on every imported module. @@ -98,8 +77,8 @@ def __init__( self , speller , writer=None - , filter=None - , ignore_identifiers=True ): + , ignore_identifiers=True + , text_preprocessor=None ): """ initialization method @@ -113,9 +92,6 @@ :param writer: reference to instance of class that has write method. By default sys.stdout will be used. - :param filter: list of files or directories - :type filter: [ str ] - :param filter_type: provides interpretation for content of filter parameter :type filter_type: L{FILTER_TYPE} @@ -124,6 +100,9 @@ usually introduce spell error. If ignore_identifiers set to True, those names will be ignored. :type ignore_identifiers: bool + + :param text_preprocessor: a callable, which takes a text before it is passed to + the spell checker. The result will be passed to the spell checker. """ object.__init__( self ) self.__checked = set() @@ -135,13 +114,24 @@ self.writer = writer if self.writer is None: self.writer = sys.stdout - self.filter = filter + self.__include_paths = set() self.ignored_words = set() + self.add_include_paths( '.') self.ignore_identifiers = ignore_identifiers + self.text_preprocessor = text_preprocessor + if not self.text_preprocessor: + self.text_preprocessor = lambda t: t + def add_include_paths( self, path ): + np = lambda p: normalize_path( os.path.abspath( p ) ) + if isinstance( path, str ): + self.__include_paths.add( np( path ) ) + else: + for pi in path: + self.__include_paths.add( np( pi ) ) + def should_be_checked( self, obj, module=None ): """returns True, if obj should be checked, False otherwise""" - if id(obj) in self.__checked: return False if inspect.isbuiltin( obj ): @@ -149,16 +139,11 @@ if inspect.ismodule( obj ): if obj.__name__ in self.__already_imported: return False #do not check already imported modules - if self.filter: - try: - source_file = self.getsourcefile(obj) - if source_file is None: - source_file = inspect.getfile( obj ) - return self.filter.check( source_file ) - except TypeError: - return False #built in module + source_file = self.getsourcefile(obj) + if source_file: + return contains_parent_dir( source_file, self.__include_paths ) else: - return True + return False obj_module = inspect.getmodule( obj ) if not obj_module is module: return False @@ -182,20 +167,43 @@ @staticmethod def getsourcefile( obj ): try: - return inspect.getsourcefile( obj ) + fpath = inspect.getsourcefile( obj ) + if fpath is None: + fpath = inspect.getfile( obj ) + if fpath: + fpath = os.path.abspath( fpath ) + fpath = normalize_path( fpath ) + return fpath except TypeError: pass - def __check_text_impl( self, obj, text, text_type ): + def __get_local_ignored_words( self, obj ): + names = set() + if inspect.ismethod( obj ) or inspect.isfunction( obj ): + args_desc = inspect.getargspec( obj ) + names.update( args_desc[0] ) + if args_desc[1]: + names.add( args_desc[1] ) + if args_desc[2]: + names.add( args_desc[2] ) + return names + + def __check_text_impl( self, obj, text_, text_type ): + text = self.text_preprocessor( text_ ) if not text: return if self.ignore_identifiers and hasattr( obj, '__name__' ) and obj.__name__: self.ignored_words.add( obj.__name__ ) + + local_ignored_words = self.__get_local_ignored_words( obj ) + errors = {} self.speller.set_text( text ) for error in self.speller: - if error.word in self.ignored_words: + if error.word in self.ignored_words or error.word in local_ignored_words: continue + if is_identifier( error.word ): + continue if not errors.has_key( error.word ): errors[ error.word ] = [] errors[ error.word ] = self.speller.suggest() @@ -204,8 +212,7 @@ write = self.writer.write if self.getsourcefile( inspect.getmodule( obj ) ): write( ' error details: %s' % os.linesep ) - write( ' file : %s%s' % ( self.getsourcefile( inspect.getmodule( obj ) ), os.linesep ) ) - write( ' line : %d%s' % ( inspect.getsourcelines( obj )[1], os.linesep ) ) + write( ' location : %s:%d%s' % ( self.getsourcefile( inspect.getmodule( obj ) ), 1 + inspect.getsourcelines( obj )[1], os.linesep ) ) write( ' text type : %s%s' % ( text_type, os.linesep ) ) else: write( ' error details: %s' % os.linesep ) @@ -213,6 +220,9 @@ for word, suggestions in errors.items(): write( ' misspelled word: %s%s' % ( word, os.linesep ) ) write( ' suggestions : %s%s' % ( `suggestions`, os.linesep ) ) + clean = lambda t: t.replace( '\n', ' ' ).replace( '\r', '' ) + write( ' source file text: %s\n' % clean( text_ ) ) + write( ' checked text : %s\n' % clean( text ) ) def __check_text( self, obj): self.__check_text_impl( obj, inspect.getdoc( obj ), 'documentation string' ) @@ -237,27 +247,20 @@ doc_checker = None if 'PYDSC' in os.environ: if not 'sphinx' in os.environ['PYDSC']: - doc_checker = checker_t( checker.SpellChecker( "en_US" ) ) + doc_checker = checker_t( checker.SpellChecker( "en_US" )) #, filters=[checker.EmailFilter,checker.URLFilter] ) ) else: - doc_checker = checker_t( checker.SpellChecker( "en_US" ) ) + doc_checker = checker_t( checker.SpellChecker( "en_US" ))#, filters=[checker.EmailFilter,checker.URLFilter, checker.WikiWordFilter] ) ) -def exclude( what ): - """ - excludes all modules, from the check process, that are lying in *what* directory(ies) - *what* - a path or list of paths, could be or contain file and/or directory names +def include_paths( what ): """ - doc_checker.filter = filter_by_path_t( what, filter_by_path_t.FILTER_TYPE.EXCLUDE ) - -def include( what ): - """ includes all modules, to the check process, that are lying in *what* directory(ies) *what* - a path or list of paths, could be or contain file and/or directory names """ - doc_checker.filter = filter_by_path_t( what, filter_by_path_t.FILTER_TYPE.INCLUDE ) + doc_checker.add_include_paths( what ) -def ignore( what, case_sensitive=False ): +def ignore_words( what, case_sensitive=False ): """ adds *what*, word or list of words, to the ignore list. @@ -270,6 +273,42 @@ else: for word in what: if case_sensitive: - word = what.lower() + word = word.lower() doc_checker.ignored_words.add( word ) +def ignore_dictionary( path, case_sensitive=False ): + """ + adds all words from file to the "ignore" list + + The file should contain one word per line + + :param path: path to dictionary file + :type path: str + """ + for w in file( path, 'r' ).readlines(): + w = w.strip() + if case_sensitive: + w = w.lower() + if w: + doc_checker.ignored_words.add( w ) + +def set_text_preprocessor( preprocessor ): + doc_checker.text_preprocessor = preprocessor + +__ref_def = re.compile( r':[_a-zA-Z]+(\s+[_a-zA-Z]+)?:' ) +__ref_no_title = re.compile( r'`(\:\:)?[_a-zA-Z]+[_a-zA-Z0-9\.\:]*`' ) +__ref_with_title = re.compile( r'`(?P<text>.+)?\s(\<.*\>)`' ) + +def sphinx_preprocessor( text ): + def replace( m ): + if 'text' in m.groupdict(): + return ' ' * ( m.start( 'text' ) - m.start() ) + m.group( 'text' ) + ' ' * ( m.end() - m.end( 'text' ) ) + else: + return ' ' * ( m.end() - m.start() ) + if not text: + return text + result = text + result = __ref_no_title.sub( replace, result ) + result = __ref_def.sub( replace, result ) + result = __ref_with_title.sub( replace, result ) + return result Modified: pydsc_dev/unittests/tester.py =================================================================== --- pydsc_dev/unittests/tester.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pydsc_dev/unittests/tester.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -9,8 +9,7 @@ import pydsc -pydsc.exclude( os.path.abspath( os.path.join( os.curdir, 'do_not_check' ) ) ) -pydsc.ignore( 'abracadabra' ) +pydsc.ignore_words( 'abracadabra' ) import to_be_tested import do_not_check Modified: pydsc_dev/unittests/to_be_tested.py =================================================================== --- pydsc_dev/unittests/to_be_tested.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pydsc_dev/unittests/to_be_tested.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -11,6 +11,9 @@ code_creator_t is the base class for all code creators. This class defines interface that every code creator should implement. Also it provides few convinience functions. + + + qeqerqwerqwerqwer """ PYPLUSPLUS_NS_NAME = 'pyplusplus' __INDENTATION = ' ' Modified: pygccxml_dev/pygccxml/__init__.py =================================================================== --- pygccxml_dev/pygccxml/__init__.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/__init__.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -12,19 +12,16 @@ XML file. This XML file is then read by pygccxml and the contents are made available as appropriate Python objects. -To parse a set of C/C++ header files you use the -L{parse()<parser.parse>} function in the L{parser} sub package which -returns a tree that contains all declarations found in the header -files. The root of the tree represents the main namespace C{::} and -the children nodes represent the namespace contents such as other -namespaces, classes, functions, etc. Each node in the tree is an -object of a type derived from the -L{declaration_t<declarations.declaration_t>} base class. An inner -node is always either a namespace (L{namespace_t<declarations.namespace_t>}) -or a class (L{class_t<declarations.class_t>}) which are both derived -from L{scopedef_t<declarations.scopedef_t>}. Everything else (free functions, -member functions, enumerations, variables, etc.) is always a leaf. -You will find all those declaration classes in the L{declarations} +To parse a set of C/C++ header files you use the :func:`parse <parser.parse>` +function in the :mod:parser sub package which returns a tree that contains all +declarations found in the header files. The root of the tree represents the main +namespace `::` and the children nodes represent the namespace contents such as other +namespaces, classes, functions, etc. Each node in the tree is an object of a type +derived from the :class:`declaration_t` class. An inner node is always either a +namespace :class:`declarations.namespace_t` or a class :class:`declarations.class_t`, +which are both derived from :class:`declarations.scopedef_t` class. Everything +else (free functions, member functions, enumerations, variables, etc.) is always +a leaf. You will find all those declaration classes in the :mod:declarations sub-package. """ Modified: pygccxml_dev/pygccxml/declarations/algorithm.py =================================================================== --- pygccxml_dev/pygccxml/declarations/algorithm.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/algorithm.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -15,7 +15,7 @@ :type decl: :class:`declaration_t` :rtype: [names], where first item contains top parent name and last item - contains decl name + contains the `decl` name """ if not decl: return [] @@ -45,7 +45,7 @@ :type decl: :class:`declaration_t` :rtype: [names], where first item contains top parent name and last item - contains decl name + contains the `decl` name """ #TODO: #If parent declaration cache already has declaration_path, reuse it for @@ -98,8 +98,8 @@ def full_name( decl, with_defaults=True ): """ returns declaration full qualified name - - If `decl` belongs to anonymious namespace or class, the function will return C++ illegal qualified name. + + If `decl` belongs to anonymous namespace or class, the function will return C++ illegal qualified name. :param decl: :class:`declaration_t` :type decl: :class:`declaration_t` :rtype: full name of declarations. Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -501,7 +501,7 @@ return get_partial_name( self.name ) def find_noncopyable_vars( self ): - """returns list of all noncopyable variables""" + """returns list of all `noncopyable` variables""" import type_traits as tt#prevent cyclic dependencies logger = utils.loggers.cxx_parser mvars = self.vars( lambda v: not v.type_qualifiers.has_static, recursive=False, allow_empty=True ) Modified: pygccxml_dev/pygccxml/declarations/enumeration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/enumeration.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/enumeration.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -4,7 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines class, that describes C++ enum +defines class, that describes C++ `enum` """ import copy @@ -14,15 +14,15 @@ class enumeration_t( declaration.declaration_t ): """ - describes C++ enum + describes C++ `enum` """ def __init__( self, name='', values=None ): - """creates class that describes C++ enum declaration + """creates class that describes C++ `enum` declaration The items of the list 'values' may either be strings containing the enumeration value name or tuples (name, numvalue). - :param name: Enum name + :param name: `enum` name :type name: str :param parent: Parent declaration :type parent: declaration_t @@ -75,7 +75,7 @@ @type: list""") def append_value(self, valuename, valuenum=None): - """Append another enumeration value to the enum. + """Append another enumeration value to the `enum`. The numeric value may be None in which case it is automatically determined by increasing the value of the last item. @@ -99,7 +99,7 @@ self._values.append((valuename, int(valuenum))) def has_value_name(self, name): - """Check if this enum has a particular name among its values. + """Check if this `enum` has a particular name among its values. :param name: Enumeration value name :type name: str @@ -111,7 +111,7 @@ return False def get_name2value_dict( self ): - """returns a dictionary, that maps between enum name( key ) and enum value( value )""" + """returns a dictionary, that maps between `enum` name( key ) and `enum` value( value )""" x = {} for val, num in self._values: x[val] = num Modified: pygccxml_dev/pygccxml/declarations/matcher.py =================================================================== --- pygccxml_dev/pygccxml/declarations/matcher.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/matcher.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -32,11 +32,12 @@ @staticmethod def find( decl_matcher, decls, recursive=True ): - """returns a list of declarations that match "decl_matcher" defined criretia or None + """ + returns a list of declarations that match `decl_matcher` defined criteria or None - :param decl_matcher: Python callable object, that takes one argument - reference to declaration - :param decls: reference to declaration or list of declarations to be searched in - :param recursive: boolean, if True the method will run decl_matcher, on internal declarations too + :param decl_matcher: Python callable object, that takes one argument - reference to a declaration + :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t + :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ where = [] @@ -50,13 +51,14 @@ @staticmethod def find_single( decl_matcher, decls, recursive=True ): - """returns a reference to declaration, that match "decl_matcher" defined - criretia, if a unique declaration could not be found the method will return - None. + """ + returns a reference to the declaration, that match `decl_matcher` defined criteria. - :param decl_matcher: Python callable object, that takes one argument - reference to declaration - :param decls: reference to declaration or list of declarations to be searched in - :param recursive: boolean, if True the method will run decl_matcher, on internal declarations too + if a unique declaration could not be found the method will return None. + + :param decl_matcher: Python callable object, that takes one argument - reference to a declaration + :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t + :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ answer = matcher.find( decl_matcher, decls, recursive ) if len(answer) == 1: @@ -64,13 +66,14 @@ @staticmethod def get_single( decl_matcher, decls, recursive=True ): - """returns a reference to declaration, that match "decl_matcher" defined - criretia, if a unique declaration could not be found, an appropriate - exception will be raised. + """ + returns a reference to declaration, that match `decl_matcher` defined criteria. - :param decl_matcher: Python callable object, that takes one argument - reference to declaration - :param decls: reference to declaration or list of declarations to be searched in - :param recursive: boolean, if True the method will run decl_matcher, on internal declarations too + If a unique declaration could not be found, an appropriate exception will be raised. + + :param decl_matcher: Python callable object, that takes one argument - reference to a declaration + :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t + :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ answer = matcher.find( decl_matcher, decls, recursive ) if len(answer) == 1: Modified: pygccxml_dev/pygccxml/declarations/matchers.py =================================================================== --- pygccxml_dev/pygccxml/declarations/matchers.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/matchers.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -110,7 +110,7 @@ """ Instance of this class will match declarations by next criteria: - declaration name, also could be fully qualified name - Example: wstring or ::std::wstring + Example: `wstring` or `::std::wstring` - declaration type Example: :class:`class_t`, :class:`namespace_t`, :class:`enumeration_t` - location within file system ( file or directory ) @@ -491,15 +491,15 @@ class virtuality_type_matcher_t( matcher_base_t ): """ - Instance of this class will match declaration by its virtuality type: not virtual, - virtual or pure virtual. If declarations does not have virtuality type, for example - free function, then False will be returned. + Instance of this class will match declaration by its virtual type: not virtual, + virtual or pure virtual. If declarations does not have "virtual" property, + for example free function, then `False` will be returned. """ def __init__( self, virtuality_type ): """ :param access_type: declaration access type - :type access_type: :class:VIRTUALITY_TYPES defines few consts for your convinience. + :type access_type: :class:VIRTUALITY_TYPES defines few constants for your convenience. """ matcher_base_t.__init__( self ) self.virtuality_type = virtuality_type Modified: pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py =================================================================== --- pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -31,17 +31,26 @@ callable_( *arguments, **keywords ) class mdecl_wrapper_t( object ): - """Multiple declarations wrapper. + """ + multiple declarations class wrapper - The main purpose of this class is to allow an user to work on many - declarations, as they were only one single declaration. + The main purpose of this class is to allow an user to work on many declarations, + as they were only one single declaration. - Example: - mb = module_builder_t( ... ) - #lets say we want to exclude all member functions, that returns reference to int: - mb.member_functions( return_type='int &' ).exclude() + For example, instead of writing `for` loop like the following - "exclude" function will be called on every function that match the criteria. + .. code-block:: python + + for c in global_namespace.classes(): + c.compiler = "GCCXML 1.127" + + you can write: + + .. code-block:: python + + global_namespace.classes().compiler = "GCCXML 1.127" + + The same functionality could be applied on "set" methods too. """ def __init__( self, decls ): @@ -69,7 +78,7 @@ invalid_decls = filter( lambda d: not hasattr( d, name ), self.declarations ) sep = os.linesep + ' ' if invalid_decls: - raise RuntimeError( "Next declarations don't have '%s' attribute: %s" + raise RuntimeError( "Next declarations don't have '%s' attribute: %s" % ( name, sep.join( map( str, invalid_decls ) ) ) ) def __setattr__( self, name, value ): @@ -93,4 +102,4 @@ l = [] for d in self.declarations: l.append( d ) - return l \ No newline at end of file + return l Modified: pygccxml_dev/pygccxml/declarations/namespace.py =================================================================== --- pygccxml_dev/pygccxml/declarations/namespace.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/namespace.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -50,9 +50,9 @@ def adopt_declaration( self, decl ): self.declarations.append( decl ) - decl.parent = self + decl.parent = self decl.cache.reset() - + def remove_declaration( self, decl ): """ removes decl from members list @@ -67,24 +67,24 @@ # decl.parent=None def namespace( self, name=None, function=None, recursive=None ): - """returns reference to namespace declaration, that is matched defined criterias""" + """returns reference to namespace declaration, that is matched defined criteria""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function , recursive=recursive ) ns = namespace - + def namespaces( self, name=None, function=None, recursive=None, allow_empty=None ): - """returns a set of namespace declarations, that are matched defined criterias""" + """returns a set of namespace declarations, that are matched defined criteria""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function , recursive=recursive , allow_empty=allow_empty) nss = namespaces - + def free_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to free function declaration, that is matched defined criterias""" + """returns reference to free function declaration, that is matched defined criteria""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function @@ -95,9 +95,9 @@ , header_file=header_file , recursive=recursive ) free_fun = free_function - + 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 ): - """returns a set of free function declarations, that are matched defined criterias""" + """returns a set of free function declarations, that are matched defined criteria""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function @@ -111,7 +111,7 @@ free_funs = free_functions def free_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to free operator declaration, that is matched defined criterias""" + """returns reference to free operator declaration, that is matched defined criteria""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -124,7 +124,7 @@ , 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, allow_empty=None ): - """returns a set of free operator declarations, that are matched defined criterias""" + """returns a set of free operator declarations, that are matched defined criteria""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -28,10 +28,10 @@ 1. `name` - declaration name, could be full qualified name - 2. `header_dir` - directory, to which belongs file, that the declaration was declarated in. + 2. `header_dir` - directory, to which belongs file, that the declaration was declared in. `header_dir` should be absolute path. - 3. `header_file` - file that the declaration was declarated in. + 3. `header_file` - file that the declaration was declared in. 4. `function` - user ( your ) custom criteria. The interesting thing is that this function will be joined with other arguments ( criteria ). @@ -40,31 +40,25 @@ internal declarations too. - Every "select" API you can invoke and pass as first argument at declaration - name or function. This class will find out correctly what argument represents. + Every ""query"" API, takes name or function as the first argument. - Example: :: - ns - referrers to global namespace - ns.member_function( "do_something ) - will return reference to member - function named "do_something". If there is no such function exception - will be raised. If there is more then one function exception will be - raised too. + .. code-block:: python - Example 2: :: - ns - referers to global namespace - do_smths = ns.member_functions( "do_something ) - will return instance - of :class:`mdecl_wrapper_t` object. This object allows you few things: + global_namespace.member_function( "do_something ) - 1. To iterate on selected declarations + the statement returns reference to member function named "do_something". + If there the function doesn't exist or more than one function exists, + an exception is raised. - 2. To set some property to desired value using one line of code only: - do_smths.call_policies = x + If you want to query for many declarations, use other function(s): - 3. To call some function on every instance using one line of code: - do_smths.exclude() + .. code-block:: python + do_something = global_namespace.member_functions( "do_something ) - Pay attention: you can not use "get" functions or properties. + the statement returns :class:`mdecl_wrapper_t` instance. That object will save + you writing `for` loops. For more information see :class:`the class <mdecl_wrapper_t>` + documentation. """ RECURSIVE_DEFAULT = True @@ -168,7 +162,9 @@ , self.declarations ) ) def init_optimizer(self): - """Initializes query optimizer state. + """ + Initializes query optimizer state. + There are 4 internals hash tables: 1. from type to declarations 2. from type to declarations for non-recursive queries @@ -177,7 +173,7 @@ Almost every query includes declaration type information. Also very common query is to search some declaration(s) by name or full name. - Those hashtables allows to search declaration very quick. + Those hash tables allows to search declaration very quick. """ if self.name == '::': self._logger.debug( "preparing data structures for query optimizer - started" ) @@ -382,7 +378,7 @@ return mfound def decl( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to declaration, that is matched defined criterias""" + """returns reference to declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.decl ] , name=name , function=function @@ -392,7 +388,7 @@ , recursive=recursive) def decls( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of declarations, that are matched defined criterias""" + """returns a set of declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.decl ] , name=name , function=function @@ -403,7 +399,7 @@ , allow_empty=allow_empty) def class_( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to class declaration, that is matched defined criterias""" + """returns reference to class declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.class_ ] , name=name , function=function @@ -413,7 +409,7 @@ , recursive=recursive) def classes( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of class declarations, that are matched defined criterias""" + """returns a set of class declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.class_ ] , name=name , function=function @@ -424,7 +420,7 @@ , allow_empty=allow_empty) def variable( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to variable declaration, that is matched defined criterias""" + """returns reference to variable declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.variable ] , name=name , function=function @@ -435,7 +431,7 @@ var = variable #small alias def variables( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of variable declarations, that are matched defined criterias""" + """returns a set of variable declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.variable ] , name=name , function=function @@ -447,7 +443,7 @@ vars = variables #small alias def calldef( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to "calldef" declaration, that is matched defined criterias""" + """returns reference to "calldef" declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.calldef ] , name=name , function=function @@ -459,7 +455,7 @@ , recursive=recursive ) def calldefs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of calldef declarations, that are matched defined criterias""" + """returns a set of calldef declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.calldef ] , name=name , function=function @@ -472,7 +468,7 @@ , allow_empty=allow_empty) def operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to operator declaration, that is matched defined criterias""" + """returns reference to operator declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -485,7 +481,7 @@ , recursive=recursive ) def 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 ): - """returns a set of operator declarations, that are matched defined criterias""" + """returns a set of operator declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -499,7 +495,7 @@ , 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 ): - """returns reference to member declaration, that is matched defined criterias""" + """returns reference to member declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.member_function ] , name=name , function=function @@ -512,7 +508,7 @@ mem_fun = member_function 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 ): - """returns a set of member function declarations, that are matched defined criterias""" + """returns a set of member function declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.member_function ] , name=name , function=function @@ -526,7 +522,7 @@ mem_funs = member_functions def constructor( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to constructor declaration, that is matched defined criterias""" + """returns reference to constructor declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.constructor ] , name=name , function=function @@ -538,7 +534,7 @@ , recursive=recursive ) def constructors( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of constructor declarations, that are matched defined criterias""" + """returns a set of constructor declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.constructor ] , name=name , function=function @@ -551,7 +547,7 @@ , 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 ): - """returns reference to member operator declaration, that is matched defined criterias""" + """returns reference to member operator declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.member_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -564,7 +560,7 @@ , recursive=recursive ) mem_oper = member_operator 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 ): - """returns a set of member operator declarations, that are matched defined criterias""" + """returns a set of member operator declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.member_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol @@ -579,7 +575,7 @@ mem_opers = member_operators def casting_operator( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to casting operator declaration, that is matched defined criterias""" + """returns reference to casting operator declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.casting_operator ] , name=name , function=function @@ -591,7 +587,7 @@ , recursive=recursive ) 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 ): - """returns a set of casting operator declarations, that are matched defined criterias""" + """returns a set of casting operator declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.casting_operator ] , name=name , function=function @@ -604,7 +600,7 @@ , allow_empty=allow_empty) def enumeration( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to enumeration declaration, that is matched defined criterias""" + """returns reference to enumeration declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.enumeration ] , name=name , function=function @@ -617,7 +613,7 @@ """adding small aliase to enumeration method""" def enumerations( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of enumeration declarations, that are matched defined criterias""" + """returns a set of enumeration declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.enumeration ] , name=name , function=function @@ -630,7 +626,7 @@ enums = enumerations def typedef( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ): - """returns reference to typedef declaration, that is matched defined criterias""" + """returns reference to typedef declaration, that is matched defined criteria""" return self._find_single( self._impl_matchers[ scopedef_t.typedef ] , name=name , function=function @@ -640,7 +636,7 @@ , recursive=recursive) def typedefs( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): - """returns a set of typedef declarations, that are matched defined criterias""" + """returns a set of typedef declarations, that are matched defined criteria""" return self._find_multiple( self._impl_matchers[ scopedef_t.typedef ] , name=name , function=function @@ -651,9 +647,10 @@ , allow_empty=allow_empty) def __getitem__(self, name_or_function): - """ Allow simple name based find of decls. Internally just calls decls() method. - :param name_or_function Name of decl to lookup or finder function. """ + Allow simple name based find of declarations. Internally just calls `decls` method. + :param name_or_function: Name of `decl` to lookup or finder function. + """ return self.decls(name_or_function) Modified: pygccxml_dev/pygccxml/declarations/templates.py =================================================================== --- pygccxml_dev/pygccxml/declarations/templates.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/declarations/templates.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -3,11 +3,11 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -""" +""" template instantiation parser This module implements all functionality necessary to parse C++ template -instantiations.In other words this module is able to extract next information from +instantiations.In other words this module is able to extract next information from the string like this C{ std::vector<int> }. - name ( std::vector ) - list of arguments ( int ) @@ -21,11 +21,11 @@ def is_instantiation( decl_string ): """ - returns True if decl_string is template instantiation and False otherwise - + returns True if `decl_string` is template instantiation and False otherwise + :param decl_string: string that should be checked for pattern presence :type decl_string: str - + :rtype: bool """ global __THE_PARSER @@ -34,7 +34,7 @@ def name( decl_string ): """ returns name of instantiated template - + :type decl_string: str :rtype: str """ @@ -44,18 +44,18 @@ def args( decl_string ): """ returns list of template arguments - - :type decl_string: str - :rtype: [str] + + :type decl_string: `str` + :rtype: [`str`] """ global __THE_PARSER return __THE_PARSER.args( decl_string ) - + def split( decl_string ): """returns (name, [arguments] )""" global __THE_PARSER return __THE_PARSER.split( decl_string ) - + def split_recursive( decl_string ): """returns [(name, [arguments])]""" global __THE_PARSER @@ -67,8 +67,8 @@ return __THE_PARSER.join( name, args ) def normalize( decl_string ): - """returns decl_string, which contains "normalized" spaces - + """returns `decl_string`, which contains "normalized" spaces + this functionality allows to implement comparison of 2 different string which are actually same: x::y< z > and x::y<z> """ Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/pygccxml/utils/__init__.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -4,7 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines logger classes and few convinience methods, not related to the declarations +defines logger classes and few convenience methods, not related to the declarations tree """ @@ -59,7 +59,7 @@ """ root = logging.getLogger( 'pygccxml' ) - """root logger exists for your convinience only""" + """root logger exists for your convenience only""" all = [ root, cxx_parser, queries_engine, declarations_cache, pdb_reader ] """contains all logger classes, defined by the class""" @@ -74,7 +74,7 @@ % ( file_name, str( error ) ) ) def create_temp_file_name(suffix, prefix=None, dir=None): - """small convinience function that creates temporal file. + """small convenience function that creates temporal file. This function is a wrapper aroung Python built-in function - tempfile.mkstemp """ Modified: pygccxml_dev/unittests/autoconfig.py =================================================================== --- pygccxml_dev/unittests/autoconfig.py 2009-02-03 20:42:16 UTC (rev 1657) +++ pygccxml_dev/unittests/autoconfig.py 2009-02-04 16:32:04 UTC (rev 1658) @@ -15,8 +15,11 @@ this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) ) sys.path.append( os.path.abspath( os.path.join( this_module_dir_path, '..', '..', 'pydsc_dev' ) ) ) -#~ import pydsc +import pydsc +pydsc.ignore_dictionary( 'ignore_dictionary.txt' ) +pydsc.set_text_preprocessor( pydsc.sphinx_preprocessor ) +pydsc.include_paths( os.path.join( this_module_dir_path, '..', '..', 'pygccxml_dev' ) ) data_directory = os.path.join( this_module_dir_path, 'data' ) build_directory = os.path.join( this_module_dir_path, 'temp' ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-09 21:10:13
|
Revision: 1669 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1669&view=rev Author: roman_yakovenko Date: 2009-02-09 21:10:08 +0000 (Mon, 09 Feb 2009) Log Message: ----------- sphinx Modified Paths: -------------- index.rest pydsc_dev/docs/pydsc.rest pygccxml_dev/docs/apidocs/binary_parsers.rest pygccxml_dev/docs/apidocs/declarations.rest pygccxml_dev/docs/apidocs/parser.rest pygccxml_dev/docs/apidocs/utils.rest pygccxml_dev/docs/pygccxml.rest pygccxml_dev/pygccxml/binary_parsers/__init__.py pygccxml_dev/pygccxml/binary_parsers/parsers.py pygccxml_dev/pygccxml/utils/__init__.py Modified: index.rest =================================================================== --- index.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ index.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -10,10 +10,8 @@ * Do you need to build code generator? * Do you need to create UML diagram? -`pygccxml`_ is the way to go! `Learn more`__. +:doc:`pygccxml <pygccxml/pygccxml>` is the way to go! :doc:`Learn more <pygccxml/pygccxml>`. -.. __: `pygccxml`_ - ------------ Py++ package ------------ @@ -21,79 +19,36 @@ "I love deadlines. I love the whooshing noise they make as they go by." -- Douglas Adams -Meet your deadlines with powerful code generator engine - `Py++`_. -`Py++`_ package and `Boost.Python`_ library provide a complete solution for -interfacing Python and C++. `Learn more`_. +Meet your deadlines with powerful code generator engine - :doc:`Py++ <pyplusplus/pyplusplus>`. -*European Space Agency*, *Ogre*, *PyOpenSG* and many others `use`__ Py++. +:doc:`Py++ <pyplusplus/pyplusplus>`, `ctypes <http://docs.python.org/library/ctypes.html>`_ +and `Boost.Python <http://www.boost.org/doc/libs/1_38_0/libs/python/doc/index.html>`_ +provide a complete solution for interfacing Python and C\\C++. +:doc:`Learn more <pyplusplus/pyplusplus>`. -.. _`Learn more` : `Py++`_ +*European Space Agency*, *Ogre*, *PyOpenSG* and many others :doc:`use <pyplusplus/quotes>` `Py++`. -.. __: ./pyplusplus/quotes.html - ---------------- -pyboost package ---------------- - -`Boost`_ provides free peer-reviewed portable C++ source libraries. `pyboost`_ -package export the following libraries to Python: - - * `Boost.Date_Time`_ - date time library designed to provide a basis for - performing efficient time calculations - * `Boost.CRC`_ - cyclic redundancy code computation objects - * `Boost.Rational`_ - rational number class - * `Boost.Random`_ - a complete system for random number generation - -Python bindings for `boost.graph`_ library is also available from -http://www.osl.iu.edu/~dgregor/bgl-python . - ------------- pydsc package ------------- -Documentation strings contain spelling errors? `Fix them in a minute`_. +Documentation strings contain spelling errors? :doc:`Fix them in a minute <pydsc/pydsc>`! -.. _`Fix them in a minute` : `pydsc`_ +------------- +Documentation +------------- ------------------ -pyeasybmp package ------------------ - -`EasyBMP`_ could be easier? Yes of course! Learn more about `EasyBMP Python bindings`_. - -.. _`EasyBMP Python bindings`: ./pyplusplus/examples/easybmp/easybmp.html - - -.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - .. toctree:: :maxdepth: 2 - pydsc/pydsc.rest pygccxml/pygccxml.rest pyplusplus/pyplusplus.rest + pydsc/pydsc.rest +------------------ +Indices and tables +------------------ -.. _`pyboost` : ./pyplusplus/examples/boost/boost.html -.. _`boost.graph` : http://www.boost.org/libs/graph/doc/table_of_contents.html -.. _`boost.date_time` : http://boost.org/doc/html/date_time.html -.. _`boost.crc` : http://boost.org/libs/crc/index.html -.. _`boost.rational` : http://boost.org/libs/rational/index.html -.. _`boost.random` : http://boost.org/libs/random/index.html - -.. _`Boost`: http://boost.org/ -.. _`Python`: http://www.python.org -.. _`pygccxml`: ./pygccxml/pygccxml.html -.. _`Py++`: ./pyplusplus/pyplusplus.html -.. _`pydsc`: ./pydsc/pydsc.html -.. _`EasyBMP`: http://easybmp.sourceforge.net/ - -.. _`many others` : ./x.html +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` Modified: pydsc_dev/docs/pydsc.rest =================================================================== --- pydsc_dev/docs/pydsc.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ pydsc_dev/docs/pydsc.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -1,14 +1,7 @@ -================== +================== pydsc introduction ================== -.. contents:: Table of contents - -.. toctree:: - :maxdepth: 1 - - API <api> - .. meta:: :description: Python documentation string spell checker :keywords: Python, docstring, documentation, spell, check @@ -69,5 +62,14 @@ python setup.py install +--- +API +--- +.. toctree:: + :maxdepth: 1 + + API <api> + + .. _`PyEnchant`: http://pyenchant.sourceforge.net/ Modified: pygccxml_dev/docs/apidocs/binary_parsers.rest =================================================================== --- pygccxml_dev/docs/apidocs/binary_parsers.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/docs/apidocs/binary_parsers.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -2,9 +2,16 @@ pygccxml.binary_parsers API =========================== -parsers -------- +binary_parsers package +---------------------- +.. automodule:: pygccxml.binary_parsers + :members: + :show-inheritance: + +parsers module +-------------- + .. automodule:: pygccxml.binary_parsers.parsers :members: :show-inheritance: Modified: pygccxml_dev/docs/apidocs/declarations.rest =================================================================== --- pygccxml_dev/docs/apidocs/declarations.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/docs/apidocs/declarations.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -2,176 +2,184 @@ pygccxml.declarations package ============================= -algorithm ---------- +declarations package +-------------------- -.. automodule:: pygccxml.declarations.algorithm +.. automodule:: pygccxml.declarations :members: :show-inheritance: -algorithms_cache + +algorithm module ---------------- +.. automodule:: pygccxml.declarations.algorithm + :members: + :show-inheritance: + +algorithms_cache module +------------------------- + .. automodule:: pygccxml.declarations.algorithms_cache :members: :show-inheritance: -calldef -------- +calldef module +---------------- .. automodule:: pygccxml.declarations.calldef :members: :show-inheritance: -call_invocation ---------------- +call_invocation module +------------------------ .. automodule:: pygccxml.declarations.call_invocation :members: :show-inheritance: -class_declaration ------------------ +class_declaration module +-------------------------- .. automodule:: pygccxml.declarations.class_declaration :members: :show-inheritance: -compilers ---------- +compilers module +------------------ .. automodule:: pygccxml.declarations.compilers :members: :show-inheritance: -container_traits ----------------- +container_traits module +------------------------- .. automodule:: pygccxml.declarations.container_traits :members: :show-inheritance: -cpptypes --------- +cpptypes module +----------------- .. automodule:: pygccxml.declarations.cpptypes :members: :show-inheritance: -declaration ------------ +declaration module +-------------------- .. automodule:: pygccxml.declarations.declaration :members: :show-inheritance: -decl_factory ------------- +decl_factory module +--------------------- .. automodule:: pygccxml.declarations.decl_factory :members: :show-inheritance: -decl_printer ------------- +decl_printer module +--------------------- .. automodule:: pygccxml.declarations.decl_printer :members: :show-inheritance: -decl_visitor ------------- +decl_visitor module +--------------------- .. automodule:: pygccxml.declarations.decl_visitor :members: :show-inheritance: -dependencies ------------- +dependencies module +--------------------- .. automodule:: pygccxml.declarations.dependencies :members: :show-inheritance: -enumeration ------------ +enumeration module +-------------------- .. automodule:: pygccxml.declarations.enumeration :members: :show-inheritance: -function_traits ---------------- +function_traits module +------------------------ .. automodule:: pygccxml.declarations.function_traits :members: :show-inheritance: -matcher -------- +matcher module +---------------- .. automodule:: pygccxml.declarations.matcher :members: :show-inheritance: -matchers --------- +matchers module +----------------- .. automodule:: pygccxml.declarations.matchers :members: :show-inheritance: -mdecl_wrapper -------------- +mdecl_wrapper module +---------------------- .. automodule:: pygccxml.declarations.mdecl_wrapper :members: :show-inheritance: -namespace ---------- +namespace module +------------------ .. automodule:: pygccxml.declarations.namespace :members: :show-inheritance: -scopedef --------- +scopedef module +----------------- .. automodule:: pygccxml.declarations.scopedef :members: :show-inheritance: -templates ---------- +templates module +------------------ .. automodule:: pygccxml.declarations.templates :members: :show-inheritance: -typedef -------- +typedef module +---------------- .. automodule:: pygccxml.declarations.typedef :members: :show-inheritance: -type_traits ------------ +type_traits module +-------------------- .. automodule:: pygccxml.declarations.type_traits :members: :show-inheritance: -type_visitor ------------- +type_visitor module +--------------------- .. automodule:: pygccxml.declarations.type_visitor :members: :show-inheritance: -variable --------- +variable module +--------------- .. automodule:: pygccxml.declarations.variable :members: Modified: pygccxml_dev/docs/apidocs/parser.rest =================================================================== --- pygccxml_dev/docs/apidocs/parser.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/docs/apidocs/parser.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -2,44 +2,51 @@ pygccxml.parser package ======================= -config ------- +parser package +-------------- +.. automodule:: pygccxml.parser + :members: + :show-inheritance: + +config module +--------------- + .. automodule:: pygccxml.parser.config :members: :show-inheritance: -declarations_cache ------------------- +declarations_cache module +---------------------------- .. automodule:: pygccxml.parser.declarations_cache :members: :show-inheritance: -directory_cache ---------------- +directory_cache module +------------------------ .. automodule:: pygccxml.parser.directory_cache :members: :show-inheritance: -patcher -------- +patcher module +---------------- .. automodule:: pygccxml.parser.patcher :members: :show-inheritance: -project_reader --------------- +project_reader module +--------------------- .. automodule:: pygccxml.parser.project_reader :members: :show-inheritance: -source_reader -------------- +source_reader module +---------------------- .. automodule:: pygccxml.parser.source_reader :members: Modified: pygccxml_dev/docs/apidocs/utils.rest =================================================================== --- pygccxml_dev/docs/apidocs/utils.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/docs/apidocs/utils.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -2,10 +2,17 @@ pygccxml.utils package ====================== +utils package +------------- -fs_utils --------- +.. automodule:: pygccxml.utils + :members: + :show-inheritance: + +fs_utils module +--------------- + .. automodule:: pygccxml.utils.fs_utils :members: :show-inheritance: Modified: pygccxml_dev/docs/pygccxml.rest =================================================================== --- pygccxml_dev/docs/pygccxml.rest 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/docs/pygccxml.rest 2009-02-09 21:10:08 UTC (rev 1669) @@ -1,4 +1,4 @@ -====================== +====================== pygccxml documentation ====================== @@ -17,12 +17,12 @@ ------------------------ What can you do with it? ------------------------ -Using :doc:`pygccxml <pygccxml>` you can: +Using `pygccxml` you can: * parse C++ source code * create a powerful code generator - + :doc:`Py++ <../pyplusplus/pyplusplus>` is heavily based on :doc:`pygccxml <pygccxml>` + + :doc:`Py++ <../pyplusplus/pyplusplus>` is heavily based on `pygccxml` + generate `WSDL`_ file from sources + ... @@ -36,8 +36,9 @@ Query interface --------------- -:doc:`pygccxml <pygccxml>` provides simple and powerful API to query declarations tree. How many -lines is needed to write the following query? +`pygccxml` provides simple and powerful API to query declarations tree. + +How many lines is needed to write the following query? :: select all free functions from the project @@ -47,7 +48,7 @@ function has two arguments second argument type is int -Only 1 ( one ) line of code is needed: +Only single line of code is needed: .. code-block:: python @@ -61,7 +62,7 @@ Type traits ----------- -:doc:`pygccxml <pygccxml>` provides a lot of functionality to analyze C++ types and relationship +`pygccxml` provides a lot of functionality to analyze C++ types and relationship between them. For more information please refer to :doc:`design <design>` document or API documentation. Just a few names of algorithms: @@ -92,7 +93,7 @@ * parse each file separately and then join the results The difference between these approaches is the caching algorithm used in the -second case. :doc:`pygccxml <pygccxml>` supports both of them. Actually :doc:`pygccxml <pygccxml>` supports +second case. `pygccxml` supports both of them. Actually `pygccxml` supports more caching strategies, read the API documentation for more information. @@ -106,7 +107,7 @@ Test environment ---------------- -:doc:`pygccxml <pygccxml>` comes with comprehensive unit tests. They are executed on Windows XP +`pygccxml` comes with comprehensive unit tests. They are executed on Windows XP and `Ubuntu`_ Linux operating systems. In most cases Python 2.5 and 2.6 are used. All in all, `pygccxml` has more than 230 tests. @@ -119,9 +120,9 @@ .. toctree:: example/example.rest + query_interface.rest download.rest design.rest - query_interface.rest upgrade_issues.rest users.rest links.rest Modified: pygccxml_dev/pygccxml/binary_parsers/__init__.py =================================================================== --- pygccxml_dev/pygccxml/binary_parsers/__init__.py 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/pygccxml/binary_parsers/__init__.py 2009-02-09 21:10:08 UTC (rev 1669) @@ -5,9 +5,9 @@ """ contains classes that allows to extract different information from binary files -( .pdb, .map, .dll, .bsc, .so ) and integrate it with existing declarations tree +( .map, .dll, .so ) and integrate it with existing declarations tree -The main function of this package is "merge_information" +The main function of this package is :func:`pygccxml.binary_parsers.parsers.merge_information`. """ import undname @@ -18,7 +18,8 @@ return undname.undname_creator_t().undecorate_blob( blob ) def format_decl( decl, hint=None ): - """returns string, that represents formatted declaration, according to some rules - hint valid values are: "msvc" and "nm" """ + returns string, that represents formatted declaration, according to some rules + :param hint: valid values are: "msvc" and "nm" + """ return undname.undname_creator_t().format_decl( decl, hint=hint ) Modified: pygccxml_dev/pygccxml/binary_parsers/parsers.py =================================================================== --- pygccxml_dev/pygccxml/binary_parsers/parsers.py 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/pygccxml/binary_parsers/parsers.py 2009-02-09 21:10:08 UTC (rev 1669) @@ -9,8 +9,10 @@ Those classes extract decorated\mangled names from the files. Later the extracted symbols are used for: -* building "dynamic library" public interface -* extracting function calling convention + + * building "dynamic library" public interface + * extracting function calling convention + """ import os Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2009-02-09 19:09:47 UTC (rev 1668) +++ pygccxml_dev/pygccxml/utils/__init__.py 2009-02-09 21:10:08 UTC (rev 1669) @@ -4,8 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines logger classes and few convenience methods, not related to the declarations -tree +defines logger classes and few convenience methods, not related to the declarations tree """ import os This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-11 19:37:48
|
Revision: 1672 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1672&view=rev Author: roman_yakovenko Date: 2009-02-11 19:37:44 +0000 (Wed, 11 Feb 2009) Log Message: ----------- adding new test case Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/type_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2009-02-11 09:34:27 UTC (rev 1671) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2009-02-11 19:37:44 UTC (rev 1672) @@ -331,7 +331,6 @@ Precondition: self.is_my_case( type ) == True """ - assert self.is_my_case( type_ ) return self.__apply_sequence( type_ ) enum_traits = declaration_xxx_traits( enumeration.enumeration_t ) Modified: pygccxml_dev/unittests/type_traits_tester.py =================================================================== --- pygccxml_dev/unittests/type_traits_tester.py 2009-02-11 09:34:27 UTC (rev 1671) +++ pygccxml_dev/unittests/type_traits_tester.py 2009-02-11 19:37:44 UTC (rev 1672) @@ -271,9 +271,48 @@ #~ declarations.print_declarations( [declarations.class_traits.get_declaration( x )] ) +class class_traits_tester_t(unittest.TestCase): + def __init__(self, *args ): + unittest.TestCase.__init__(self, *args) + + def test(self): + code = """ + namespace A{ + struct B{ + int c; + }; + + template <class T> + struct C: public T{ + int d; + }; + + template <class T> + struct D{ + int dD; + }; + + typedef C<B> easy; + typedef D<easy> Deasy; + + inline void instantiate(){ + sizeof(easy); + } + + } + """ + + global_ns = parser.parse_string( code, autoconfig.cxx_parsers_cfg.gccxml) + global_ns = declarations.get_global_namespace( global_ns ) + easy = global_ns.typedef( 'easy' ) + c_a = declarations.class_traits.get_declaration( easy ) #this works very well + deasy = global_ns.typedef( 'Deasy' ) + d_a = declarations.class_traits.get_declaration( deasy ) + self.failUnless( isinstance( d_a, declarations.class_types ) ) + def create_suite(): suite = unittest.TestSuite() - #~ suite.addTest( unittest.makeSuite(tester_diff_t)) + suite.addTest( unittest.makeSuite(class_traits_tester_t)) suite.addTest( unittest.makeSuite(tester_t)) suite.addTest( unittest.makeSuite(missing_decls_tester_t)) return suite This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-04-23 10:22:08
|
Revision: 1702 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1702&view=rev Author: roman_yakovenko Date: 2009-04-23 10:22:07 +0000 (Thu, 23 Apr 2009) Log Message: ----------- fixing small bug on Windows, related to parsing configuration file Modified Paths: -------------- pygccxml_dev/pygccxml/parser/config.py Added Paths: ----------- pygccxml_dev/unittests/gccxml.cfg Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2009-04-23 10:19:29 UTC (rev 1701) +++ pygccxml_dev/pygccxml/parser/config.py 2009-04-23 10:22:07 UTC (rev 1702) @@ -231,7 +231,7 @@ gccxml_path= #gccxml working directory - optional, could be set to your source code directory working_directory= - #additional include directories, separated by ';' or ':' + #additional include directories, separated by ';' include_paths= #gccxml has a nice algorithms, which selects what C++ compiler to emulate. #You can explicitly set what compiler it should emulate. @@ -264,10 +264,9 @@ gccxml_cfg.working_directory = value elif name == 'include_paths': for p in value.split( ';' ): - for pp in p.split( ':' ): - pp = pp.strip() - if pp: - gccxml_cfg.include_paths.append( pp ) + p = p.strip() + if p: + gccxml_cfg.include_paths.append( p ) elif name == 'compiler': gccxml_cfg.compiler = value else: Added: pygccxml_dev/unittests/gccxml.cfg =================================================================== --- pygccxml_dev/unittests/gccxml.cfg (rev 0) +++ pygccxml_dev/unittests/gccxml.cfg 2009-04-23 10:22:07 UTC (rev 1702) @@ -0,0 +1,13 @@ +[gccxml] +#path to gccxml executable file - optional, if not provided, os.environ['PATH'] +#variable is used to find it +gccxml_path= +#gccxml working directory - optional, could be set to your source code directory +working_directory= +#additional include directories, separated by ';' or ':' +include_paths= +#gccxml has a nice algorithms, which selects what C++ compiler to emulate. +#You can explicitly set what compiler it should emulate. +#Valid options are: g++, msvc6, msvc7, msvc71, msvc8, cl. +compiler=msvc71 +#GCC-XML site: http://gccxml.org/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-05-10 18:14:11
|
Revision: 1709 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1709&view=rev Author: roman_yakovenko Date: 2009-05-10 18:14:04 +0000 (Sun, 10 May 2009) Log Message: ----------- update history and clean testers from PDB compiler Modified Paths: -------------- pygccxml_dev/docs/history/history.rest pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/compilers.py pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/pygccxml/declarations/enumeration.py pygccxml_dev/pygccxml/parser/config.py pygccxml_dev/unittests/core_tester.py pygccxml_dev/unittests/data/core_cache.hpp pygccxml_dev/unittests/templates_tester.py Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/docs/history/history.rest 2009-05-10 18:14:04 UTC (rev 1709) @@ -35,7 +35,7 @@ See :func:`pygccxml.parser.config.load_gccxml_configuration` for details. 4. From now on, :doc:`pygccxml <../pygccxml>` will use `Sphinx <http://sphinx.pocoo.org/>`_ - for all documentation. + for all documentation. The documentation format and content were updated. 5. From now on, `pygccxml` will provide convenient setup for latest `GCC-XML`_ version (CVS). See :doc:`download <../download>` document. @@ -43,6 +43,7 @@ 6. Bug `[ 2431993 ] pygccxml parses const volatile variable args as just const <http://sourceforge.net/tracker/index.php?func=detail&aid=2431993&group_id=118209&atid=684318>`_ was fixed. + ----------- Version 1.0 ----------- Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -276,33 +276,7 @@ return self._recursive_derived def _get_is_abstract(self): - if self.compiler == compilers.MSVC_PDB_9: - #prevent cyclic dependencies - import calldef - import function_traits - from matchers import virtuality_type_matcher_t as vtmatcher_t - filter_pv = vtmatcher_t( calldef.VIRTUALITY_TYPES.PURE_VIRTUAL ) - if self.calldefs( filter_pv, recursive=False, allow_empty=True ): - return True - filter_npv = vtmatcher_t( calldef.VIRTUALITY_TYPES.VIRTUAL ) \ - | vtmatcher_t( calldef.VIRTUALITY_TYPES.NOT_VIRTUAL ) - pv_calldefs = [] - npv_calldefs = [] - - npv_calldefs.extend( self.calldefs( filter_npv, recursive=False, allow_empty=True ) ) - for base in self.recursive_bases: - cls = base.related_class - pv_calldefs.extend( cls.calldefs( filter_pv, recursive=False, allow_empty=True ) ) - npv_calldefs.extend( cls.calldefs( filter_npv, recursive=False, allow_empty=True ) ) - - for pure_virtual in pv_calldefs: - impl_found = filter( lambda f: function_traits.is_same_function( pure_virtual, f ) - , npv_calldefs ) - if not impl_found: - return True - return False - else: - return self._is_abstract + return self._is_abstract def _set_is_abstract( self, is_abstract ): self._is_abstract = is_abstract is_abstract = property( _get_is_abstract, _set_is_abstract @@ -344,8 +318,6 @@ , doc="Size of this class in bytes @type: int") def _get_byte_align(self): - if self.compiler == compilers.MSVC_PDB_9: - compilers.on_missing_functionality( self.compiler, "byte align" ) return self._byte_align def _set_byte_align( self, new_byte_align ): self._byte_align = new_byte_align Modified: pygccxml_dev/pygccxml/declarations/compilers.py =================================================================== --- pygccxml_dev/pygccxml/declarations/compilers.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/pygccxml/declarations/compilers.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -16,8 +16,6 @@ #are dumped whether the user declared them or not. Those that were #implicitly declared by the compiler are marked as "artificial". -MSVC_PDB_9 = "MSVC PDB 9.0" - def on_missing_functionality( compiler, functionality ): raise NotImplementedError( '"%s" compiler doesn\'t support functionality "%s"' % ( compiler, functionality )) Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -65,8 +65,6 @@ , doc="Size of this type in bytes @type: int") def _get_byte_align(self): - if self.compiler == compilers.MSVC_PDB_9: - compilers.on_missing_functionality( self.compiler, "byte align" ) return self._byte_align def _set_byte_align( self, new_byte_align ): self._byte_align = new_byte_align Modified: pygccxml_dev/pygccxml/declarations/enumeration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/enumeration.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/pygccxml/declarations/enumeration.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -128,8 +128,6 @@ , doc="Size of this class in bytes @type: int") def _get_byte_align(self): - if self.compiler == compilers.MSVC_PDB_9: - compilers.on_missing_functionality( self.compiler, "byte align" ) return self._byte_align def _set_byte_align( self, new_byte_align ): self._byte_align = new_byte_align Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/pygccxml/parser/config.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -205,7 +205,7 @@ gccxml_path= #gccxml working directory - optional, could be set to your source code directory working_directory= -#additional include directories, separated by ';' or ':' +#additional include directories, separated by ';' include_paths= #gccxml has a nice algorithms, which selects what C++ compiler to emulate. #You can explicitly set what compiler it should emulate. Modified: pygccxml_dev/unittests/core_tester.py =================================================================== --- pygccxml_dev/unittests/core_tester.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/unittests/core_tester.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -1,414 +1,397 @@ -# Copyright 2004-2008 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 pprint -import unittest -import tempfile -import autoconfig -import parser_test_case -from pprint import pformat - -import pygccxml -from pygccxml.utils import * -from pygccxml.parser import * -from pygccxml.declarations import * - -def is_sub_path( root, some_path ): - root = normalize_path( root ) - some_path = normalize_path( some_path ) - return some_path.startswith( root ) - - -class core_t( parser_test_case.parser_test_case_t ): - """Tests core algorithms of GCC-XML and GCC-XML file reader. - Those most white-box testing. - """ - global_ns = None - def __init__(self, *args ): - parser_test_case.parser_test_case_t.__init__( self, *args ) - self.global_ns = None - - 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 - nss = [ '::ns', '::ns::ns12', '::ns::ns22', '::ns::ns32' ] - #list of all namespaces that have unnamed namespace - unnamed_nss = nss[1:] - #list of all enums [0:2] [3:5] [6:8] - has same parent - enums = [ '::E11', '::E21', '::E31' - , '::ns::E12', '::ns::E22', '::ns::E32' - , '::ns::ns12::E13', '::ns::ns22::E23', '::ns::ns32::E33' ] - - for ns in nss: - self.global_ns.namespace( ns ) - - for enum in enums: - self.global_ns.enum( enum ) - - ns = self.global_ns.namespace( nss[0] ) - ns12 = self.global_ns.namespace( nss[1] ) - ns22 = self.global_ns.namespace( nss[2] ) - ns32 = self.global_ns.namespace( nss[3] ) - self.failUnless( ns and ( ns is ns12.parent is ns22.parent is ns32.parent ) - , 'There are 2 or more instances of ns namespace.' ) - - E11 = self.global_ns.enum( enums[0] ) - E21 = self.global_ns.enum( enums[1] ) - E31 = self.global_ns.enum( enums[2] ) - self.failUnless( E11.parent is E21.parent is E31.parent - , 'There are 2 or more instances of global namespace.' ) - - nsE12 = self.global_ns.enum( enums[3] ) - nsE23 = self.global_ns.enum( enums[4] ) - nsE33 = self.global_ns.enum( enums[5] ) - self.failUnless( ns and ( ns is nsE12.parent is nsE23.parent is nsE33.parent ) - , 'There are 2 or more instances of ns namespace.' ) - - def _test_ns_membership(self, ns, enum_name ): - unnamed_enum = ns.enum( lambda d: d.name == '' \ - and is_sub_path( autoconfig.data_directory, d.location.file_name ) - , recursive=False ) - self.failUnless( unnamed_enum in ns.declarations - , "namespace '%s' does not contains unnamed enum." % ns.name ) - - enum = ns.enum( enum_name, recursive=False ) - - self.failUnless( enum in ns.declarations - , "namespace '%s' does not contains enum '%s'" % ( ns.name, enum.name ) ) - - self.failUnless( unnamed_enum.parent is ns - , "unnamed enum belong to namespace '%s' but this namespace is not it's parent." % ns.name ) - - self.failUnless( enum.parent is ns - , "enum '%s' belong to namespace '%s' but this namespace is not it's parent." % ( enum.name, ns.name ) ) - - def _test_class_membership( self, class_inst, enum_name, access ): - #getting enum through get_members function - if class_inst.compiler == compilers.MSVC_PDB_9: - nested_enum1 = class_inst.enum( name=enum_name ) - else: - nested_enum1 = class_inst.enum( name=enum_name, function=access_type_matcher_t( access ) ) - - #getting enum through declarations property - nested_enum2 = class_inst.enum( enum_name ) - - #it shoud be same object - 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.' ) - - #test gccxml_file_reader_t._update_membership algorithm - def test_membership(self): - 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' ) - 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 ) - self._test_class_membership( class_nested_enums, 'ENestedPrivate', ACCESS_TYPES.PRIVATE ) - - def test_mangled(self): - std = self.global_ns.namespace( 'std' ) - self.failUnless( std, 'std namespace has not been found' ) - self.failUnless( std.mangled, 'mangled name of std namespace should be different from None' ) - - def _test_is_based_and_derived(self, base, derived, access): - dhi_v = hierarchy_info_t( derived, access, True ) - dhi_not_v = hierarchy_info_t( derived, access, False ) - self.failUnless( dhi_v in base.derived or dhi_not_v in base.derived - , "base class '%s' doesn't has derived class '%s'" %( base.name, derived.name ) ) - - bhi_v = hierarchy_info_t( base, access, True ) - bhi_not_v = hierarchy_info_t( base, access, False ) - - self.failUnless( bhi_v in derived.bases or bhi_not_v in derived.bases - , "derive class '%s' doesn't has base class '%s'" %( derived.name, base.name ) ) - - def test_class_hierarchy(self): - class_hierarchy = self.global_ns.namespace( 'class_hierarchy' ) - - base = class_hierarchy.class_( 'base_t' ) - other_base = class_hierarchy.class_( 'other_base_t' ) - derived_public = class_hierarchy.class_( 'derived_public_t' ) - derived_protected = class_hierarchy.class_( 'derived_protected_t' ) - derived_private = class_hierarchy.class_( 'derived_private_t' ) - multi_derived = class_hierarchy.class_( 'multi_derived_t' ) - - self._test_is_based_and_derived( base, derived_public, ACCESS_TYPES.PUBLIC ) - self._test_is_based_and_derived( base, derived_protected, ACCESS_TYPES.PROTECTED ) - self._test_is_based_and_derived( base, derived_private, ACCESS_TYPES.PRIVATE ) - self._test_is_based_and_derived( base, multi_derived, ACCESS_TYPES.PROTECTED ) - self._test_is_based_and_derived( other_base, multi_derived, ACCESS_TYPES.PRIVATE ) - self._test_is_based_and_derived( derived_private, multi_derived, ACCESS_TYPES.PRIVATE ) - - def _test_is_same_bases(self, derived1, derived2 ): - bases1 = set([ id(hierarchy_info.related_class) for hierarchy_info in derived1.bases ]) - bases2 = set([ id(hierarchy_info.related_class) for hierarchy_info in derived2.bases ]) - self.failUnless( bases1 == bases2 - , "derived class '%s' and derived class '%s' has references to different instance of base classes " \ - % ( derived1.name, derived2.name ) ) - - def test_class_join(self): - diamand_hierarchy = self.global_ns.namespace( 'diamand_hierarchy' ) - base = diamand_hierarchy.class_( 'base_t' ) - derived1 = diamand_hierarchy.class_( 'derived1_t' ) - derived2 = diamand_hierarchy.class_( 'derived2_t' ) - final_derived = diamand_hierarchy.class_( 'final_derived_t' ) - - self._test_is_based_and_derived( base, derived1, ACCESS_TYPES.PUBLIC ) - self._test_is_based_and_derived( base, derived2, ACCESS_TYPES.PUBLIC ) - self._test_is_based_and_derived( derived1, final_derived, ACCESS_TYPES.PUBLIC ) - self._test_is_based_and_derived( derived2, final_derived, ACCESS_TYPES.PUBLIC ) - self._test_is_same_bases(derived1, derived2) - - def test_fundamental_types(self): - #check whether all build in types could be constructed - errors = [] - 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 ) - if typedef.type.decl_string != fundamental_type.decl_string: - errors.append( "there is a difference between typedef base type name('%s') and expected one('%s')" - % (typedef.type.decl_string, fundamental_type.decl_string) ) - if self.global_ns.compiler != compilers.MSVC_PDB_9: - self.failIf( errors, pprint.pformat( errors ) ) - else: - self.failUnless( 5 == len( errors ), pprint.pformat( errors ) ) - - def test_compound_types(self): - 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' ) - 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' ) - 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' ) - 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' ) - self._test_type_composition( typedef_inst.type, volatile_t, int_t ) - - 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' ) - 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' ) - self.failUnless( typedef_inst.type.declaration is enum_declaration - , "instance of declaration_t has reference to '%s' instead of '%s'" \ - % ( 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' ) - 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 ) - , "return function type of typedef 'function_ptr' should be '%s' instead of '%s' " \ - %( 'int_t', function_type.return_type.__class__.__name__ ) ) - self.failUnless( len( function_type.arguments_types ) == 2 - , "number of arguments of function of typedef 'function_ptr' should be 2 instead of '%d' " \ - % len( function_type.arguments_types ) ) - self.failUnless( isinstance( function_type.arguments_types[0], int_t ) - , "first argument of function of typedef 'function_ptr' should be '%s' instead of '%s' " \ - %( 'int_t', function_type.arguments_types[0].__class__.__name__ ) ) - self.failUnless( isinstance( function_type.arguments_types[1], double_t ) - , "first argument of function of typedef 'function_ptr' should be '%s' instead of '%s' " \ - %( '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') - self._test_type_composition( function_ptr.type, pointer_t, member_function_type_t ) - - function_type = function_ptr.type.base - - members_pointers = self.global_ns.class_( 'members_pointers_t' ) - self.failUnless( function_type.class_inst.declaration is members_pointers - , "member function type class should be '%s' instead of '%s'" \ - % ( members_pointers.decl_string, function_type.class_inst.decl_string ) ) - - self.failUnless( isinstance( function_type.return_type, int_t ) - , "return function type of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \ - %( 'int_t', function_type.return_type.__class__.__name__ ) ) - self.failUnless( len( function_type.arguments_types ) == 1 - , "number of arguments of function of typedef 'member_function_ptr_t' should be 1 instead of '%d' " \ - % len( function_type.arguments_types ) ) - self.failUnless( isinstance( function_type.arguments_types[0], double_t ) - , "first argument of function of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \ - %( 'double_t', function_type.arguments_types[0].__class__.__name__ ) ) - - if self.global_ns.compiler != compilers.MSVC_PDB_9: - self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." ) - - def test_member_variable_type(self): - if self.global_ns.compiler == compilers.MSVC_PDB_9: - return - - 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' ) - self.failUnless( members_pointers, "unable to find class('%s')" % 'members_pointers_t' ) - self._test_type_composition( mv.type.base, member_variable_type_t, declarated_t ) - mv_type = mv.type.base - self.failUnless( mv_type.base.declaration is members_pointers - , "member function type class should be '%s' instead of '%s'" \ - % ( members_pointers.decl_string, mv_type.base.decl_string ) ) - - def test_overloading(self): - ns = self.global_ns.namespace( 'overloads' ) - - do_nothings = ns.calldefs( 'do_nothing', recursive=False ) - self.failUnless( 4 == len(do_nothings) - , "expected number of overloaded 'do_nothing' functions is %d and existing(%d) is different" \ - % ( 4, len(do_nothings) ) ) - for index, do_nothing in enumerate(do_nothings): - others = do_nothings[:index] + do_nothings[index+1:] - if set( do_nothing.overloads ) != set( others ): - print '\nexisting: ' - for x in do_nothing.overloads: - print str(x) - print '\nexpected: ' - for x in others: - print str(x) - - self.failUnless( set( do_nothing.overloads ) == set( others ) - , "there is a difference between expected function overloads and existing ones." ) - - def test_abstract_classes(self): - ns = self.global_ns.namespace( 'abstract_classes' ) - abstract_i = ns.class_( 'abstract_i' ) - self.failUnless( abstract_i.is_abstract, "class 'abstract_i' should be abstract" ) - derived_abstract_i = ns.class_( 'derived_abstract_i' ) - self.failUnless( derived_abstract_i.is_abstract, "class 'derived_abstract_i' should be abstract" ) - implementation = ns.class_( 'implementation' ) - self.failUnless( not implementation.is_abstract, "class 'implementation' should not be abstract" ) - - def test_versioning(self): - for d in self.global_ns.decls(): - self.failUnless( d.compiler ) - - def test_byte_size( self ): - mptrs = self.global_ns.class_( 'members_pointers_t' ) - self.failUnless( mptrs.byte_size != 0 ) - - def test_byte_align( self ): - mptrs = self.global_ns.class_( 'members_pointers_t' ) - if mptrs.compiler != compilers.MSVC_PDB_9: - self.failUnless( mptrs.byte_align != 0 ) - - def test_byte_offset( self ): - mptrs = self.global_ns.class_( 'members_pointers_t' ) - self.failUnless( mptrs.var( 'xxx' ).byte_offset != 0 ) - -class pdb_based_core_tester_t( core_t ): - def __init__(self, *args ): - core_t.__init__( self, *args ) - self.global_ns = autoconfig.get_pdb_global_ns() - -class core_gccxml_t( core_t ): - """Tests core algorithms of GCC-XML and GCC-XML file reader. - Those most white-box testing. - """ - global_ns = None - def __init__(self, *args ): - core_t.__init__( self, *args ) - self.test_files = [ 'core_ns_join_1.hpp' - , 'core_ns_join_2.hpp' - , 'core_ns_join_3.hpp' - , 'core_membership.hpp' - , 'core_class_hierarchy.hpp' - , 'core_types.hpp' - , 'core_diamand_hierarchy_base.hpp' - , 'core_diamand_hierarchy_derived1.hpp' - , 'core_diamand_hierarchy_derived2.hpp' - , 'core_diamand_hierarchy_final_derived.hpp' - , '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 ) - core_t.global_ns = pygccxml.declarations.get_global_namespace( decls ) - if self.INIT_OPTIMIZER: - core_t.global_ns.init_optimizer() - self.global_ns = core_t.global_ns - -class core_all_at_once_t( core_gccxml_t ): - COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE - INIT_OPTIMIZER = True - def __init__(self, *args): - core_gccxml_t.__init__(self, *args) - -class core_all_at_once_no_opt_t( core_gccxml_t ): - COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE - INIT_OPTIMIZER = False - def __init__(self, *args): - core_gccxml_t.__init__(self, *args) - -class core_file_by_file_t( core_gccxml_t ): - COMPILATION_MODE = COMPILATION_MODE.FILE_BY_FILE - INIT_OPTIMIZER = True - def __init__(self, *args): - core_gccxml_t.__init__(self, *args) - -class core_file_by_file_no_opt_t( core_gccxml_t ): - COMPILATION_MODE = COMPILATION_MODE.FILE_BY_FILE - INIT_OPTIMIZER = False - def __init__(self, *args): - core_gccxml_t.__init__(self, *args) - -def create_suite(): - suite = unittest.TestSuite() - if autoconfig.cxx_parsers_cfg.gccxml: - 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)) - suite.addTest( unittest.makeSuite(core_file_by_file_no_opt_t)) - #~ if autoconfig.cxx_parsers_cfg.pdb_loader: - #~ suite.addTest( unittest.makeSuite(pdb_based_core_tester_t)) - return suite - -def run_suite(): - unittest.TextTestRunner(verbosity=2).run( create_suite() ) - -if __name__ == "__main__": - run_suite() -##~ import hotshot -##~ import hotshot.stats -##~ statistics_file = tempfile.mkstemp( suffix='.stat' )[1] -##~ profile = hotshot.Profile(statistics_file) -##~ -##~ profile.runcall( run_suite ) -##~ profile.close() -##~ statistics = hotshot.stats.load( statistics_file ) -##~ statistics.strip_dirs() -##~ statistics.sort_stats( 'time', 'calls' ) -##~ statistics.print_stats( 678 ) +# Copyright 2004-2008 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 pprint +import unittest +import tempfile +import autoconfig +import parser_test_case +from pprint import pformat + +import pygccxml +from pygccxml.utils import * +from pygccxml.parser import * +from pygccxml.declarations import * + +def is_sub_path( root, some_path ): + root = normalize_path( root ) + some_path = normalize_path( some_path ) + return some_path.startswith( root ) + + +class core_t( parser_test_case.parser_test_case_t ): + """Tests core algorithms of GCC-XML and GCC-XML file reader. + Those most white-box testing. + """ + global_ns = None + def __init__(self, *args ): + parser_test_case.parser_test_case_t.__init__( self, *args ) + self.global_ns = None + + 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 + nss = [ '::ns', '::ns::ns12', '::ns::ns22', '::ns::ns32' ] + #list of all namespaces that have unnamed namespace + unnamed_nss = nss[1:] + #list of all enums [0:2] [3:5] [6:8] - has same parent + enums = [ '::E11', '::E21', '::E31' + , '::ns::E12', '::ns::E22', '::ns::E32' + , '::ns::ns12::E13', '::ns::ns22::E23', '::ns::ns32::E33' ] + + for ns in nss: + self.global_ns.namespace( ns ) + + for enum in enums: + self.global_ns.enum( enum ) + + ns = self.global_ns.namespace( nss[0] ) + ns12 = self.global_ns.namespace( nss[1] ) + ns22 = self.global_ns.namespace( nss[2] ) + ns32 = self.global_ns.namespace( nss[3] ) + self.failUnless( ns and ( ns is ns12.parent is ns22.parent is ns32.parent ) + , 'There are 2 or more instances of ns namespace.' ) + + E11 = self.global_ns.enum( enums[0] ) + E21 = self.global_ns.enum( enums[1] ) + E31 = self.global_ns.enum( enums[2] ) + self.failUnless( E11.parent is E21.parent is E31.parent + , 'There are 2 or more instances of global namespace.' ) + + nsE12 = self.global_ns.enum( enums[3] ) + nsE23 = self.global_ns.enum( enums[4] ) + nsE33 = self.global_ns.enum( enums[5] ) + self.failUnless( ns and ( ns is nsE12.parent is nsE23.parent is nsE33.parent ) + , 'There are 2 or more instances of ns namespace.' ) + + def _test_ns_membership(self, ns, enum_name ): + unnamed_enum = ns.enum( lambda d: d.name == '' \ + and is_sub_path( autoconfig.data_directory, d.location.file_name ) + , recursive=False ) + self.failUnless( unnamed_enum in ns.declarations + , "namespace '%s' does not contains unnamed enum." % ns.name ) + + enum = ns.enum( enum_name, recursive=False ) + + self.failUnless( enum in ns.declarations + , "namespace '%s' does not contains enum '%s'" % ( ns.name, enum.name ) ) + + self.failUnless( unnamed_enum.parent is ns + , "unnamed enum belong to namespace '%s' but this namespace is not it's parent." % ns.name ) + + self.failUnless( enum.parent is ns + , "enum '%s' belong to namespace '%s' but this namespace is not it's parent." % ( enum.name, ns.name ) ) + + def _test_class_membership( self, class_inst, enum_name, access ): + #getting enum through get_members function + nested_enum1 = class_inst.enum( name=enum_name, function=access_type_matcher_t( access ) ) + + #getting enum through declarations property + nested_enum2 = class_inst.enum( enum_name ) + + #it shoud be same object + 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.' ) + + #test gccxml_file_reader_t._update_membership algorithm + def test_membership(self): + 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' ) + 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 ) + self._test_class_membership( class_nested_enums, 'ENestedPrivate', ACCESS_TYPES.PRIVATE ) + + def test_mangled(self): + std = self.global_ns.namespace( 'std' ) + self.failUnless( std, 'std namespace has not been found' ) + self.failUnless( std.mangled, 'mangled name of std namespace should be different from None' ) + + def _test_is_based_and_derived(self, base, derived, access): + dhi_v = hierarchy_info_t( derived, access, True ) + dhi_not_v = hierarchy_info_t( derived, access, False ) + self.failUnless( dhi_v in base.derived or dhi_not_v in base.derived + , "base class '%s' doesn't has derived class '%s'" %( base.name, derived.name ) ) + + bhi_v = hierarchy_info_t( base, access, True ) + bhi_not_v = hierarchy_info_t( base, access, False ) + + self.failUnless( bhi_v in derived.bases or bhi_not_v in derived.bases + , "derive class '%s' doesn't has base class '%s'" %( derived.name, base.name ) ) + + def test_class_hierarchy(self): + class_hierarchy = self.global_ns.namespace( 'class_hierarchy' ) + + base = class_hierarchy.class_( 'base_t' ) + other_base = class_hierarchy.class_( 'other_base_t' ) + derived_public = class_hierarchy.class_( 'derived_public_t' ) + derived_protected = class_hierarchy.class_( 'derived_protected_t' ) + derived_private = class_hierarchy.class_( 'derived_private_t' ) + multi_derived = class_hierarchy.class_( 'multi_derived_t' ) + + self._test_is_based_and_derived( base, derived_public, ACCESS_TYPES.PUBLIC ) + self._test_is_based_and_derived( base, derived_protected, ACCESS_TYPES.PROTECTED ) + self._test_is_based_and_derived( base, derived_private, ACCESS_TYPES.PRIVATE ) + self._test_is_based_and_derived( base, multi_derived, ACCESS_TYPES.PROTECTED ) + self._test_is_based_and_derived( other_base, multi_derived, ACCESS_TYPES.PRIVATE ) + self._test_is_based_and_derived( derived_private, multi_derived, ACCESS_TYPES.PRIVATE ) + + def _test_is_same_bases(self, derived1, derived2 ): + bases1 = set([ id(hierarchy_info.related_class) for hierarchy_info in derived1.bases ]) + bases2 = set([ id(hierarchy_info.related_class) for hierarchy_info in derived2.bases ]) + self.failUnless( bases1 == bases2 + , "derived class '%s' and derived class '%s' has references to different instance of base classes " \ + % ( derived1.name, derived2.name ) ) + + def test_class_join(self): + diamand_hierarchy = self.global_ns.namespace( 'diamand_hierarchy' ) + base = diamand_hierarchy.class_( 'base_t' ) + derived1 = diamand_hierarchy.class_( 'derived1_t' ) + derived2 = diamand_hierarchy.class_( 'derived2_t' ) + final_derived = diamand_hierarchy.class_( 'final_derived_t' ) + + self._test_is_based_and_derived( base, derived1, ACCESS_TYPES.PUBLIC ) + self._test_is_based_and_derived( base, derived2, ACCESS_TYPES.PUBLIC ) + self._test_is_based_and_derived( derived1, final_derived, ACCESS_TYPES.PUBLIC ) + self._test_is_based_and_derived( derived2, final_derived, ACCESS_TYPES.PUBLIC ) + self._test_is_same_bases(derived1, derived2) + + def test_fundamental_types(self): + #check whether all build in types could be constructed + errors = [] + 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 ) + if typedef.type.decl_string != fundamental_type.decl_string: + errors.append( "there is a difference between typedef base type name('%s') and expected one('%s')" + % (typedef.type.decl_string, fundamental_type.decl_string) ) + self.failIf( errors, pprint.pformat( errors ) ) + + def test_compound_types(self): + 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' ) + 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' ) + 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' ) + 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' ) + self._test_type_composition( typedef_inst.type, volatile_t, int_t ) + + 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' ) + 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' ) + self.failUnless( typedef_inst.type.declaration is enum_declaration + , "instance of declaration_t has reference to '%s' instead of '%s'" \ + % ( 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' ) + 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 ) + , "return function type of typedef 'function_ptr' should be '%s' instead of '%s' " \ + %( 'int_t', function_type.return_type.__class__.__name__ ) ) + self.failUnless( len( function_type.arguments_types ) == 2 + , "number of arguments of function of typedef 'function_ptr' should be 2 instead of '%d' " \ + % len( function_type.arguments_types ) ) + self.failUnless( isinstance( function_type.arguments_types[0], int_t ) + , "first argument of function of typedef 'function_ptr' should be '%s' instead of '%s' " \ + %( 'int_t', function_type.arguments_types[0].__class__.__name__ ) ) + self.failUnless( isinstance( function_type.arguments_types[1], double_t ) + , "first argument of function of typedef 'function_ptr' should be '%s' instead of '%s' " \ + %( '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') + self._test_type_composition( function_ptr.type, pointer_t, member_function_type_t ) + + function_type = function_ptr.type.base + + members_pointers = self.global_ns.class_( 'members_pointers_t' ) + self.failUnless( function_type.class_inst.declaration is members_pointers + , "member function type class should be '%s' instead of '%s'" \ + % ( members_pointers.decl_string, function_type.class_inst.decl_string ) ) + + self.failUnless( isinstance( function_type.return_type, int_t ) + , "return function type of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \ + %( 'int_t', function_type.return_type.__class__.__name__ ) ) + self.failUnless( len( function_type.arguments_types ) == 1 + , "number of arguments of function of typedef 'member_function_ptr_t' should be 1 instead of '%d' " \ + % len( function_type.arguments_types ) ) + self.failUnless( isinstance( function_type.arguments_types[0], double_t ) + , "first argument of function of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \ + %( 'double_t', function_type.arguments_types[0].__class__.__name__ ) ) + + self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." ) + + def test_member_variable_type(self): + 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' ) + self.failUnless( members_pointers, "unable to find class('%s')" % 'members_pointers_t' ) + self._test_type_composition( mv.type.base, member_variable_type_t, declarated_t ) + mv_type = mv.type.base + self.failUnless( mv_type.base.declaration is members_pointers + , "member function type class should be '%s' instead of '%s'" \ + % ( members_pointers.decl_string, mv_type.base.decl_string ) ) + + def test_overloading(self): + ns = self.global_ns.namespace( 'overloads' ) + + do_nothings = ns.calldefs( 'do_nothing', recursive=False ) + self.failUnless( 4 == len(do_nothings) + , "expected number of overloaded 'do_nothing' functions is %d and existing(%d) is different" \ + % ( 4, len(do_nothings) ) ) + for index, do_nothing in enumerate(do_nothings): + others = do_nothings[:index] + do_nothings[index+1:] + if set( do_nothing.overloads ) != set( others ): + print '\nexisting: ' + for x in do_nothing.overloads: + print str(x) + print '\nexpected: ' + for x in others: + print str(x) + + self.failUnless( set( do_nothing.overloads ) == set( others ) + , "there is a difference between expected function overloads and existing ones." ) + + def test_abstract_classes(self): + ns = self.global_ns.namespace( 'abstract_classes' ) + abstract_i = ns.class_( 'abstract_i' ) + self.failUnless( abstract_i.is_abstract, "class 'abstract_i' should be abstract" ) + derived_abstract_i = ns.class_( 'derived_abstract_i' ) + self.failUnless( derived_abstract_i.is_abstract, "class 'derived_abstract_i' should be abstract" ) + implementation = ns.class_( 'implementation' ) + self.failUnless( not implementation.is_abstract, "class 'implementation' should not be abstract" ) + + def test_versioning(self): + for d in self.global_ns.decls(): + self.failUnless( d.compiler ) + + def test_byte_size( self ): + mptrs = self.global_ns.class_( 'members_pointers_t' ) + self.failUnless( mptrs.byte_size != 0 ) + + def test_byte_align( self ): + mptrs = self.global_ns.class_( 'members_pointers_t' ) + self.failUnless( mptrs.byte_align != 0 ) + + def test_byte_offset( self ): + mptrs = self.global_ns.class_( 'members_pointers_t' ) + self.failUnless( mptrs.var( 'xxx' ).byte_offset != 0 ) + + +class core_gccxml_t( core_t ): + """Tests core algorithms of GCC-XML and GCC-XML file reader. + Those most white-box testing. + """ + global_ns = None + def __init__(self, *args ): + core_t.__init__( self, *args ) + self.test_files = [ 'core_ns_join_1.hpp' + , 'core_ns_join_2.hpp' + , 'core_ns_join_3.hpp' + , 'core_membership.hpp' + , 'core_class_hierarchy.hpp' + , 'core_types.hpp' + , 'core_diamand_hierarchy_base.hpp' + , 'core_diamand_hierarchy_derived1.hpp' + , 'core_diamand_hierarchy_derived2.hpp' + , 'core_diamand_hierarchy_final_derived.hpp' + , '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 ) + core_t.global_ns = pygccxml.declarations.get_global_namespace( decls ) + if self.INIT_OPTIMIZER: + core_t.global_ns.init_optimizer() + self.global_ns = core_t.global_ns + +class core_all_at_once_t( core_gccxml_t ): + COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE + INIT_OPTIMIZER = True + def __init__(self, *args): + core_gccxml_t.__init__(self, *args) + +class core_all_at_once_no_opt_t( core_gccxml_t ): + COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE + INIT_OPTIMIZER = False + def __init__(self, *args): + core_gccxml_t.__init__(self, *args) + +class core_file_by_file_t( core_gccxml_t ): + COMPILATION_MODE = COMPILATION_MODE.FILE_BY_FILE + INIT_OPTIMIZER = True + def __init__(self, *args): + core_gccxml_t.__init__(self, *args) + +class core_file_by_file_no_opt_t( core_gccxml_t ): + COMPILATION_MODE = COMPILATION_MODE.FILE_BY_FILE + INIT_OPTIMIZER = False + def __init__(self, *args): + core_gccxml_t.__init__(self, *args) + +def create_suite(): + suite = unittest.TestSuite() + if autoconfig.cxx_parsers_cfg.gccxml: + 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)) + suite.addTest( unittest.makeSuite(core_file_by_file_no_opt_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() +##~ import hotshot +##~ import hotshot.stats +##~ statistics_file = tempfile.mkstemp( suffix='.stat' )[1] +##~ profile = hotshot.Profile(statistics_file) +##~ +##~ profile.runcall( run_suite ) +##~ profile.close() +##~ statistics = hotshot.stats.load( statistics_file ) +##~ statistics.strip_dirs() +##~ statistics.sort_stats( 'time', 'calls' ) +##~ statistics.print_stats( 678 ) Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/unittests/data/core_cache.hpp 2009-05-10 18:14:04 UTC (rev 1709) @@ -22,4 +22,4 @@ #endif//__core_cache_hpp__ -//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 \ No newline at end of file Modified: pygccxml_dev/unittests/templates_tester.py =================================================================== --- pygccxml_dev/unittests/templates_tester.py 2009-04-28 05:49:45 UTC (rev 1708) +++ pygccxml_dev/unittests/templates_tester.py 2009-05-10 18:14:04 UTC (rev 1709) @@ -1,76 +1,76 @@ -#! /usr/bin/python -# Copyright 2004-2008 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 pygccxml -from pygccxml.utils import * -from pygccxml.parser import * -from pygccxml import declarations - -class tester_t( unittest.TestCase ): - def __init__(self, *args ): - unittest.TestCase.__init__( self, *args ) - - def __test_split_impl(self, decl_string, name, args): - self.failUnless( ( name, args ) == declarations.templates.split( decl_string ) ) - - def __test_split_recursive_impl(self, decl_string, control_seq): - self.failUnless( control_seq == declarations.templates.split_recursive( decl_string ) ) - - def __test_is_template_impl( self, decl_string ): - self.failUnless( declarations.templates.is_instantiation( decl_string ) ) - - def test_split_on_vector(self): - self.__test_is_template_impl( "vector<int,std::allocator<int> >" ) - - self.__test_split_impl( "vector<int,std::allocator<int> >" - , "vector" - , [ "int", "std::allocator<int>" ] ) - - self.__test_split_recursive_impl( "vector<int,std::allocator<int> >" - , [ ( "vector", [ "int", "std::allocator<int>" ] ) - , ( "std::allocator", ["int"] ) ] ) - - def test_split_on_string(self): - self.__test_is_template_impl( "basic_string<char,std::char_traits<char>,std::allocator<char> >" ) - - self.__test_split_impl( "basic_string<char,std::char_traits<char>,std::allocator<char> >" - , "basic_string" - , [ "char", "std::char_traits<char>", "std::allocator<char>" ] ) - - def test_split_on_map(self): - self.__test_is_template_impl( "map<long int,std::vector<int, std::allocator<int> >,std::less<long int>,std::allocator<std::pair<const long int, std::vector<int, std::allocator<int> > > > >" ) - - self.__test_split_impl( "map<long int,std::vector<int, std::allocator<int> >,std::less<long int>,std::allocator<std::pair<const long int, std::vector<int, std::allocator<int> > > > >" - , "map" - , [ "long int" - , "std::vector<int, std::allocator<int> >" - , "std::less<long int>" - , "std::allocator<std::pair<const long int, std::vector<int, std::allocator<int> > > >" ] ) - - def test_join_on_vector(self): - self.failUnless( "vector< int, std::allocator<int> >" - == declarations.templates.join("vector", ( "int", "std::allocator<int>" ) ) ) - - def test_bug_is_tmpl_inst(self): - self.failUnless( False == declarations.templates.is_instantiation( "::FX::QMemArray<unsigned char>::setRawData" ) ) - - def test_split_bug_fptr(self): - x = 'map<std::string, bool (*)(std::string&, Ogre::MaterialScriptContext&), std::less<std::string>, std::allocator<std::pair<std::string const, bool (*)(std::string&, Ogre::MaterialScriptContext&)> > >' - name, args = declarations.templates.split( x ) - self.failUnless( len(x) == 4 ) - -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 +#! /usr/bin/python +# Copyright 2004-2008 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 pygccxml +from pygccxml.utils import * +from pygccxml.parser import * +from pygccxml import declarations + +class tester_t( unittest.TestCase ): + def __init__(self, *args ): + unittest.TestCase.__init__( self, *args ) + + def __test_split_impl(self, decl_string, name, args): + self.failUnless( ( name, args ) == declarations.templates.split( decl_string ) ) + + def __test_split_recursive_impl(self, decl_string, control_seq): + self.failUnless( control_seq == declarations.templates.split_recursive( decl_string ) ) + + def __test_is_template_impl( self, decl_string ): + self.failUnless( declarations.templates.is_instantiation( decl_string ) ) + + def test_split_on_vector(self): + self.__test_is_template_impl( "vector<int,std::allocator<int> >" ) + + self.__test_split_impl( "vector<int,std::allocator<int> >" + , "vector" + , [ "int", "std::allocator<int>" ] ) + + self.__test_split_recursive_impl( "vector<int,std::allocator<int> >" + , [ ( "vector", [ "int", "std::allocator<int>" ] ) + , ( "std::allocator", ["int"] ) ] ) + + def test_split_on_string(self): + self.__test_is_template_impl( "basic_string<char,std::char_traits<char>,std::allocator<char> >" ) + + self.__test_split_impl( "basic_string<char,std::char_traits<char>,std::allocator<char> >" + , "basic_string" + , [ "char", "std::char_traits<char>", "std::allocator<char>" ] ) + + def test_split_on_map(self): + self.__test_is_template_impl( "map<long int,std::vector<int, std::allocator<int> >,std::less<long int>,std::allocator<std::pair<const long int, std::vector<int, std::allocator<int> > > > >" ) + + self.__test_split_impl( "map<long int,std::vector<int, std::allocator<int> >,std::less<long int>,std::allocator<std::pair<const long int, std::vector<int, std::allocator<int> > > > >" + , "map" + , [ "long int" + , "std::vector<int, std::allocator<int> >" + , "std::less<long int>" + , "std::allocator<std::pair<const long int, std::vector<int, std::allocator<int> > > >" ] ) + + def test_join_on_vector(self): + self.failUnless( "vector< int, std::allocator<int> >" + == declarations.templates.join("vector", ( "int", "std::allocator<int>" ) ) ) + + def test_bug_is_tmpl_inst(self): + self.failUnless( False == declarations.templates.is_instantiation( "::FX::QMemArray<unsigned char>::setRawData" ) ) + + def test_split_bug_fptr(self): + x = 'map<std::string, bool (*)(std::string&, Ogre::MaterialScriptContext&), std::less<std::string>, std::allocator<std::pair<std::string const, bool (*)(std::string&, Ogre::MaterialScriptContext&)> > >' + name, args = declarations.templates.split( x ) + self.failUnless( len(x) == 4, "This test is expected to fail." ) + +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() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-05-17 08:29:28
|
Revision: 1735 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1735&view=rev Author: roman_yakovenko Date: 2009-05-17 08:29:22 +0000 (Sun, 17 May 2009) Log Message: ----------- fix 2779781 bug( pygccxml reverses array dimensions ) Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/array_bug_tester.py Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-05-17 05:48:47 UTC (rev 1734) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-05-17 08:29:22 UTC (rev 1735) @@ -446,8 +446,23 @@ doc="returns array size" ) def build_decl_string(self, with_defaults=True): - return self.base.build_decl_string(with_defaults) + '[%d]' % self.size + #return self.base.build_decl_string(with_defaults) + '[%d]' % self.size + return self.__bds_for_multi_dim_arrays( None, with_defaults ) + def __bds_for_multi_dim_arrays(self, parent_dims=None, with_defaults=True): + if parent_dims: + parent_dims.append( self.size ) + else: + parent_dims = [self.size] + + if isinstance( self.base, array_t ): + return self.base.__bds_for_multi_dim_arrays( parent_dims, with_defaults) + else: + tmp = [] + for s in parent_dims: + tmp.append( '[%d]' % s ) + return self.base.build_decl_string(with_defaults) + ''.join( tmp ) + def _clone_impl( self ): return array_t( self.base.clone(), self.size ) Added: pygccxml_dev/unittests/array_bug_tester.py =================================================================== --- pygccxml_dev/unittests/array_bug_tester.py (rev 0) +++ pygccxml_dev/unittests/array_bug_tester.py 2009-05-17 08:29:22 UTC (rev 1735) @@ -0,0 +1,58 @@ +# Copyright 2004-2008 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) + + def test1(self): + code = 'int aaaa[2][3][4][5];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( 'int[2][3][4][5]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + def test2(self): + code = 'int* aaaa[2][3][4][5];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( 'int *[2][3][4][5]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + def test3(self): + code = 'int aaaa[2];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( 'int[2]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + def test4(self): + code = 'struct xyz{}; xyz aaaa[2][3];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( '::xyz[2][3]' == aaaa_type.decl_string, aaaa_type.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() Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2009-05-17 05:48:47 UTC (rev 1734) +++ pygccxml_dev/unittests/test_all.py 2009-05-17 08:29:22 UTC (rev 1735) @@ -54,6 +54,7 @@ import undname_creator_tester import calling_convention_tester import const_volatile_arg_tester +import array_bug_tester testers = [ decl_string_tester @@ -104,6 +105,7 @@ , undname_creator_tester , calling_convention_tester , const_volatile_arg_tester + , array_bug_tester ] def create_suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-06-10 06:32:34
|
Revision: 1738 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1738&view=rev Author: roman_yakovenko Date: 2009-06-10 06:31:44 +0000 (Wed, 10 Jun 2009) Log Message: ----------- adding problematic use case, contributed by Zbigniew Mandziejewicz Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/unittests/project_reader_correctness_tester.py Added Paths: ----------- pygccxml_dev/unittests/data/separate_compilation/ pygccxml_dev/unittests/data/separate_compilation/all.h pygccxml_dev/unittests/data/separate_compilation/base.h pygccxml_dev/unittests/data/separate_compilation/data.h pygccxml_dev/unittests/data/separate_compilation/derived.h Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-05-19 17:44:52 UTC (rev 1737) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-06-10 06:31:44 UTC (rev 1738) @@ -29,7 +29,7 @@ self.__verbose = verbose self.__writer = writer if not self.__writer: - self.__writer = lambda x: sys.stdout.write( x + os.linesep ) + self.__writer = lambda x: sys.stdout.write( x ) def clone(self, increment_level=True): level = self.__level Added: pygccxml_dev/unittests/data/separate_compilation/all.h =================================================================== --- pygccxml_dev/unittests/data/separate_compilation/all.h (rev 0) +++ pygccxml_dev/unittests/data/separate_compilation/all.h 2009-06-10 06:31:44 UTC (rev 1738) @@ -0,0 +1,8 @@ +#ifndef __all_h_10062009__ +#define __all_h_10062009__ 1 + +#include "data.h" +#include "base.h" +#include "derived.h" + +#endif//__all_h_10062009__ Added: pygccxml_dev/unittests/data/separate_compilation/base.h =================================================================== --- pygccxml_dev/unittests/data/separate_compilation/base.h (rev 0) +++ pygccxml_dev/unittests/data/separate_compilation/base.h 2009-06-10 06:31:44 UTC (rev 1738) @@ -0,0 +1,15 @@ +#ifndef __base_h_10062009__ +#define __base_h_10062009__ 1 + +#include "data.h" + +namespace buggy{ + +struct base_t{ + virtual ~base_t() {}; + virtual data_t* get_data() const = 0; +}; + +} + +#endif//__base_h_10062009__ Added: pygccxml_dev/unittests/data/separate_compilation/data.h =================================================================== --- pygccxml_dev/unittests/data/separate_compilation/data.h (rev 0) +++ pygccxml_dev/unittests/data/separate_compilation/data.h 2009-06-10 06:31:44 UTC (rev 1738) @@ -0,0 +1,32 @@ +#ifndef __data_h_10062009__ +#define __data_h_10062009__ 1 + +namespace std{ + +template<class T1, class T2> +struct pair{ + typedef pair<T1, T2> _Myt; + typedef T1 first_type; + typedef T2 second_type; + + pair(): first(T1()), second(T2()) + {} + + pair(const T1& t1, const T2& t2) + : first(t1), second(t2) + {} + + T1 first; // the first stored value + T2 second; // the second stored value +}; +} + +namespace buggy{ + +struct data_t{ + typedef std::pair<data_t*, data_t*> pair_t; +}; + +} + +#endif//__data_h_10062009__ Added: pygccxml_dev/unittests/data/separate_compilation/derived.h =================================================================== --- pygccxml_dev/unittests/data/separate_compilation/derived.h (rev 0) +++ pygccxml_dev/unittests/data/separate_compilation/derived.h 2009-06-10 06:31:44 UTC (rev 1738) @@ -0,0 +1,20 @@ +#ifndef __derived_h_10062009__ +#define __derived_h_10062009__ 1 + +#include "base.h" + +namespace buggy{ + +class derived_t: public base_t{ +public: + + virtual ~derived_t() {}; + virtual data_t* get_data() const; + +private: + data_t::pair_t data_pair; +}; + +} + +#endif//__derived_h_10062009__ Modified: pygccxml_dev/unittests/project_reader_correctness_tester.py =================================================================== --- pygccxml_dev/unittests/project_reader_correctness_tester.py 2009-05-19 17:44:52 UTC (rev 1737) +++ pygccxml_dev/unittests/project_reader_correctness_tester.py 2009-06-10 06:31:44 UTC (rev 1738) @@ -10,7 +10,7 @@ import pygccxml from pygccxml import utils from pygccxml import parser -from pygccxml import declarations +from pygccxml import declarations class tester_t( parser_test_case.parser_test_case_t ): def __init__(self, *args): @@ -50,10 +50,39 @@ def test_correctness(self): for src in self.__files: self.__test_correctness_impl( src ) - + + +class tester2_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args): + parser_test_case.parser_test_case_t.__init__(self, *args) + self.__files = [ + 'separate_compilation/data.h' + , 'separate_compilation/base.h' + , 'separate_compilation/derived.h' + ] + + def test(self): + prj_reader = parser.project_reader_t( self.config ) + prj_decls = prj_reader.read_files( self.__files + , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE ) + src_reader = parser.source_reader_t( self.config ) + src_decls = src_reader.read_file( 'separate_compilation/all.h' ) + if src_decls != prj_decls: + s = src_decls[0] + p = prj_decls[0] + sr = file( os.path.join( autoconfig.build_directory , 'separate_compilation.sr.txt'),'w+b' ) + pr = file( os.path.join( autoconfig.build_directory , 'separate_compilation.pr.txt'), 'w+b' ) + declarations.print_declarations( s, writer=lambda l: sr.write( l ) ) + declarations.print_declarations( p, writer=lambda l: pr.write( l ) ) + sr.close() + pr.close() + self.fail( "Expected - There is a difference between declarations" ) + + def create_suite(): - suite = unittest.TestSuite() - suite.addTest( unittest.makeSuite(tester_t)) + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + suite.addTest( unittest.makeSuite(tester2_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...> - 2009-10-01 22:57:09
|
Revision: 1761 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1761&view=rev Author: roman_yakovenko Date: 2009-10-01 22:56:50 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Adding "explicit" attribute to constructor_t class Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/pygccxml/parser/scanner.py pygccxml_dev/unittests/data/declarations_calldef.hpp pygccxml_dev/unittests/declarations_tester.py pygccxml_dev/unittests/filters_tester.py Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2009-09-22 18:41:38 UTC (rev 1760) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2009-10-01 22:56:50 UTC (rev 1761) @@ -532,7 +532,19 @@ """describes constructor declaration""" def __init__( self, *args, **keywords ): member_calldef_t.__init__( self, *args, **keywords ) + self._explicit = True + def _get_explicit(self): + return self._explicit + def _set_explicit(self, explicit): + if explicit in [True, '1']: + self._explicit = True + else: + self._explicit = False + explicit = property( _get_explicit, _set_explicit + , doc="""True, if constructor has "explicit" keyword, False otherwise + @type: bool""" ) + def __str__(self): # Get the full name of the calldef... name = algorithm.full_name(self) @@ -568,7 +580,6 @@ def is_trivial_constructor(self): return not bool( self.arguments ) - class destructor_t( member_calldef_t ): """describes deconstructor declaration""" def __init__( self, *args, **keywords ): Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-09-22 18:41:38 UTC (rev 1760) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-10-01 22:56:50 UTC (rev 1761) @@ -146,8 +146,11 @@ self.print_decl_header() self.print_calldef_info() + indent = ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( indent + "explicit: " + str(self.__inst.explicit) + os.linesep) + if self.__print_details: - self.writer( ' ' * ( self.level + 1 ) * self.INDENT_SIZE + self.writer( indent + 'copy constructor: ' + str(self.__inst.is_copy_constructor) + os.linesep) def visit_destructor( self ): Modified: pygccxml_dev/pygccxml/parser/scanner.py =================================================================== --- pygccxml_dev/pygccxml/parser/scanner.py 2009-09-22 18:41:38 UTC (rev 1760) +++ pygccxml_dev/pygccxml/parser/scanner.py 2009-10-01 22:56:50 UTC (rev 1761) @@ -29,6 +29,7 @@ XML_AN_CVS_REVISION = "cvs_revision" XML_AN_DEFAULT = "default" XML_AN_DEMANGLED = "demangled" +XML_AN_EXPLICIT = "explicit" XML_AN_EXTERN = "extern" XML_AN_FILE = "file" XML_AN_ID = "id" @@ -494,6 +495,7 @@ def __read_constructor( self, attrs ): constructor = self.__decl_factory.create_constructor() self.__read_member_function( constructor, attrs, True ) + constructor.explicit = attrs.get( XML_AN_EXPLICIT, False ) return constructor def __read_function(self, attrs): Modified: pygccxml_dev/unittests/data/declarations_calldef.hpp =================================================================== --- pygccxml_dev/unittests/data/declarations_calldef.hpp 2009-09-22 18:41:38 UTC (rev 1760) +++ pygccxml_dev/unittests/data/declarations_calldef.hpp 2009-10-01 22:56:50 UTC (rev 1761) @@ -27,8 +27,10 @@ struct calldefs_t{ calldefs_t(); - calldefs_t(char); + explicit calldefs_t(char); + calldefs_t(some_exception_t); + calldefs_t(int,double); calldefs_t(const calldefs_t&); Modified: pygccxml_dev/unittests/declarations_tester.py =================================================================== --- pygccxml_dev/unittests/declarations_tester.py 2009-09-22 18:41:38 UTC (rev 1760) +++ pygccxml_dev/unittests/declarations_tester.py 2009-10-01 22:56:50 UTC (rev 1761) @@ -123,7 +123,7 @@ destructor = struct_calldefs.calldef( '~calldefs_t' ) self._test_calldef_args( destructor, [] ) - self._test_calldef_return_type( destructor, None.__class__) + self._test_calldef_return_type( destructor, None.__class__) #well, now we have a few functions ( constructors ) with the same name, there is no easy way #to find the desired one. Well in my case I have only 4 constructors @@ -132,14 +132,23 @@ #3. default #4. copy constructor constructor_found = struct_calldefs.constructors( 'calldefs_t' ) - self.failUnless( len( constructor_found ) == 4 - , "struct 'calldefs_t' has 4 constructors, pygccxml parser reports only about %d." \ + self.failUnless( len( constructor_found ) == 5 + , "struct 'calldefs_t' has 5 constructors, pygccxml parser reports only about %d." \ % len( constructor_found ) ) self.failUnless( 1 == len( filter( lambda constructor: constructor.is_copy_constructor, constructor_found ) ) , "copy constructor has not been found" ) #there is nothing to check about constructors - I know the implementation of parser #In this case it doesn't different from any other function + c = struct_calldefs.constructor( 'calldefs_t', arg_types=['char'] ) + self.failUnless( c.explicit == True + , "calldef_t constructor defined with 'explicit' keyword, for some reason the value is False ") + + arg_type = declarated_t( self.global_ns.class_('some_exception_t') ) + c = struct_calldefs.constructor( 'calldefs_t', arg_types=[arg_type] ) + self.failUnless( c.explicit == False + , "calldef_t constructor defined without 'explicit' keyword, for some reason the value is True ") + def test_operator_symbol(self): calldefs_operators = ['=', '==' ] calldefs_cast_operators = ['char *', 'double'] Modified: pygccxml_dev/unittests/filters_tester.py =================================================================== --- pygccxml_dev/unittests/filters_tester.py 2009-09-22 18:41:38 UTC (rev 1760) +++ pygccxml_dev/unittests/filters_tester.py 2009-10-01 22:56:50 UTC (rev 1761) @@ -40,9 +40,9 @@ public_members = declarations.matcher.find( criteria, self.global_ns ) if '0.9' in public_members[0].compiler: public_members = filter( lambda d: not d.is_artificial, public_members ) - self.failUnless( 16 == len( public_members ) ) + self.failUnless( 17 == len( public_members ) ) else: - self.failUnless( 20 == len( public_members ) ) + self.failUnless( 21 == len( public_members ) ) def test_or_matcher( self ): criteria1 = declarations.regex_matcher_t( 'oper.*' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-10-04 19:41:50
|
Revision: 1763 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1763&view=rev Author: roman_yakovenko Date: 2009-10-04 19:41:39 +0000 (Sun, 04 Oct 2009) Log Message: ----------- "nm" utility invocation was fixed. Now it handles right relative paths and paths with spaces Modified Paths: -------------- pygccxml_dev/docs/history/history.rest pygccxml_dev/pygccxml/binary_parsers/parsers.py Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2009-10-01 22:59:08 UTC (rev 1762) +++ pygccxml_dev/docs/history/history.rest 2009-10-04 19:41:39 UTC (rev 1763) @@ -22,6 +22,7 @@ * Ben Schleimer * Gustavo Carneiro * Christopher Bruns +* Alejandro Dubrovsky ----------- SVN Version @@ -50,7 +51,11 @@ 8. "explicit" property was added to ``declarations.constructor_t`` class. Many thanks to Christopher Bruns, for finding out how this property works in `GCC-XML`_. - + +9. "List symbols" (`nm`) utility invocation was improved and now handles + right relative paths and paths with spaces. Many thanks to Alejandro Dubrovsky + for providing the patch. + ----------- Version 1.0 ----------- Modified: pygccxml_dev/pygccxml/binary_parsers/parsers.py =================================================================== --- pygccxml_dev/pygccxml/binary_parsers/parsers.py 2009-10-01 22:59:08 UTC (rev 1762) +++ pygccxml_dev/pygccxml/binary_parsers/parsers.py 2009-10-04 19:41:39 UTC (rev 1763) @@ -216,8 +216,9 @@ """parser for Linux .so file""" nm_executable = 'nm' #numeric-sort used for mapping between mangled and unmangled name - cmd_mangled = '%(nm)s --extern-only --dynamic --defined-only --numeric-sort %(lib)s' - cmd_demangled = '%(nm)s --extern-only --dynamic --defined-only --demangle --numeric-sort %(lib)s' + cmd_mangled = '%(nm)s --extern-only --dynamic --defined-only --numeric-sort %(lib)s'.split() + cmd_demangled = '%(nm)s --extern-only --dynamic --defined-only --demangle --numeric-sort %(lib)s'.split() + entry = re.compile( r'^(?P<address>(?:\w|\d)+)\s\w\s(?P<symbol>.+)$' ) def __init__( self, global_ns, binary_file ): @@ -225,11 +226,9 @@ def __execute_nm( self, cmd ): process = subprocess.Popen( args=cmd - , shell=True , stdin=subprocess.PIPE , stdout=subprocess.PIPE - , stderr=subprocess.STDOUT - , cwd=os.path.dirname( self.binary_file ) ) + , stderr=subprocess.STDOUT ) process.stdin.close() output = [] @@ -254,8 +253,9 @@ def load_symbols( self ): tmpl_args = dict( nm=self.nm_executable, lib=self.binary_file ) - mangled_smbls = self.__extract_symbols( self.cmd_mangled % tmpl_args ) - demangled_smbls = self.__extract_symbols( self.cmd_demangled % tmpl_args ) + mangled_smbls = self.__extract_symbols( [part % tmpl_args for part in self.cmd_mangled] ) + demangled_smbls = self.__extract_symbols( [part % tmpl_args for part in self.cmd_demangled] ) + result = [] for address, blob in mangled_smbls.iteritems(): if address in demangled_smbls: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-16 19:14:31
|
Revision: 1805 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1805&view=rev Author: roman_yakovenko Date: 2010-01-16 19:14:12 +0000 (Sat, 16 Jan 2010) Log Message: ----------- fix bug related to merging free functions Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/unittests/xmlfile_reader_tester.py Added Paths: ----------- pygccxml_dev/unittests/data/merge_free_functions.hpp Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2010-01-14 12:54:55 UTC (rev 1804) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2010-01-16 19:14:12 UTC (rev 1805) @@ -262,6 +262,7 @@ from mdecl_wrapper import mdecl_wrapper_t from decl_printer import decl_printer_t +from decl_printer import dump_declarations from decl_printer import print_declarations @@ -334,10 +335,3 @@ __impl_matchers[ namespace_t.free_operator ] = operator_matcher_t __impl_decl_types[ namespace_t.free_operator ] = free_operator_t - - - - - - - Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2010-01-14 12:54:55 UTC (rev 1804) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2010-01-16 19:14:12 UTC (rev 1805) @@ -177,7 +177,8 @@ , self.return_type , self.has_extern , self.does_throw - , self._sorted_list( self.exceptions ) ] + , self._sorted_list( self.exceptions ) + , self.demangled_name ] items.extend( self._get__cmp__call_items() ) return items @@ -188,8 +189,8 @@ and self.arguments == other.arguments \ and self.has_extern == other.has_extern \ and self.does_throw == other.does_throw \ - and self._sorted_list( self.exceptions ) \ - == other._sorted_list( other.exceptions ) + and self._sorted_list( self.exceptions ) == other._sorted_list( other.exceptions ) \ + and self.demangled_name == other.demangled_name def _get_arguments(self): return self._arguments Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2010-01-14 12:54:55 UTC (rev 1804) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2010-01-16 19:14:12 UTC (rev 1805) @@ -285,3 +285,14 @@ prn.level = 0 prn.instance = d algorithm.apply_visitor(prn, d) + +def dump_declarations( decls, fpath ): + """ + dump declarations tree rooted at each of the included nodes to the file + + :param decls: either a single :class:declaration_t object or list of :class:declaration_t objects + :param fpath: file name + """ + fobj = file( fpath, 'w+' ) + print_declarations( decls, writer=fobj.write ) + fobj.close() Added: pygccxml_dev/unittests/data/merge_free_functions.hpp =================================================================== --- pygccxml_dev/unittests/data/merge_free_functions.hpp (rev 0) +++ pygccxml_dev/unittests/data/merge_free_functions.hpp 2010-01-16 19:14:12 UTC (rev 1805) @@ -0,0 +1,32 @@ +// Copyright 2004-2008 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 __merge_free_functions_hpp__ +#define __merge_free_functions_hpp__ + +#include <iostream> + +/* +namespace n1{ + +struct s1{}; +struct s2{}; + +template<typename _Facet> +bool has_facet(int i) throw(){ + return false; +} + +void do_smth(){ + has_facet<s1>( 12 ); + has_facet<s2>( 12 ); +} + +} +*/ + + +#endif//__merge_free_functions_hpp__ + Modified: pygccxml_dev/unittests/xmlfile_reader_tester.py =================================================================== --- pygccxml_dev/unittests/xmlfile_reader_tester.py 2010-01-14 12:54:55 UTC (rev 1804) +++ pygccxml_dev/unittests/xmlfile_reader_tester.py 2010-01-16 19:14:12 UTC (rev 1805) @@ -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 @@ -14,13 +15,15 @@ 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.__fname = 'core_types.hpp' + #self.__fname = 'core_types.hpp' + self.__fname = 'merge_free_functions.hpp' def test(self): src_reader = parser.source_reader_t( self.config ) src_decls = src_reader.read_file( self.__fname ) xmlfile = src_reader.create_xml_file( self.__fname ) + print xmlfile try: fconfig = parser.file_configuration_t( data=xmlfile , start_with_declarations=None @@ -29,11 +32,16 @@ prj_reader = parser.project_reader_t( self.config ) prj_decls = prj_reader.read_files( [fconfig] , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE ) - - self.failUnless( src_decls == prj_decls - , "There is a difference between declarations in file %s." % self.__fname ) + + declarations.dump_declarations( src_decls + , os.path.join( autoconfig.build_directory, 'xmlfile_reader.src.txt' ) ) + declarations.dump_declarations( prj_decls + , os.path.join( autoconfig.build_directory, 'xmlfile_reader.prj.txt' ) ) + + if src_decls != prj_decls: + self.fail( "There is a difference between declarations in file %s." % self.__fname ) finally: - utils.remove_file_no_raise( xmlfile ) + pass #utils.remove_file_no_raise( xmlfile ) 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...> - 2010-01-18 22:09:15
|
Revision: 1813 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1813&view=rev Author: roman_yakovenko Date: 2010-01-18 22:09:09 +0000 (Mon, 18 Jan 2010) Log Message: ----------- improve decl_printer - sort declarations before printing Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/unittests/project_reader_correctness_tester.py Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2010-01-18 20:04:41 UTC (rev 1812) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2010-01-18 22:09:09 UTC (rev 1813) @@ -208,6 +208,8 @@ self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + is_virtual.ljust( self.JUSTIFY ) + os.linesep) def print_members(members_type, members, curr_level): + members = members[:] + members.sort() self.writer( ' ' * curr_level * self.INDENT_SIZE + members_type.ljust( self.JUSTIFY ) + os.linesep) if self.__recursive: curr_level += 1 @@ -240,7 +242,9 @@ return #don't print info about empty namespaces self.print_decl_header() if self.__recursive: - for decl in self.__inst.declarations: + inst_decls = self.__inst.declarations[:] + inst_decls.sort() + for decl in inst_decls: if self.is_builtin_decl( decl ): continue prn = self.clone() Modified: pygccxml_dev/unittests/project_reader_correctness_tester.py =================================================================== --- pygccxml_dev/unittests/project_reader_correctness_tester.py 2010-01-18 20:04:41 UTC (rev 1812) +++ pygccxml_dev/unittests/project_reader_correctness_tester.py 2010-01-18 22:09:09 UTC (rev 1813) @@ -67,18 +67,16 @@ , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE ) src_reader = parser.source_reader_t( self.config ) src_decls = src_reader.read_file( 'separate_compilation/all.h' ) - if src_decls != prj_decls: - s = src_decls[0] - p = prj_decls[0] - sr = file( os.path.join( autoconfig.build_directory , 'separate_compilation.sr.txt'),'w+b' ) - pr = file( os.path.join( autoconfig.build_directory , 'separate_compilation.pr.txt'), 'w+b' ) - declarations.print_declarations( s, writer=lambda l: sr.write( l ) ) - declarations.print_declarations( p, writer=lambda l: pr.write( l ) ) - sr.close() - pr.close() - self.fail( "Expected - There is a difference between declarations" ) + + declarations.dump_declarations( src_decls + , os.path.join( autoconfig.build_directory, 'separate_compilation.sr.txt' ) ) + declarations.dump_declarations( prj_decls + , os.path.join( autoconfig.build_directory, 'separate_compilation.pr.txt' ) ) + self.failUnless( src_decls == prj_decls, "There is a difference between declarations" ) + + 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...> - 2010-01-26 20:37:04
|
Revision: 1819 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1819&view=rev Author: roman_yakovenko Date: 2010-01-26 20:36:57 +0000 (Tue, 26 Jan 2010) Log Message: ----------- add new test case and bit fields size to the decl_printer Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/gccxml10184_tester.py Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2010-01-26 20:14:05 UTC (rev 1818) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2010-01-26 20:36:57 UTC (rev 1819) @@ -262,6 +262,10 @@ self.writer( ' ' * curr_level * self.INDENT_SIZE + 'type: %s' % self.__inst.type.decl_string + os.linesep) self.writer( ' ' * curr_level * self.INDENT_SIZE + 'value: %s' % self.__inst.value + os.linesep) if self.__print_details: + if self.__inst.bits: + bits = 'bits: %d'%(self.__inst.bits) + self.writer( ' ' * curr_level * self.INDENT_SIZE + bits.ljust( self.JUSTIFY ) + os.linesep) + byte_size = 'size: %d'%(self.__inst.type.byte_size) self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ) + os.linesep) try: Added: pygccxml_dev/unittests/gccxml10184_tester.py =================================================================== --- pygccxml_dev/unittests/gccxml10184_tester.py (rev 0) +++ pygccxml_dev/unittests/gccxml10184_tester.py 2010-01-26 20:36:57 UTC (rev 1819) @@ -0,0 +1,45 @@ +# Copyright 2004-2008 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 unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + +code = \ +""" +class A { +public: + virtual ~A() = 0; + unsigned int a : 1; + unsigned int unused : 31; +}; +""" + +class tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args): + parser_test_case.parser_test_case_t.__init__(self, *args) + + def test(self): + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + self.failUnless( global_ns.var( 'a' ).bits == 1 ) + self.failUnless( global_ns.var( 'unused' ).bits == 31 ) + +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() Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2010-01-26 20:14:05 UTC (rev 1818) +++ pygccxml_dev/unittests/test_all.py 2010-01-26 20:36:57 UTC (rev 1819) @@ -55,8 +55,9 @@ import calling_convention_tester import const_volatile_arg_tester import array_bug_tester +import gccxml10183_tester +import gccxml10184_tester import gccxml10185_tester -import gccxml10183_tester testers = [ decl_string_tester @@ -108,8 +109,9 @@ , calling_convention_tester , const_volatile_arg_tester , array_bug_tester - , gccxml10185_tester - , gccxml10183_tester + , gccxml10183_tester + , gccxml10184_tester + , gccxml10185_tester ] def create_suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-07-12 19:50:37
|
Revision: 1843 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1843&view=rev Author: roman_yakovenko Date: 2010-07-12 19:50:31 +0000 (Mon, 12 Jul 2010) Log Message: ----------- allow pygccxml to run on FreeBSD Modified Paths: -------------- pygccxml_dev/docs/history/history.rest pygccxml_dev/pygccxml/__init__.py pygccxml_dev/pygccxml/parser/config.py Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2010-05-16 10:53:45 UTC (rev 1842) +++ pygccxml_dev/docs/history/history.rest 2010-07-12 19:50:31 UTC (rev 1843) @@ -56,6 +56,10 @@ right relative paths and paths with spaces. Many thanks to Alejandro Dubrovsky for providing the patch. +10. Small fix, which allows pygccxml to be usable on FreeBSD too: replace + `elif sys.platform == 'linux2' or sys.platform == 'darwin'` with `os.name == 'posix'`, + as suggested by `Jakub Wilk <http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/572d2286ca0b2cec?pli=1>` + ----------- Version 1.0 ----------- Modified: pygccxml_dev/pygccxml/__init__.py =================================================================== --- pygccxml_dev/pygccxml/__init__.py 2010-05-16 10:53:45 UTC (rev 1842) +++ pygccxml_dev/pygccxml/__init__.py 2010-07-12 19:50:31 UTC (rev 1843) @@ -33,6 +33,6 @@ #TODO: # 1. Add "explicit" property for constructors -__version__ = '1.5.0' +__version__ = '1.5.1' __revision__ = 1080 Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2010-05-16 10:53:45 UTC (rev 1842) +++ pygccxml_dev/pygccxml/parser/config.py 2010-07-12 19:50:31 UTC (rev 1843) @@ -176,7 +176,7 @@ if sys.platform == 'win32': gccxml_name = 'gccxml' + '.exe' environment_var_delimiter = ';' - elif sys.platform == 'linux2' or sys.platform == 'darwin': + elif os.name == 'posix': gccxml_name = 'gccxml' environment_var_delimiter = ':' else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-07-19 06:28:21
|
Revision: 1844 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1844&view=rev Author: roman_yakovenko Date: 2010-07-19 06:28:14 +0000 (Mon, 19 Jul 2010) Log Message: ----------- "__int128_t" and "__uint128_t" types were introduced. Many thanks to Gustavo Carneiro for the patch Modified Paths: -------------- pygccxml_dev/docs/history/history.rest pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/pygccxml/declarations/type_visitor.py pygccxml_dev/pygccxml/parser/linker.py pygccxml_dev/unittests/core_tester.py Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/docs/history/history.rest 2010-07-19 06:28:14 UTC (rev 1844) @@ -60,6 +60,9 @@ `elif sys.platform == 'linux2' or sys.platform == 'darwin'` with `os.name == 'posix'`, as suggested by `Jakub Wilk <http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/572d2286ca0b2cec?pli=1>` +11. "__int128_t" and "__uint128_t" types were introduced. Many thanks to Gustavo Carneiro + for providing the patch. + ----------- Version 1.0 ----------- Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2010-07-19 06:28:14 UTC (rev 1844) @@ -42,6 +42,8 @@ from cpptypes import long_unsigned_int_t from cpptypes import long_long_int_t from cpptypes import long_long_unsigned_int_t +from cpptypes import int128_t +from cpptypes import uint128_t from cpptypes import float_t from cpptypes import double_t from cpptypes import long_double_t Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2010-07-19 06:28:14 UTC (rev 1844) @@ -302,6 +302,19 @@ def __init__( self ): java_fundamental_t.__init__( self, jboolean_t.JNAME ) +class int128_t( fundamental_t ): + """represents __int128_t type""" + CPPNAME = '__int128_t' + def __init__( self ): + fundamental_t.__init__( self, int128_t.CPPNAME ) + +class uint128_t( fundamental_t ): + """represents __uint128_t type""" + CPPNAME = '__uint128_t' + def __init__( self ): + fundamental_t.__init__( self, uint128_t.CPPNAME ) + + FUNDAMENTAL_TYPES = { void_t.CPPNAME : void_t() , char_t.CPPNAME : char_t() @@ -319,6 +332,8 @@ , long_unsigned_int_t.CPPNAME : long_unsigned_int_t() , long_long_int_t.CPPNAME : long_long_int_t() , long_long_unsigned_int_t.CPPNAME : long_long_unsigned_int_t() + , int128_t.CPPNAME : int128_t() + , uint128_t.CPPNAME : uint128_t() , float_t.CPPNAME : float_t() , double_t.CPPNAME : double_t() , long_double_t.CPPNAME : long_double_t() Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2010-07-19 06:28:14 UTC (rev 1844) @@ -142,7 +142,9 @@ + create_cv_types( cpptypes.long_int_t() ) \ + create_cv_types( cpptypes.long_unsigned_int_t() ) \ + create_cv_types( cpptypes.long_long_int_t() ) \ - + create_cv_types( cpptypes.long_long_unsigned_int_t() ) + + create_cv_types( cpptypes.long_long_unsigned_int_t() ) \ + + create_cv_types( cpptypes.int128_t() ) \ + + create_cv_types( cpptypes.uint128_t() ) return remove_alias( type ) in integral_def Modified: pygccxml_dev/pygccxml/declarations/type_visitor.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_visitor.py 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/pygccxml/declarations/type_visitor.py 2010-07-19 06:28:14 UTC (rev 1844) @@ -58,6 +58,12 @@ def visit_long_long_unsigned_int( self ): raise NotImplementedError() + def visit_int128( self ): + raise NotImplementedError() + + def visit_uint128( self ): + raise NotImplementedError() + def visit_float( self ): raise NotImplementedError() Modified: pygccxml_dev/pygccxml/parser/linker.py =================================================================== --- pygccxml_dev/pygccxml/parser/linker.py 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/pygccxml/parser/linker.py 2010-07-19 06:28:14 UTC (rev 1844) @@ -188,6 +188,12 @@ def visit_long_long_unsigned_int( self ): pass + def visit_int128( self ): + pass + + def visit_uint128( self ): + pass + def visit_float( self ): pass Modified: pygccxml_dev/unittests/core_tester.py =================================================================== --- pygccxml_dev/unittests/core_tester.py 2010-07-12 19:50:31 UTC (rev 1843) +++ pygccxml_dev/unittests/core_tester.py 2010-07-19 06:28:14 UTC (rev 1844) @@ -177,6 +177,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, (int128_t, uint128_t) ): + continue #I don't have test case for this if isinstance( fundamental_type, java_fundamental_t ): continue #I don't check this at all typedef_name = 'typedef_' + fundamental_type_name.replace( ' ', '_' ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2011-02-26 20:08:38
|
Revision: 1852 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1852&view=rev Author: roman_yakovenko Date: 2011-02-26 20:08:30 +0000 (Sat, 26 Feb 2011) Log Message: ----------- "has_inline" property was added to ``declarations.calldef_t`` class. Modified Paths: -------------- pygccxml_dev/docs/history/history.rest pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/pygccxml/parser/scanner.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/data/inline_specifier.hpp pygccxml_dev/unittests/inline_specifier_tester.py Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2011-02-26 19:32:41 UTC (rev 1851) +++ pygccxml_dev/docs/history/history.rest 2011-02-26 20:08:30 UTC (rev 1852) @@ -65,7 +65,9 @@ for providing the patch. 12. Thanks to Aron Xu, for pointing out that it is better to use "os.name", - instead of "sys.platform" for platform specific logic + instead of "sys.platform" for platform specific logic. + +13. "has_inline" property was added to ``declarations.calldef_t`` class. ----------- Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2011-02-26 19:32:41 UTC (rev 1851) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2011-02-26 20:08:30 UTC (rev 1852) @@ -166,6 +166,7 @@ self._has_extern = has_extern self._demangled_name = None self._calling_convention = None + self._has_inline = None def _get__cmp__call_items(self): """implementation details""" @@ -178,7 +179,8 @@ , self.has_extern , self.does_throw , self._sorted_list( self.exceptions ) - , self.demangled_name ] + , self.demangled_name + , self.has_inline ] items.extend( self._get__cmp__call_items() ) return items @@ -274,6 +276,15 @@ @type: bool """) + def _get_has_inline(self): + return self._has_inline + def _set_has_inline(self, has_inline): + self._has_inline = has_inline + has_inline = property( _get_has_inline, _set_has_inline, + doc="""Was this callable declared with "inline" specifier + @type: bool + """) + def __remove_parent_fname( self, demangled ): """implementation details""" demangled = demangled.strip() Modified: pygccxml_dev/pygccxml/parser/scanner.py =================================================================== --- pygccxml_dev/pygccxml/parser/scanner.py 2011-02-26 19:32:41 UTC (rev 1851) +++ pygccxml_dev/pygccxml/parser/scanner.py 2011-02-26 20:08:30 UTC (rev 1852) @@ -35,6 +35,7 @@ XML_AN_ID = "id" XML_AN_INCOMPLETE = "incomplete" XML_AN_INIT = "init" +XML_AN_INLINE = "inline" XML_AN_LINE = "line" XML_AN_MANGLED = "mangled" XML_AN_MAX = "max" @@ -406,6 +407,7 @@ self.__calldefs.append( calldef ) calldef.name = attrs.get(XML_AN_NAME, '') calldef.has_extern = attrs.get( XML_AN_EXTERN, False ) + calldef.has_inline = bool( attrs.get( XML_AN_INLINE, "" ) == "1" ) throw_stmt = attrs.get( XML_AN_THROW, None ) if None is throw_stmt: calldef.does_throw = True Added: pygccxml_dev/unittests/data/inline_specifier.hpp =================================================================== --- pygccxml_dev/unittests/data/inline_specifier.hpp (rev 0) +++ pygccxml_dev/unittests/data/inline_specifier.hpp 2011-02-26 20:08:30 UTC (rev 1852) @@ -0,0 +1,8 @@ +struct text_t{ + inline bool inlined() const { return true; } + unsigned long not_inlined() const; +}; + + +inline bool inlined(text_t){ return true; } +unsigned long not_inlined(text_t); Added: pygccxml_dev/unittests/inline_specifier_tester.py =================================================================== --- pygccxml_dev/unittests/inline_specifier_tester.py (rev 0) +++ pygccxml_dev/unittests/inline_specifier_tester.py 2011-02-26 20:08:30 UTC (rev 1852) @@ -0,0 +1,52 @@ +# Copyright 2004-2008 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 = 'inline_specifier.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 ): + inlined_funcs = self.global_ns.calldefs( 'inlined' ) + self.failUnless( len(inlined_funcs) ) + for f in inlined_funcs: + self.failUnless( f.has_inline == True ) + + not_inlined_funcs = self.global_ns.calldefs( 'not_inlined' ) + self.failUnless( len(not_inlined_funcs) ) + for f in not_inlined_funcs: + self.failUnless( f.has_inline == False ) + + + def test2( self ): + 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() Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2011-02-26 19:32:41 UTC (rev 1851) +++ pygccxml_dev/unittests/test_all.py 2011-02-26 20:08:30 UTC (rev 1852) @@ -58,6 +58,7 @@ import gccxml10183_tester import gccxml10184_tester import gccxml10185_tester +import inline_specifier_tester testers = [ decl_string_tester @@ -112,6 +113,7 @@ , gccxml10183_tester , gccxml10184_tester , gccxml10185_tester + , inline_specifier_tester ] def create_suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |