Package pygccxml :: Package msvc :: Module bsc_impl_details |

# Source Code for Module pygccxml.msvc.bsc_impl_details

      1  import os
      2  import sys
      3  import ctypes
      4  import logging
      5  import msvc_details
      6  from ctypes import *
      7  from ctypes.wintypes import ULONG
      8  from ctypes.wintypes import DWORD
      9  from ctypes.wintypes import BOOL
     10  from ctypes.wintypes import BYTE
     11  from ctypes.wintypes import WORD
     12  from ctypes.wintypes import UINT
     13
     14  sys.path.append( r'../..' )
     15
     16  from pygccxml import utils
     17  from pygccxml import declarations
     18
     19
     20  STRING = c_char_p
     21  _libraries = {}
     22  _libraries['msvcr70.dll'] = CDLL(msvc_details.msvcr_path, mode=RTLD_GLOBAL)
     23  _libraries['msbsc70.dll'] = CDLL(msvc_details.msbsc_path, mode=RTLD_GLOBAL)
     24
     25
     26  qyMac = 9
     27  refreshAllOp = 4
     28  qyDervOf = 7
     29  delOp = 1
     30  qyImpMembers = 8
     31  changeOp = 2
     32  qyRefs = 4
     33  qyCalls = 2
     34  changeIinstOp = 3
     35  qyContains = 1
     36  qyCalledBy = 3
     37  noOp = 5
     38  qyBaseOf = 6
     39  qyNil = 0
     40  addOp = 0
     41  qyDefs = 5
     42  PULONG = POINTER(ULONG)
     43  USHORT = c_ushort
     44  PUSHORT = POINTER(USHORT)
     45  UCHAR = c_ubyte
     46  PUCHAR = POINTER(UCHAR)
     47  PSZ = STRING
     48  FLOAT = c_float
     49  PFLOAT = POINTER(FLOAT)
     50  PBOOL = POINTER(BOOL)
     51  LPBOOL = POINTER(BOOL)
     52  PBYTE = POINTER(BYTE)
     53  LPBYTE = POINTER(BYTE)
     54  PINT = POINTER(c_int)
     55  LPINT = POINTER(c_int)
     56  PWORD = POINTER(WORD)
     57  LPWORD = POINTER(WORD)
     58  LPLONG = POINTER(c_long)
     59  PDWORD = POINTER(DWORD)
     60  LPDWORD = POINTER(DWORD)
     61  LPVOID = c_void_p
     62  LPCVOID = c_void_p
     63  INT = c_int
     64  PUINT = POINTER(c_uint)
     65  ULONG_PTR = POINTER(ULONG)
     66  NI = ULONG
     67  IINST = ULONG
     68  IREF = ULONG
     69  IDEF = ULONG
     70  IMOD = USHORT
     71  LINE = USHORT
     72  TYP = BYTE
     73  ATR = USHORT
     74  ATR32 = ULONG
     75  MBF = ULONG
     76  SZ = STRING
     77  SZ_CONST = STRING
     78
     79 -class Bsc(Structure):
     80      pass
     81
     82  # values for enumeration 'OPERATION'
     83  OPERATION = c_int # enum
     84 -class IinstInfo(Structure):
     85      pass
     86  IinstInfo._fields_ = [
     87      ('m_iinst', IINST),
     88      ('m_szName', SZ_CONST),
     89      ('m_ni', NI),
     90  ]
     91 -class BSC_STAT(Structure):
     92      pass
     93  BSC_STAT._fields_ = [
     94      ('cDef', ULONG),
     95      ('cRef', ULONG),
     96      ('cInst', ULONG),
     97      ('cMod', ULONG),
     98      ('cUseLink', ULONG),
     99      ('cBaseLink', ULONG),
    100  ]
    101 -class NiQ(Structure):
    102      pass
    103  NiQ._fields_ = [
    104      ('m_iinstOld', IINST),
    105      ('m_iInfoNew', IinstInfo),
    106      ('m_op', OPERATION),
    107      ('m_typ', TYP),
    108  ]
    109  pfnNotifyChange = CFUNCTYPE(BOOL, POINTER(NiQ), ULONG, ULONG_PTR)
    110
    111  # values for enumeration '_qy_'
    112  _qy_ = c_int # enum
    113  QY = _qy_
    114  Bsc._fields_ = [
    115  ]
    116  BSCOpen = _libraries['msbsc70.dll'].BSCOpen
    117  BSCOpen.restype = BOOL
    118  BSCOpen.argtypes = [SZ_CONST, POINTER(POINTER(Bsc))]
    119  BSCClose = _libraries['msbsc70.dll'].BSCClose
    120  BSCClose.restype = BOOL
    121  BSCClose.argtypes = [POINTER(Bsc)]
    122  BSCIinstInfo = _libraries['msbsc70.dll'].BSCIinstInfo
    123  BSCIinstInfo.restype = BOOL
    124  BSCIinstInfo.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR)]
    125  BSCIrefInfo = _libraries['msbsc70.dll'].BSCIrefInfo
    126  BSCIrefInfo.restype = BOOL
    127  BSCIrefInfo.argtypes = [POINTER(Bsc), IREF, POINTER(SZ), POINTER(LINE)]
    128  BSCIdefInfo = _libraries['msbsc70.dll'].BSCIdefInfo
    129  BSCIdefInfo.restype = BOOL
    130  BSCIdefInfo.argtypes = [POINTER(Bsc), IDEF, POINTER(SZ), POINTER(LINE)]
    131  BSCImodInfo = _libraries['msbsc70.dll'].BSCImodInfo
    132  BSCImodInfo.restype = BOOL
    133  BSCImodInfo.argtypes = [POINTER(Bsc), IMOD, POINTER(SZ)]
    134  BSCSzFrTyp = _libraries['msbsc70.dll'].BSCSzFrTyp
    135  BSCSzFrTyp.restype = SZ
    136  BSCSzFrTyp.argtypes = [POINTER(Bsc), TYP]
    137  BSCSzFrAtr = _libraries['msbsc70.dll'].BSCSzFrAtr
    138  BSCSzFrAtr.restype = SZ
    139  BSCSzFrAtr.argtypes = [POINTER(Bsc), ATR]
    140  BSCGetIinstByvalue = _libraries['msbsc70.dll'].BSCGetIinstByvalue
    141  BSCGetIinstByvalue.restype = BOOL
    142  BSCGetIinstByvalue.argtypes = [POINTER(Bsc), SZ, TYP, ATR, POINTER(IINST)]
    143  BSCGetOverloadArray = _libraries['msbsc70.dll'].BSCGetOverloadArray
    144  BSCGetOverloadArray.restype = BOOL
    145  BSCGetOverloadArray.argtypes = [POINTER(Bsc), SZ, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
    146  BSCGetUsedByArray = _libraries['msbsc70.dll'].BSCGetUsedByArray
    147  BSCGetUsedByArray.restype = BOOL
    148  BSCGetUsedByArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
    149  BSCGetUsesArray = _libraries['msbsc70.dll'].BSCGetUsesArray
    150  BSCGetUsesArray.restype = BOOL
    151  BSCGetUsesArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
    152  BSCGetBaseArray = _libraries['msbsc70.dll'].BSCGetBaseArray
    153  BSCGetBaseArray.restype = BOOL
    154  BSCGetBaseArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
    155  BSCGetDervArray = _libraries['msbsc70.dll'].BSCGetDervArray
    156  BSCGetDervArray.restype = BOOL
    157  BSCGetDervArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
    158  BSCGetMembersArray = _libraries['msbsc70.dll'].BSCGetMembersArray
    159  BSCGetMembersArray.restype = BOOL
    160  BSCGetMembersArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
    161  BSCGetDefArray = _libraries['msbsc70.dll'].BSCGetDefArray
    162  BSCGetDefArray.restype = BOOL
    163  BSCGetDefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
    164  BSCGetRefArray = _libraries['msbsc70.dll'].BSCGetRefArray
    165  BSCGetRefArray.restype = BOOL
    166  BSCGetRefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
    167  BSCGetModuleContents = _libraries['msbsc70.dll'].BSCGetModuleContents
    168  BSCGetModuleContents.restype = BOOL
    169  BSCGetModuleContents.argtypes = [POINTER(Bsc), IMOD, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
    170  BSCGetModuleByName = _libraries['msbsc70.dll'].BSCGetModuleByName
    171  BSCGetModuleByName.restype = BOOL
    172  BSCGetModuleByName.argtypes = [POINTER(Bsc), SZ, POINTER(IMOD)]
    173  BSCGetAllModulesArray = _libraries['msbsc70.dll'].BSCGetAllModulesArray
    174  BSCGetAllModulesArray.restype = BOOL
    175  BSCGetAllModulesArray.argtypes = [POINTER(Bsc), POINTER(POINTER(IMOD)), POINTER(ULONG)]
    176  BSCDisposeArray = _libraries['msbsc70.dll'].BSCDisposeArray
    177  BSCDisposeArray.restype = None
    178  BSCDisposeArray.argtypes = [POINTER(Bsc), c_void_p]
    179  BSCFormatDname = _libraries['msbsc70.dll'].BSCFormatDname
    180  BSCFormatDname.restype = SZ
    181  BSCFormatDname.argtypes = [POINTER(Bsc), SZ]
    182  BSCFInstFilter = _libraries['msbsc70.dll'].BSCFInstFilter
    183  BSCFInstFilter.restype = BOOL
    184  BSCFInstFilter.argtypes = [POINTER(Bsc), IINST, MBF]
    185  BSCIinstFrIref = _libraries['msbsc70.dll'].BSCIinstFrIref
    186  BSCIinstFrIref.restype = IINST
    187  BSCIinstFrIref.argtypes = [POINTER(Bsc), IREF]
    188  BSCIinstFrIdef = _libraries['msbsc70.dll'].BSCIinstFrIdef
    189  BSCIinstFrIdef.restype = IINST
    190  BSCIinstFrIdef.argtypes = [POINTER(Bsc), IDEF]
    191  BSCIinstContextIref = _libraries['msbsc70.dll'].BSCIinstContextIref
    192  BSCIinstContextIref.restype = IINST
    193  BSCIinstContextIref.argtypes = [POINTER(Bsc), IREF]
    194  BSCGetStatistics = _libraries['msbsc70.dll'].BSCGetStatistics
    195  BSCGetStatistics.restype = BOOL
    196  BSCGetStatistics.argtypes = [POINTER(Bsc), POINTER(BSC_STAT)]
    197  BSCGetModuleStatistics = _libraries['msbsc70.dll'].BSCGetModuleStatistics
    198  BSCGetModuleStatistics.restype = BOOL
    199  BSCGetModuleStatistics.argtypes = [POINTER(Bsc), IMOD, POINTER(BSC_STAT)]
    200  BSCFCaseSensitive = _libraries['msbsc70.dll'].BSCFCaseSensitive
    201  BSCFCaseSensitive.restype = BOOL
    202  BSCFCaseSensitive.argtypes = [POINTER(Bsc)]
    203  BSCSetCaseSensitivity = _libraries['msbsc70.dll'].BSCSetCaseSensitivity
    204  BSCSetCaseSensitivity.restype = BOOL
    205  BSCSetCaseSensitivity.argtypes = [POINTER(Bsc), BOOL]
    206  BSCGetAllGlobalsArray = _libraries['msbsc70.dll'].BSCGetAllGlobalsArray
    207  BSCGetAllGlobalsArray.restype = BOOL
    208  BSCGetAllGlobalsArray.argtypes = [POINTER(Bsc), MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
    209  BSCSzFrAtr2 = _libraries['msbsc70.dll'].BSCSzFrAtr2
    210  BSCSzFrAtr2.restype = SZ
    211  BSCSzFrAtr2.argtypes = [POINTER(Bsc), ATR32]
    212  BSCIinstInfo2 = _libraries['msbsc70.dll'].BSCIinstInfo2
    213  BSCIinstInfo2.restype = BOOL
    214  BSCIinstInfo2.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR32)]
    215  BSCGetIinstByvalue2 = _libraries['msbsc70.dll'].BSCGetIinstByvalue2
    216  BSCGetIinstByvalue2.restype = BOOL
    217  BSCGetIinstByvalue2.argtypes = [POINTER(Bsc), SZ, TYP, ATR32, POINTER(IINST)]
    218  OpenBSCQuery = _libraries['msbsc70.dll'].OpenBSCQuery
    219  OpenBSCQuery.restype = BOOL
    220  OpenBSCQuery.argtypes = [POINTER(Bsc)]
    221  CloseBSCQuery = _libraries['msbsc70.dll'].CloseBSCQuery
    222  CloseBSCQuery.restype = BOOL
    223  CloseBSCQuery.argtypes = []
    224  BOB = ULONG
    225  InitBSCQuery = _libraries['msbsc70.dll'].InitBSCQuery
    226  InitBSCQuery.restype = BOOL
    227  InitBSCQuery.argtypes = [QY, BOB]
    228  BobNext = _libraries['msbsc70.dll'].BobNext
    229  BobNext.restype = BOB
    230  BobNext.argtypes = []
    231  BobFrName = _libraries['msbsc70.dll'].BobFrName
    232  BobFrName.restype = BOB
    233  BobFrName.argtypes = [SZ]
    234  LszNameFrBob = _libraries['msbsc70.dll'].LszNameFrBob
    235  LszNameFrBob.restype = SZ
    236  LszNameFrBob.argtypes = [BOB]
    237  CLS = USHORT
    238
    239 -class enums:
    240 -    class MBF(utils.enum):
    241          NIL       = 0x000
    242          VARS      = 0x001
    243          FUNCS     = 0x002
    244          MACROS    = 0x004
    245          TYPES     = 0x008
    246          CLASS     = 0x010
    247          INCL      = 0x020
    248          MSGMAP    = 0x040
    249          DIALOGID  = 0x080
    250          LIBRARY   = 0x100
    251          IMPORT    = 0x200
    252          TEMPLATE  = 0x400
    253          NAMESPACE = 0x800
    254          ALL       = 0xFFF
    255
    256 -    class TYPES(utils.enum):
    257          FUNCTION  = 0x01
    258          LABEL     = 0x02
    259          PARAMETER = 0x03
    260          VARIABLE  = 0x04
    261          CONSTANT  = 0x05
    262          MACRO     = 0x06
    263          TYPEDEF   = 0x07
    264          STRUCNAM  = 0x08
    265          ENUMNAM   = 0x09
    266          ENUMMEM   = 0x0A
    267          UNIONNAM  = 0x0B
    268          SEGMENT   = 0x0C
    269          GROUP     = 0x0D
    270          PROGRAM   = 0x0E
    271          CLASSNAM  = 0x0F
    272          MEMFUNC   = 0x10
    273          MEMVAR    = 0x11
    274
    275 -    class ATTRIBUTES(utils.enum):
    276          LOCAL     = 0x001
    277          STATIC    = 0x002
    278          SHARED    = 0x004
    279          NEAR      = 0x008
    280          COMMON    = 0x010
    281          DECL_ONLY = 0x020
    282          PUBLIC    = 0x040
    283          NAMED     = 0x080
    284          MODULE    = 0x100
    285          VIRTUAL   = 0x200
    286          PRIVATE   = 0x400
    287          PROTECT   = 0x800
    288
    289 -class definition_t(object):
    290      #represents some other symbol
    291 -    def __init__( self, def_id, bsc ):
    292          self.__bsc = bsc
    293          self.__def_id = def_id
    294
    295      @property
    296 -    def def_id(self):
    297          return self.__def_id
    298
    299      @utils.cached
    300 -    def location( self ):
    301          module = STRING()
    302          line = LINE()
    303          if not BSCIdefInfo( self.__bsc, self.def_id, byref( module ), byref( line ) ):
    304              raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__def_id ) )
    305          return (module, line)
    306
    307      @utils.cached
    308 -    def file_name(self):
    309          return self.location[0].value
    310
    311      @utils.cached
    312 -    def line(self):
    313          return self.location[1].value
    314
    315 -    def __str__( self ):
    316          return self.file_name + ': %d' % self.line + ' name: %s' % self.as_instance.name
    317
    318      @utils.cached
    319 -    def as_instance(self):
    320          return self.__bsc.create_instance( BSCIinstFrIdef( self.__bsc, self.def_id) )
    321
    322 -class instance_t(object):
    323      #represents some symbol
    324 -    def __init__( self, inst_id, bsc ):
    325          self.__bsc = bsc
    326          self.__inst_id = inst_id
    327
    328      @property
    329 -    def inst_id(self):
    330          return self.__inst_id
    331
    332      @utils.cached
    333 -    def name_type_attribute_mangled_name( self ):
    334          name = STRING()
    335          typ = TYP()
    336          attribute = ATR()
    337          if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ):
    338              raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) )
    339          undecorated_name = BSCFormatDname( self.__bsc, name )
    340          return undecorated_name, typ, attribute, name.value
    341
    342
    343      @utils.cached
    344 -    def mangled_name(self):
    345          return self.name_type_attribute_mangled_name[3]
    346
    347      @utils.cached
    348 -    def name(self):
    349          return self.name_type_attribute_mangled_name[0]
    350
    351      @utils.cached
    352 -    def type(self):
    353          return self.name_type_attribute_mangled_name[1].value
    354
    355      @utils.cached
    356 -    def attribute(self):
    357          return self.name_type_attribute_mangled_name[2].value
    358
    359 -    def __str__( self ):
    360          tmp = []
    361          if enums.TYPES.has_value( self.type ):
    362              tmp.append( 'type( "%s" )' % enums.TYPES.name_of( self.type ) )
    363          if enums.ATTRIBUTES.has_value( self.attribute ):
    364              tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) )
    365          tmp.append( 'name( "%s" )' % self.name )
    366          tmp.append( 'mangled name( "%s" )' % self.mangled_name )
    367          return ', '.join( tmp )
    368
    369
    370      @utils.cached
    371 -    def definitions( self ):
    372          definitions_len = ULONG(0)
    373          definitions_ids = pointer( IDEF() )
    374
    375          if not BSCGetDefArray( self.__bsc, self.inst_id, byref( definitions_ids ), byref( definitions_len ) ):
    376              raise RuntimeError( "Unable to call BSCGetDefArray" )
    377
    378          definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc )
    379                             , range( definitions_len.value ) )
    380
    381          BSCDisposeArray( self.__bsc, definitions_ids )
    382          return definitions
    383
    384      @utils.cached
    385 -    def members( self ):
    386          instances_len = ULONG(0)
    387          instances_ids = pointer( IINST() )
    388
    389          if not BSCGetMembersArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
    390              raise RuntimeError( "Unable to call BSCGetMembersArray" )
    391
    392          instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
    393                           , range( instances_len.value ) )
    394
    395          BSCDisposeArray( self.__bsc, instances_ids )
    396          return instances
    397
    398      @utils.cached
    399 -    def used_symbols(self):
    400          instances_len = ULONG(0)
    401          instances_ids = pointer( IINST() )
    402
    403          if not BSCGetUsesArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
    404              raise RuntimeError( "Unable to call BSCGetUsesArray" )
    405
    406          instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
    407                           , range( instances_len.value ) )
    408
    409          BSCDisposeArray( self.__bsc, instances_ids )
    410          return instances
    411
    412      @utils.cached
    413 -    def base_classes(self):
    414          instances_len = ULONG(0)
    415          instances_ids = pointer( IINST() )
    416
    417          if not BSCGetBaseArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
    418              raise RuntimeError( "Unable to call BSCGetBaseArray" )
    419
    420          instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
    421                           , range( instances_len.value ) )
    422
    423          BSCDisposeArray( self.__bsc, instances_ids )
    424          return instances
    425
    426      @utils.cached
    427 -    def derived_classes(self):
    428          instances_len = ULONG(0)
    429          instances_ids = pointer( IINST() )
    430
    431          if not BSCGetDervArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
    432              raise RuntimeError( "Unable to call BSCGetDervArray" )
    433
    434          instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
    435                           , range( instances_len.value ) )
    436
    437          BSCDisposeArray( self.__bsc, instances_ids )
    438          return instances
    439
    440 -class module_t(object):
    441      #represents file
    442 -    def __init__( self, mod_id, bsc ):
    443          self.__bsc = bsc
    444          self.__mod_id = mod_id
    445
    446      @property
    447 -    def mod_id( self ):
    448          return self.__mod_id
    449
    450      @utils.cached
    451 -    def path( self ):
    452          name = STRING()
    453          BSCImodInfo(self.__bsc, self.__mod_id, byref(name))
    454          return name.value
    455
    456      @utils.cached
    457 -    def instances( self ):
    458          instances_len = ULONG(0)
    459          instances_ids = pointer( IINST() )
    460
    461          if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
    462              raise RuntimeError( "Unable to call BSCGetModuleContents" )
    463
    464          instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
    465                           , range( instances_len.value ) )
    466
    467          BSCDisposeArray( self.__bsc, instances_ids )
    468          return instances
    469
    470 -class bsc_reader_t( object ):
    471 -    def __init__( self, bsc_file ):
    472          self.logger = utils.loggers.pdb_reader
    473          self.logger.setLevel(logging.INFO)
    474
    475          self.__bsc_file = bsc_file
    476          self.__bsc = pointer( Bsc() )
    477          if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ):
    478              raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file )
    479
    480          self.__instances_cache = {} #inst id : instance_t
    481          self.__bsc.create_instance = lambda inst_id: self.__create_instance( inst_id )
    482
    483 -    def __create_instance( self, inst_id ):
    484          try:
    485              return self.__instances_cache[ inst_id ]
    486          except KeyError:
    487              inst = instance_t( inst_id, self.__bsc )
    488              self.__instances_cache[ inst_id ] = inst
    489              return inst
    490
    491 -    def query_all_instances( self ):
    492          instances_len = ULONG(0)
    493          instances = pointer( IINST() )
    494
    495          if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.ALL, byref( instances ), byref( instances_len ) ):
    496              raise RuntimeError( "Unable to load all globals symbols" )
    497          for i in range( instances_len.value ):
    498              self.__instances.append( instances[i] )
    499          BSCDisposeArray( self.__bsc, instances )
    500
    501      @utils.cached
    502 -    def is_case_sensitive( self ):
    503          return bool( BSCFCaseSensitive( self.__bsc ) )
    504
    505      @utils.cached
    506 -    def files(self):
    507          module_ids = pointer( IMOD() )
    508          module_len = ULONG()
    509          bs = BSC_STAT()
    510
    511          if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_len) ):
    512              raise RuntimeError( "Unable to load all modules" )
    513
    514          modules = map( lambda i: module_t( module_ids[i], self.__bsc )
    515                         , range( module_len.value ) )
    516
    517          BSCDisposeArray( self.__bsc, module_ids )
    518
    519          return modules
    520
    521 -    def print_stat( self ):
    522          stat = BSC_STAT()
    523          BSCGetStatistics( self.__bsc, byref( stat ) )
    524          for f, t in stat._fields_:
    525              print '%s: %s' % ( f, str( getattr( stat, f) ) )
    526
    527 -    def print_classes(self, file_name=None):
    528          for m in self.files:
    529              if file_name and m.path != file_name:
    530                  continue
    531              print 'File: ', m.path
    532              if m.instances:
    533                  print '\tInstances:'
    534                  for inst in m.instances:
    535                      print '\t\t', str(inst)
    536                      if inst.definitions:
    537                          print '\t\t\tDefinitions:'
    538                          for definition in inst.definitions:
    539                              print '\t\t\t\t', str( definition )
    540                      if inst.members:
    541                          print '\t\t\tMembers:'
    542                          for member in inst.members:
    543                              print '\t\t\t\t', str( member )
    544                      if inst.used_symbols:
    545                          print '\t\t\tUsed symbols:'
    546                          for used_symbol in inst.used_symbols:
    547                              print '\t\t\t\t', str( used_symbol )
    548                      if inst.base_classes:
    549                          print '\t\t\tBase classes:'
    550                          for base_class in inst.base_classes:
    551                              print '\t\t\t\t', str( base_class )
    552                      if inst.derived_classes:
    553                          print '\t\t\tDerived classes:'
    554                          for derived_class in inst.derived_classes:
    555                              print '\t\t\t\t', str( derived_class )
    556
    557 -    def __del__( self ):
    558          if self.__bsc:
    559              BSCClose( self.__bsc )
    560
    561  if __name__ == '__main__':
    562      control_bsc = r'xxx.bsc'
    563      reader = bsc_reader_t( control_bsc )
    564      reader.print_stat()
    565      print 'is_case_sensitive', reader.is_case_sensitive
    566      #~ reader.query_all_instances()
    567      #reader.files
    568      reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
    569