pygccxml-commit Mailing List for C++ Python language bindings (Page 25)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(190) |
Apr
(166) |
May
(170) |
Jun
(75) |
Jul
(105) |
Aug
(131) |
Sep
(99) |
Oct
(84) |
Nov
(67) |
Dec
(54) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(66) |
Feb
(49) |
Mar
(25) |
Apr
(62) |
May
(21) |
Jun
(34) |
Jul
(9) |
Aug
(21) |
Sep
(5) |
Oct
|
Nov
(63) |
Dec
(34) |
| 2008 |
Jan
(10) |
Feb
(42) |
Mar
(26) |
Apr
(25) |
May
(6) |
Jun
(40) |
Jul
(18) |
Aug
(29) |
Sep
(6) |
Oct
(32) |
Nov
(14) |
Dec
(56) |
| 2009 |
Jan
(127) |
Feb
(52) |
Mar
(2) |
Apr
(10) |
May
(29) |
Jun
(3) |
Jul
|
Aug
(16) |
Sep
(4) |
Oct
(11) |
Nov
(8) |
Dec
(14) |
| 2010 |
Jan
(31) |
Feb
(1) |
Mar
(7) |
Apr
(9) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
(8) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <rom...@us...> - 2008-02-25 07:25:25
|
Revision: 1259
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1259&view=rev
Author: roman_yakovenko
Date: 2008-02-24 23:25:27 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
adding new test case
Modified Paths:
--------------
pyplusplus_dev/docs/history/history.rest
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
pyplusplus_dev/unittests/override_bug_tester.py
Modified: pyplusplus_dev/docs/history/history.rest
===================================================================
--- pyplusplus_dev/docs/history/history.rest 2008-02-24 15:07:30 UTC (rev 1258)
+++ pyplusplus_dev/docs/history/history.rest 2008-02-25 07:25:27 UTC (rev 1259)
@@ -34,6 +34,99 @@
3. Users always changed the name of the projects. I saw at least 6 different names.
+-----------
+Version SVN
+-----------
+
+1. The algorithm, which calculates what member functions should be redefined in derived
+ class wrappers was improved. For example:
+
+ .. code-block:: C++
+
+ struct A{
+ virtual void foo() {}
+ };
+
+ class B: public A{
+ };
+
+ Previous version of `Py++`_ didn't generate wrapper for class ``B``, even
+ though ``B`` inherits ``A``'s virtual function. Now if you have the following
+ Python code:
+
+ .. code-block:: Python
+
+ class C(B):
+ def __init__( self ):
+ B.__init__(self)
+ def foo(self):
+ print "C.foo"
+
+ then when ``foo`` is invoked on this instance on the C++ side of things, the
+ Python code won't be executed as the wrapper is missing.
+
+ If you use "function transformation" functionality, than it is possible the
+ generated code will not compile. Consider next example:
+
+ .. code-block:: C++
+
+ struct A{
+ virtual void foo(int& i) {/*do smth*/}
+ };
+
+ class B: public A{
+ virtual void foo(int& i) {/*do smth else*/}
+ };
+
+ The `Py++`_ code:
+
+ .. code-block:: Python
+
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+
+ mb = module_builder_t( ... )
+ foo = mb.mem_funs( 'foo' )
+ foo.add_transformation( FT.output(0) )
+
+ The generated code of wrapper class, for class ``B``, will contain next code:
+
+ .. code-block:: C++
+
+ virtual void foo() {
+ ...
+ }
+
+ static boost::python::tuple default_foo( ::B & inst ){
+ ...
+ }
+
+ virtual void foo() {
+ ...
+ }
+
+ static boost::python::tuple default_foo( ::B & inst ){
+ ...
+ }
+
+ Yes, the functions will be defined twice! In the previous version, the functions
+ were also defined twice but in the different classes. It was unclear, what
+ function will be called in this or that situation.
+
+ If you have such situation, I suggest you to give aliases to the functions:
+
+ .. code-block:: Python
+
+
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+
+ mb = module_builder_t( ... )
+ for f in mb.mem_funs( 'foo' )
+ foo.add_transformation( FT.output(0), alias=f.name + '_' + f.parent.name )
+
+
+
-------------
Version 0.9.5
-------------
Modified: pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-24 15:07:30 UTC (rev 1258)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-25 07:25:27 UTC (rev 1259)
@@ -60,6 +60,18 @@
}
+class AA
+{
+ public:
+ virtual void do_smth(int& i) const { i = 'a' ;}
+ virtual ~AA(){}
+};
+
+class BB: public AA
+{
+ virtual void do_smth(int& i) const { i = 'b' ;}
+};
+
}
#endif//__final_classes_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py 2008-02-24 15:07:30 UTC (rev 1258)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-02-25 07:25:27 UTC (rev 1259)
@@ -7,6 +7,7 @@
import sys
import unittest
import fundamental_tester_base
+from pyplusplus import function_transformers as FT
class tester_t(fundamental_tester_base.fundamental_tester_base_t):
EXTENSION_NAME = 'override_bug'
@@ -19,6 +20,9 @@
def customize( self, mb ):
mb.class_("Derived2").member_functions("eval_c").exclude()
+ mb.class_( 'BB' ).include()
+ do_smth = mb.mem_funs( 'do_smth' )
+ do_smth.add_transformation( FT.output(0) )
def run_tests(self, module):
class C( module.B ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-24 15:07:25
|
Revision: 1258
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1258&view=rev
Author: roman_yakovenko
Date: 2008-02-24 07:07:30 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
add typedef
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/scanner.py
Modified: pygccxml_dev/pygccxml/pdb_reader/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-24 08:12:00 UTC (rev 1257)
+++ pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-24 15:07:30 UTC (rev 1258)
@@ -44,6 +44,7 @@
self.__enums = {}
self.__classes = {}
+ self.__typedefs = {}
self.__namespaces = {'': self.__global_ns}
@@ -138,6 +139,7 @@
name_splitter = details.get_name_splitter( enum_smbl.name )
enum_decl = declarations.enumeration_t( name_splitter.name )
enum_decl.dia_symbols = [ enum_smbl.symIndexId ]
+ enum_decl.byte_size = enum_smbl.length
values = enum_smbl.findChildren( msdia.SymTagData, None, 0 )
for v in iter(values):
v = AsDiaSymbol(v)
@@ -169,8 +171,30 @@
self.__enums[ enum_smbl.name ] = [ enum_decl ]
self.logger.debug( '\tfound %s %s' % ( enum_smbl.name, str(enum_decl) ) )
self.logger.debug( 'loading enums to "%s" - done' % parent_symbol.name )
-
+ def __create_typedef( self, typedef_smbl ):
+ name_splitter = details.get_name_splitter( typedef_smbl.name )
+ typedef_decl = declarations.typedef_t( name_splitter.name )
+ typedef_decl.dia_symbols = [ typedef_smbl.symIndexId ]
+ return typedef_decl
+
+ def __load_typedefs( self, parent_symbol_id ):
+ parent_symbol = self.__dia_session.symbolById( parent_symbol_id )
+ self.logger.debug( 'loading typedefs to "%s" ' % parent_symbol.name )
+ for typedef_smbl in iter( parent_symbol.findChildren( SymTagEnum, None, 0 ) ):
+ typedef_smbl = AsDiaSymbol( typedef_smbl )
+ typedef_decl = self.__create_typedef( typedef_smbl )
+ try:
+ for typedef_discovered in self.__typedefs[ typedef_smbl.name ]:
+ if self.__are_symbols_equivalent( typedef_smbl.symIndexId, typedef_discovered.dia_symbols[0] ):
+ continue
+ else:
+ self.__typedefs[ typedef_smbl.name ].append( typedef_decl )
+ except KeyError:
+ self.__typedefs[ typedef_smbl.name ] = [ typedef_decl ]
+ self.logger.debug( '\tfound %s %s' % ( typedef_smbl.name, str(typedef_decl) ) )
+ self.logger.debug( 'loading typedefs to "%s" - done' % parent_symbol.name )
+
def __load_classes( self, parent_symbol_id ):
parent_symbol = self.__dia_session.symbolById( parent_symbol_id )
self.logger.debug( 'loading classes to "%s" ' % parent_symbol.name )
@@ -207,16 +231,18 @@
parent_ns.adopt_declaration( ns_decl )
self.__namespaces[ ns_name ] = ns_decl
- 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 = set([dia_class.symIndexId])
- return klass
+ def __create_class( self, class_smbl ):
+ name_splitter = details.get_name_splitter( class_smbl.name )
+ class_decl = declarations.class_t( name_splitter.name )
+ class_decl.class_type = details.guess_class_type(class_smbl.udtKind)
+ class_decl.dia_symbols = set([class_smbl.symIndexId])
+ class_decl.byte_size = class_smbl.length
+ return class_decl
def __populate_scopes(self):
self.__load_enums( self.dia_global_scope.symIndexId )
self.__load_classes( self.dia_global_scope.symIndexId )
+ self.__load_typedefs( self.dia_global_scope.symIndexId )
#~ main_classes = self.__list_main_classes()
#~ self.__create_nss()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-24 08:11:55
|
Revision: 1257
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1257&view=rev
Author: roman_yakovenko
Date: 2008-02-24 00:12:00 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/msdia_details.py
Added Paths:
-----------
pygccxml_dev/pygccxml/pdb_reader/scanner.py
Removed Paths:
-------------
pygccxml_dev/pygccxml/pdb_reader/reader.py
Modified: pygccxml_dev/pygccxml/pdb_reader/msdia_details.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/msdia_details.py 2008-02-24 06:31:16 UTC (rev 1256)
+++ pygccxml_dev/pygccxml/pdb_reader/msdia_details.py 2008-02-24 08:12:00 UTC (rev 1257)
@@ -11,9 +11,6 @@
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:
@@ -37,20 +34,6 @@
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
-
- 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)
@@ -59,6 +42,7 @@
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:
Deleted: pygccxml_dev/pygccxml/pdb_reader/reader.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/reader.py 2008-02-24 06:31:16 UTC (rev 1256)
+++ pygccxml_dev/pygccxml/pdb_reader/reader.py 2008-02-24 08:12:00 UTC (rev 1257)
@@ -1,223 +0,0 @@
-import os
-import sys
-import ctypes
-import pprint
-import logging
-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
-
-import details
-
-
-SymTagEnum = 12
-
-def AsDiaSymbol( x ):
- return ctypes.cast( x, ctypes.POINTER( msdia.IDiaSymbol ) )
-
-
-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
-
-
-class pdb_reader_t(object):
- def __init__(self, pdb_file_path ):
- 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 )
- self.__dia_source.loadDataFromPdb(pdb_file_path)
- self.logger.debug( 'opening session' )
- self.__dia_session = self.__dia_source.openSession()
- self.logger.debug( 'opening session - done' )
- self.__global_ns = declarations.namespace_t( '::' )
- self.__classes = {}
- self.__namespaces = {'': self.__global_ns}
-
-
- def read(self):
- self.__populate_scopes()
-
- @property
- def dia_global_scope(self):
- return self.__dia_session.globalScope
-
- @property
- def global_ns(self):
- return self.__global_ns
-
- 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( 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 )
- #~ return [AsDiaSymbol( s ) for s in iter(found)]
- #~ for s in iter(found):
- #~ s =
- #~ print s.name
- #~ print details.guess_class_type(s.udtKind)
- else:
- self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name )
- return None
-
- def __list_main_classes( self ):
- #in this context main classes, are classes that were defined within a namespace
- #as opposite to the 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 )
- name_splitter = details.get_name_splitter( dia_class.name )
- for index, scope in enumerate( name_splitter.scope_names ):
- if scope in self.__namespaces:
- continue
- else:
- udt = self.__find_udt( scope )
- if udt:
- classes.append( udt )
- if index:
- self.__namespaces[ name_splitter.scope_names[index-1] ] = None
- break
- else:
- self.__namespaces[ scope ] = None
- else:
- classes.append( dia_class )
- if name_splitter.scope_names:
- self.__namespaces[ name_splitter.scope_names[-1] ] = None
- return classes
-
- def __add_inner_classes( self, parent_class ):
- self.logger.debug( 'adding inner classes to "%s"' % parent_class.decl_string )
- for symbol_id in parent_class.dia_symbols:
- self.logger.debug( '\tdia symbol id: %d' % symbol_id )
- dia_symbol = self.__dia_session.symbolById( symbol_id )
- found = dia_symbol.findChildren( msdia.SymTagUDT, None, 0 )
- for inner_dia_class in iter(found):
- inner_dia_class = AsDiaSymbol( inner_dia_class )
- self.logger.debug( '\t\tinner UDT found - %s' % inner_dia_class.name )
- inner_name_splitter = details.get_name_splitter( inner_dia_class.name )
- try:
- inner_klass = parent_class.class_( inner_name_splitter.name, recursive=False )
- inner_klass.dia_symbols.add( inner_dia_class.symIndexId )
- except parent_class.declaration_not_found_t:
- inner_klass = self.__create_class( inner_dia_class )
- parent_class.adopt_declaration( inner_klass
- , details.guess_access_type( inner_dia_class.access ) )
- self.__classes[ inner_dia_class.name ] = inner_klass
- self.logger.debug( 'adding inner classes to "%s" - done' % parent_class.decl_string )
-
- def __create_enum( self, enum_smbl ):
- name_splitter = details.get_name_splitter( enum_smbl.name )
- enum_decl = declarations.enumeration_t( name_splitter.name )
- values = enum_smbl.findChildren( msdia.SymTagData, None, 0 )
- for v in iter(values):
- v = AsDiaSymbol(v)
- if v.classParent.symIndexId != enum_smbl.symIndexId:
- continue
- enum_decl.append_value( v.name, v.value )
- if enum_decl.values:
- return enum_decl
- else:
- #for some reason same enum could appear under global namespace and
- #under the class, it was defined in. This is a criteria I use to distinguish
- #between those cases
- return None
-
- def __add_enums( self, parent_symbol_id ):
- parent_symbol = self.__dia_session.symbolById( parent_symbol_id )
- self.logger.debug( 'adding enums to "%s" ' % parent_symbol.name )
- for enum_smbl in iter( parent_symbol.findChildren( SymTagEnum, None, 0 ) ):
- enum_smbl = AsDiaSymbol( enum_smbl )
- enum_decl = self.__create_enum( enum_smbl )
- if not enum_decl:
- continue
- self.logger.debug( '\tfound %s' % str(enum_decl) )
- name_splitter = details.get_name_splitter( enum_smbl.name )
- if not name_splitter.scope_names:
- self.global_ns.adopt_declaration( enum_decl )
- self.logger.debug( '\tenum "%s" was added to global namespace' % enum_decl.name )
- else:
- try:
- self.logger.debug( '\tadding enum "%s" to a namespace' % enum_decl.name )
- ns = self.__namespaces[ name_splitter.scope_names[-1] ]
- ns.adopt_declaration( enum_decl )
- self.logger.debug( '\tadding enum "%s" to a namespace - done' % enum_decl.name )
- except KeyError:
- self.logger.debug( '\tadding enum "%s" to a class' % enum_decl.name )
- klass = self.__classes[ name_splitter.scope_names[-1] ]
- klass.adopt_declaration( enum_decl, details.guess_access_type( enum_smbl.access ) )
- self.logger.debug( '\tadding enum "%s" to a class - done' % enum_decl.name )
- self.logger.debug( 'adding enums to "%s" - done' % parent_symbol.name )
-
- def __create_nss( self ):
- nss = self.__namespaces.keys()
- nss.sort()
-
- for ns_name in nss:
- name_splitter = details.get_name_splitter( ns_name )
- if not name_splitter.scope_names:
- parent_ns = self.global_ns
- else:
- parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
- ns_decl = declarations.namespace_t( name_splitter.name )
- parent_ns.adopt_declaration( ns_decl )
- self.__namespaces[ ns_name ] = ns_decl
-
- 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 = set([dia_class.symIndexId])
- return klass
-
- def __populate_scopes(self):
- main_classes = self.__list_main_classes()
- self.__create_nss()
-
- for dia_class in main_classes:
- name_splitter = details.get_name_splitter( dia_class.name )
- if not name_splitter.scope_names:
- parent_ns = self.global_ns
- else:
- parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
-
- try:
- klass = parent_ns.class_( name_splitter.name, recursive=False )
- klass.dia_symbols.add( dia_class.symIndexId )
- except parent_ns.declaration_not_found_t:
- klass = self.__create_class( dia_class )
- parent_ns.adopt_declaration( klass )
- self.__classes[ dia_class.name ] = klass
-
- map( self.__add_inner_classes, self.__classes.values() )
-
- self.__add_enums( self.dia_global_scope.symIndexId )
- for klass in self.__classes.itervalues():
- map( self.__add_enums, klass.dia_symbols )
-
- #declarations.print_declarations( self.global_ns )#.namespace( 'ns1' ) )
- #declarations.print_declarations( self.global_ns.namespace( 'std' ) )
-
-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()
- f = file( 'decls.cpp', 'w+' )
- declarations.print_declarations( reader.global_ns, writer=f.write )
- f.close()
\ No newline at end of file
Copied: pygccxml_dev/pygccxml/pdb_reader/scanner.py (from rev 1256, pygccxml_dev/pygccxml/pdb_reader/reader.py)
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/scanner.py (rev 0)
+++ pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-24 08:12:00 UTC (rev 1257)
@@ -0,0 +1,254 @@
+import os
+import sys
+import ctypes
+import pprint
+import logging
+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
+
+import details
+
+
+SymTagEnum = 12
+
+def AsDiaSymbol( x ):
+ return ctypes.cast( x, ctypes.POINTER( msdia.IDiaSymbol ) )
+
+
+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
+
+
+class scanner_t(object):
+ def __init__(self, pdb_file_path ):
+ 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 )
+ self.__dia_source.loadDataFromPdb(pdb_file_path)
+ self.logger.debug( 'opening session' )
+ self.__dia_session = self.__dia_source.openSession()
+ self.logger.debug( 'opening session - done' )
+ self.__global_ns = declarations.namespace_t( '::' )
+
+ self.__enums = {}
+ self.__classes = {}
+ self.__namespaces = {'': self.__global_ns}
+
+
+ def read(self):
+ self.__populate_scopes()
+
+ @property
+ def dia_global_scope(self):
+ return self.__dia_session.globalScope
+
+ @property
+ def global_ns(self):
+ return self.__global_ns
+
+ def __are_symbols_equivalent( self, smbl1_id, smbl2_id ):
+ smbl1 = self.__dia_session.symbolById(smbl1_id)
+ smbl2 = self.__dia_session.symbolById(smbl2_id)
+ result = self.__dia_session.symsAreEquiv( smbl1, smbl2 )
+ if result:
+ msg = 'Symbols "%s(%d)" and "%s(%d)" are equivalent.'
+ else:
+ msg = 'Symbols "%s(%d)" and "%s(%d)" are NOT equivalent.'
+ self.logger.debug( msg, smbl1.name, smbl1_id, smbl2.name, smbl2_id )
+ return result
+
+ 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( 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 )
+ #~ return [AsDiaSymbol( s ) for s in iter(found)]
+ #~ for s in iter(found):
+ #~ s =
+ #~ print s.name
+ #~ print details.guess_class_type(s.udtKind)
+ else:
+ self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name )
+ return None
+
+ def __list_main_classes( self ):
+ #in this context main classes, are classes that were defined within a namespace
+ #as opposite to the 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 )
+ name_splitter = details.get_name_splitter( dia_class.name )
+ for index, scope in enumerate( name_splitter.scope_names ):
+ if scope in self.__namespaces:
+ continue
+ else:
+ udt = self.__find_udt( scope )
+ if udt:
+ classes.append( udt )
+ if index:
+ self.__namespaces[ name_splitter.scope_names[index-1] ] = None
+ break
+ else:
+ self.__namespaces[ scope ] = None
+ else:
+ classes.append( dia_class )
+ if name_splitter.scope_names:
+ self.__namespaces[ name_splitter.scope_names[-1] ] = None
+ return classes
+
+ def __add_inner_classes( self, parent_class ):
+ self.logger.debug( 'adding inner classes to "%s"' % parent_class.decl_string )
+ for symbol_id in parent_class.dia_symbols:
+ self.logger.debug( '\tdia symbol id: %d' % symbol_id )
+ dia_symbol = self.__dia_session.symbolById( symbol_id )
+ found = dia_symbol.findChildren( msdia.SymTagUDT, None, 0 )
+ for inner_dia_class in iter(found):
+ inner_dia_class = AsDiaSymbol( inner_dia_class )
+ self.logger.debug( '\t\tinner UDT found - %s' % inner_dia_class.name )
+ inner_name_splitter = details.get_name_splitter( inner_dia_class.name )
+ try:
+ inner_klass = parent_class.class_( inner_name_splitter.name, recursive=False )
+ inner_klass.dia_symbols.add( inner_dia_class.symIndexId )
+ except parent_class.declaration_not_found_t:
+ inner_klass = self.__create_class( inner_dia_class )
+ parent_class.adopt_declaration( inner_klass
+ , details.guess_access_type( inner_dia_class.access ) )
+ self.__classes[ inner_dia_class.name ] = inner_klass
+ self.logger.debug( 'adding inner classes to "%s" - done' % parent_class.decl_string )
+
+ def __create_enum( self, enum_smbl ):
+ name_splitter = details.get_name_splitter( enum_smbl.name )
+ enum_decl = declarations.enumeration_t( name_splitter.name )
+ enum_decl.dia_symbols = [ enum_smbl.symIndexId ]
+ values = enum_smbl.findChildren( msdia.SymTagData, None, 0 )
+ for v in iter(values):
+ v = AsDiaSymbol(v)
+ if v.classParent.symIndexId != enum_smbl.symIndexId:
+ continue
+ enum_decl.append_value( v.name, v.value )
+ if enum_decl.values:
+ return enum_decl
+ else:
+ #for some reason same enum could appear under global namespace and
+ #under the class, it was defined in. This is a criteria I use to distinguish
+ #between those cases
+ return None
+
+ def __load_enums( self, parent_symbol_id ):
+ parent_symbol = self.__dia_session.symbolById( parent_symbol_id )
+ self.logger.debug( 'loading enums to "%s" ' % parent_symbol.name )
+ for enum_smbl in iter( parent_symbol.findChildren( SymTagEnum, None, 0 ) ):
+ enum_smbl = AsDiaSymbol( enum_smbl )
+ enum_decl = self.__create_enum( enum_smbl )
+ if enum_decl:
+ try:
+ for enum_discovered in self.__enums[ enum_smbl.name ]:
+ if self.__are_symbols_equivalent( enum_smbl.symIndexId, enum_discovered.dia_symbols[0] ):
+ continue
+ else:
+ self.__enums[ enum_smbl.name ].append( enum_decl )
+ except KeyError:
+ self.__enums[ enum_smbl.name ] = [ enum_decl ]
+ self.logger.debug( '\tfound %s %s' % ( enum_smbl.name, str(enum_decl) ) )
+ self.logger.debug( 'loading enums to "%s" - done' % parent_symbol.name )
+
+
+ def __load_classes( self, parent_symbol_id ):
+ parent_symbol = self.__dia_session.symbolById( parent_symbol_id )
+ self.logger.debug( 'loading classes to "%s" ' % parent_symbol.name )
+ for class_smbl in iter( parent_symbol.findChildren( msdia.SymTagUDT, None, 0 ) ):
+ class_smbl = AsDiaSymbol( class_smbl )
+ class_decl = self.__create_class( class_smbl )
+ try:
+ equivalent_found = False
+ for class_discovered in self.__classes[ class_smbl.name ]:
+ for smbl_discovered in class_discovered.dia_symbols:
+ equivalent_found = self.__are_symbols_equivalent( smbl_discovered, class_smbl.symIndexId )
+ if equivalent_found:
+ class_discovered.dia_symbols.add( class_smbl.symIndexId )
+ break
+ if equivalent_found:
+ break
+ if not equivalent_found:
+ self.__classes[ class_smbl.name ].append( class_decl )
+ except KeyError:
+ self.__classes[ class_smbl.name ] = [ class_decl ]
+ self.logger.debug( '\tfound %s' % str(class_decl) )
+ self.logger.debug( 'loading classes to "%s" - done' % parent_symbol.name )
+
+ def __create_nss( self ):
+ nss = self.__namespaces.keys()
+ nss.sort()
+ for ns_name in nss:
+ name_splitter = details.get_name_splitter( ns_name )
+ if not name_splitter.scope_names:
+ parent_ns = self.global_ns
+ else:
+ parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
+ ns_decl = declarations.namespace_t( name_splitter.name )
+ parent_ns.adopt_declaration( ns_decl )
+ self.__namespaces[ ns_name ] = ns_decl
+
+ 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 = set([dia_class.symIndexId])
+ return klass
+
+ def __populate_scopes(self):
+ self.__load_enums( self.dia_global_scope.symIndexId )
+ self.__load_classes( self.dia_global_scope.symIndexId )
+ #~ main_classes = self.__list_main_classes()
+ #~ self.__create_nss()
+
+ #~ for dia_class in main_classes:
+ #~ name_splitter = details.get_name_splitter( dia_class.name )
+ #~ if not name_splitter.scope_names:
+ #~ parent_ns = self.global_ns
+ #~ else:
+ #~ parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
+
+ #~ try:
+ #~ klass = parent_ns.class_( name_splitter.name, recursive=False )
+ #~ klass.dia_symbols.add( dia_class.symIndexId )
+ #~ except parent_ns.declaration_not_found_t:
+ #~ klass = self.__create_class( dia_class )
+ #~ parent_ns.adopt_declaration( klass )
+ #~ self.__classes[ dia_class.name ] = klass
+
+ #~ map( self.__add_inner_classes, self.__classes.values() )
+
+ #~ self.__add_enums( self.dia_global_scope.symIndexId )
+ #~ for klass in self.__classes.itervalues():
+ #~ map( self.__add_enums, klass.dia_symbols )
+
+ #declarations.print_declarations( self.global_ns )#.namespace( 'ns1' ) )
+ #declarations.print_declarations( self.global_ns.namespace( 'std' ) )
+
+if __name__ == '__main__':
+ control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb'
+ control_pdb = r'xxx.pdb'
+ reader = scanner_t( control_pdb )
+ reader.read()
+ f = file( 'decls.cpp', 'w+' )
+ declarations.print_declarations( reader.global_ns, writer=f.write )
+ f.close()
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-23 21:13:40
|
Revision: 1255
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1255&view=rev
Author: roman_yakovenko
Date: 2008-02-23 13:13:42 -0800 (Sat, 23 Feb 2008)
Log Message:
-----------
checkpoint
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_parser/reader.py
Modified: pygccxml_dev/pygccxml/pdb_parser/reader.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-23 19:22:19 UTC (rev 1254)
+++ pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-23 21:13:42 UTC (rev 1255)
@@ -21,25 +21,7 @@
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:
@@ -91,7 +73,7 @@
#~ print details.guess_class_type(s.udtKind)
else:
self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name )
- return False
+ return None
def __list_main_classes( self ):
#in this context main classes, are classes that were defined within a namespace
@@ -120,9 +102,10 @@
return classes
def __add_inner_classes( self, parent_class ):
- self.logger.debug( 'adding inner classes to "%s"' % parent_class.dia_symbols[0].name )
- for dia_symbol in parent_class.dia_symbols:
- self.logger.debug( '\tdia symbol id: %d' % dia_symbol.symIndexId )
+ self.logger.debug( 'adding inner classes to "%s"' % parent_class.decl_string )
+ for symbol_id in parent_class.dia_symbols:
+ self.logger.debug( '\tdia symbol id: %d' % symbol_id )
+ dia_symbol = self.__dia_session.symbolById( symbol_id )
found = dia_symbol.findChildren( msdia.SymTagUDT, None, 0 )
for inner_dia_class in iter(found):
inner_dia_class = AsDiaSymbol( inner_dia_class )
@@ -130,15 +113,57 @@
inner_name_splitter = details.get_name_splitter( inner_dia_class.name )
try:
inner_klass = parent_class.class_( inner_name_splitter.name, recursive=False )
- inner_klass.dia_symbols.append( inner_dia_class )
+ inner_klass.dia_symbols.add( inner_dia_class.symIndexId )
except parent_class.declaration_not_found_t:
inner_klass = self.__create_class( inner_dia_class )
parent_class.adopt_declaration( inner_klass
, details.guess_access_type( inner_dia_class.access ) )
self.__classes[ inner_dia_class.name ] = inner_klass
- self.logger.debug( 'adding inner classes to "%s" - done' % parent_class.dia_symbols[0].name )
+ self.logger.debug( 'adding inner classes to "%s" - done' % parent_class.decl_string )
-
+ def __create_enum( self, enum_smbl ):
+ name_splitter = details.get_name_splitter( enum_smbl.name )
+ enum_decl = declarations.enumeration_t( name_splitter.name )
+ values = enum_smbl.findChildren( msdia.SymTagData, None, 0 )
+ for v in iter(values):
+ v = AsDiaSymbol(v)
+ if v.classParent.symIndexId != enum_smbl.symIndexId:
+ continue
+ enum_decl.append_value( v.name, v.value )
+ if enum_decl.values:
+ return enum_decl
+ else:
+ #for some reason same enum could appear under global namespace and
+ #under the class, it was defined in. This is a criteria I use to distinguish
+ #between those cases
+ return None
+
+ def __add_enums( self, parent_symbol_id ):
+ parent_symbol = self.__dia_session.symbolById( parent_symbol_id )
+ self.logger.debug( 'adding enums to "%s" ' % parent_symbol.name )
+ for enum_smbl in iter( parent_symbol.findChildren( SymTagEnum, None, 0 ) ):
+ enum_smbl = AsDiaSymbol( enum_smbl )
+ enum_decl = self.__create_enum( enum_smbl )
+ if not enum_decl:
+ continue
+ self.logger.debug( '\tfound %s' % str(enum_decl) )
+ name_splitter = details.get_name_splitter( enum_smbl.name )
+ if not name_splitter.scope_names:
+ self.global_ns.adopt_declaration( enum_decl )
+ self.logger.debug( '\tenum "%s" was added to global namespace' % enum_decl.name )
+ else:
+ try:
+ self.logger.debug( '\tadding enum "%s" to a namespace' % enum_decl.name )
+ ns = self.__namespaces[ name_splitter.scope_names[-1] ]
+ ns.adopt_declaration( enum_decl )
+ self.logger.debug( '\tadding enum "%s" to a namespace - done' % enum_decl.name )
+ except KeyError:
+ self.logger.debug( '\tadding enum "%s" to a class' % enum_decl.name )
+ klass = self.__classes[ name_splitter.scope_names[-1] ]
+ klass.adopt_declaration( enum_decl, details.guess_access_type( enum_smbl.access ) )
+ self.logger.debug( '\tadding enum "%s" to a class - done' % enum_decl.name )
+ self.logger.debug( 'adding enums to "%s" - done' % parent_symbol.name )
+
def __create_nss( self ):
nss = self.__namespaces.keys()
nss.sort()
@@ -157,7 +182,7 @@
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 ]
+ klass.dia_symbols = set([dia_class.symIndexId])
return klass
def __populate_scopes(self):
@@ -166,24 +191,33 @@
for dia_class in main_classes:
name_splitter = details.get_name_splitter( dia_class.name )
- parent_ns = self.global_ns
- if name_splitter.scope_names:
+ if not name_splitter.scope_names:
+ parent_ns = self.global_ns
+ else:
parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
- try:
+
+ try:
klass = parent_ns.class_( name_splitter.name, recursive=False )
- klass.dia_symbols.append( dia_class )
+ klass.dia_symbols.add( dia_class.symIndexId )
except parent_ns.declaration_not_found_t:
klass = self.__create_class( dia_class )
parent_ns.adopt_declaration( klass )
self.__classes[ dia_class.name ] = klass
map( self.__add_inner_classes, self.__classes.values() )
+
+ self.__add_enums( self.dia_global_scope.symIndexId )
+ for klass in self.__classes.itervalues():
+ map( self.__add_enums, klass.dia_symbols )
+
+ #declarations.print_declarations( self.global_ns )#.namespace( 'ns1' ) )
+ #declarations.print_declarations( self.global_ns.namespace( 'std' ) )
- declarations.print_declarations( self.global_ns.namespace( 'ns1' ) )
- declarations.print_declarations( self.global_ns.namespace( 'std' ) )
-
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()
+ f = file( 'decls.cpp', 'w+' )
+ declarations.print_declarations( reader.global_ns, writer=f.write )
+ f.close()
\ 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-02-23 19:22:13
|
Revision: 1254
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1254&view=rev
Author: roman_yakovenko
Date: 2008-02-23 11:22:19 -0800 (Sat, 23 Feb 2008)
Log Message:
-----------
checkpoint
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_parser/reader.py
Modified: pygccxml_dev/pygccxml/pdb_parser/reader.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-23 08:54:06 UTC (rev 1253)
+++ pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-23 19:22:19 UTC (rev 1254)
@@ -1,6 +1,7 @@
import os
import sys
import ctypes
+import pprint
import logging
import comtypes
import comtypes.client
@@ -56,7 +57,11 @@
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.logger.debug( 'opening session - done' )
+ self.__global_ns = declarations.namespace_t( '::' )
+ self.__classes = {}
+ self.__namespaces = {'': self.__global_ns}
+
def read(self):
self.__populate_scopes()
@@ -89,49 +94,65 @@
return False
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
+ #in this context main classes, are classes that were defined within a namespace
+ #as opposite to the 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 )
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
+ for index, scope in enumerate( name_splitter.scope_names ):
+ if scope in self.__namespaces:
+ continue
+ else:
+ udt = self.__find_udt( scope )
+ if udt:
+ classes.append( udt )
+ if index:
+ self.__namespaces[ name_splitter.scope_names[index-1] ] = None
+ break
+ else:
+ self.__namespaces[ scope ] = None
else:
classes.append( dia_class )
+ if name_splitter.scope_names:
+ self.__namespaces[ name_splitter.scope_names[-1] ] = None
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 ) )
+ def __add_inner_classes( self, parent_class ):
+ self.logger.debug( 'adding inner classes to "%s"' % parent_class.dia_symbols[0].name )
+ for dia_symbol in parent_class.dia_symbols:
+ self.logger.debug( '\tdia symbol id: %d' % dia_symbol.symIndexId )
+ found = dia_symbol.findChildren( msdia.SymTagUDT, None, 0 )
+ for inner_dia_class in iter(found):
+ inner_dia_class = AsDiaSymbol( inner_dia_class )
+ self.logger.debug( '\t\tinner UDT found - %s' % inner_dia_class.name )
+ inner_name_splitter = details.get_name_splitter( inner_dia_class.name )
+ try:
+ inner_klass = parent_class.class_( inner_name_splitter.name, recursive=False )
+ inner_klass.dia_symbols.append( inner_dia_class )
+ except parent_class.declaration_not_found_t:
+ inner_klass = self.__create_class( inner_dia_class )
+ parent_class.adopt_declaration( inner_klass
+ , details.guess_access_type( inner_dia_class.access ) )
+ self.__classes[ inner_dia_class.name ] = inner_klass
+ self.logger.debug( 'adding inner classes to "%s" - done' % parent_class.dia_symbols[0].name )
- 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_nss( self ):
+ nss = self.__namespaces.keys()
+ nss.sort()
+
+ for ns_name in nss:
+ name_splitter = details.get_name_splitter( ns_name )
+ if not name_splitter.scope_names:
+ parent_ns = self.global_ns
+ else:
+ parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
+ ns_decl = declarations.namespace_t( name_splitter.name )
+ parent_ns.adopt_declaration( ns_decl )
+ self.__namespaces[ ns_name ] = ns_decl
+
def __create_class( self, dia_class ):
name_splitter = details.get_name_splitter( dia_class.name )
klass = declarations.class_t( name_splitter.name )
@@ -141,23 +162,25 @@
def __populate_scopes(self):
main_classes = self.__list_main_classes()
+ self.__create_nss()
+
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] )
+ parent_ns = self.global_ns
+ if name_splitter.scope_names:
+ parent_ns = self.__namespaces[ name_splitter.scope_names[-1] ]
try:
- klass = ns_ref.class_( name_splitter.name, recursive=False )
+ klass = parent_ns.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 ) )
+ except parent_ns.declaration_not_found_t:
+ klass = self.__create_class( dia_class )
+ parent_ns.adopt_declaration( klass )
+ self.__classes[ dia_class.name ] = klass
- self.__add_inner_classes()
+ map( self.__add_inner_classes, self.__classes.values() )
- declarations.print_declarations( self.global_ns )
+ declarations.print_declarations( self.global_ns.namespace( 'ns1' ) )
+ declarations.print_declarations( self.global_ns.namespace( 'std' ) )
if __name__ == '__main__':
control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb'
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-21 08:05:25
|
Revision: 1252
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1252&view=rev
Author: roman_yakovenko
Date: 2008-02-21 00:05:30 -0800 (Thu, 21 Feb 2008)
Log Message:
-----------
Added Paths:
-----------
pygccxml_dev/pygccxml/pdb_parser/details.py
pygccxml_dev/pygccxml/pdb_parser/reader.py
Removed Paths:
-------------
pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py
Added: pygccxml_dev/pygccxml/pdb_parser/details.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_parser/details.py (rev 0)
+++ pygccxml_dev/pygccxml/pdb_parser/details.py 2008-02-21 08:05:30 UTC (rev 1252)
@@ -0,0 +1,58 @@
+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 full_name_splitter_t( object ):
+ def __init__( self, full_name ):
+ self.__full_name = full_name
+ self.__identifiers = self.__split_scope_identifiers()
+ self.__scope_identifiers = None
+
+ @property
+ def name( self ):
+ return self.__identifiers[-1]
+
+ @property
+ def scope_names( self ):
+ if None is 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
+
+ @property
+ def identifiers( self ):
+ return self.__identifiers
+
+ def __split_scope_identifiers( self ):
+ result = []
+ tmp = self.__full_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
+
+
+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 )
+ for x in fnsp.scope_names:
+ print x
+
+ fnsp = full_name_splitter_t( 'x' )
+ for x in fnsp.scope_names:
+ print x
Deleted: pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py 2008-02-21 06:50:59 UTC (rev 1251)
+++ pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py 2008-02-21 08:05:30 UTC (rev 1252)
@@ -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/reader.py (from rev 1251, pygccxml_dev/pygccxml/pdb_parser/pdb_reader.py)
===================================================================
--- pygccxml_dev/pygccxml/pdb_parser/reader.py (rev 0)
+++ pygccxml_dev/pygccxml/pdb_parser/reader.py 2008-02-21 08:05:30 UTC (rev 1252)
@@ -0,0 +1,141 @@
+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
+
+import details
+
+
+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
+
+
+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 __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 details.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():
+ 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 )
+
+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()
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-21 06:47:52
|
Revision: 1250
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1250&view=rev
Author: roman_yakovenko
Date: 2008-02-20 22:47:58 -0800 (Wed, 20 Feb 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/pdb_reader.py
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-20 12:57:47 UTC (rev 1249)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-21 06:47:58 UTC (rev 1250)
@@ -45,6 +45,13 @@
#~ 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 ):
@@ -56,7 +63,8 @@
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()
@@ -87,55 +95,67 @@
token = token + '::' + next_token
less_count += next_token.count( '<' )
greater_count += next_token.count( '>' )
- result.append( token )
+ result.append( token )
return result
- def __is_udt( self, name ):
+ 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:
+ 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 found.Count
-
- def __populate_scopes(self):
- classes = []
+ 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 '$' in dia_class.name:
- continue
- klass = declarations.class_t(dia_class.name)
- if msdia.UdtKind.UdtStruct == dia_class.udtKind:
- klass.class_type = declarations.CLASS_TYPES.STRUCT
- elif msdia.UdtKind.UdtClass == dia_class.udtKind:
- klass.class_type = declarations.CLASS_TYPES.CLASS
+ dia_class = AsDiaSymbol( dia_class )
+ if not classes.has_key( dia_class.name ):
+ classes[ dia_class.name ] = [ dia_class ]
else:
- klass.class_type = declarations.CLASS_TYPES.UNION
- scope_identifiers = self.__split_scope_identifiers( dia_class.name )
- if 1 == len(scope_identifiers):
- classes.append( klass )
- #self.global_ns.adopt_declaration( 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 )
- classes.sort( lambda klass1, klass2: cmp( klass1.name, klass2.name ) )
- for i in classes:
- print str(i)
- declarations.print_declarations( self.global_ns )
+ 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'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-20 12:57:43
|
Revision: 1249
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1249&view=rev
Author: roman_yakovenko
Date: 2008-02-20 04:57:47 -0800 (Wed, 20 Feb 2008)
Log Message:
-----------
auto detect of msdiaxx.dll location
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/msdia_details.py
pygccxml_dev/pygccxml/parser/pdb_reader.py
Modified: pygccxml_dev/pygccxml/parser/msdia_details.py
===================================================================
--- pygccxml_dev/pygccxml/parser/msdia_details.py 2008-02-20 08:03:33 UTC (rev 1248)
+++ pygccxml_dev/pygccxml/parser/msdia_details.py 2008-02-20 12:57:47 UTC (rev 1249)
@@ -1,13 +1,73 @@
-import getpass
+import os
import comtypes
import comtypes.client
+import _winreg as win_registry
+from distutils import msvccompiler
-msdia_path = None
-if 'root' == getpass.getuser():
- msdia_path = r'C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\msdia90.dll'
+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
-msdia = comtypes.client.GetModule( msdia_path )
+
+ 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 )
@@ -29,21 +89,3 @@
nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive
msdia.NameSearchOptions = NameSearchOptions
-
-
-#
-#from distutils import ccompiler
-#from distutils import msvccompiler
-#
-#if 'msvc' == ccompiler.get_default_compiler():
-# cc = msvccompiler.MSVCCompiler()
-# cc.initialize()
-# generator = 'NMake Makefiles'
-# native_build = '"%s" /A all' % cc.find_exe( 'nmake.exe' )
-# configure_environment_script = cc.find_exe( 'vsvars32.bat' )
-# if not configure_environment_script:
-# configure_environment_script = cc.find_exe( 'vcvars32.bat' )
-# cl_mapping = { 6.0 : "msvc6", 7.0 : "msvc7", 7.1 : "msvc71", 8.0 : "msvc8" }
-# compiler = cl_mapping[ msvccompiler.get_build_version() ]
-#else:
-# raise RuntimeError( "Unable to find out MSDIA dll location")
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-20 08:03:33 UTC (rev 1248)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-20 12:57:47 UTC (rev 1249)
@@ -5,7 +5,8 @@
import comtypes.client
from msdia_details import msdia
-sys.path.append( r'C:\dev\language-binding\pygccxml_dev' )
+sys.path.append( r'../..' )
+#sys.path.append( r'C:\dev\language-binding\pygccxml_dev' )
from pygccxml import utils
from pygccxml import declarations
@@ -36,14 +37,6 @@
continue
print ' value %s(%d): ' % ( v.name, v.value )
-def print_nss( smb, offset ):
- symbols = smb.findChildren( msdia.SymTagUDT, None, 0 )
- for internal_smb in iter( symbols ):
- internal_smb = ctypes.cast( internal_smb, ctypes.POINTER( msdia.IDiaSymbol ) )
- if internal_smb.classParentId == smb.symIndexId:
- print ' ' * offset, internal_smb.name
- print_nss( internal_smb, offset + 1 )
-
def print_files( session ):
files = iter( session.findFile( None, '', 0 ) )
for f in files:
@@ -67,6 +60,11 @@
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
@@ -141,5 +139,6 @@
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()
\ No newline at end of file
+ reader.read()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-20 08:03:29
|
Revision: 1248
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1248&view=rev
Author: roman_yakovenko
Date: 2008-02-20 00:03:33 -0800 (Wed, 20 Feb 2008)
Log Message:
-----------
describe ellipsis feature
Modified Paths:
--------------
pygccxml_dev/docs/history/history.rest
Modified: pygccxml_dev/docs/history/history.rest
===================================================================
--- pygccxml_dev/docs/history/history.rest 2008-02-20 07:54:01 UTC (rev 1247)
+++ pygccxml_dev/docs/history/history.rest 2008-02-20 08:03:33 UTC (rev 1248)
@@ -23,6 +23,27 @@
* Jeremy Sanders
* Ben Schleimer
+
+-----------
+Version SVN
+-----------
+
+1. Support for ellipsis was added.
+ Warning: this feature introduce backward compatibility problem!
+
+ Description:
+ .. code-block:: C++
+
+ void do_smth( int, ... )
+
+ Before this change, pygccxml would report that the function ``do_smth`` has
+ only one argument.
+
+ After this change, pygccxml will report that the function has two arguments.
+ The second argument type will be ``declarations.ellipsis_t``. All classes,
+ which describe callables, have new property ``has_ellipsis``. It the value of
+ the property is ``True``, than the function has ellipsis in its definition.
+
-------------
Version 0.9.5
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-20 07:53:58
|
Revision: 1247
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1247&view=rev
Author: roman_yakovenko
Date: 2008-02-19 23:54:01 -0800 (Tue, 19 Feb 2008)
Log Message:
-----------
adding another happy user
Modified Paths:
--------------
pyplusplus_dev/docs/quotes.rest
Modified: pyplusplus_dev/docs/quotes.rest
===================================================================
--- pyplusplus_dev/docs/quotes.rest 2008-02-19 22:48:47 UTC (rev 1246)
+++ pyplusplus_dev/docs/quotes.rest 2008-02-20 07:54:01 UTC (rev 1247)
@@ -112,6 +112,14 @@
* All in all, `Python-OGRE`_ project contains bindings for more than 30 libraries.
You can find code generation scripts here: https://python-ogre.svn.sourceforge.net/svnroot/python-ogre/trunk/python-ogre/code_generators/
+* `Rising Sun Pictures`_ company is using `Py++`_ to create Python bindings for
+ `Apple Shake API`_. `PyShake`_ enables running of Python code from within Shake
+ and by exposing the Shake API to Python.
+
+ .. _`Rising Sun Pictures` : http://open.rsp.com.au/
+ .. _`Apple Shake API` : http://www.apple.com/shake/
+ .. _`PyShake` : http://open.rsp.com.au/projects/pyshake
+
* I am :-). I created Python bindings for next libraries:
* `Boost.Date_Time`_
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-19 22:48:40
|
Revision: 1246
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1246&view=rev
Author: roman_yakovenko
Date: 2008-02-19 14:48:47 -0800 (Tue, 19 Feb 2008)
Log Message:
-----------
updating pdb parser
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/pdb_reader.py
Added Paths:
-----------
pygccxml_dev/pygccxml/parser/msdia_details.py
Added: pygccxml_dev/pygccxml/parser/msdia_details.py
===================================================================
--- pygccxml_dev/pygccxml/parser/msdia_details.py (rev 0)
+++ pygccxml_dev/pygccxml/parser/msdia_details.py 2008-02-19 22:48:47 UTC (rev 1246)
@@ -0,0 +1,49 @@
+import getpass
+import comtypes
+import comtypes.client
+
+msdia_path = None
+if 'root' == getpass.getuser():
+ msdia_path = r'C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\msdia90.dll'
+
+msdia = comtypes.client.GetModule( msdia_path )
+
+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
+
+
+#
+#from distutils import ccompiler
+#from distutils import msvccompiler
+#
+#if 'msvc' == ccompiler.get_default_compiler():
+# cc = msvccompiler.MSVCCompiler()
+# cc.initialize()
+# generator = 'NMake Makefiles'
+# native_build = '"%s" /A all' % cc.find_exe( 'nmake.exe' )
+# configure_environment_script = cc.find_exe( 'vsvars32.bat' )
+# if not configure_environment_script:
+# configure_environment_script = cc.find_exe( 'vcvars32.bat' )
+# cl_mapping = { 6.0 : "msvc6", 7.0 : "msvc7", 7.1 : "msvc71", 8.0 : "msvc8" }
+# compiler = cl_mapping[ msvccompiler.get_build_version() ]
+#else:
+# raise RuntimeError( "Unable to find out MSDIA dll location")
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-19 22:48:10 UTC (rev 1245)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-19 22:48:47 UTC (rev 1246)
@@ -3,26 +3,15 @@
import ctypes
import comtypes
import comtypes.client
-from sets import Set as set
+from msdia_details import msdia
-msdia_dll = r'C:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll'
-msdia_dll = r'D:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll'
+sys.path.append( r'C:\dev\language-binding\pygccxml_dev' )
-msdia_dll = 'msdia80.dll'
+from pygccxml import utils
+from pygccxml import declarations
-msdia = comtypes.client.GetModule( msdia_dll )
-control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb'
-control_pdb = r'xxx.pdb'
-ds = comtypes.client.CreateObject( msdia.DiaSource )
-ds.loadDataFromPdb(control_pdb)
-session = ds.openSession()
-
-root_symbol = session.globalScope
-
-print root_symbol
-
SymTagEnum = 12
def AsDiaSymbol( x ):
@@ -31,23 +20,17 @@
def print_enums( smb ):
enums = smb.findChildren( SymTagEnum, None, 0 )
for enum in iter( enums ):
- enum = AsDiaSymbol( enum )
- if 'shared_consts' not in enum.name:
- continue
+ enum = AsDiaSymbol( enum )
print 'name: ', enum.name
if enum.container:
print 'container: ', enum.container.name
- if enum.classParent:
+ if enum.classParent:
print 'parent: ', enum.classParent.name
if enum.lexicalParent:
print 'lexical parent: ', enum.lexicalParent.Name
- #~ print 'enum: ', enum.symIndexId
- #~ f = session.findFile( internal_smb, internal_smb.name, 0 )
- #~ print 'name: ', internal_smb.name
- #~ print f
-
- values = enum.findChildren( msdia.SymTagData, None, 0 )
- for v in iter(values):
+
+ values = enum.findChildren( msdia.SymTagData, None, 0 )
+ for v in iter(values):
v = AsDiaSymbol(v)
if v.classParent.symIndexId != enum.symIndexId:
continue
@@ -68,4 +51,95 @@
print 'File: ', f.fileName
#~ print_files( session )
-print_enums( root_symbol )
+#print_enums( root_symbol )
+
+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( '::' )
+
+ def read(self):
+ self.__populate_scopes()
+
+ @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 __is_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:
+ self.logger.debug( 'name( "%s" ) is UDT symbol' % name )
+ else:
+ self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name )
+ return found.Count
+
+ def __populate_scopes(self):
+ 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 '$' in dia_class.name:
+ continue
+ klass = declarations.class_t(dia_class.name)
+ if msdia.UdtKind.UdtStruct == dia_class.udtKind:
+ klass.class_type = declarations.CLASS_TYPES.STRUCT
+ elif msdia.UdtKind.UdtClass == dia_class.udtKind:
+ klass.class_type = declarations.CLASS_TYPES.CLASS
+ else:
+ klass.class_type = declarations.CLASS_TYPES.UNION
+ scope_identifiers = self.__split_scope_identifiers( dia_class.name )
+ if 1 == len(scope_identifiers):
+ classes.append( klass )
+ #self.global_ns.adopt_declaration( 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 )
+ 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'
+ reader = pdb_reader_t( control_pdb )
+ reader.read()
\ 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-02-19 22:48:05
|
Revision: 1245
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1245&view=rev
Author: roman_yakovenko
Date: 2008-02-19 14:48:10 -0800 (Tue, 19 Feb 2008)
Log Message:
-----------
adding aliases for exceptions
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/scopedef.py
Modified: pygccxml_dev/pygccxml/declarations/scopedef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/scopedef.py 2008-02-17 22:53:40 UTC (rev 1244)
+++ pygccxml_dev/pygccxml/declarations/scopedef.py 2008-02-19 22:48:10 UTC (rev 1245)
@@ -62,6 +62,9 @@
RECURSIVE_DEFAULT = True
ALLOW_EMPTY_MDECL_WRAPPER = False
+ declaration_not_found_t = matcher_module.matcher.declaration_not_found_t
+ multiple_declarations_found_t = matcher_module.matcher.multiple_declarations_found_t
+
_impl_matchers = {} #this class variable is used to prevent recursive imports
_impl_decl_types = {} #this class variable is used to prevent recursive imports
_impl_all_decl_types = [] #this class variable is used to prevent recursive imports
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-17 22:57:11
|
Revision: 1244
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1244&view=rev
Author: roman_yakovenko
Date: 2008-02-17 14:53:40 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
excluding functions with ellipsis
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
pyplusplus_dev/pyplusplus/messages/warnings_.py
pyplusplus_dev/unittests/algorithms_tester.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2008-02-17 19:49:54 UTC (rev 1243)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2008-02-17 22:53:40 UTC (rev 1244)
@@ -159,6 +159,8 @@
all_types = [ arg.type for arg in self.arguments ]
all_types.append( self.return_type )
for some_type in all_types:
+ if isinstance( some_type, declarations.ellipsis_t ):
+ return messages.W1053 % str( self )
units = declarations.decompose_type( some_type )
ptr2functions = filter( lambda unit: isinstance( unit, declarations.calldef_type_t )
, units )
Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py
===================================================================
--- pyplusplus_dev/pyplusplus/messages/warnings_.py 2008-02-17 19:49:54 UTC (rev 1243)
+++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2008-02-17 22:53:40 UTC (rev 1244)
@@ -213,6 +213,9 @@
W1052 = warning(
'Py++ will not expose free operator "%s" - all classes, this operator works on, are excluded.' )
+W1053 = warning(
+ 'Py++ will not expose function "%s" - the function has variable-argument list, spicified by ellipsis (...).' )
+
warnings = globals()
all_warning_msgs = []
Modified: pyplusplus_dev/unittests/algorithms_tester.py
===================================================================
--- pyplusplus_dev/unittests/algorithms_tester.py 2008-02-17 19:49:54 UTC (rev 1243)
+++ pyplusplus_dev/unittests/algorithms_tester.py 2008-02-17 22:53:40 UTC (rev 1244)
@@ -251,6 +251,24 @@
self.failUnless( xyz.class_( 'good' ).ignore == False )
self.failUnless( xyz.free_fun( 'f_bad' ).ignore == True )
+class exclude_ellipsis_tester_t( unittest.TestCase ):
+ def test(self):
+
+ code = """
+ namespace xyz{
+ void do_smth( int, ... );
+ }
+ """
+
+ mb = module_builder.module_builder_t(
+ [ module_builder.create_text_fc( code ) ]
+ , gccxml_path=autoconfig.gccxml.executable )
+
+ do_smth = mb.free_fun( 'do_smth' )
+
+ self.failUnless( do_smth.exportable == False )
+ print do_smth.why_not_exportable()
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(doc_extractor_tester_t))
@@ -264,7 +282,7 @@
suite.addTest( unittest.makeSuite(split_sequence_tester_t))
suite.addTest( unittest.makeSuite(exclude_erronious_tester_t))
suite.addTest( unittest.makeSuite(use_function_signature_bug_tester_t))
-
+ suite.addTest( unittest.makeSuite(exclude_ellipsis_tester_t))
return suite
def run_suite():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-17 19:49:48
|
Revision: 1243
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1243&view=rev
Author: roman_yakovenko
Date: 2008-02-17 11:49:54 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
adding treatment to ellipsis ("...") in function definitions
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/calldef.py
pygccxml_dev/pygccxml/declarations/cpptypes.py
pygccxml_dev/pygccxml/declarations/namespace.py
pygccxml_dev/pygccxml/parser/linker.py
pygccxml_dev/pygccxml/parser/project_reader.py
pygccxml_dev/pygccxml/parser/scanner.py
pygccxml_dev/unittests/data/declarations_calldef.hpp
pygccxml_dev/unittests/data/plain_c.c
pygccxml_dev/unittests/decl_string_tester.py
pygccxml_dev/unittests/declarations_tester.py
pygccxml_dev/unittests/filters_tester.py
pygccxml_dev/unittests/plain_c_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -25,6 +25,7 @@
from cpptypes import type_t
from cpptypes import dummy_type_t
from cpptypes import unknown_t
+from cpptypes import ellipsis_t
from cpptypes import fundamental_t
from cpptypes import void_t
from cpptypes import char_t
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -39,7 +39,7 @@
class, that describes argument of "callable" declaration
"""
- def __init__( self, name='', type=None, default_value=None, attributes=None ):
+ def __init__( self, name='', type=None, default_value=None, attributes=None):
object.__init__(self)
self._name = name
self._default_value = default_value
@@ -52,6 +52,8 @@
return argument_t( name=keywd.get( 'name', self.name )
, type=keywd.get( 'type', self.type )
, default_value=keywd.get( 'default_value', self.default_value )
+ , attributes=keywd.get( 'attributes', self.attributes ) )
+
"""
return argument_t( name=keywd.get( 'name', self.name )
, type=keywd.get( 'type', self.type )
@@ -59,10 +61,13 @@
, attributes=keywd.get( 'attributes', self.attributes ) )
def __str__(self):
- if self.default_value==None:
- return "%s %s"%(self.type, self.name)
+ if self.ellipsis:
+ return "..."
else:
- return "%s %s=%s"%(self.type, self.name, self.default_value)
+ if self.default_value==None:
+ return "%s %s"%(self.type, self.name)
+ else:
+ return "%s %s=%s"%(self.type, self.name, self.default_value)
def __eq__(self, other):
if not isinstance( other, self.__class__ ):
@@ -89,6 +94,11 @@
, doc="""Argument name.
@type: str""" )
+ @property
+ def ellipsis(self):
+ """bool, if True argument represents ellipsis ( "..." ) in function definition"""
+ return isinstance( self.type, cpptypes.ellipsis_t )
+
def _get_default_value(self):
return self._default_value
def _set_default_value(self, default_value):
@@ -163,6 +173,10 @@
@type: list of L{argument_t}""")
@property
+ def has_ellipsis( self ):
+ return self.arguments and self.arguments[-1].ellipsis
+
+ @property
def argument_types( self ):
"""list of all argument types"""
return [ arg.type for arg in self.arguments ]
@@ -209,21 +223,20 @@
, doc='''The type of the return value of the "callable" or None (constructors).
@type: L{type_t}
''')
-
- def _get_overloads(self):
+ @property
+ def overloads(self):
+ """A list of overloaded "callables" (i.e. other callables with the same name within the same scope.
+
+ @type: list of L{calldef_t}
+ """
if not self.parent:
return []
# finding all functions with the same name
- return self.parent.calldefs(
- name=self.name
- , function=lambda decl: not (decl is self )
- , allow_empty=True
- , recursive=False )
+ return self.parent.calldefs( name=self.name
+ , function=lambda decl: not (decl is self )
+ , allow_empty=True
+ , recursive=False )
- overloads = property( _get_overloads
- , doc="""A list of overloaded "callables" (i.e. other callables with the same name within the same scope.
- @type: list of L{calldef_t}""" )
-
def _get_has_extern(self):
return self._has_extern
def _set_has_extern(self, has_extern):
Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -101,6 +101,17 @@
def _clone_impl( self ):
return self
+class ellipsis_t( type_t ):
+ """type, that represents "..." in function definition"""
+ def __init__( self ):
+ type_t.__init__( self )
+
+ def build_decl_string(self, with_defaults=True):
+ return '...'
+
+ def _clone_impl( self ):
+ return self
+
################################################################################
## Fundamental types:
@@ -460,6 +471,11 @@
self._arguments_types = new_arguments_types
arguments_types = property( _get_arguments_types, _set_arguments_types
, doc="list of argument L{types<type_t>}")
+
+ @property
+ def has_ellipsis( self ):
+ return self.arguments_types and isinstance( self.arguments_types[-1], ellipsis_t )
+
class free_function_type_t( type_t, calldef_type_t ):
"""describes free function type"""
Modified: pygccxml_dev/pygccxml/declarations/namespace.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/namespace.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/declarations/namespace.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -72,7 +72,8 @@
, name=name
, function=function
, recursive=recursive )
-
+ ns = namespace
+
def namespaces( self, name=None, function=None, recursive=None, allow_empty=None ):
"""returns a set of namespace declarations, that are matched defined criterias"""
return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ]
@@ -80,7 +81,8 @@
, function=function
, recursive=recursive
, allow_empty=allow_empty)
-
+ nss = namespaces
+
def free_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
"""returns reference to free function declaration, that is matched defined criterias"""
return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ]
Modified: pygccxml_dev/pygccxml/parser/linker.py
===================================================================
--- pygccxml_dev/pygccxml/parser/linker.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/parser/linker.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -24,7 +24,7 @@
for d in self.__decls.itervalues():
self.__compiler = d.compiler
break
-
+
def _get_inst(self):
return self.__inst
def _set_inst(self, inst):
@@ -43,6 +43,8 @@
base = declarated_t( declaration=self.__decls[ type_id ] )
self.__types[type_id] = base
return base
+ elif '...' == type_id:
+ return ellipsis_t()
else:
return unknown_t()
Modified: pygccxml_dev/pygccxml/parser/project_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/project_reader.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/parser/project_reader.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -465,7 +465,8 @@
types.extend( get_from_type( arg ) )
return types
else:
- assert isinstance( cpptype, pygccxml.declarations.unknown_t )
+ assert isinstance( cpptype, ( pygccxml.declarations.unknown_t
+ , pygccxml.declarations.ellipsis_t ) )
return []
types = []
for decl in pygccxml.declarations.make_flatten( namespaces ):
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -57,6 +57,7 @@
XML_NN_CONSTRUCTOR = "Constructor"
XML_NN_CV_QUALIFIED_TYPE = "CvQualifiedType"
XML_NN_DESTRUCTOR = "Destructor"
+XML_NN_ELLIPSIS = "Ellipsis"
XML_NN_ENUMERATION = "Enumeration"
XML_NN_ENUMERATION_VALUE = "EnumValue"
XML_NN_FIELD = "Field"
@@ -113,6 +114,7 @@
, XML_NN_MEMBER_OPERATOR : self.__read_member_operator
, XML_NN_METHOD : self.__read_method
, XML_NN_GCC_XML : self.__read_version
+ , XML_NN_ELLIPSIS : self.__read_ellipsis
}
self.deep_declarations = [
XML_NN_CASTING_OPERATOR
@@ -379,6 +381,13 @@
argument.default_value = None
self.__inst.arguments.append( argument )
+ def __read_ellipsis( self, attrs ):
+ if isinstance( self.__inst, calldef_type_t ):
+ self.__inst.arguments_types.append( '...' )
+ else:
+ argument = argument_t( type='...' )
+ self.__inst.arguments.append( argument )
+
def __read_calldef( self, calldef, attrs, is_declaration ):
#destructor for example doesn't have return type
calldef.return_type = attrs.get( XML_AN_RETURNS, None )
Modified: pygccxml_dev/unittests/data/declarations_calldef.hpp
===================================================================
--- pygccxml_dev/unittests/data/declarations_calldef.hpp 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/unittests/data/declarations_calldef.hpp 2008-02-17 19:49:54 UTC (rev 1243)
@@ -1,65 +1,75 @@
-// 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)
-
-#ifndef __declarations_calldef_hpp__
-#define __declarations_calldef_hpp__
-
-namespace declarations{ namespace calldef{
-
-class some_exception_t{};
-
-class other_exception_t{};
-
-void no_return_no_args();
-
-int return_no_args();
-
-void no_return_1_arg(int arg);
-
-int return_default_args( int arg=1, bool flag=false );
-
-extern void static_call();
-
-void calldef_with_throw() throw( some_exception_t, other_exception_t );
-
-struct calldefs_t{
- calldefs_t();
-
- calldefs_t(char);
-
- calldefs_t(int,double);
-
- calldefs_t(const calldefs_t&);
-
- virtual ~calldefs_t();
-
- calldefs_t& operator=( const calldefs_t& );
- bool operator==( const calldefs_t& );
- operator char*() const;
- virtual operator double();
-
- static void static_call();
-
- inline int member_inline_call(int i){ return i;}
-
- virtual void member_virtual_call();
-
- virtual void member_pure_virtual_call() = 0;
-
- void member_const_call() const;
-
- calldefs_t* do_smth(const calldefs_t& other);
-};
-
-namespace std{
- class iostream;
-}
-
-std::iostream& operator<<( std::iostream&, const calldefs_t& );
-std::iostream& operator>>( std::iostream&, calldefs_t& );
-
-} }
-
-#endif//__declarations_calldef_hpp__
+// 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)
+
+#ifndef __declarations_calldef_hpp__
+#define __declarations_calldef_hpp__
+
+namespace declarations{ namespace calldef{
+
+class some_exception_t{};
+
+class other_exception_t{};
+
+void no_return_no_args();
+
+int return_no_args();
+
+void no_return_1_arg(int arg);
+
+int return_default_args( int arg=1, bool flag=false );
+
+extern void static_call();
+
+void calldef_with_throw() throw( some_exception_t, other_exception_t );
+
+struct calldefs_t{
+ calldefs_t();
+
+ calldefs_t(char);
+
+ calldefs_t(int,double);
+
+ calldefs_t(const calldefs_t&);
+
+ virtual ~calldefs_t();
+
+ calldefs_t& operator=( const calldefs_t& );
+ bool operator==( const calldefs_t& );
+ operator char*() const;
+ virtual operator double();
+
+ static void static_call();
+
+ inline int member_inline_call(int i){ return i;}
+
+ virtual void member_virtual_call();
+
+ virtual void member_pure_virtual_call() = 0;
+
+ void member_const_call() const;
+
+ calldefs_t* do_smth(const calldefs_t& other);
+};
+
+namespace std{
+ class iostream;
+}
+
+std::iostream& operator<<( std::iostream&, const calldefs_t& );
+std::iostream& operator>>( std::iostream&, calldefs_t& );
+
+namespace ellipsis_tester{
+
+struct ellipsis{
+ void do_smth( int, ... );
+};
+
+void do_smth_else( int, ... );
+
+}//ellipsis_tester
+
+} }
+
+#endif//__declarations_calldef_hpp__
Modified: pygccxml_dev/unittests/data/plain_c.c
===================================================================
--- pygccxml_dev/unittests/data/plain_c.c 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/unittests/data/plain_c.c 2008-02-17 19:49:54 UTC (rev 1243)
@@ -9,8 +9,8 @@
void hello_print(const char *message);
double hello_sum(double x, double y);
+void do_smth( int, ... );
-
#ifdef __cplusplus
}
#endif
Modified: pygccxml_dev/unittests/decl_string_tester.py
===================================================================
--- pygccxml_dev/unittests/decl_string_tester.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/unittests/decl_string_tester.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -40,6 +40,15 @@
return_default_args = self.global_ns.free_fun( 'return_default_args' )
decls = parser.parse_string( self.template % return_default_args.decl_string, self.config )
self.failUnless( decls, "Created decl_string for global function containes mistake" )
+
+ def test_all_mem_and_free_funs( self ):
+ ns = self.global_ns.ns( '::declarations::calldef' )
+ for f in ns.mem_funs():
+ decls = parser.parse_string( self.template % f.decl_string, self.config )
+ self.failUnless( decls, "Created decl_string for member function containes mistake" )
+ for f in ns.free_funs():
+ decls = parser.parse_string( self.template % f.decl_string, self.config )
+ self.failUnless( decls, "Created decl_string for member function containes mistake" )
def create_suite():
suite = unittest.TestSuite()
Modified: pygccxml_dev/unittests/declarations_tester.py
===================================================================
--- pygccxml_dev/unittests/declarations_tester.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/unittests/declarations_tester.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -160,6 +160,16 @@
else:
self.failUnless( decl.return_type.decl_string in calldefs_cast_operators, "unable to find operator symbol for operator '%s'" % decl.decl_string )
+ def test_ellipsis( self ):
+ ns = self.global_ns.ns( 'ellipsis_tester' )
+ do_smth = ns.mem_fun( 'do_smth' )
+ for a in do_smth.arguments:
+ print str(a)
+ self.failUnless( do_smth.has_ellipsis )
+ do_smth_else = ns.free_fun( 'do_smth_else' )
+ self.failUnless( do_smth_else.has_ellipsis )
+
+
class all_at_once_tester_t( declarations_t ):
COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE
def __init__(self, *args):
Modified: pygccxml_dev/unittests/filters_tester.py
===================================================================
--- pygccxml_dev/unittests/filters_tester.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/unittests/filters_tester.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -34,9 +34,9 @@
public_members = declarations.matcher.find( criteria, self.declarations )
if '0.9' in public_members[0].compiler:
#2 empty classes, this compiler doesn't generate constructor and copy constructor
- self.failUnless( 15 == len( public_members ) )
+ self.failUnless( 16 == len( public_members ) )
else:
- self.failUnless( 19 == len( public_members ) )
+ self.failUnless( 20 == len( public_members ) )
def test_or_matcher( self ):
criteria1 = declarations.regex_matcher_t( 'oper.*'
Modified: pygccxml_dev/unittests/plain_c_tester.py
===================================================================
--- pygccxml_dev/unittests/plain_c_tester.py 2008-02-17 18:07:39 UTC (rev 1242)
+++ pygccxml_dev/unittests/plain_c_tester.py 2008-02-17 19:49:54 UTC (rev 1243)
@@ -26,7 +26,11 @@
def test( self ):
self.global_ns.free_fun( 'hello_sum' )
self.global_ns.free_fun( 'hello_print' )
-
+ declarations.print_declarations( self.global_ns )
+ f = self.global_ns.free_fun( 'do_smth' )
+ for arg in f.arguments:
+ print arg.type.decl_string
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-17 18:07:33
|
Revision: 1242
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1242&view=rev
Author: roman_yakovenko
Date: 2008-02-17 10:07:39 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
adding tester for C language
Modified Paths:
--------------
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/data/core_cache.hpp
pygccxml_dev/unittests/test_all.py
Added Paths:
-----------
pygccxml_dev/unittests/data/plain_c.c
pygccxml_dev/unittests/plain_c_tester.py
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-02-17 11:44:47 UTC (rev 1241)
+++ pygccxml_dev/unittests/autoconfig.py 2008-02-17 18:07:39 UTC (rev 1242)
@@ -46,9 +46,6 @@
, define_symbols=[ gccxml_version ]
, compiler=compiler )
- synopsis = pygccxml.parser.synopsis_configuration_t( working_directory=data_directory )
-
-
#~ try:
#~ import pydsc
#~ pydsc.include( r'D:\pygccxml_sources\sources\pygccxml_dev' )
Modified: pygccxml_dev/unittests/data/core_cache.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_cache.hpp 2008-02-17 11:44:47 UTC (rev 1241)
+++ pygccxml_dev/unittests/data/core_cache.hpp 2008-02-17 18:07:39 UTC (rev 1242)
@@ -22,4 +22,4 @@
#endif//__core_cache_hpp__
-//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
+//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
Added: pygccxml_dev/unittests/data/plain_c.c
===================================================================
--- pygccxml_dev/unittests/data/plain_c.c (rev 0)
+++ pygccxml_dev/unittests/data/plain_c.c 2008-02-17 18:07:39 UTC (rev 1242)
@@ -0,0 +1,18 @@
+#ifndef __HELLO_H__
+#define __HELLO_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+void hello_print(const char *message);
+double hello_sum(double x, double y);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HELLO_H__ */
Added: pygccxml_dev/unittests/plain_c_tester.py
===================================================================
--- pygccxml_dev/unittests/plain_c_tester.py (rev 0)
+++ pygccxml_dev/unittests/plain_c_tester.py 2008-02-17 18:07:39 UTC (rev 1242)
@@ -0,0 +1,39 @@
+# 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)
+
+import unittest
+import autoconfig
+import parser_test_case
+
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
+
+class tester_t( parser_test_case.parser_test_case_t ):
+ def __init__(self, *args ):
+ parser_test_case.parser_test_case_t.__init__( self, *args )
+ self.header = 'plain_c.c'
+ self.global_ns = None
+
+ def setUp(self):
+ if not self.global_ns:
+ decls = parser.parse( [self.header], self.config )
+ self.global_ns = declarations.get_global_namespace( decls )
+ self.global_ns.init_optimizer()
+
+ def test( self ):
+ self.global_ns.free_fun( 'hello_sum' )
+ self.global_ns.free_fun( 'hello_print' )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2008-02-17 11:44:47 UTC (rev 1241)
+++ pygccxml_dev/unittests/test_all.py 2008-02-17 18:07:39 UTC (rev 1242)
@@ -48,6 +48,7 @@
import attributes_tester
import type_as_exception_bug_tester
import copy_constructor_tester
+import plain_c_tester
testers = [
decl_string_tester
@@ -92,6 +93,7 @@
, attributes_tester
, type_as_exception_bug_tester
, copy_constructor_tester
+ , plain_c_tester
]
def create_suite():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-17 11:44:43
|
Revision: 1241
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1241&view=rev
Author: roman_yakovenko
Date: 2008-02-17 03:44:47 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
adding new tests
Modified Paths:
--------------
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
pyplusplus_dev/unittests/override_bug_tester.py
Modified: pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-17 11:43:23 UTC (rev 1240)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-17 11:44:47 UTC (rev 1241)
@@ -24,6 +24,42 @@
inline int invoke_foo( const A& a ){
return a.foo();
};
+
+class Base1
+{
+public:
+ virtual int eval_a() { return 1; }
+ virtual int eval_b() { return 10; }
+ virtual int eval_c() { return 100; }
+ virtual int eval_d() { return 1000; }
+ virtual int eval_e() { return 10000; }
+};
+
+class Derived2: public Base1
+{
+protected:
+ virtual int eval_a() { return 2; }
+ virtual int eval_b() { return 20; }
+ virtual int eval_c() { return 200; }
+ virtual int eval_d() { return 2000; }
+ virtual int eval_e() { return 20000; }
+};
+
+class Derived3: public Derived2
+{
+};
+
+int eval(Base1* obj) {
+ return
+ obj->eval_a()
+ + obj->eval_b()
+ + obj->eval_c()
+ + obj->eval_d()
+ + obj->eval_e()
+ ;
+}
+
+
}
#endif//__final_classes_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py 2008-02-17 11:43:23 UTC (rev 1240)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-02-17 11:44:47 UTC (rev 1241)
@@ -17,6 +17,9 @@
, tester_t.EXTENSION_NAME
, *args )
+ def customize( self, mb ):
+ mb.class_("Derived2").member_functions("eval_c").exclude()
+
def run_tests(self, module):
class C( module.B ):
def __init__( self ):
@@ -24,7 +27,26 @@
def foo( self ):
return ord( 'c' )
self.failUnless( ord('c') == module.invoke_foo( C() ) )
+
+ class Derived4(module.Derived3):
+ def __init__( self ):
+ module.Derived3.__init__( self )
+ def eval_a(self):
+ return 3
+ def eval_c(self):
+ return 300 # ignored because eval_c excluded
+ self.failUnless( 22223 == module.eval( Derived4() ) )
+
+ # Notes:
+ # would return 22222 before any patch, since Derived3 wouldn't have a wrapper
+ # would return 22123 with my original "ignore" handling and a list
+ # instead of a set, because eval_c would be excluded naively
+ # would return 22323 if ignore flag wouldn't be considered
+ # would return ????3 (1s in some locations and 2s in others because of
+ # hashing) if set wouldn't be replaced by a list
+ # would return 11113 if protected virtual methods wouldn't be included
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-17 11:43:18
|
Revision: 1240
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1240&view=rev
Author: roman_yakovenko
Date: 2008-02-17 03:43:23 -0800 (Sun, 17 Feb 2008)
Log Message:
-----------
remove synopsis integration
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/__init__.py
Modified: pygccxml_dev/pygccxml/parser/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/parser/__init__.py 2008-02-17 06:02:25 UTC (rev 1239)
+++ pygccxml_dev/pygccxml/parser/__init__.py 2008-02-17 11:43:23 UTC (rev 1240)
@@ -8,9 +8,7 @@
from config import config_t
from config import gccxml_configuration_t
-from config import synopsis_configuration_t
-
from project_reader import COMPILATION_MODE
from project_reader import project_reader_t
from project_reader import file_configuration_t
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-17 06:02:22
|
Revision: 1239
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1239&view=rev
Author: roman_yakovenko
Date: 2008-02-16 22:02:25 -0800 (Sat, 16 Feb 2008)
Log Message:
-----------
bug fix - improving algorithm, which selects what functions should\could be overriden
Thanks to Julian Scheid for bug reporting
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
pyplusplus_dev/unittests/override_bug_tester.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-02-15 20:50:07 UTC (rev 1238)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-02-17 06:02:25 UTC (rev 1239)
@@ -428,26 +428,31 @@
all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
- all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
- all_public_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.VIRTUAL ) \
- & declarations.access_type_matcher_t( 'public' )
+ all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
+ all_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.VIRTUAL ) \
+ & (declarations.access_type_matcher_t( 'public' ) \
+ | declarations.access_type_matcher_t( 'protected' ))
all_not_pure_virtual = ~all_pure_virtual
- query = all_protected | all_pure_virtual | all_public_virtual
+ query = all_protected | all_pure_virtual
+ mf_query = query | all_virtual
relevant_opers = declarations.custom_matcher_t( lambda decl: decl.symbol in ('()', '[]') )
- funcs = set()
- defined_funcs = set()
+ funcs = []
+ defined_funcs = []
for base in self.recursive_bases:
if base.access == ACCESS_TYPES.PRIVATE:
continue
base_cls = base.related_class
- funcs.update( base_cls.member_functions( query, recursive=False, allow_empty=True ) )
- funcs.update( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )
+ #funcs.extend( base_cls.member_functions( query, recursive=False, allow_empty=True ) )
+ #funcs.extend( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )
- defined_funcs.update( base_cls.member_functions( all_not_pure_virtual, recursive=False, allow_empty=True ) )
- defined_funcs.update( base_cls.member_operators( all_not_pure_virtual & relevant_opers, recursive=False, allow_empty=True ) )
+ funcs.extend( base_cls.member_functions( mf_query, recursive=False, allow_empty=True ) )
+ funcs.extend( base_cls.member_operators( relevant_opers & query, recursive=False, allow_empty=True ) )
+ defined_funcs.extend( base_cls.member_functions( all_not_pure_virtual, recursive=False, allow_empty=True ) )
+ defined_funcs.extend( base_cls.member_operators( all_not_pure_virtual & relevant_opers, recursive=False, allow_empty=True ) )
+
not_reimplemented_funcs = set()
is_same_function = declarations.is_same_function
for f in funcs:
@@ -473,8 +478,10 @@
if is_same_function( f, f_defined ):
break
else:
- not_reimplemented_funcs.add( f )
- functions = list( not_reimplemented_funcs )
+ not_reimplemented_funcs.add( f )
+ functions = filter( lambda f: not f.ignore and f.exportable
+ , list( not_reimplemented_funcs ) )
+
functions.sort( cmp=lambda f1, f2: cmp( ( f1.name, f1.location.as_tuple() )
, ( f2.name, f2.location.as_tuple() ) ) )
self._redefined_funcs = functions
Modified: pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-15 20:50:07 UTC (rev 1238)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-17 06:02:25 UTC (rev 1239)
@@ -13,7 +13,7 @@
class A
{
public:
- virtual void foo() const {}
+ virtual int foo() const {return int('a');}
virtual ~A(){}
};
@@ -21,8 +21,8 @@
{
};
-inline void invoke_foo( const A& a ){
- a.foo();
+inline int invoke_foo( const A& a ){
+ return a.foo();
};
}
Modified: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py 2008-02-15 20:50:07 UTC (rev 1238)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-02-17 06:02:25 UTC (rev 1239)
@@ -22,8 +22,8 @@
def __init__( self ):
module.B.__init__( self )
def foo( self ):
- print "C.foo"
- module.invoke_foo( C() )
+ return ord( 'c' )
+ self.failUnless( ord('c') == module.invoke_foo( C() ) )
def create_suite():
suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-15 20:50:05
|
Revision: 1238
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1238&view=rev
Author: roman_yakovenko
Date: 2008-02-15 12:50:07 -0800 (Fri, 15 Feb 2008)
Log Message:
-----------
bug fix - improving algorithm, which selects what functions should\could be overriden
Thanks to Julian Scheid for bug reporting
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/unittests/hierarchy3_tester.py
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
pyplusplus_dev/unittests/override_bug_tester.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-02-14 07:12:22 UTC (rev 1237)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-02-15 20:50:07 UTC (rev 1238)
@@ -429,9 +429,11 @@
all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
+ all_public_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.VIRTUAL ) \
+ & declarations.access_type_matcher_t( 'public' )
all_not_pure_virtual = ~all_pure_virtual
- query = all_protected | all_pure_virtual
+ query = all_protected | all_pure_virtual | all_public_virtual
relevant_opers = declarations.custom_matcher_t( lambda decl: decl.symbol in ('()', '[]') )
funcs = set()
defined_funcs = set()
Added: pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-15 20:50:07 UTC (rev 1238)
@@ -0,0 +1,30 @@
+// 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)
+
+#ifndef __final_classes_to_be_exported_hpp__
+#define __final_classes_to_be_exported_hpp__
+
+#include <string>
+
+namespace override_bug{
+
+class A
+{
+ public:
+ virtual void foo() const {}
+ virtual ~A(){}
+};
+
+class B: public A
+{
+};
+
+inline void invoke_foo( const A& a ){
+ a.foo();
+};
+}
+
+#endif//__final_classes_to_be_exported_hpp__
+
Modified: pyplusplus_dev/unittests/hierarchy3_tester.py
===================================================================
--- pyplusplus_dev/unittests/hierarchy3_tester.py 2008-02-14 07:12:22 UTC (rev 1237)
+++ pyplusplus_dev/unittests/hierarchy3_tester.py 2008-02-15 20:50:07 UTC (rev 1238)
@@ -26,8 +26,8 @@
, type=declarations.class_t)
found = find( matcher, mb.code_creator.body.creators )
self.failUnless( found )
- self.failUnless( not found.wrapper )
- self.failUnless( 0 == len( found.creators ) )
+ self.failUnless( found.wrapper )
+ #self.failUnless( 0 == len( found.creators ) )
def run_tests(self, module):
pass
Added: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py (rev 0)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-02-15 20:50:07 UTC (rev 1238)
@@ -0,0 +1,37 @@
+# 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)
+
+import os
+import sys
+import unittest
+import fundamental_tester_base
+
+class tester_t(fundamental_tester_base.fundamental_tester_base_t):
+ EXTENSION_NAME = 'override_bug'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def run_tests(self, module):
+ class C( module.B ):
+ def __init__( self ):
+ module.B.__init__( self )
+ def foo( self ):
+ print "C.foo"
+ module.invoke_foo( C() )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2008-02-14 07:12:22 UTC (rev 1237)
+++ pyplusplus_dev/unittests/test_all.py 2008-02-15 20:50:07 UTC (rev 1238)
@@ -84,6 +84,7 @@
import final_classes_tester
import templates_tester
import deepcopy_tester
+import override_bug_tester
#gui_tester
#gui_wizard_tester
#
@@ -187,6 +188,7 @@
, balanced_files_tester
, ft_inout_tester
, deepcopy_tester
+ , override_bug_tester
]
class module_runner_t( object ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-14 07:12:16
|
Revision: 1237
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1237&view=rev
Author: roman_yakovenko
Date: 2008-02-13 23:12:22 -0800 (Wed, 13 Feb 2008)
Log Message:
-----------
switching to msdia80
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/pdb_reader.py
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-12 21:31:45 UTC (rev 1236)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-14 07:12:22 UTC (rev 1237)
@@ -6,10 +6,14 @@
from sets import Set as set
msdia_dll = r'C:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll'
+msdia_dll = r'D:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll'
+msdia_dll = 'msdia80.dll'
+
msdia = comtypes.client.GetModule( msdia_dll )
control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb'
+control_pdb = r'xxx.pdb'
ds = comtypes.client.CreateObject( msdia.DiaSource )
ds.loadDataFromPdb(control_pdb)
@@ -27,24 +31,27 @@
def print_enums( smb ):
enums = smb.findChildren( SymTagEnum, None, 0 )
for enum in iter( enums ):
- enum = AsDiaSymbol( enum )
- print 'enum name: ', enum.name
+ enum = AsDiaSymbol( enum )
+ if 'shared_consts' not in enum.name:
+ continue
+ 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
#~ print 'enum: ', enum.symIndexId
#~ f = session.findFile( internal_smb, internal_smb.name, 0 )
#~ print 'name: ', internal_smb.name
#~ print f
- #~ print 'IDiaSymbol::sourceFileName: ', internal_smb.sourceFileName
- #~ print 'IDiaSymbol::symbolsFileName: ', internal_smb.symbolsFileName
values = enum.findChildren( msdia.SymTagData, None, 0 )
for v in iter(values):
v = AsDiaSymbol(v)
if v.classParent.symIndexId != enum.symIndexId:
continue
- print '\t\tvalue name: ', v.name, ' ', v.value
- #~ print 'value parent: ', v.classParent
- #~ print 'value parent id: ', v.classParentId
- #~ print 'value parent sym id: ', v.classParent.symIndexId
+ print ' value %s(%d): ' % ( v.name, v.value )
def print_nss( smb, offset ):
symbols = smb.findChildren( msdia.SymTagUDT, None, 0 )
@@ -61,4 +68,4 @@
print 'File: ', f.fileName
#~ print_files( session )
-print_enums( root_symbol )
\ No newline at end of file
+print_enums( root_symbol )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-12 21:31:40
|
Revision: 1236
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1236&view=rev
Author: roman_yakovenko
Date: 2008-02-12 13:31:45 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
testing pdb
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/pdb_reader.py
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-12 21:31:45 UTC (rev 1236)
@@ -1,31 +1,64 @@
import os
import sys
+import ctypes
import comtypes
import comtypes.client
from sets import Set as set
-comtypes.client.gen_dir = r'D:\dev\language-binding\sources\pygccxml_dev\pygccxml\parser\gen'
-print comtypes.client.GetModule( r'D:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll' )
+msdia_dll = r'C:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll'
-#~ MODULE_IDENTIFIER = ('{106173A0-0173-4e5c-84E7-E915422BE997}', 0, 2, 0)
-#~ MODULE_PATH = r'Lib\site-packages\win32com\gen_py\106173A0-0173-4e5c-84E7-E915422BE997x0x2x0.py'
+msdia = comtypes.client.GetModule( msdia_dll )
-#~ try:
- #~ full_module_path = os.path.split( sys.executable )[0]
- #~ full_module_path = os.path.join( full_module_path, MODULE_PATH )
- #~ if os.path.exists( full_module_path ):
- #~ os.remove( full_module_path )
- #~ print(full_module_path, " removed successfully")
-#~ except Exception, error:
- #~ print 'Exception:', str(error)
+control_pdb = r'C:\dev\produce_pdb\Debug\produce_pdb.pdb'
-#~ msdia = win32com.client.gencache.EnsureModule( *MODULE_IDENTIFIER )
+ds = comtypes.client.CreateObject( msdia.DiaSource )
+ds.loadDataFromPdb(control_pdb)
+session = ds.openSession()
-#ds = comtypes.client.CreateObject( "{e60afbee-502d-46ae-858f-8272a09bd707}" )
-#print dir( ds )
-#ds.loadDataFromPdb( 'xxx.pdb' )
+root_symbol = session.globalScope
-#~ ds = msdia.DiaSource()
-#~ ds.loadDataFromPdb( 'xxx.pdb' )
-#~ session = ds.openSession()
-#~ print 'done'
+print root_symbol
+
+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 'enum name: ', enum.name
+ #~ print 'enum: ', enum.symIndexId
+ #~ f = session.findFile( internal_smb, internal_smb.name, 0 )
+ #~ print 'name: ', internal_smb.name
+ #~ print f
+ #~ print 'IDiaSymbol::sourceFileName: ', internal_smb.sourceFileName
+ #~ print 'IDiaSymbol::symbolsFileName: ', internal_smb.symbolsFileName
+
+ values = enum.findChildren( msdia.SymTagData, None, 0 )
+ for v in iter(values):
+ v = AsDiaSymbol(v)
+ if v.classParent.symIndexId != enum.symIndexId:
+ continue
+ print '\t\tvalue name: ', v.name, ' ', v.value
+ #~ print 'value parent: ', v.classParent
+ #~ print 'value parent id: ', v.classParentId
+ #~ print 'value parent sym id: ', v.classParent.symIndexId
+
+def print_nss( smb, offset ):
+ symbols = smb.findChildren( msdia.SymTagUDT, None, 0 )
+ for internal_smb in iter( symbols ):
+ internal_smb = ctypes.cast( internal_smb, ctypes.POINTER( msdia.IDiaSymbol ) )
+ if internal_smb.classParentId == smb.symIndexId:
+ print ' ' * offset, internal_smb.name
+ print_nss( internal_smb, offset + 1 )
+
+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 )
\ 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-02-07 07:47:22
|
Revision: 1235
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1235&view=rev
Author: roman_yakovenko
Date: 2008-02-06 23:47:26 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
removing synopsis parser
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/config.py
pygccxml_dev/pygccxml/parser/etree_scanner.py
pygccxml_dev/pygccxml/parser/pdb_reader.py
pygccxml_dev/pygccxml/parser/project_reader.py
pygccxml_dev/pygccxml/parser/source_reader.py
pygccxml_dev/unittests/data/core_cache.hpp
Removed Paths:
-------------
pygccxml_dev/pygccxml/parser/synopsis_reader.py
pygccxml_dev/pygccxml/parser/synopsis_scanner.py
Modified: pygccxml_dev/pygccxml/parser/config.py
===================================================================
--- pygccxml_dev/pygccxml/parser/config.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/config.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -14,13 +14,13 @@
"""Configuration object to collect parameters for invoking C++ parser
This class serves as a base class for the parameters that can be used
- to customize the call to C++ parser. This class also allows users to work with
+ to customize the call to C++ parser. This class also allows users to work with
relative files paths. In this case files are searched in the following order:
-
+
1. current directory
-
+
2. working directory
-
+
3. additional include paths specified by the user
"""
@@ -31,7 +31,7 @@
, undefine_symbols=None
, cflags=""
, compiler=None):
- """Constructor.
+ """Constructor.
"""
object.__init__( self )
self.__working_directory = working_directory
@@ -49,23 +49,23 @@
self.__undefine_symbols = undefine_symbols
self.__cflags = cflags
-
+
self.__compiler = compiler
-
+
def clone(self):
raise NotImplementedError( self.__class__.__name__ )
-
+
def __get_working_directory(self):
return self.__working_directory
def __set_working_directory(self, working_dir):
self.__working_directory=working_dir
working_directory = property( __get_working_directory, __set_working_directory )
-
+
@property
def include_paths(self):
"""list of include paths to look for header files"""
return self.__include_paths
-
+
@property
def define_symbols(self):
"""list of "define" directives """
@@ -77,7 +77,7 @@
return self.__undefine_symbols
@property
- def compiler(self):
+ def compiler(self):
"""compiler name to simulate"""
return self.__compiler
@@ -90,7 +90,7 @@
def __ensure_dir_exists( self, dir_path, meaning ):
if os.path.isdir( dir_path ):
- return
+ return
msg = None
if os.path.exists( self.working_directory ):
raise RuntimeError( '%s("%s") does not exist!' % ( meaning, dir_path ) )
@@ -98,18 +98,18 @@
raise RuntimeError( '%s("%s") should be "directory", not a file.' % ( meaning, dir_path ) )
- def raise_on_wrong_settings( self ):
+ def raise_on_wrong_settings( self ):
"""validates the configuration settings and raises RuntimeError on error"""
self.__ensure_dir_exists( self.working_directory, 'working directory' )
map( lambda idir: self.__ensure_dir_exists( idir, 'include directory' )
, self.include_paths )
-
+
class gccxml_configuration_t(parser_configuration_t):
"""Configuration object to collect parameters for invoking gccxml.
This class serves as a container for the parameters that can be used
- to customize the call to gccxml.
+ to customize the call to gccxml.
"""
def __init__( self
, gccxml_path=''
@@ -121,7 +121,7 @@
, ignore_gccxml_output=False
, cflags=""
, compiler=None):
- """Constructor.
+ """Constructor.
"""
parser_configuration_t.__init__( self
, working_directory=working_directory
@@ -130,7 +130,7 @@
, undefine_symbols=undefine_symbols
, cflags=cflags
, compiler=compiler)
-
+
self.__gccxml_path = gccxml_path
if not start_with_declarations:
@@ -138,10 +138,10 @@
self.__start_with_declarations = start_with_declarations
self.__ignore_gccxml_output = ignore_gccxml_output
-
+
def clone(self):
return copy.deepcopy( self )
-
+
def __get_gccxml_path(self):
return self.__gccxml_path
def __set_gccxml_path(self, new_path ):
@@ -151,9 +151,9 @@
@property
def start_with_declarations(self):
- """list of declarations gccxml should start with, when it dumps declaration tree"""
+ """list of declarations gccxml should start with, when it dumps declaration tree"""
return self.__start_with_declarations
-
+
def __get_ignore_gccxml_output(self):
return self.__ignore_gccxml_output
def __set_ignore_gccxml_output(self, val=True):
@@ -161,11 +161,11 @@
ignore_gccxml_output = property( __get_ignore_gccxml_output, __set_ignore_gccxml_output
, doc="set this property to True, if you want pygccxml to ignore any error\\warning that comes from gccxml" )
-
- def raise_on_wrong_settings( self ):
+
+ def raise_on_wrong_settings( self ):
super( gccxml_configuration_t, self ).raise_on_wrong_settings()
if os.path.isfile( self.gccxml_path ):
- return
+ return
if sys.platform == 'win32':
gccxml_name = 'gccxml' + '.exe'
environment_var_delimiter = ';'
@@ -187,31 +187,5 @@
msg = 'gccxml_path("%s") should exists or to be a valid file name.' \
% self.gccxml_path
raise RuntimeError( msg )
-
-config_t = gccxml_configuration_t #backward computability
-class synopsis_configuration_t(parser_configuration_t):
- """Configuration object to collect parameters for invoking gccxml.
-
- This class serves as a container for the parameters that can be used
- to customize the call to synopsis.
- """
- def __init__( self
- , working_directory='.'
- , include_paths=None
- , define_symbols=None
- , undefine_symbols=None
- , cflags=""
- , compiler=None):
- """Constructor.
- """
- parser_configuration_t.__init__( self
- , working_directory=working_directory
- , include_paths=include_paths
- , define_symbols=define_symbols
- , undefine_symbols=undefine_symbols
- , cflags=cflags
- , compiler=compiler)
-
- def clone(self):
- return copy.deepcopy( self )
+config_t = gccxml_configuration_t #backward computability
Modified: pygccxml_dev/pygccxml/parser/etree_scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/etree_scanner.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/etree_scanner.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -5,12 +5,12 @@
import scanner
import xml.etree.cElementTree as ElementTree
-
+
class etree_saxifier_t(object):
def __init__(self, etree, handler):
self.__root_elem = etree.getroot()
- self.__handler = handler
-
+ self.__handler = handler
+
def saxify(self):
self.__handler.startDocument()
self.__recursive_saxify( self.__root_elem )
@@ -18,31 +18,23 @@
def __recursive_saxify(self, element ):
self.__handler.startElement( element.tag, element.attrib )
-
- #~ if element.text:
- #~ self.__handler.characters(element.text)
-
map( self.__recursive_saxify, element )
-
self.__handler.endElement( element.tag )
- #~ if element.tail:
- #~ self.__handler.characters(element.tail)
-
class etree_scanner_t( scanner.scanner_t ):
def __init__(self, gccxml_file, decl_factory, *args ):
scanner.scanner_t.__init__( self, gccxml_file, decl_factory, *args )
-
- def read( self ):
+
+ def read( self ):
tree = ElementTree.parse( self.gccxml_file )
saxifier = etree_saxifier_t( tree, self )
- saxifier.saxify()
+ saxifier.saxify()
class ietree_scanner_t( scanner.scanner_t ):
def __init__(self, gccxml_file, decl_factory, *args ):
scanner.scanner_t.__init__( self, gccxml_file, decl_factory, *args )
-
- def read( self ):
+
+ def read( self ):
context = ElementTree.iterparse(self.gccxml_file, events=("start", "end"))
for event, elem in context:
if event == 'start':
@@ -51,5 +43,5 @@
self.endElement( elem.tag )
elem.clear()
self.endDocument()
-
+
etree_scanner_t = ietree_scanner_t
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -1,8 +1,12 @@
import os
import sys
+import comtypes
import comtypes.client
from sets import Set as set
+comtypes.client.gen_dir = r'D:\dev\language-binding\sources\pygccxml_dev\pygccxml\parser\gen'
+print comtypes.client.GetModule( r'D:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll' )
+
#~ MODULE_IDENTIFIER = ('{106173A0-0173-4e5c-84E7-E915422BE997}', 0, 2, 0)
#~ MODULE_PATH = r'Lib\site-packages\win32com\gen_py\106173A0-0173-4e5c-84E7-E915422BE997x0x2x0.py'
@@ -17,8 +21,9 @@
#~ msdia = win32com.client.gencache.EnsureModule( *MODULE_IDENTIFIER )
-ds = comtypes.client.CreateObject( "{e60afbee-502d-46ae-858f-8272a09bd707}" )
-ds.loadDataFromPdb( 'xxx.pdb' )
+#ds = comtypes.client.CreateObject( "{e60afbee-502d-46ae-858f-8272a09bd707}" )
+#print dir( ds )
+#ds.loadDataFromPdb( 'xxx.pdb' )
#~ ds = msdia.DiaSource()
#~ ds.loadDataFromPdb( 'xxx.pdb' )
Modified: pygccxml_dev/pygccxml/parser/project_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/project_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/project_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -71,21 +71,21 @@
and self.__content_type == self.CONTENT_TYPE.CACHED_SOURCE_FILE:
self.__cached_source_file = self.__data + '.xml'
- def __get_data(self):
+ @property
+ def data(self):
return self.__data
- data = property( __get_data )
- def __get_start_with_declarations(self):
+ @property
+ def start_with_declarations(self):
return self.__start_with_declarations
- start_with_declarations = property( __get_start_with_declarations )
- def __get_content_type(self):
+ @property
+ def content_type(self):
return self.__content_type
- content_type = property( __get_content_type )
- def __get_cached_source_file(self):
+ @property
+ def cached_source_file(self):
return self.__cached_source_file
- cached_source_file = property( __get_cached_source_file )
def create_text_fc( text ):
"""
@@ -427,7 +427,7 @@
for decl_wrapper_type in declarated_types:
#it is possible, that cache contains reference to dropped class
#We need to clear it
- decl_wrapper_type.cache.reset()
+ decl_wrapper_type.cache.reset()
if isinstance( decl_wrapper_type.declaration, pygccxml.declarations.class_t ):
key = create_key(decl_wrapper_type.declaration)
if leaved_classes.has_key( key ):
Modified: pygccxml_dev/pygccxml/parser/source_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/source_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/source_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -10,29 +10,28 @@
import patcher
import pygccxml.utils
-try: #select faster xml parser
+try: #select the faster xml parser
from etree_scanner import etree_scanner_t as scanner_t
except:
from scanner import scanner_t
import declarations_cache
-from pygccxml import utils
+from pygccxml import utils
from pygccxml.declarations import *
class gccxml_runtime_error_t( RuntimeError ):
def __init__( self, msg ):
RuntimeError.__init__( self, msg )
-
def bind_aliases( decls ):
"""
- This function binds between class and it's typedefs.
+ This function binds between class and it's typedefs.
@param decls: list of all declarations
@type all_classes: list of L{declaration_t} items
@return: None
- """
+ """
visited = set()
typedefs = filter( lambda decl: isinstance( decl, typedef_t ), decls )
for decl in typedefs:
@@ -50,31 +49,31 @@
class source_reader_t:
"""
This class reads C++ source code and returns declarations tree.
-
- This class is the only class that have an intime knowledge about GCC-XML.
+
+ This class is the only class that have an intime knowledge about GCC-XML.
It has only one responsibility: it calls GCC-XML with a source file specified
by user and creates declarations tree. The implementation of this class is split
- to 2 classes:
-
- 1. L{scanner_t} - this class scans the "XML" file, generated by GCC-XML and
- creates `pygccxml`_ declarations and types classes. After the xml file has
- been processed declarations and type class instances keeps references to
- each other using GCC-XML generated id's.
+ to 2 classes:
- 2. L{linker_t} - this class contains logic for replacing GCC-XML generated
+ 1. L{scanner_t} - this class scans the "XML" file, generated by GCC-XML and
+ creates `pygccxml`_ declarations and types classes. After the xml file has
+ been processed declarations and type class instances keeps references to
+ each other using GCC-XML generated id's.
+
+ 2. L{linker_t} - this class contains logic for replacing GCC-XML generated
ids with references to declarations or type class instances.
"""
def __init__( self, config, cache=None, decl_factory=None ):
"""
- @param config: instance of L{config_t} class, that contains GCC-XML
+ @param config: instance of L{config_t} class, that contains GCC-XML
configuration
@type config: L{config_t}
-
- @param cache: reference to cache object, that will be updated after
+
+ @param cache: reference to cache object, that will be updated after
file has been parsed.
@param cache: instance of class, that derives from {cache_base_t}
-
- @param decl_factory: declarations factory, if not given default
+
+ @param decl_factory: declarations factory, if not given default
declarations factory L{decl_factory_t} will be used
"""
self.logger = utils.loggers.cxx_parser
@@ -99,7 +98,7 @@
cmd.append( '"%s"' % os.path.normpath( self.__config.gccxml_path ) )
else:
cmd.append( '%s' % os.path.normpath( self.__config.gccxml_path ) )
-
+
# Add all cflags passed
if self.__config.cflags != "":
cmd.append(" %s "%self.__config.cflags)
@@ -116,7 +115,7 @@
cmd.append( '-fxml-start="%s"' % ','.join( self.__config.start_with_declarations ) )
# Specify compiler if asked to
if self.__config.compiler:
- cmd.append( " --gccxml-compiler %s" % self.__config.compiler )
+ cmd.append( " --gccxml-compiler %s" % self.__config.compiler )
cmd_line = ' '.join(cmd)
if 'win32' in sys.platform :
cmd_line = '"%s"' % cmd_line
@@ -126,16 +125,16 @@
def create_xml_file( self, header, destination=None ):
"""
This function will return the file name of the file, created by GCC-XML
- for "header" file. If destination_file_path is not None, then this file
+ for "header" file. If destination_file_path is not None, then this file
path will be used and returned.
@param header: path to source file, that should be parsed
@type header: str
-
- @param destination: if given, will be used as target file/path for
+
+ @param destination: if given, will be used as target file/path for
GCC-XML generated file.
@type destination: str
-
+
@return: path to GCC-XML generated file
"""
gccxml_file = destination
@@ -173,13 +172,13 @@
def create_xml_file_from_string( self, content, destination=None ):
"""
Creates XML file from text.
-
+
@param content: C++ source code
@type content: str
-
+
@param destination: file name for GCC-XML generated file
@type destination: str
-
+
@return: returns file name of GCC-XML generated file
"""
header_file = pygccxml.utils.create_temp_file_name( suffix='.h' )
@@ -198,11 +197,11 @@
return self.read_gccxml_file( source_file )
else:
return self.read_synopsis_file( source_file )
-
+
def read_gccxml_file(self, source_file):
"""
Reads C++ source file and returns declarations tree
-
+
@param source_file: path to C++ source file
@type source_file: str
"""
@@ -230,10 +229,10 @@
def read_xml_file(self, gccxml_created_file):
"""
Reads GCC-XML generated XML file.
-
+
@param gccxml_created_file: path to GCC-XML generated file
@type gccxml_created_file: str
-
+
@return: declarations tree
"""
assert(self.__config!=None)
@@ -289,7 +288,7 @@
return file_path
except Exception:
return file_path
-
+
def __parse_gccxml_created_file( self, gccxml_file ):
scanner_ = scanner_t( gccxml_file, self.__decl_factory )
scanner_.read()
@@ -314,20 +313,20 @@
#some times gccxml report typedefs defined in no namespace
#it happens for example in next situation
#template< typename X>
- #void ddd(){ typedef typename X::Y YY;}
+ #void ddd(){ typedef typename X::Y YY;}
#if I will fail on this bug next time, the right way to fix it may be different
patcher.fix_calldef_decls( scanner_.calldefs(), scanner_.enums() )
decls = filter( lambda inst: isinstance( inst, namespace_t ) and not inst.parent
, decls.itervalues() )
return ( decls, files.values() )
-
+
def read_synopsis_file( self, source_file ):
import synopsis_scanner
from Synopsis import AST
from Synopsis.Parsers import Cxx
ffname = self.__file_full_name(source_file)
-
+
cppflags = []
map( lambda dpath: cppflags.append( '-I %s' % dpath )
, self.__config.include_paths )
@@ -335,7 +334,7 @@
, self.__config.define_symbols )
map( lambda define: cppflags.append( '-U %s' % define )
, self.__config.undefine_symbols )
-
+
cxx = Cxx.Parser( preprocess=True, cppflags=cppflags )
ast = AST.AST()
cxx.process( ast, input=[source_file] )
@@ -344,4 +343,4 @@
declarations = [scanner.global_ns]
self.__dcache.update( ffname, self.__config, declarations, [] )
return declarations
-
+
Deleted: pygccxml_dev/pygccxml/parser/synopsis_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/synopsis_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/synopsis_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -1,36 +0,0 @@
-import os
-import sys
-
-from Synopsis import AST
-from Synopsis.Parsers import Cxx
-
-headers_dir = '/home/roman/language-binding/sources/pygccxml_dev/unittests/data'
-
-offset = 0
-def print_decls( d ):
- global offset
- print offset * ' ', d.name(), d.__class__.__name__
- if hasattr( d, 'declarations' ):
- offset += 1
- for d1 in d.declarations():
- print_decls( d1 )
- offset -= 1
-
-def parse( f ):
- global offset, headers_dir
- print 'file ', f
- cxx = Cxx.Parser(
- preprocess=True
- , cppflags=['-I %s' % headers_dir ] )
-
- ast = AST.AST()
- cxx.process( ast, input=[os.path.join(headers_dir, f )] )
-
- offset = 0
- for d in ast.declarations():
- print_decls( d )
-
-parse( 'declarations_enums.hpp' )
-#for x in os.listdir( headers_dir ):
- #if x.endswith( 'hpp' ):
- #parse( x )
Deleted: pygccxml_dev/pygccxml/parser/synopsis_scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/synopsis_scanner.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/synopsis_scanner.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -1,46 +0,0 @@
-# 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)
-
-import os
-import types
-import pprint
-import warnings
-from Synopsis import AST
-from pygccxml import utils
-from pygccxml.declarations import *
-
-class scanner_t( AST.Visitor, object ):
- def __init__(self, ast, decl_factory ):
- self.logger = utils.loggers.cxx_parser
- self.ast = ast
-
- assert isinstance( decl_factory, decl_factory_t )
- self.__decl_factory = decl_factory
-
- #mapping from id -> decl
- self.__decl = self.__decl_factory.create_namespace( name='::' )
- self.global_ns = self.__decl
-
-
- def read_deaclaration( self, node, decl ):
- #this function should not be called for namespace
- decl.name = node.name()
- decl.location = location_t( file_name=node.file(), line=node.line() )
-
- def visitModule( self, node ):
- ns = self.__decl_factory.create_namespace( name=node.name() )
- self.__decl.adopt_declaration( ns )
- self.__decl = ns
- super( scanner_t, self ).visitModule( node )
-
- def visitEnum( self, node ):
- values = []
- for enumerator in node.enumerators():
- print enumerator.name(), ':', enumerator.value()
- values.append( ( enumerator.name(), enumerator.value() ) )
- enum = self.__decl_factory.create_enumeration( values=values )
- self.read_deaclaration( node, enum )
- self.__decl.adopt_declaration( enum )
- super( scanner_t, self ).visitEnum( node )
Modified: pygccxml_dev/unittests/data/core_cache.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_cache.hpp 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/unittests/data/core_cache.hpp 2008-02-07 07:47:26 UTC (rev 1235)
@@ -22,4 +22,4 @@
#endif//__core_cache_hpp__
-//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
+//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|