Thread: [pygccxml-commit] SF.net SVN: pygccxml: [11] pygccxml_dev/pygccxml
Brought to you by:
mbaas,
roman_yakovenko
From: <mb...@us...> - 2006-04-28 10:07:55
|
Revision: 11 Author: mbaas Date: 2006-04-28 03:07:47 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=11&view=rev Log Message: ----------- Added *.pyc files to the svn:ignore property Property Changed: ---------------- pygccxml_dev/pygccxml/ pygccxml_dev/pygccxml/declarations/ pygccxml_dev/pygccxml/parser/ pygccxml_dev/pygccxml/utils/ Property changes on: pygccxml_dev/pygccxml ___________________________________________________________________ Name: svn:ignore + *.pyc Property changes on: pygccxml_dev/pygccxml/declarations ___________________________________________________________________ Name: svn:ignore + *.pyc Property changes on: pygccxml_dev/pygccxml/parser ___________________________________________________________________ Name: svn:ignore + *.pyc Property changes on: pygccxml_dev/pygccxml/utils ___________________________________________________________________ Name: svn:ignore + *.pyc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2006-11-13 19:54:46
|
Revision: 700 http://svn.sourceforge.net/pygccxml/?rev=700&view=rev Author: roman_yakovenko Date: 2006-11-08 10:58:43 -0800 (Wed, 08 Nov 2006) Log Message: ----------- adding fix for signed char, char bug Modified Paths: -------------- 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 Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-11-08 18:47:53 UTC (rev 699) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-11-08 18:58:43 UTC (rev 700) @@ -27,6 +27,7 @@ from cpptypes import fundamental_t from cpptypes import void_t from cpptypes import char_t +from cpptypes import signed_char_t from cpptypes import unsigned_char_t from cpptypes import wchar_t from cpptypes import short_int_t Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2006-11-08 18:47:53 UTC (rev 699) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2006-11-08 18:58:43 UTC (rev 700) @@ -112,6 +112,12 @@ def __init__( self ): fundamental_t.__init__( self, char_t.CPPNAME ) +class signed_char_t( fundamental_t ): + """represents signed char type""" + CPPNAME = 'signed char' + def __init__( self ): + fundamental_t.__init__( self, signed_char_t.CPPNAME ) + class unsigned_char_t( fundamental_t ): """represents unsigned char type""" CPPNAME = 'unsigned char' @@ -265,7 +271,7 @@ FUNDAMENTAL_TYPES = { void_t.CPPNAME : void_t() , char_t.CPPNAME : char_t() - , 'signed ' + char_t.CPPNAME : char_t() + , signed_char_t.CPPNAME : signed_char_t() , unsigned_char_t.CPPNAME : unsigned_char_t() , wchar_t.CPPNAME : wchar_t() , short_int_t.CPPNAME : short_int_t() Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-11-08 18:47:53 UTC (rev 699) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-11-08 18:58:43 UTC (rev 700) @@ -118,6 +118,7 @@ """returns True, if type represents C++ integral type, False otherwise""" integral_def = create_cv_types( cpptypes.char_t() ) \ + create_cv_types( cpptypes.unsigned_char_t() ) \ + + create_cv_types( cpptypes.signed_char_t() ) \ + create_cv_types( cpptypes.wchar_t() ) \ + create_cv_types( cpptypes.short_int_t() ) \ + create_cv_types( cpptypes.short_unsigned_int_t() ) \ Modified: pygccxml_dev/pygccxml/declarations/type_visitor.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_visitor.py 2006-11-08 18:47:53 UTC (rev 699) +++ pygccxml_dev/pygccxml/declarations/type_visitor.py 2006-11-08 18:58:43 UTC (rev 700) @@ -24,7 +24,10 @@ def visit_unsigned_char( self ): raise NotImplementedError() - + + def visit_signed_char( self ): + raise NotImplementedError() + def visit_wchar( self ): raise NotImplementedError() Modified: pygccxml_dev/pygccxml/parser/linker.py =================================================================== --- pygccxml_dev/pygccxml/parser/linker.py 2006-11-08 18:47:53 UTC (rev 699) +++ pygccxml_dev/pygccxml/parser/linker.py 2006-11-08 18:58:43 UTC (rev 700) @@ -141,6 +141,9 @@ def visit_char( self ): pass + def visit_signed_char( self ): + pass + def visit_unsigned_char( self ): pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-21 06:50:53
|
Revision: 1251 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1251&view=rev Author: roman_yakovenko Date: 2008-02-20 22:50:59 -0800 (Wed, 20 Feb 2008) Log Message: ----------- small restructuring Modified Paths: -------------- pygccxml_dev/pygccxml/utils/__init__.py Added Paths: ----------- pygccxml_dev/pygccxml/pdb_parser/ pygccxml_dev/pygccxml/pdb_parser/msdia_details.py pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py Removed Paths: ------------- pygccxml_dev/pygccxml/parser/msdia_details.py pygccxml_dev/pygccxml/parser/pdb_reader.py Deleted: pygccxml_dev/pygccxml/parser/msdia_details.py =================================================================== --- pygccxml_dev/pygccxml/parser/msdia_details.py 2008-02-21 06:47:58 UTC (rev 1250) +++ pygccxml_dev/pygccxml/parser/msdia_details.py 2008-02-21 06:50:59 UTC (rev 1251) @@ -1,91 +0,0 @@ -import os -import comtypes -import comtypes.client -import _winreg as win_registry -from distutils import msvccompiler - -class msdia_searcher_t: - def __init__( self ): - self.root_reg_key = win_registry.HKEY_LOCAL_MACHINE - - def find_path( self ): - vss_installed = self.__get_installed_vs_dirs() - msdia_dlls = self.__get_msdia_dll_paths( vss_installed ) - #D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\ - #D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\Debugger\msdia71.dll - #C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\msdia90.dll - if 1 == len(msdia_dlls): - return msdia_dlls[0] - else: - #TODO find the highest version and use it. - pass - - def __get_msdia_dll_paths( self, vss_installed ): - msdia_dlls = [] - for vs in vss_installed: - vs = os.path.split( vs )[0] - debug_dir = os.path.join( vs, 'Packages', 'Debugger' ) - files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' ) - , os.listdir( debug_dir ) ) - if not files: - continue - msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ]) - if not msdia_dlls: - raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' ) - return msdia_dlls - - def __get_installed_vs_dirs( self ): - vs_reg_path = 'Software\Microsoft\VisualStudio' - vss = self.read_keys( self.root_reg_key, vs_reg_path ) - vs_installed_and_exist = [] - - for vs_installed in vss: - values = self.read_values( self.root_reg_key, vs_reg_path + '\\' + vs_installed ) - try: - vs_installed_and_exist.append( os.path.realpath( values['installdir'] ) ) - except KeyError: - pass - - if not vs_installed_and_exist: - raise RuntimeError( 'pygccxml unable to find out a Visual Studio installation directory' ) - return vs_installed_and_exist - - - def read_keys(self, base, key): - return msvccompiler.read_keys(base, key) - - def read_values(self, base, key): - return msvccompiler.read_values(base, key) - -msdia_path = msdia_searcher_t().find_path() - -comtypes_client_gen_dir = comtypes.client.gen_dir -try: - comtypes.client.gen_dir = None - msdia = comtypes.client.GetModule( msdia_path ) -finally: - comtypes.client.gen_dir = comtypes_client_gen_dir - -#Adding code, that was not generated for some reason. - -class UdtKind: - UdtStruct, UdtClass, UdtUnion = ( 0, 1, 2 ) - -msdia.UdtKind = UdtKind - -class NameSearchOptions: - nsNone = 0 - nsfCaseSensitive = 0x1 - nsfCaseInsensitive = 0x2 - nsfFNameExt = 0x4 - nsfRegularExpression = 0x8 - nsfUndecoratedName = 0x10 - - # For backward compabibility: - nsCaseSensitive = nsfCaseSensitive - nsCaseInsensitive = nsfCaseInsensitive - nsFNameExt = nsfFNameExt - nsRegularExpression = nsfRegularExpression | nsfCaseSensitive - nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive - -msdia.NameSearchOptions = NameSearchOptions Deleted: pygccxml_dev/pygccxml/parser/pdb_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-21 06:47:58 UTC (rev 1250) +++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-21 06:50:59 UTC (rev 1251) @@ -1,164 +0,0 @@ -import os -import sys -import ctypes -import comtypes -import comtypes.client -from msdia_details import msdia - -sys.path.append( r'../..' ) -#sys.path.append( r'C:\dev\language-binding\pygccxml_dev' ) - -from pygccxml import utils -from pygccxml import declarations - - - -SymTagEnum = 12 - -def AsDiaSymbol( x ): - return ctypes.cast( x, ctypes.POINTER( msdia.IDiaSymbol ) ) - -def print_enums( smb ): - enums = smb.findChildren( SymTagEnum, None, 0 ) - for enum in iter( enums ): - enum = AsDiaSymbol( enum ) - print 'name: ', enum.name - if enum.container: - print 'container: ', enum.container.name - if enum.classParent: - print 'parent: ', enum.classParent.name - if enum.lexicalParent: - print 'lexical parent: ', enum.lexicalParent.Name - - values = enum.findChildren( msdia.SymTagData, None, 0 ) - for v in iter(values): - v = AsDiaSymbol(v) - if v.classParent.symIndexId != enum.symIndexId: - continue - print ' value %s(%d): ' % ( v.name, v.value ) - -def print_files( session ): - files = iter( session.findFile( None, '', 0 ) ) - for f in files: - f = ctypes.cast( f, ctypes.POINTER(msdia.IDiaSourceFile) ) - print 'File: ', f.fileName - -#~ print_files( session ) -#print_enums( root_symbol ) -def guess_class_type( udt_kind ): - if msdia.UdtKind.UdtStruct == udt_kind: - return declarations.CLASS_TYPES.STRUCT - elif msdia.UdtKind.UdtClass == udt_kind: - return declarations.CLASS_TYPES.CLASS - else: - return declarations.CLASS_TYPES.UNION - -class pdb_reader_t(object): - def __init__(self, pdb_file_path ): - self.logger = utils.loggers.gccxml - self.logger.debug( 'creating DiaSource object' ) - self.__dia_source = comtypes.client.CreateObject( msdia.DiaSource ) - self.logger.debug( 'loading pdb file: %s' % pdb_file_path ) - self.__dia_source.loadDataFromPdb(pdb_file_path) - self.logger.debug( 'opening session' ) - self.__dia_session = self.__dia_source.openSession() - self.__global_ns = declarations.namespace_t( '::' ) - self.__id2decl = {} #hash table unique symbol id : pygccxml declaration - - def read(self): - self.__populate_scopes() - - files = iter( self.__dia_session.findFile( None, '', 0 ) ) - for f in files: - f = ctypes.cast( f, ctypes.POINTER(msdia.IDiaSourceFile) ) - print 'File: ', f.fileName - - @property - def dia_global_scope(self): - return self.__dia_session.globalScope - - @property - def global_ns(self): - return self.__global_ns - - def __split_scope_identifiers( self, name ): - result = [] - tmp = name.split( '::' ) - tmp.reverse() - while tmp: - token = tmp.pop() - less_count = token.count( '<' ) - greater_count = token.count( '>' ) - if less_count != greater_count: - while less_count != greater_count: - next_token = tmp.pop() - token = token + '::' + next_token - less_count += next_token.count( '<' ) - greater_count += next_token.count( '>' ) - result.append( token ) - return result - - def __scope_identifie - - def __found_udt( self, name ): - self.logger.debug( 'testing whether name( "%s" ) is UDT symbol' % name ) - flags = msdia.NameSearchOptions.nsfCaseSensitive - found = self.dia_global_scope.findChildren( msdia.SymTagUDT, name, flags ) - if found.Count == 1: - self.logger.debug( 'name( "%s" ) is UDT symbol' % name ) - return AsDiaSymbol( fount.Item[0] ) - elif 1 < found.Count: - raise RuntimeError( "duplicated UDTs with name '%s', were found" % name ) - #~ self.logger.debug( 'name( "%s" ) is UDT symbol' % name ) - #~ return [AsDiaSymbol( s ) for s in iter(found)] - #~ for s in iter(found): - #~ s = - #~ print s.name - #~ print guess_class_type(s.udtKind) - else: - self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name ) - return False - - def __populate_scopes(self): - classes = {} #full name to list of symbols - dia_classes = self.dia_global_scope.findChildren( msdia.SymTagUDT, None, 0 ) - for dia_class in iter( dia_classes ): - dia_class = AsDiaSymbol( dia_class ) - if not classes.has_key( dia_class.name ): - classes[ dia_class.name ] = [ dia_class ] - else: - classes[ dia_class.name ].append( dia_class ) - for name, class_list in classes.iteritems(): - if len( class_list ) != 1: - print len( class_list ), name - - #~ klass = declarations.class_t(dia_class.name) - #~ klass.class_type = guess_class_type( dia_class.udtKind ) - #~ scope_identifiers = self.__split_scope_identifiers( dia_class.name ) - #~ if 1 == len(scope_identifiers): - #~ classes.append( klass ) - #~ else: - #~ ns_ref = self.global_ns - #~ for i in range( len(scope_identifiers) - 1): - #~ full_identifier = '::'.join( scope_identifiers[0:i+1] ) - #~ if not self.__is_udt( full_identifier ): - #~ #we have namespace - #~ try: - #~ ns_ref = ns_ref.namespace( scope_identifiers[i], recursive=False) - #~ except ns_ref.declaration_not_found_t: - #~ new_ns = declarations.namespace_t( scope_identifiers[i] ) - #~ ns_ref.adopt_declaration( new_ns ) - #~ ns_ref = new_ns - #~ else: - #~ classes.append( klass ) - #~ break - #~ classes.sort( lambda klass1, klass2: cmp( klass1.name, klass2.name ) ) - #~ for i in classes: - #~ print str(i) - #~ declarations.print_declarations( self.global_ns ) - -if __name__ == '__main__': - control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb' - control_pdb = r'xxx.pdb' - reader = pdb_reader_t( control_pdb ) - reader.read() Copied: pygccxml_dev/pygccxml/pdb_parser/msdia_details.py (from rev 1249, pygccxml_dev/pygccxml/parser/msdia_details.py) =================================================================== --- pygccxml_dev/pygccxml/pdb_parser/msdia_details.py (rev 0) +++ pygccxml_dev/pygccxml/pdb_parser/msdia_details.py 2008-02-21 06:50:59 UTC (rev 1251) @@ -0,0 +1,91 @@ +import os +import comtypes +import comtypes.client +import _winreg as win_registry +from distutils import msvccompiler + +class msdia_searcher_t: + def __init__( self ): + self.root_reg_key = win_registry.HKEY_LOCAL_MACHINE + + def find_path( self ): + vss_installed = self.__get_installed_vs_dirs() + msdia_dlls = self.__get_msdia_dll_paths( vss_installed ) + #D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\ + #D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\Debugger\msdia71.dll + #C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\msdia90.dll + if 1 == len(msdia_dlls): + return msdia_dlls[0] + else: + #TODO find the highest version and use it. + pass + + def __get_msdia_dll_paths( self, vss_installed ): + msdia_dlls = [] + for vs in vss_installed: + vs = os.path.split( vs )[0] + debug_dir = os.path.join( vs, 'Packages', 'Debugger' ) + files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' ) + , os.listdir( debug_dir ) ) + if not files: + continue + msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ]) + if not msdia_dlls: + raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' ) + return msdia_dlls + + def __get_installed_vs_dirs( self ): + vs_reg_path = 'Software\Microsoft\VisualStudio' + vss = self.read_keys( self.root_reg_key, vs_reg_path ) + vs_installed_and_exist = [] + + for vs_installed in vss: + values = self.read_values( self.root_reg_key, vs_reg_path + '\\' + vs_installed ) + try: + vs_installed_and_exist.append( os.path.realpath( values['installdir'] ) ) + except KeyError: + pass + + if not vs_installed_and_exist: + raise RuntimeError( 'pygccxml unable to find out a Visual Studio installation directory' ) + return vs_installed_and_exist + + + def read_keys(self, base, key): + return msvccompiler.read_keys(base, key) + + def read_values(self, base, key): + return msvccompiler.read_values(base, key) + +msdia_path = msdia_searcher_t().find_path() + +comtypes_client_gen_dir = comtypes.client.gen_dir +try: + comtypes.client.gen_dir = None + msdia = comtypes.client.GetModule( msdia_path ) +finally: + comtypes.client.gen_dir = comtypes_client_gen_dir + +#Adding code, that was not generated for some reason. + +class UdtKind: + UdtStruct, UdtClass, UdtUnion = ( 0, 1, 2 ) + +msdia.UdtKind = UdtKind + +class NameSearchOptions: + nsNone = 0 + nsfCaseSensitive = 0x1 + nsfCaseInsensitive = 0x2 + nsfFNameExt = 0x4 + nsfRegularExpression = 0x8 + nsfUndecoratedName = 0x10 + + # For backward compabibility: + nsCaseSensitive = nsfCaseSensitive + nsCaseInsensitive = nsfCaseInsensitive + nsFNameExt = nsfFNameExt + nsRegularExpression = nsfRegularExpression | nsfCaseSensitive + nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive + +msdia.NameSearchOptions = NameSearchOptions Copied: pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py (from rev 1250, pygccxml_dev/pygccxml/parser/pdb_reader.py) =================================================================== --- pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py (rev 0) +++ pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py 2008-02-21 06:50:59 UTC (rev 1251) @@ -0,0 +1,164 @@ +import os +import sys +import ctypes +import comtypes +import comtypes.client +from msdia_details import msdia + +sys.path.append( r'../..' ) +#sys.path.append( r'C:\dev\language-binding\pygccxml_dev' ) + +from pygccxml import utils +from pygccxml import declarations + + + +SymTagEnum = 12 + +def AsDiaSymbol( x ): + return ctypes.cast( x, ctypes.POINTER( msdia.IDiaSymbol ) ) + +def print_enums( smb ): + enums = smb.findChildren( SymTagEnum, None, 0 ) + for enum in iter( enums ): + enum = AsDiaSymbol( enum ) + print 'name: ', enum.name + if enum.container: + print 'container: ', enum.container.name + if enum.classParent: + print 'parent: ', enum.classParent.name + if enum.lexicalParent: + print 'lexical parent: ', enum.lexicalParent.Name + + values = enum.findChildren( msdia.SymTagData, None, 0 ) + for v in iter(values): + v = AsDiaSymbol(v) + if v.classParent.symIndexId != enum.symIndexId: + continue + print ' value %s(%d): ' % ( v.name, v.value ) + +def print_files( session ): + files = iter( session.findFile( None, '', 0 ) ) + for f in files: + f = ctypes.cast( f, ctypes.POINTER(msdia.IDiaSourceFile) ) + print 'File: ', f.fileName + +#~ print_files( session ) +#print_enums( root_symbol ) +def guess_class_type( udt_kind ): + if msdia.UdtKind.UdtStruct == udt_kind: + return declarations.CLASS_TYPES.STRUCT + elif msdia.UdtKind.UdtClass == udt_kind: + return declarations.CLASS_TYPES.CLASS + else: + return declarations.CLASS_TYPES.UNION + +class pdb_reader_t(object): + def __init__(self, pdb_file_path ): + self.logger = utils.loggers.gccxml + self.logger.debug( 'creating DiaSource object' ) + self.__dia_source = comtypes.client.CreateObject( msdia.DiaSource ) + self.logger.debug( 'loading pdb file: %s' % pdb_file_path ) + self.__dia_source.loadDataFromPdb(pdb_file_path) + self.logger.debug( 'opening session' ) + self.__dia_session = self.__dia_source.openSession() + self.__global_ns = declarations.namespace_t( '::' ) + self.__id2decl = {} #hash table unique symbol id : pygccxml declaration + + def read(self): + self.__populate_scopes() + + files = iter( self.__dia_session.findFile( None, '', 0 ) ) + for f in files: + f = ctypes.cast( f, ctypes.POINTER(msdia.IDiaSourceFile) ) + print 'File: ', f.fileName + + @property + def dia_global_scope(self): + return self.__dia_session.globalScope + + @property + def global_ns(self): + return self.__global_ns + + def __split_scope_identifiers( self, name ): + result = [] + tmp = name.split( '::' ) + tmp.reverse() + while tmp: + token = tmp.pop() + less_count = token.count( '<' ) + greater_count = token.count( '>' ) + if less_count != greater_count: + while less_count != greater_count: + next_token = tmp.pop() + token = token + '::' + next_token + less_count += next_token.count( '<' ) + greater_count += next_token.count( '>' ) + result.append( token ) + return result + + def __scope_identifie + + def __found_udt( self, name ): + self.logger.debug( 'testing whether name( "%s" ) is UDT symbol' % name ) + flags = msdia.NameSearchOptions.nsfCaseSensitive + found = self.dia_global_scope.findChildren( msdia.SymTagUDT, name, flags ) + if found.Count == 1: + self.logger.debug( 'name( "%s" ) is UDT symbol' % name ) + return AsDiaSymbol( fount.Item[0] ) + elif 1 < found.Count: + raise RuntimeError( "duplicated UDTs with name '%s', were found" % name ) + #~ self.logger.debug( 'name( "%s" ) is UDT symbol' % name ) + #~ return [AsDiaSymbol( s ) for s in iter(found)] + #~ for s in iter(found): + #~ s = + #~ print s.name + #~ print guess_class_type(s.udtKind) + else: + self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name ) + return False + + def __populate_scopes(self): + classes = {} #full name to list of symbols + dia_classes = self.dia_global_scope.findChildren( msdia.SymTagUDT, None, 0 ) + for dia_class in iter( dia_classes ): + dia_class = AsDiaSymbol( dia_class ) + if not classes.has_key( dia_class.name ): + classes[ dia_class.name ] = [ dia_class ] + else: + classes[ dia_class.name ].append( dia_class ) + for name, class_list in classes.iteritems(): + if len( class_list ) != 1: + print len( class_list ), name + + #~ klass = declarations.class_t(dia_class.name) + #~ klass.class_type = guess_class_type( dia_class.udtKind ) + #~ scope_identifiers = self.__split_scope_identifiers( dia_class.name ) + #~ if 1 == len(scope_identifiers): + #~ classes.append( klass ) + #~ else: + #~ ns_ref = self.global_ns + #~ for i in range( len(scope_identifiers) - 1): + #~ full_identifier = '::'.join( scope_identifiers[0:i+1] ) + #~ if not self.__is_udt( full_identifier ): + #~ #we have namespace + #~ try: + #~ ns_ref = ns_ref.namespace( scope_identifiers[i], recursive=False) + #~ except ns_ref.declaration_not_found_t: + #~ new_ns = declarations.namespace_t( scope_identifiers[i] ) + #~ ns_ref.adopt_declaration( new_ns ) + #~ ns_ref = new_ns + #~ else: + #~ classes.append( klass ) + #~ break + #~ classes.sort( lambda klass1, klass2: cmp( klass1.name, klass2.name ) ) + #~ for i in classes: + #~ print str(i) + #~ declarations.print_declarations( self.global_ns ) + +if __name__ == '__main__': + control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb' + control_pdb = r'xxx.pdb' + reader = pdb_reader_t( control_pdb ) + reader.read() Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2008-02-21 06:47:58 UTC (rev 1250) +++ pygccxml_dev/pygccxml/utils/__init__.py 2008-02-21 06:50:59 UTC (rev 1251) @@ -19,7 +19,7 @@ handler = logging.StreamHandler() handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) ) logger.addHandler(handler) - logger.setLevel(logging.INFO) + logger.setLevel(logging.DEBUG) return logger class loggers: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-23 08:54:01
|
Revision: 1253 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1253&view=rev Author: roman_yakovenko Date: 2008-02-23 00:54:06 -0800 (Sat, 23 Feb 2008) Log Message: ----------- pdb reader - adding treatment of inner classes Modified Paths: -------------- pygccxml_dev/pygccxml/pdb_parser/details.py pygccxml_dev/pygccxml/pdb_parser/msdia_details.py pygccxml_dev/pygccxml/pdb_parser/reader.py pygccxml_dev/pygccxml/utils/__init__.py Modified: pygccxml_dev/pygccxml/pdb_parser/details.py =================================================================== --- pygccxml_dev/pygccxml/pdb_parser/details.py 2008-02-21 08:05:30 UTC (rev 1252) +++ pygccxml_dev/pygccxml/pdb_parser/details.py 2008-02-23 08:54:06 UTC (rev 1253) @@ -1,3 +1,6 @@ +from msdia_details import msdia +from pygccxml import declarations + def guess_class_type( udt_kind ): if msdia.UdtKind.UdtStruct == udt_kind: return declarations.CLASS_TYPES.STRUCT @@ -6,7 +9,14 @@ else: return declarations.CLASS_TYPES.UNION - +def guess_access_type( access_type ): + if msdia.CV_access_e.CV_private == access_type: + return declarations.ACCESS_TYPES.PRIVATE + elif msdia.CV_access_e.CV_protected == access_type: + return declarations.ACCESS_TYPES.PROTECTED + else: + return declarations.ACCESS_TYPES.PUBLIC + class full_name_splitter_t( object ): def __init__( self, full_name ): self.__full_name = full_name @@ -20,7 +30,7 @@ @property def scope_names( self ): if None is self.__scope_identifiers: - self.__scope_identifiers = ['::'] + self.__scope_identifiers = []# ['::'] for i in range( len(self.__identifiers) - 1): self.__scope_identifiers.append( '::'.join( self.__identifiers[0:i+1] ) ) return self.__scope_identifiers @@ -46,7 +56,16 @@ result.append( token ) return result +__name_splitters = {} +def get_name_splitter( full_name ): + try: + return __name_splitters[full_name] + except KeyError: + splitter = full_name_splitter_t( full_name ) + __name_splitters[full_name] = splitter + return splitter + if '__main__' == __name__: name = "boost::detail::is_base_and_derived_impl2<engine_objects::universal_base_t,engine_objects::erroneous_transactions_file_configuration_t>::Host" fnsp = full_name_splitter_t( name ) Modified: pygccxml_dev/pygccxml/pdb_parser/msdia_details.py =================================================================== --- pygccxml_dev/pygccxml/pdb_parser/msdia_details.py 2008-02-21 08:05:30 UTC (rev 1252) +++ pygccxml_dev/pygccxml/pdb_parser/msdia_details.py 2008-02-23 08:54:06 UTC (rev 1253) @@ -23,8 +23,7 @@ def __get_msdia_dll_paths( self, vss_installed ): msdia_dlls = [] for vs in vss_installed: - vs = os.path.split( vs )[0] - debug_dir = os.path.join( vs, 'Packages', 'Debugger' ) + debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' ) files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' ) , os.listdir( debug_dir ) ) if not files: @@ -35,16 +34,18 @@ return msdia_dlls def __get_installed_vs_dirs( self ): - vs_reg_path = 'Software\Microsoft\VisualStudio' - vss = self.read_keys( self.root_reg_key, vs_reg_path ) - vs_installed_and_exist = [] + vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7' + values = self.read_values( self.root_reg_key, vs_reg_path ) + return [ values.values()[0] ] + #~ vss = self.read_keys( self.root_reg_key, vs_reg_path ) + #~ vs_installed_and_exist = [] - for vs_installed in vss: - values = self.read_values( self.root_reg_key, vs_reg_path + '\\' + vs_installed ) - try: - vs_installed_and_exist.append( os.path.realpath( values['installdir'] ) ) - except KeyError: - pass + #~ for vs_installed in vss: + #~ values = self.read_values( self.root_reg_key, vs_reg_path + '\\' + vs_installed ) + #~ try: + #~ vs_installed_and_exist.append( os.path.realpath( values['installdir'] ) ) + #~ except KeyError: + #~ pass if not vs_installed_and_exist: raise RuntimeError( 'pygccxml unable to find out a Visual Studio installation directory' ) @@ -69,9 +70,13 @@ #Adding code, that was not generated for some reason. class UdtKind: - UdtStruct, UdtClass, UdtUnion = ( 0, 1, 2 ) + UdtStruct, UdtClass, UdtUnion = (0, 1, 2) +class CV_access_e: + CV_private, CV_protected, CV_public = (1, 2, 3) + msdia.UdtKind = UdtKind +msdia.CV_access_e = CV_access_e class NameSearchOptions: nsNone = 0 Modified: pygccxml_dev/pygccxml/pdb_parser/reader.py =================================================================== --- pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-21 08:05:30 UTC (rev 1252) +++ pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-23 08:54:06 UTC (rev 1253) @@ -1,6 +1,7 @@ import os import sys import ctypes +import logging import comtypes import comtypes.client from msdia_details import msdia @@ -47,7 +48,8 @@ class pdb_reader_t(object): def __init__(self, pdb_file_path ): - self.logger = utils.loggers.gccxml + self.logger = utils.loggers.pdb_reader + self.logger.setLevel(logging.DEBUG) self.logger.debug( 'creating DiaSource object' ) self.__dia_source = comtypes.client.CreateObject( msdia.DiaSource ) self.logger.debug( 'loading pdb file: %s' % pdb_file_path ) @@ -55,16 +57,10 @@ self.logger.debug( 'opening session' ) self.__dia_session = self.__dia_source.openSession() self.__global_ns = declarations.namespace_t( '::' ) - self.__id2decl = {} #hash table unique symbol id : pygccxml declaration def read(self): self.__populate_scopes() - - files = iter( self.__dia_session.findFile( None, '', 0 ) ) - for f in files: - f = ctypes.cast( f, ctypes.POINTER(msdia.IDiaSourceFile) ) - print 'File: ', f.fileName - + @property def dia_global_scope(self): return self.__dia_session.globalScope @@ -72,15 +68,14 @@ @property def global_ns(self): return self.__global_ns - - def __found_udt( self, name ): + def __find_udt( self, name ): self.logger.debug( 'testing whether name( "%s" ) is UDT symbol' % name ) flags = msdia.NameSearchOptions.nsfCaseSensitive found = self.dia_global_scope.findChildren( msdia.SymTagUDT, name, flags ) if found.Count == 1: self.logger.debug( 'name( "%s" ) is UDT symbol' % name ) - return AsDiaSymbol( fount.Item[0] ) + return AsDiaSymbol( found.Item(0) ) elif 1 < found.Count: raise RuntimeError( "duplicated UDTs with name '%s', were found" % name ) #~ self.logger.debug( 'name( "%s" ) is UDT symbol' % name ) @@ -92,50 +87,80 @@ else: self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name ) return False - - def __populate_scopes(self): - classes = {} #full name to list of symbols + + def __list_main_classes( self ): + #in this context main classes, are classes that was defined within a namespace + #as opposite to classes defined in other classes + classes = [] dia_classes = self.dia_global_scope.findChildren( msdia.SymTagUDT, None, 0 ) for dia_class in iter( dia_classes ): dia_class = AsDiaSymbol( dia_class ) - if not classes.has_key( dia_class.name ): - classes[ dia_class.name ] = [ dia_class ] + name_splitter = details.get_name_splitter( dia_class.name ) + for scope in name_splitter.scope_names: + udt = self.__find_udt( scope ) + if udt: + classes.append( udt ) + break else: - classes[ dia_class.name ].append( dia_class ) + classes.append( dia_class ) + return classes + + def __add_inner_classes( self ): + for klass in self.global_ns.classes(recursive=True): + for dia_symbol in klass.dia_symbols: + flags = msdia.NameSearchOptions.nsCaseInRegularExpression + inner_name = dia_symbol.name + '::.*' + found = dia_symbol.findChildren( msdia.SymTagUDT, None, flags ) + for inner_dia_class in iter(found): + inner_dia_class = AsDiaSymbol( inner_dia_class ) + inner_name_splitter = details.get_name_splitter( inner_dia_class.name ) + try: + inner_klass = klass.class_( inner_name_splitter.name, recursive=False ) + inner_klass.dia_symbols.append( inner_dia_class ) + except klass.declaration_not_found_t: + klass.adopt_declaration( self.__create_class( inner_dia_class ) + , details.guess_access_type( inner_dia_class.access ) ) - for name, class_list in classes.iteritems(): - fname_splitter = details.full_name_splitter_t( name ) - klass = declarations.class_t(fname_splitter.name) - klass.class_type = details.guess_class_type( dia_class.udtKind ) - klass.dia_symbols = class_list - - for index, scope in enumerate( fname_splitter.scope_names ): - - - if not fname_splitter.scope_name: - classes.append( klass ) - else: - ns_ref = self.global_ns - for i in range( len(scope_identifiers) - 1): - full_identifier = '::'.join( scope_identifiers[0:i+1] ) - if not self.__is_udt( full_identifier ): - #we have namespace - try: - ns_ref = ns_ref.namespace( scope_identifiers[i], recursive=False) - except ns_ref.declaration_not_found_t: - new_ns = declarations.namespace_t( scope_identifiers[i] ) - ns_ref.adopt_declaration( new_ns ) - ns_ref = new_ns - else: - classes.append( klass ) - break - #~ classes.sort( lambda klass1, klass2: cmp( klass1.name, klass2.name ) ) - #~ for i in classes: - #~ print str(i) - #~ declarations.print_declarations( self.global_ns ) - + def __create_parent_ns( self, ns_full_name ): + name_splitter = details.get_name_splitter( ns_full_name ) + ns_ref = self.global_ns + for ns_name in name_splitter.identifiers: + try: + ns_ref = ns_ref.ns( ns_name, recursive=False ) + except ns_ref.declaration_not_found_t: + ns = declarations.namespace_t( ns_name ) + ns_ref.adopt_declaration( ns ) + ns_ref = ns + + def __create_class( self, dia_class ): + name_splitter = details.get_name_splitter( dia_class.name ) + klass = declarations.class_t( name_splitter.name ) + klass.class_type = details.guess_class_type(dia_class.udtKind) + klass.dia_symbols = [ dia_class ] + return klass + + def __populate_scopes(self): + main_classes = self.__list_main_classes() + for dia_class in main_classes: + name_splitter = details.get_name_splitter( dia_class.name ) + map( self.__create_parent_ns, name_splitter.scope_names ) + for dia_class in main_classes: + name_splitter = details.get_name_splitter( dia_class.name ) + ns_ref = self.global_ns + if 1 < len(name_splitter.identifiers): + ns_ref = self.global_ns.ns( '::' + name_splitter.scope_names[-1] ) + try: + klass = ns_ref.class_( name_splitter.name, recursive=False ) + klass.dia_symbols.append( dia_class ) + except ns_ref.declaration_not_found_t: + ns_ref.adopt_declaration( self.__create_class( dia_class ) ) + + self.__add_inner_classes() + + declarations.print_declarations( self.global_ns ) + if __name__ == '__main__': control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb' - control_pdb = r'xxx.pdb' + #control_pdb = r'xxx.pdb' reader = pdb_reader_t( control_pdb ) reader.read() Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2008-02-21 08:05:30 UTC (rev 1252) +++ pygccxml_dev/pygccxml/utils/__init__.py 2008-02-23 08:54:06 UTC (rev 1253) @@ -19,7 +19,7 @@ handler = logging.StreamHandler() handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) ) logger.addHandler(handler) - logger.setLevel(logging.DEBUG) + logger.setLevel(logging.INFO) return logger class loggers: @@ -33,7 +33,12 @@ """ gccxml = cxx_parser #backward compatability - + + pdb_reader = _create_logger_( 'pygccxml.pdb_reader' ) + """logger for MS .pdb file reader functionality + """ + + queries_engine = _create_logger_( 'pygccxml.queries_engine' ) """logger for query engine functionality. @@ -53,7 +58,7 @@ root = logging.getLogger( 'pygccxml' ) """root logger exists for your convinience only""" - all = [ root, cxx_parser, queries_engine, declarations_cache ] + all = [ root, cxx_parser, queries_engine, declarations_cache, pdb_reader ] """contains all logger classes, defined by the class""" def remove_file_no_raise(file_name ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-24 06:31:10
|
Revision: 1256 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1256&view=rev Author: roman_yakovenko Date: 2008-02-23 22:31:16 -0800 (Sat, 23 Feb 2008) Log Message: ----------- update name to better reflect package purpose Added Paths: ----------- pygccxml_dev/pygccxml/pdb_reader/ Removed Paths: ------------- pygccxml_dev/pygccxml/pdb_parser/ Copied: pygccxml_dev/pygccxml/pdb_reader (from rev 1255, pygccxml_dev/pygccxml/pdb_parser) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-26 20:38:14
|
Revision: 1263 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1263&view=rev Author: roman_yakovenko Date: 2008-02-26 12:38:16 -0800 (Tue, 26 Feb 2008) Log Message: ----------- adding bsc support Modified Paths: -------------- pygccxml_dev/pygccxml/pdb_reader/details.py pygccxml_dev/pygccxml/pdb_reader/scanner.py pygccxml_dev/pygccxml/utils/__init__.py Added Paths: ----------- pygccxml_dev/pygccxml/pdb_reader/bsc.py pygccxml_dev/pygccxml/pdb_reader/msvc_details.py Removed Paths: ------------- pygccxml_dev/pygccxml/pdb_reader/msdia_details.py Added: pygccxml_dev/pygccxml/pdb_reader/bsc.py =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/bsc.py (rev 0) +++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-02-26 20:38:16 UTC (rev 1263) @@ -0,0 +1,10 @@ +import os +import sys +import ctypes +import msvc_details + +bsc = ctypes.cdll.LoadLibrary( msvc_details.msbsc_path ) + +class bsc_t( object ): + def __init__( self, bsc_file_path ): + self.__bsc_file = bsc_file_path \ No newline at end of file Modified: pygccxml_dev/pygccxml/pdb_reader/details.py =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/details.py 2008-02-25 20:47:57 UTC (rev 1262) +++ pygccxml_dev/pygccxml/pdb_reader/details.py 2008-02-26 20:38:16 UTC (rev 1263) @@ -1,4 +1,4 @@ -from msdia_details import msdia +from msvc_details import msdia from pygccxml import declarations def guess_class_type( udt_kind ): Deleted: pygccxml_dev/pygccxml/pdb_reader/msdia_details.py =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/msdia_details.py 2008-02-25 20:47:57 UTC (rev 1262) +++ pygccxml_dev/pygccxml/pdb_reader/msdia_details.py 2008-02-26 20:38:16 UTC (rev 1263) @@ -1,80 +0,0 @@ -import os -import comtypes -import comtypes.client -import _winreg as win_registry -from distutils import msvccompiler - -class msdia_searcher_t: - def __init__( self ): - self.root_reg_key = win_registry.HKEY_LOCAL_MACHINE - - def find_path( self ): - vss_installed = self.__get_installed_vs_dirs() - msdia_dlls = self.__get_msdia_dll_paths( vss_installed ) - if 1 == len(msdia_dlls): - return msdia_dlls[0] - else: - #TODO find the highest version and use it. - pass - - def __get_msdia_dll_paths( self, vss_installed ): - msdia_dlls = [] - for vs in vss_installed: - debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' ) - files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' ) - , os.listdir( debug_dir ) ) - if not files: - continue - msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ]) - if not msdia_dlls: - raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' ) - return msdia_dlls - - def __get_installed_vs_dirs( self ): - vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7' - values = self.read_values( self.root_reg_key, vs_reg_path ) - return [ values.values()[0] ] - - def read_keys(self, base, key): - return msvccompiler.read_keys(base, key) - - def read_values(self, base, key): - return msvccompiler.read_values(base, key) - -msdia_path = msdia_searcher_t().find_path() -print msdia_path - -comtypes_client_gen_dir = comtypes.client.gen_dir -try: - comtypes.client.gen_dir = None - msdia = comtypes.client.GetModule( msdia_path ) -finally: - comtypes.client.gen_dir = comtypes_client_gen_dir - -#Adding code, that was not generated for some reason. - -class UdtKind: - UdtStruct, UdtClass, UdtUnion = (0, 1, 2) - -class CV_access_e: - CV_private, CV_protected, CV_public = (1, 2, 3) - -msdia.UdtKind = UdtKind -msdia.CV_access_e = CV_access_e - -class NameSearchOptions: - nsNone = 0 - nsfCaseSensitive = 0x1 - nsfCaseInsensitive = 0x2 - nsfFNameExt = 0x4 - nsfRegularExpression = 0x8 - nsfUndecoratedName = 0x10 - - # For backward compabibility: - nsCaseSensitive = nsfCaseSensitive - nsCaseInsensitive = nsfCaseInsensitive - nsFNameExt = nsfFNameExt - nsRegularExpression = nsfRegularExpression | nsfCaseSensitive - nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive - -msdia.NameSearchOptions = NameSearchOptions Copied: pygccxml_dev/pygccxml/pdb_reader/msvc_details.py (from rev 1262, pygccxml_dev/pygccxml/pdb_reader/msdia_details.py) =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/msvc_details.py (rev 0) +++ pygccxml_dev/pygccxml/pdb_reader/msvc_details.py 2008-02-26 20:38:16 UTC (rev 1263) @@ -0,0 +1,90 @@ +import os +import sys +import comtypes +import comtypes.client +import _winreg as win_registry +from distutils import msvccompiler + + +class binaries_searcher_t: + + def get_msbsc_path( self ): + relative_path = os.path.dirname( sys.modules[__name__].__file__) + absolute_path = os.path.abspath (relative_path) + return os.path.join( absolute_path, 'msbsc70.dll' ) + + def get_msdia_path( self ): + vss_installed = self.__get_installed_vs_dirs() + msdia_dlls = self.__get_msdia_dll_paths( vss_installed ) + if 1 == len(msdia_dlls): + return msdia_dlls[0] + else: + #TODO find the highest version and use it. + pass + + def __get_msdia_dll_paths( self, vss_installed ): + msdia_dlls = [] + for vs in vss_installed: + debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' ) + files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' ) + , os.listdir( debug_dir ) ) + if not files: + continue + msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ]) + if not msdia_dlls: + raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' ) + return msdia_dlls + + def __get_installed_vs_dirs( self ): + vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7' + values = self.read_values( win_registry.HKEY_LOCAL_MACHINE, vs_reg_path ) + return [ values.values()[0] ] + + def read_keys(self, base, key): + return msvccompiler.read_keys(base, key) + + def read_values(self, base, key): + return msvccompiler.read_values(base, key) + +bs = binaries_searcher_t() + +msdia_path = bs.get_msdia_path() +print 'msdia path: ', msdia_path + +msbsc_path = bs.get_msbsc_path() +print 'msbsc path: ', msbsc_path + +comtypes_client_gen_dir = comtypes.client.gen_dir +try: + comtypes.client.gen_dir = None + msdia = comtypes.client.GetModule( msdia_path ) +finally: + comtypes.client.gen_dir = comtypes_client_gen_dir + +#Adding code, that was not generated for some reason. + +class UdtKind: + UdtStruct, UdtClass, UdtUnion = (0, 1, 2) + +class CV_access_e: + CV_private, CV_protected, CV_public = (1, 2, 3) + +msdia.UdtKind = UdtKind +msdia.CV_access_e = CV_access_e + +class NameSearchOptions: + nsNone = 0 + nsfCaseSensitive = 0x1 + nsfCaseInsensitive = 0x2 + nsfFNameExt = 0x4 + nsfRegularExpression = 0x8 + nsfUndecoratedName = 0x10 + + # For backward compabibility: + nsCaseSensitive = nsfCaseSensitive + nsCaseInsensitive = nsfCaseInsensitive + nsFNameExt = nsfFNameExt + nsRegularExpression = nsfRegularExpression | nsfCaseSensitive + nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive + +msdia.NameSearchOptions = NameSearchOptions Modified: pygccxml_dev/pygccxml/pdb_reader/scanner.py =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-25 20:47:57 UTC (rev 1262) +++ pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-26 20:38:16 UTC (rev 1263) @@ -5,7 +5,7 @@ import logging import comtypes import comtypes.client -from msdia_details import msdia +from msvc_details import msdia sys.path.append( r'../..' ) #sys.path.append( r'C:\dev\language-binding\pygccxml_dev' ) Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2008-02-25 20:47:57 UTC (rev 1262) +++ pygccxml_dev/pygccxml/utils/__init__.py 2008-02-26 20:38:16 UTC (rev 1263) @@ -17,7 +17,8 @@ """implementation details""" logger = logging.getLogger(name) handler = logging.StreamHandler() - handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) ) + #handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) ) + handler.setFormatter( logging.Formatter( '%(levelname)s %(message)s' ) ) logger.addHandler(handler) logger.setLevel(logging.INFO) return logger This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-03-04 10:33:01
|
Revision: 1271 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1271&view=rev Author: roman_yakovenko Date: 2008-03-04 02:33:07 -0800 (Tue, 04 Mar 2008) Log Message: ----------- refactoring of bsc module Modified Paths: -------------- pygccxml_dev/pygccxml/pdb_reader/bsc.py pygccxml_dev/pygccxml/utils/__init__.py Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-03 20:21:22 UTC (rev 1270) +++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-04 10:33:07 UTC (rev 1271) @@ -236,22 +236,118 @@ LszNameFrBob.argtypes = [BOB] CLS = USHORT -class MBF: - mbfNil = 0x000 - mbfVars = 0x001 - mbfFuncs = 0x002 - mbfMacros = 0x004 - mbfTypes = 0x008 - mbfClass = 0x010 - mbfIncl = 0x020 - mbfMsgMap = 0x040 - mbfDialogID = 0x080 - mbfLibrary = 0x100 - mbfImport = 0x200 - mbfTemplate = 0x400 - mbfNamespace = 0x800 - mbfAll = 0xFFF +class enums: + class MBF: + Nil = (0x000, 'Nil') + Vars = (0x001, 'Vars') + Funcs = (0x002, 'Funcs') + Macros = (0x004, 'Macros') + Types = (0x008, 'Types') + Class = (0x010, 'Class') + Incl = (0x020, 'Incl') + MsgMap = (0x040, 'MsgMap') + DialogID = (0x080, 'DialogID') + Library = (0x100, 'Library') + Import = (0x200, 'Import') + Template = (0x400, 'Template') + Namespace = (0x800, 'Namespace') + All = (0xFFF, 'All') + + class TYP: + FUNCTION = (0x01, 'Function') + LABEL = (0x02, 'Label') + PARAMETER = (0x03, 'Parameter') + VARIABLE = (0x04, 'Variable') + CONSTANT = (0x05, 'Const') + MACRO = (0x06, 'Macro') + TYPEDEF = (0x07, 'Typedef') + STRUCNAM = (0x08, 'Struct') + ENUMNAM = (0x09, 'Enum') + ENUMMEM = (0x0A, 'Enum value') + UNIONNAM = (0x0B, 'Union') + SEGMENT = (0x0C, 'Segment') + GROUP = (0x0D, 'Group') + PROGRAM = (0x0E, 'Program') + CLASSNAM = (0x0F, 'Class') + MEMFUNC = (0x10, 'Mem Function') + MEMVAR = (0x11, 'Mem Variable') +class instance_t(object): + #represents some symbol + def __init__( self, inst_id, bsc, logger ): + self.__bsc = bsc + self.__inst_id = inst_id + self.logger = logger + + @property + def inst_id(self): + return self.__inst_id + + @utils.cached + def name_type_attribute( self ): + name = STRING() + typ = TYP() + attribute = ATR() + self.logger.debug( 'call BSCIinstInfo( %s ) function', str(self.__inst_id) ) + if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ): + self.logger.debug( 'call BSCIinstInfo( %s ) function - failure', str(self.__inst_id) ) + raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) ) + self.logger.debug( 'call BSCIinstInfo( %s ) function - success', str(self.__inst_id) ) + name = BSCFormatDname( self.__bsc, name ) + return name, typ, attribute + + @utils.cached + def name(self): + return self.name_type_attribute[0] + + @utils.cached + def type(self): + return self.name_type_attribute[1].value + + @utils.cached + def attribute(self): + return self.name_type_attribute[2].value + + def __str__( self ): + return 'type( "%s" ), attribute( "%s" ), name( "%s" )' \ + % ( TYP_ENUM.names[ self.type], str( self.attribute ), self.name ) + +class module_t(object): + #represents file + def __init__( self, mod_id, bsc, logger ): + self.__bsc = bsc + self.__mod_id = mod_id + self.logger = logger + + @property + def mod_id( self ): + return self.__mod_id + + @utils.cached + def path( self ): + name = STRING() + BSCImodInfo(self.__bsc, self.__mod_id, byref(name)) + return name + + @utils.cached + def instances( self ): + self.logger.debug( 'load instances for file "%s"', self.path ) + + instances_len = ULONG(0) + instances_ids = pointer( IINST() ) + + self.logger.debug( 'call BSCGetModuleContents function' ) + if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.All[0], byref( instances_ids ), byref( instances_len ) ): + self.logger.debug( 'call BSCGetModuleContents function - failure' ) + raise RuntimeError( "Unable to call BSCGetModuleContents" ) + self.logger.debug( 'load instances for file "%s" - done', self.path ) + + instances = map( lambda i: instance_t( instances_ids[i], self.__bsc, self.logger ) + , range( instances_len.value ) ) + + BSCDisposeArray( self.__bsc, instances_ids ) + return instances + class bsc_reader_t( object ): def __init__( self, bsc_file ): self.logger = utils.loggers.pdb_reader @@ -263,19 +359,14 @@ if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ): self.logger.debug( 'unable to open bsc file "%s"', self.__bsc_file ) raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file ) - self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file ) + self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file ) - self.__instances = [] - - self.__files = self.__load_files() - self.__file_instances = self.__load_files_instances( self.__files ) - def query_all_instances( self ): instances_len = ULONG(0) instances = pointer( IINST() ) self.logger.debug( 'call BSCGetAllGlobalsArray function' ) - if not BSCGetAllGlobalsArray( self.__bsc, MBF.mbfAll, byref( instances ), byref( instances_len ) ): + if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.All[0], byref( instances ), byref( instances_len ) ): self.logger.debug( 'call BSCGetAllGlobalsArray function - failure' ) raise RuntimeError( "Unable to load all globals symbols" ) self.logger.debug( 'call BSCGetAllGlobalsArray function - success' ) @@ -284,32 +375,24 @@ self.__instances.append( instances[i] ) BSCDisposeArray( self.__bsc, instances ) - @property - def files( self ): - return self.__files.keys() - - def __load_files(self): + @utils.cached + def files(self): module_ids = pointer( IMOD() ) - module_ids_len = ULONG() + module_len = ULONG() bs = BSC_STAT() + self.logger.debug( 'call BSCGetAllModulesArray function' ) - - if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_ids_len) ): + if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_len) ): self.logger.debug( 'call BSCGetAllModulesArray function - failure' ) raise RuntimeError( "Unable to load all modules" ) self.logger.debug( 'call BSCGetAllModulesArray function - success' ) - modules = [ module_ids[i] for i in range( module_ids_len.value ) ] + + modules = map( lambda i: module_t( module_ids[i], self.__bsc, self.logger ) + , range( module_len.value ) ) - files = {} - - for m in modules: - name = STRING() - BSCImodInfo(self.__bsc, m, byref(name)) - files[ name.value ] = m - BSCDisposeArray( self.__bsc, module_ids ) - return files + return modules def print_stat( self ): stat = BSC_STAT() @@ -317,39 +400,14 @@ for f, t in stat._fields_: print '%s: %s' % ( f, str( getattr( stat, f) ) ) - def __load_files_instances( self, files ): - file_instances = {} - for fname, file_id in files.iteritems(): - self.logger.debug( 'load instances for file "%s"', fname ) - - instances_len = ULONG(0) - instances = pointer( IINST() ) - - self.logger.debug( 'call BSCGetModuleContents function' ) - if not BSCGetModuleContents( self.__bsc, file_id, MBF.mbfClass, byref( instances ), byref( instances_len ) ): - self.logger.debug( 'call BSCGetModuleContents function - failure' ) - raise RuntimeError( "Unable to call BSCGetModuleContents" ) - file_instances[ fname ] = [ instances[i] for i in range( instances_len.value ) ] - - self.logger.debug( 'load instances for file "%s" - done', fname ) - return file_instances + def print_classes(self): + for m in self.files: + print m.path + for inst in m.instances: + print '\t', str(inst) def __del__( self ): BSCClose( self.__bsc ) - - def print_classes( self ): - for fname, instances in self.__file_instances.iteritems(): - print 'file: ', fname - for inst in instances: - name = STRING() - typ = TYP() - attribute = ATR() - BSCIinstInfo( self.__bsc, inst, byref( name ), byref( typ ), byref( attribute ) ) - name = BSCFormatDname( self.__bsc, name ) - print '\tname: ', name - print '\ttype: ', typ - print '\tattribute: ', attribute - if __name__ == '__main__': control_bsc = r'xxx.bsc' Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2008-03-03 20:21:22 UTC (rev 1270) +++ pygccxml_dev/pygccxml/utils/__init__.py 2008-03-04 10:33:07 UTC (rev 1271) @@ -99,3 +99,29 @@ else: raise RuntimeError( "Unknown architecture" ) + +#The following code is cut-and-paste from this post: +#http://groups.google.com/group/comp.lang.python/browse_thread/thread/5b71896c06bd0f76/ +#Thanks to Michele Simionato, for it +class cached(property): + 'Convert a method into a cached attribute' + def __init__(self, method): + private = '_' + method.__name__ + def fget(s): + try: + return getattr(s, private) + except AttributeError: + value = method(s) + setattr(s, private, value) + return value + def fdel(s): + del s.__dict__[private] + super(cached, self).__init__(fget, fdel=fdel) + + @staticmethod + def reset(self): + cls = self.__class__ + for name in dir(cls): + attr = getattr(cls, name) + if isinstance(attr, cached): + delattr(self, name) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-03-05 21:29:36
|
Revision: 1272 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1272&view=rev Author: roman_yakovenko Date: 2008-03-05 13:29:40 -0800 (Wed, 05 Mar 2008) Log Message: ----------- adding bsc support Modified Paths: -------------- pygccxml_dev/pygccxml/pdb_reader/bsc.py pygccxml_dev/pygccxml/utils/__init__.py Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py =================================================================== --- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-04 10:33:07 UTC (rev 1271) +++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-05 21:29:40 UTC (rev 1272) @@ -236,42 +236,90 @@ LszNameFrBob.argtypes = [BOB] CLS = USHORT -class enums: - class MBF: - Nil = (0x000, 'Nil') - Vars = (0x001, 'Vars') - Funcs = (0x002, 'Funcs') - Macros = (0x004, 'Macros') - Types = (0x008, 'Types') - Class = (0x010, 'Class') - Incl = (0x020, 'Incl') - MsgMap = (0x040, 'MsgMap') - DialogID = (0x080, 'DialogID') - Library = (0x100, 'Library') - Import = (0x200, 'Import') - Template = (0x400, 'Template') - Namespace = (0x800, 'Namespace') - All = (0xFFF, 'All') +class enums: + class MBF(utils.enum): + NIL = 0x000 + VARS = 0x001 + FUNCS = 0x002 + MACROS = 0x004 + TYPES = 0x008 + CLASS = 0x010 + INCL = 0x020 + MSGMAP = 0x040 + DIALOGID = 0x080 + LIBRARY = 0x100 + IMPORT = 0x200 + TEMPLATE = 0x400 + NAMESPACE = 0x800 + ALL = 0xFFF + + class TYPES(utils.enum): + FUNCTION = 0x01 + LABEL = 0x02 + PARAMETER = 0x03 + VARIABLE = 0x04 + CONSTANT = 0x05 + MACRO = 0x06 + TYPEDEF = 0x07 + STRUCNAM = 0x08 + ENUMNAM = 0x09 + ENUMMEM = 0x0A + UNIONNAM = 0x0B + SEGMENT = 0x0C + GROUP = 0x0D + PROGRAM = 0x0E + CLASSNAM = 0x0F + MEMFUNC = 0x10 + MEMVAR = 0x11 + + class ATTRIBUTES(utils.enum): + LOCAL = 0x001 + STATIC = 0x002 + SHARED = 0x004 + NEAR = 0x008 + COMMON = 0x010 + DECL_ONLY = 0x020 + PUBLIC = 0x040 + NAMED = 0x080 + MODULE = 0x100 + VIRTUAL = 0x200 + PRIVATE = 0x400 + PROTECT = 0x800 + +class definition_t(object): + #represents some other symbol + def __init__( self, def_id, bsc, logger ): + self.__bsc = bsc + self.__def_id = def_id + self.logger = logger + + @property + def def_id(self): + return self.__def_id - class TYP: - FUNCTION = (0x01, 'Function') - LABEL = (0x02, 'Label') - PARAMETER = (0x03, 'Parameter') - VARIABLE = (0x04, 'Variable') - CONSTANT = (0x05, 'Const') - MACRO = (0x06, 'Macro') - TYPEDEF = (0x07, 'Typedef') - STRUCNAM = (0x08, 'Struct') - ENUMNAM = (0x09, 'Enum') - ENUMMEM = (0x0A, 'Enum value') - UNIONNAM = (0x0B, 'Union') - SEGMENT = (0x0C, 'Segment') - GROUP = (0x0D, 'Group') - PROGRAM = (0x0E, 'Program') - CLASSNAM = (0x0F, 'Class') - MEMFUNC = (0x10, 'Mem Function') - MEMVAR = (0x11, 'Mem Variable') + @utils.cached + def location( self ): + module = STRING() + line = LINE() + self.logger.debug( 'call BSCIdefInfo( %s ) function', str(self.__def_id) ) + if not BSCIdefInfo( self.__bsc, self.def_id, byref( module ), byref( line ) ): + self.logger.debug( 'call BSCIdefInfo( %s ) function - failure', str(self.__def_id) ) + raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__def_id ) ) + self.logger.debug( 'call BSCIdefInfo( %s ) function - success', str(self.__def_id) ) + return (module, line) + + @utils.cached + def file_name(self): + return self.location[0].value + @utils.cached + def line(self): + return self.location[1].value + + def __str__( self ): + return self.file_name + ': %d' % self.line + + class instance_t(object): #represents some symbol def __init__( self, inst_id, bsc, logger ): @@ -308,10 +356,34 @@ def attribute(self): return self.name_type_attribute[2].value - def __str__( self ): - return 'type( "%s" ), attribute( "%s" ), name( "%s" )' \ - % ( TYP_ENUM.names[ self.type], str( self.attribute ), self.name ) + def __str__( self ): + tmp = [] + if enums.TYPES.has_value( self.type ): + tmp.append( 'type( "%s" )' % enums.TYPES.name_of( self.type ) ) + if enums.ATTRIBUTES.has_value( self.attribute ): + tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) ) + tmp.append( 'name( "%s" )' % self.name ) + return ', '.join( tmp ) + + @utils.cached + def definitions( self ): + self.logger.debug( 'load definitions for instance "%s"', self.name ) + definitions_len = ULONG(0) + definitions_ids = pointer( IDEF() ) + + self.logger.debug( 'call BSCGetDefArray function' ) + if not BSCGetDefArray( self.__bsc, self.inst_id, byref( definitions_ids ), byref( definitions_len ) ): + self.logger.debug( 'call BSCGetDefArray function - failure' ) + raise RuntimeError( "Unable to call BSCGetDefArray" ) + self.logger.debug( 'load definitions for instance "%s" - done', self.name ) + + definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc, self.logger ) + , range( definitions_len.value ) ) + + BSCDisposeArray( self.__bsc, definitions_ids ) + return definitions + class module_t(object): #represents file def __init__( self, mod_id, bsc, logger ): @@ -327,7 +399,7 @@ def path( self ): name = STRING() BSCImodInfo(self.__bsc, self.__mod_id, byref(name)) - return name + return name.value @utils.cached def instances( self ): @@ -337,7 +409,7 @@ instances_ids = pointer( IINST() ) self.logger.debug( 'call BSCGetModuleContents function' ) - if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.All[0], byref( instances_ids ), byref( instances_len ) ): + if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ): self.logger.debug( 'call BSCGetModuleContents function - failure' ) raise RuntimeError( "Unable to call BSCGetModuleContents" ) self.logger.debug( 'load instances for file "%s" - done', self.path ) @@ -366,7 +438,7 @@ instances = pointer( IINST() ) self.logger.debug( 'call BSCGetAllGlobalsArray function' ) - if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.All[0], byref( instances ), byref( instances_len ) ): + if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.ALL, byref( instances ), byref( instances_len ) ): self.logger.debug( 'call BSCGetAllGlobalsArray function - failure' ) raise RuntimeError( "Unable to load all globals symbols" ) self.logger.debug( 'call BSCGetAllGlobalsArray function - success' ) @@ -376,6 +448,10 @@ BSCDisposeArray( self.__bsc, instances ) @utils.cached + def is_case_sensitive( self ): + return bool( BSCFCaseSensitive( self.__bsc ) ) + + @utils.cached def files(self): module_ids = pointer( IMOD() ) module_len = ULONG() @@ -405,14 +481,18 @@ print m.path for inst in m.instances: print '\t', str(inst) + for definition in inst.definitions: + print '\t\t', str( definition ) def __del__( self ): - BSCClose( self.__bsc ) + if self.__bsc: + BSCClose( self.__bsc ) if __name__ == '__main__': control_bsc = r'xxx.bsc' reader = bsc_reader_t( control_bsc ) reader.print_stat() + print 'is_case_sensitive', reader.is_case_sensitive #~ reader.query_all_instances() #reader.files reader.print_classes() Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2008-03-04 10:33:07 UTC (rev 1271) +++ pygccxml_dev/pygccxml/utils/__init__.py 2008-03-05 21:29:40 UTC (rev 1272) @@ -125,3 +125,30 @@ attr = getattr(cls, name) if isinstance(attr, cached): delattr(self, name) + +class enum( object ): + """Usage example: + class fruits(enum): + apple = 0 + orange = 1 + + fruits.has_value( 1 ) + fruits.name_of( 1 ) + """ + + @classmethod + def has_value( cls, enum_numeric_value ): + for name, value in cls.__dict__.iteritems(): + if enum_numeric_value == value: + return True + else: + return False + + @classmethod + def name_of( cls, enum_numeric_value ): + for name, value in cls.__dict__.iteritems(): + if enum_numeric_value == value: + return name + else: + raise RuntimeError( 'Unable to find name for value(%d) in enumeration "%s"' + % ( enum_numeric_value, cls.__name__ ) ) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-03-12 11:59:25
|
Revision: 1277 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1277&view=rev Author: roman_yakovenko Date: 2008-03-12 04:59:29 -0700 (Wed, 12 Mar 2008) Log Message: ----------- rename directory to better reflect the content Added Paths: ----------- pygccxml_dev/pygccxml/msvc/ Removed Paths: ------------- pygccxml_dev/pygccxml/pdb_reader/ Copied: pygccxml_dev/pygccxml/msvc (from rev 1276, pygccxml_dev/pygccxml/pdb_reader) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-04-22 19:35:19
|
Revision: 1311 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1311&view=rev Author: roman_yakovenko Date: 2008-04-22 12:35:17 -0700 (Tue, 22 Apr 2008) Log Message: ----------- adding new files Added Paths: ----------- pygccxml_dev/pygccxml/declarations/compilers.py pygccxml_dev/pygccxml/msvc/pdb/kb.txt Added: pygccxml_dev/pygccxml/declarations/compilers.py =================================================================== --- pygccxml_dev/pygccxml/declarations/compilers.py (rev 0) +++ pygccxml_dev/pygccxml/declarations/compilers.py 2008-04-22 19:35:17 UTC (rev 1311) @@ -0,0 +1,19 @@ +# Copyright 2004 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) + +""" +contains enumeration of all compilers supported by the project +""" + +GCC_XML_06 = "GCC-XML 0.6" +GCC_XML_07 = "GCC-XML 0.7" +GCC_XML_09 = "GCC-XML 0.9" +GCC_XML_09_BUGGY = "GCC-XML 0.9 BUGGY" + +MSVC_PDB_9 = "MSVC PDB 9.0" + +def on_missing_functionality( compiler, functionality ): + raise NotImplementedError( '"%s" compiler doesn\'t support functionality "%s"' + % ( compiler, functionality )) Added: pygccxml_dev/pygccxml/msvc/pdb/kb.txt =================================================================== --- pygccxml_dev/pygccxml/msvc/pdb/kb.txt (rev 0) +++ pygccxml_dev/pygccxml/msvc/pdb/kb.txt 2008-04-22 19:35:17 UTC (rev 1311) @@ -0,0 +1,17 @@ +url: http://www.hightechtalks.com/visual-studio-net-debugging/re-using-dia-sdk-find-360868.html +Q: how to find out member variable offset? +A (By Oleg): +1. Assuming that you have IDiaSymbol interface pointer for the class (UDT) symbol, +use IDiaSymbol::findChildren (with SymTagData as the tag) to lookup the field +with the given name (or all fields). + +2. IDiaSymbol::findChildren will give you IDiaEnumSymbols interface, which you can use +to retrieve IDiaSymbol for the field(s). + +3. Using the field's IDiaSymbol interface, call IDiaSymbol::get_locationType to determine +the location of the field. +If the location is LocIsThisRel, use IDiaSymbol::get_offset to obtain the offset. +If the location is LocIsStatic, use IDiaSymbol::get_addressSection and IDiaSymbol::get_addressOffset, +or IDiaSymbol::get_relativeVirtualAddress, or IDiaSymbol::get_virtualAddress to obtain +the address of the static member. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-05-11 20:22:54
|
Revision: 1319 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1319&view=rev Author: roman_yakovenko Date: 2008-05-11 13:23:01 -0700 (Sun, 11 May 2008) Log Message: ----------- adding basic support for functions Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/pygccxml/msvc/pdb/enums.py pygccxml_dev/pygccxml/msvc/pdb/loader.py Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-05-08 20:05:35 UTC (rev 1318) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-05-11 20:23:01 UTC (rev 1319) @@ -97,15 +97,18 @@ def __get_method_signature(self, decl=None): - """ Returns function signature: [retval, [arg1, ..., argN]]. """ - if None is decl: - decl = self.__inst - retval = decl.return_type.decl_string - args = [] - for arg in decl.arguments: - args.append(arg.type.decl_string) - return [retval, args] + """ Returns function signature: [retval, [arg1, ..., argN]]. """ + if None is decl: + decl = self.__inst + retval = None + if decl.return_type: + retval = decl.return_type.decl_string + args = [] + for arg in decl.arguments: + args.append(arg.type.decl_string) + return [retval, args] + def visit_member_function( self ): self.print_decl_header() self.writer( ' ' * (self.level+1) * self.INDENT_SIZE @@ -113,6 +116,9 @@ def visit_constructor( self ): self.print_decl_header() + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + + "Signature: " + str( self.__get_method_signature() ) + os.linesep ) + if self.__print_details: self.writer( ' ' * ( self.level + 1 ) * self.INDENT_SIZE + 'copy constructor: ' + str(self.__inst.is_copy_constructor) @@ -123,15 +129,23 @@ def visit_member_operator( self ): self.print_decl_header() + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + + "Signature: " + str( self.__get_method_signature() ) + os.linesep ) def visit_casting_operator( self ): self.print_decl_header() + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + + "Signature: " + str( self.__get_method_signature() ) + os.linesep ) def visit_free_function( self ): self.print_decl_header() + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + + "Signature: " + str( self.__get_method_signature() ) + os.linesep ) def visit_free_operator( self ): self.print_decl_header() + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + + "Signature: " + str( self.__get_method_signature() ) + os.linesep ) def visit_class_declaration(self ): self.print_decl_header() @@ -148,7 +162,7 @@ byte_align = 'align: %d'%(self.__inst.byte_align) self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep ) except NotImplementedError: - self.writer( ' ' * curr_level * self.INDENT_SIZE + "not implemented".ljust( self.JUSTIFY ) + os.linesep ) + self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ) + os.linesep ) if self.__inst.aliases: aliases = map( lambda typedef: typedef.name, self.__inst.aliases ) @@ -219,7 +233,7 @@ byte_align = 'align: %d'%(self.__inst.type.byte_align) self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep ) except NotImplementedError: - self.writer( ' ' * curr_level * self.INDENT_SIZE + "not implemented".ljust( self.JUSTIFY ) + os.linesep ) + self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ) + os.linesep ) byte_offset = 'offset: %d'%(self.__inst.byte_offset) self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_offset + os.linesep) Modified: pygccxml_dev/pygccxml/msvc/pdb/enums.py =================================================================== --- pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-05-08 20:05:35 UTC (rev 1318) +++ pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-05-11 20:23:01 UTC (rev 1319) @@ -45,3 +45,16 @@ nsRegularExpression = nsfRegularExpression | nsfCaseSensitive nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive + +class DataKind( utils.enum ): + DataIsUnknown = 0 + DataIsLocal = 1 + DataIsStaticLocal = 2 + DataIsParam = 3 + DataIsObjectPtr = 4 + DataIsFileStatic = 5 + DataIsGlobal = 6 + DataIsMember = 7 + DataIsStaticMember = 8 + DataIsConstant = 9 + Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py =================================================================== --- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-08 20:05:35 UTC (rev 1318) +++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-11 20:23:01 UTC (rev 1319) @@ -1,4 +1,5 @@ import os +import re import pdb import sys import ctypes @@ -502,23 +503,62 @@ self.__update_decls_tree( function_decl ) self.logger.info( 'building function objects(%d) - done', functions_count ) + def __guess_operator_type( self, smbl, operator_type ): + #assumption: the code deals with correct code + if not smbl.uname.startswith( 'operator' ) or smbl.uname == 'operator': + return None + oper_smbls = ('!', ' ', '*', '%', '&', '(', '+', '-', ',', '/', '|', '~', '[', '^', '=', '<') + if smbl.uname[ len( 'operator' ) ] not in oper_smbls: + return None + if smbl.uname[ len( 'operator' ) ] == ' ' \ + and smbl.uname not in ['operator new', 'operator delete']: + #we have casting operator + return declarations.casting_operator_t() + if isinstance( operator_type, declarations.member_function_type_t ): + return declarations.member_operator_t() + else: + return declarations.free_operator_t() + + def __guess_constructor( self, smbl, calldef_type ): + tmpls = declarations.templates + class_ = declarations.remove_declarated( calldef_type.class_inst ) + if class_.name == smbl.uname \ + or ( tmpls.is_instantiation( class_.name ) + and tmpls.name( class_.name ) == smbl.uname ): + calldef_type.return_type = None + return declarations.constructor_t() + def __create_calldef( self, smbl ): self.logger.debug( 'creating calldef "%s"', smbl.uname ) name_splitter = impl_details.get_name_splitter( smbl.uname ) calldef_type = self.create_type( smbl.type ) #what does happen with constructor? + decl = None if isinstance( calldef_type, declarations.member_function_type_t ): - decl = declarations.member_function_t() + if smbl.uname.startswith( '~' ): + decl = declarations.destructor_t() + if not decl: #may be operator + decl = self.__guess_operator_type(smbl, calldef_type) + if not decl: #may be constructor + decl = self.__guess_constructor( smbl, calldef_type ) + if not decl: + decl = declarations.member_function_t() else: - decl = declarations.free_function_t() + decl = self.__guess_operator_type(smbl, calldef_type) + if not decl: + decl = declarations.free_function_t() decl.name = smbl.uname decl.arguments = map( lambda t: declarations.argument_t( type=t ) , calldef_type.arguments_types ) + + args_smbls = map( as_symbol, smbl.findChildren( msdia.SymTagData, None, 0 ) ) + args_smbls = filter( lambda smbl: smbl.dataKind == enums.DataKind.DataIsParam, args_smbls ) + + for index, arg_smbl in enumerate( args_smbls ): + arg_decl = decl.arguments[index] + arg_decl.name = arg_smbl.name + arg_decl.default_value = arg_smbl.value decl.return_type = calldef_type.return_type - #~ args_smbls = smbl.findChildren( msdia.SymTagFunctionArgType, None, 0 ) - #~ args = map( create_arg, itertools.imap(as_symbol, args_smbls) ) - #~ if 'some_function' in smbl.name: - #~ pdb.set_trace() self.__update_decl( decl, smbl ) self.logger.debug( 'creating calldef "%s" - done', smbl.uname ) return decl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |