Package pygccxml :: Package declarations :: Module dependencies |

# Source Code for Module pygccxml.declarations.dependencies

     1  # Copyright 2004-2008 Roman Yakovenko.
     2  # Distributed under the Boost Software License, Version 1.0. (See
     3  # accompanying file LICENSE_1_0.txt or copy at
     4  # http://www.boost.org/LICENSE_1_0.txt)
     5
     6  """
     7  this module contains class that keeps dependency information of some declaration
     8  """
     9
    10  import cpptypes
    11
    12 -class dependency_info_t( object ):
    13 -    def __init__( self, declaration, depend_on_it, access_type=None, hint=None ):
    14          object.__init__( self )
    15          #prevent recursive import
    16          import class_declaration
    17          assert isinstance( depend_on_it, ( class_declaration.class_t, cpptypes.type_t ) )
    18          self._declaration = declaration
    19          self._depend_on_it = depend_on_it
    20          self._access_type = access_type
    21          self._hint = hint
    22
    23      @property
    24 -    def declaration( self ):
    25          return self._declaration
    26      #short name
    27      decl = declaration
    28
    29      @property
    30 -    def depend_on_it( self ):
    31          return self._depend_on_it
    32
    33 -    def _get_access_type( self ):
    34          return self._access_type
    35 -    def _set_access_type( self, access_type ):
    36          self._access_type = access_type
    37      access_type = property( _get_access_type, _set_access_type )
    38
    39 -    def __str__( self ):
    40          return 'declaration "%s" depends( %s ) on "%s" ' \
    41                 % ( self.declaration, self.access_type, self.depend_on_it )
    42
    43      @property
    44 -    def hint(self):
    45          """the declaration, that report dependency can put some additional inforamtion
    46          about dependency. It can be used later"""
    47          return self._hint
    48
    49 -    def find_out_depend_on_declaration( self ):
    50          """if declaration depends on other declaration and not on some type
    51             this function will return reference to it. Otherwise None will be returned
    52          """
    53          #prevent recursive import
    54          from pygccxml import declarations
    55
    56          if isinstance( self.depend_on_it, declarations.declaration_t ):
    57              return self.depend_on_it
    58          base_type = declarations.base_type( declarations.remove_alias( self.depend_on_it ) )
    59          if isinstance( base_type, cpptypes.declarated_t ):
    60              return base_type.declaration
    61          return None
    62