Package pygccxml :: Package msvc :: Package pdb :: Module impl_details

# Source Code for Module pygccxml.msvc.pdb.impl_details

     1  from . import enums
     2  from pygccxml import declarations
     3
     4 -def guess_class_type( udt_kind ):
     5      if enums.UdtKind.UdtStruct == udt_kind:
     6          return declarations.CLASS_TYPES.STRUCT
     7      elif enums.UdtKind.UdtClass == udt_kind:
     8          return declarations.CLASS_TYPES.CLASS
     9      else:
    10          return declarations.CLASS_TYPES.UNION
    11
    12 -class full_name_splitter_t( object ):
    13 -    def __init__( self, full_name ):
    14          self.__full_name = full_name
    15          self.__identifiers = self.__split_scope_identifiers()
    16          self.__scope_identifiers = None
    17
    18      @property
    19 -    def name( self ):
    20          return self.__identifiers[-1]
    21
    22      @property
    23 -    def scope_names( self ):
    24          if None is self.__scope_identifiers:
    25              self.__scope_identifiers = []# ['::']
    26              for i in range( len(self.__identifiers) - 1):
    27                  self.__scope_identifiers.append( '::'.join( self.__identifiers[0:i+1] ) )
    28          return self.__scope_identifiers
    29
    30      @property
    31 -    def identifiers( self ):
    32          return self.__identifiers
    33
    34 -    def __split_scope_identifiers( self ):
    35          try:
    36              result = []
    37              tmp = self.__full_name.split( '::' )
    38              tmp.reverse()
    39              while tmp:
    40                  token = tmp.pop()
    41                  less_count = token.count( '<' )
    42                  greater_count = token.count( '>' )
    43                  if less_count != greater_count:
    44                      while less_count != greater_count and tmp:
    45                          next_token = tmp.pop()
    46                          token = token + '::' + next_token
    47                          less_count += next_token.count( '<' )
    48                          greater_count += next_token.count( '>' )
    49                  result.append( token )
    50              return result
    51          except Exception, err:
    52              msg = 'Unable to split scope for identifiers. The full scope name is: "%s". Error: %s'
    53              msg = msg % ( self.__full_name, str(err) )
    54              raise RuntimeError( msg )
    55
    56  __name_splitters = {}
    57 -def get_name_splitter( full_name ):
    58      try:
    59          return __name_splitters[full_name]
    60      except KeyError:
    61          splitter = full_name_splitter_t( full_name )
    62          __name_splitters[full_name] = splitter
    63          return splitter
    64
    65  if '__main__' == __name__:
    66      name = "boost::detail::is_base_and_derived_impl2<engine_objects::universal_base_t,engine_objects::erroneous_transactions_file_configuration_t>::Host"
    67      fnsp = full_name_splitter_t( name )
    68      for x in fnsp.scope_names:
    69          print x
    70
    71      fnsp = full_name_splitter_t( 'x' )
    72      for x in fnsp.scope_names:
    73          print x
    74