pygccxml-commit Mailing List for C++ Python language bindings (Page 24)
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-03-22 22:09:57
|
Revision: 1284
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1284&view=rev
Author: roman_yakovenko
Date: 2008-03-22 15:10:00 -0700 (Sat, 22 Mar 2008)
Log Message:
-----------
porting "data" files to msvc 9.0
Modified Paths:
--------------
pygccxml_dev/unittests/data/attributes.hpp
pygccxml_dev/unittests/data/remove_template_defaults.hpp
Modified: pygccxml_dev/unittests/data/attributes.hpp
===================================================================
--- pygccxml_dev/unittests/data/attributes.hpp 2008-03-17 07:45:39 UTC (rev 1283)
+++ pygccxml_dev/unittests/data/attributes.hpp 2008-03-22 22:10:00 UTC (rev 1284)
@@ -6,6 +6,8 @@
#ifndef __atributes_hpp__
#define __atributes_hpp__
+#ifdef __GCCXML__
+
#define _out_ __attribute( (gccxml( "out" ) ) )
#define _sealed_ __attribute( (gccxml( "sealed" ) ) )
#define _no_throw_ __attribute( (gccxml( "no throw" ) ) )
@@ -20,5 +22,7 @@
}
+#endif//__GCCXML__
+
#endif//__atributes_hpp__
Modified: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp 2008-03-17 07:45:39 UTC (rev 1283)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2008-03-22 22:10:00 UTC (rev 1284)
@@ -13,7 +13,11 @@
#else
#include <hash_set>
#include <hash_map>
- #define HASH_XXX_NS std
+ #ifdef __GCCXML__
+ #define HASH_XXX_NS std
+ #else
+ #define HASH_XXX_NS stdext
+ #endif//GCCXML
#endif
#include <string>
#include <vector>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-17 07:45:33
|
Revision: 1283
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1283&view=rev
Author: roman_yakovenko
Date: 2008-03-17 00:45:39 -0700 (Mon, 17 Mar 2008)
Log Message:
-----------
adding support for Visual Studio 8.0+
Modified Paths:
--------------
pyplusplus_dev/unittests/autoconfig.py
Modified: pyplusplus_dev/unittests/autoconfig.py
===================================================================
--- pyplusplus_dev/unittests/autoconfig.py 2008-03-16 11:13:48 UTC (rev 1282)
+++ pyplusplus_dev/unittests/autoconfig.py 2008-03-17 07:45:39 UTC (rev 1283)
@@ -30,15 +30,17 @@
@staticmethod
def create_sconstruct():
code = [
- "SharedLibrary( target=r'%(target)s'"
- , " , source=[ %(sources)s ]"
- , " , LIBS=[ %s ]" % ','.join( [ 'r"%s"' % lib for lib in scons_config.libs ] )
- , " , LIBPATH=[ %s ]" % ','.join( [ 'r"%s"' % path for path in scons_config.libpath ] )
- , " , CPPPATH=[ %s ]" % ','.join( [ 'r"%s"' % path for path in scons_config.include_dirs] )
- , " , CCFLAGS=[ %s ]" % ','.join( [ 'r"%s"' % flag for flag in scons.ccflags ] )
- , " , SHLIBPREFIX=''"
- , " , SHLIBSUFFIX='%s'" % scons.suffix #explicit better then implicit
- , ")" ]
+ "env = Environment()"
+ , "env.SharedLibrary( target=r'%(target)s'"
+ , " , source=[ %(sources)s ]"
+ , " , LIBS=[ %s ]" % ','.join( [ 'r"%s"' % lib for lib in scons_config.libs ] )
+ , " , LIBPATH=[ %s ]" % ','.join( [ 'r"%s"' % path for path in scons_config.libpath ] )
+ , " , CPPPATH=[ %s ]" % ','.join( [ 'r"%s"' % path for path in scons_config.include_dirs] )
+ , " , CCFLAGS=[ %s ]" % ','.join( [ 'r"%s"' % flag for flag in scons.ccflags ] )
+ , " , SHLIBPREFIX=''"
+ , " , SHLIBSUFFIX='%s'" % scons.suffix #explicit better then implicit
+ , ")"
+ , "env.AddPostAction('%(target)s', 'mt.exe -nologo -manifest %(target)s.pyd.manifest -outputresource:%(target)s.pyd;2' )" ]
return os.linesep.join( code )
#I need this in order to allow Python to load just compiled modules
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-16 11:13:42
|
Revision: 1282
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1282&view=rev
Author: roman_yakovenko
Date: 2008-03-16 04:13:48 -0700 (Sun, 16 Mar 2008)
Log Message:
-----------
small update
Modified Paths:
--------------
pyplusplus_dev/docs/history/history.rest
Modified: pyplusplus_dev/docs/history/history.rest
===================================================================
--- pyplusplus_dev/docs/history/history.rest 2008-03-15 19:46:34 UTC (rev 1281)
+++ pyplusplus_dev/docs/history/history.rest 2008-03-16 11:13:48 UTC (rev 1282)
@@ -20,26 +20,17 @@
* Andy Miller
* Martin Preisler
* Meghana Haridev
+* Julian Scheid
-------------
-Project name
-------------
-
-In version 0.8.1 project has been renamed from "pyplusplus" to "Py++".
-There were few reasons to this:
-
-1. I like "Py++" more then "pyplusplus".
-
-2. "Py++" was the original name of the project: http://mail.python.org/pipermail/c++-sig/2005-July/009280.html
-
-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:
+1. The algorithm, which calculates what member functions should be redefined in
+ derived class wrappers, was improved. Many thanks to Julian Scheid for the bug
+ fix.
+
+ The change explanation.
.. code-block:: C++
@@ -63,10 +54,13 @@
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.
+ Python code won't be executed as the wrapper was missing.
+ **Warning!** **There is a possibility that your generated code will not work!**
+ **Keep reading.**
+
If you use "function transformation" functionality, than it is possible the
- generated code will not compile. Consider next example:
+ generated code will **NOT** work. Consider next example:
.. code-block:: C++
@@ -89,44 +83,57 @@
foo = mb.mem_funs( 'foo' )
foo.add_transformation( FT.output(0) )
- The generated code of wrapper class, for class ``B``, will contain next code:
+ The generated code, for class ``B``, is:
.. code-block:: C++
- virtual void foo() {
- ...
- }
-
- static boost::python::tuple default_foo( ::B & inst ){
- ...
- }
+ namespace bp = boost::python;
+
+ struct B_wrapper : B, bp::wrapper< B > {
+ virtual void foo( int & i ) const { ... }
+
+ static boost::python::tuple default_foo( ::B const & inst )
+ { ... }
+
+ virtual void foo( int & i ) const
+ { ... }
+
+ static boost::python::object default_foo( ::A const & inst )
+ { ... }
+ };
+ ...
+ bp::class_< B_wrapper, bp::bases< A > >( "B" )
+ .def( "foo", (boost::python::tuple (*)( ::B const & ))( &B_wrapper::default_foo ) )
+ .def( "foo", (boost::python::object (*)( ::A const & ))( &B_wrapper::default_foo ) );
- virtual void foo() {
- ...
- }
-
- static boost::python::tuple default_foo( ::B & inst ){
- ...
- }
+ As you can see, after applying the transformation both functions have same
+ signature. Do you know what function will be called in some situation? I do -
+ the wrong one :-(.
- 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.
+ Unfortunately, there is no easy work around or some trick that you can use,
+ which will not break the existing code. I see few solutions to the problem:
- 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
+ * change the alias of the functions
+ .. code-block:: Python
- mb = module_builder_t( ... )
- for f in mb.mem_funs( 'foo' )
- foo.add_transformation( FT.output(0), alias=f.name + '_' + f.parent.name )
+ from pyplusplus import module_builder
+ from pyplusplus import function_transformers as FT
+ mb = module_builder_t( ... )
+ foo = mb.mem_funs( '::A::foo' ).add_transformation( FT.output(0), alias="foo_a" )
+ foo = mb.mem_funs( '::B::foo' ).add_transformation( FT.output(0), alias="foo_b" )
+
+ * use ``inout`` transformation - it preserves a function signature
+
+ * `Py++`_ can introduce a configuration, that will preserve the previous behaviour.
+ I think this is a wrong way to go and doing the API changes is the 'right'
+ longer term solution.
+
+ If you **absolutely need** to preserve API backward compatible, contact me
+ and I will introduce such configuration option.
+
+ Sorry for inconvenience.
-
-------------
Version 0.9.5
-------------
@@ -330,13 +337,16 @@
* ``is_immutable`` - returns ``True`` if exposed type is Python immutable type
+
-------------
Version 0.8.1
-------------
+
1. Georgiy Dernovoy contributed a patch, which allows `Py++`_ GUI to
save\\load last used header file.
+
2. `Py++`_ improved a lot functionality related to providing feedback to user:
* every package has its own logger
@@ -365,8 +375,23 @@
10. Bug fixes.
-11. Documentation was improved..
+11. Documentation was improved.
+
+Project name changed
+--------------------
+
+In this version the project has been renamed from "pyplusplus" to "Py++".
+There were few reasons to this:
+
+1. I like "Py++" more then "pyplusplus".
+
+2. "Py++" was the original name of the project: http://mail.python.org/pipermail/c++-sig/2005-July/009280.html
+
+3. Users always changed the name of the projects. I saw at least 6 different names.
+
+
+
-------------
Version 0.8.0
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-15 19:46:30
|
Revision: 1281
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1281&view=rev
Author: roman_yakovenko
Date: 2008-03-15 12:46:34 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-03-15 19:18:36 UTC (rev 1280)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-03-15 19:46:34 UTC (rev 1281)
@@ -79,7 +79,8 @@
def ns_filter( smbl ):
tags = ( msdia.SymTagFunction
, msdia.SymTagBlock
- , msdia.SymTagData
+ #I should skipp data, because it requier different treatment
+ #, msdia.SymTagData
, msdia.SymTagAnnotation
, msdia.SymTagPublicSymbol
, msdia.SymTagUDT
@@ -100,8 +101,12 @@
elif smbl.classParent:
if smbl.classParent.name:
return False
- elif smbl.classParent.symTag == msdia.SymTagUDT:
- return False
+ parent_smbl = smbl.classParent
+ while parent_smbl:
+ if parent_smbl.symTag == msdia.SymTagUDT:
+ return False
+ else:
+ parent_smbl = parent_smbl.classParent
elif smbl.name.endswith( '__unnamed' ):
return False
return True
@@ -113,6 +118,8 @@
for index, smbl in enumerate( itertools.ifilter( ns_filter, self.symbols.itervalues() ) ):
if index and ( index % 10000 == 0 ):
self.logger.debug( '%d symbols scanned', index )
+ if '_Facetptr<std::ctype<char> >' in smbl.name:
+ i = 0
name_splitter = impl_details.get_name_splitter( smbl.name )
names.update( name_splitter.scope_names )
names = list( names )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-15 19:18:31
|
Revision: 1280
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1280&view=rev
Author: roman_yakovenko
Date: 2008-03-15 12:18:36 -0700 (Sat, 15 Mar 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/__init__.py
pygccxml_dev/pygccxml/msvc/pdb/impl_details.py
pygccxml_dev/unittests/pdb_tester.py
Added Paths:
-----------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
Modified: pygccxml_dev/pygccxml/msvc/pdb/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/__init__.py 2008-03-12 21:11:19 UTC (rev 1279)
+++ pygccxml_dev/pygccxml/msvc/pdb/__init__.py 2008-03-15 19:18:36 UTC (rev 1280)
@@ -19,266 +19,4 @@
finally:
comtypes.client.gen_dir = comtypes_client_gen_dir
-
-
-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 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.__enums = {}
- self.__classes = {}
- self.__typedefs = {}
- 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 impl_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 = impl_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 = impl_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
- , impl_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 = impl_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)
- 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 __create_typedef( self, typedef_smbl ):
- name_splitter = impl_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 )
- 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 = impl_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, class_smbl ):
- name_splitter = impl_details.get_name_splitter( class_smbl.name )
- class_decl = declarations.class_t( name_splitter.name )
- class_decl.class_type = impl_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()
-
- #~ for dia_class in main_classes:
- #~ name_splitter = impl_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()
+from loader import decl_loader_t
\ No newline at end of file
Modified: pygccxml_dev/pygccxml/msvc/pdb/impl_details.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/impl_details.py 2008-03-12 21:11:19 UTC (rev 1279)
+++ pygccxml_dev/pygccxml/msvc/pdb/impl_details.py 2008-03-15 19:18:36 UTC (rev 1280)
@@ -41,22 +41,27 @@
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
-
+ try:
+ 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 and tmp:
+ next_token = tmp.pop()
+ token = token + '::' + next_token
+ less_count += next_token.count( '<' )
+ greater_count += next_token.count( '>' )
+ result.append( token )
+ return result
+ except Exception, err:
+ msg = 'Unable to split scope for identifiers. The full scope name is: "%s". Error: %s'
+ msg = msg % ( self.__full_name, str(err) )
+ raise RuntimeError( msg )
+
__name_splitters = {}
def get_name_splitter( full_name ):
try:
Added: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py (rev 0)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-03-15 19:18:36 UTC (rev 1280)
@@ -0,0 +1,343 @@
+import os
+import sys
+import ctypes
+import pprint
+import logging
+import comtypes
+import itertools
+import comtypes.client
+
+from . import enums
+from . import impl_details
+
+from ... import utils
+from ... import declarations
+from .. import config as msvc_cfg
+
+msdia = comtypes.client.GetModule( msvc_cfg.msdia_path )
+
+SymTagEnum = 12
+msdia.SymTagEnum = 12
+
+def as_symbol( x ):
+ return ctypes.cast( x, ctypes.POINTER( msdia.IDiaSymbol ) )
+
+def as_table( x ):
+ return ctypes.cast( x, ctypes.POINTER( msdia.IDiaTable ) )
+
+def as_enum_symbols( x ):
+ return ctypes.cast( x, ctypes.POINTER( msdia.IDiaEnumSymbols ) )
+
+def as_enum_variant( x ):
+ return ctypes.cast( x, ctypes.POINTER( comtypes.automation.IEnumVARIANT ) )
+
+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 decl_loader_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.__typedefs = {}
+
+ def __find_table(self, name):
+ valid_names = ( 'Symbols', 'SourceFiles', 'Sections'
+ , 'SegmentMap', 'InjectedSource', 'FrameData' )
+ tables = self.__dia_session.getEnumTables()
+ for table in itertools.imap(as_table, tables):
+ if name == table.name:
+ return table
+ else:
+ return None
+
+ @utils.cached
+ def symbols_table(self):
+ return self.__find_table( "Symbols" )
+
+ @utils.cached
+ def symbols(self):
+ smbls = {}
+ for smbl in itertools.imap( as_symbol, as_enum_variant( self.symbols_table._NewEnum ) ):
+ smbls[ smbl.symIndexId ] = smbl
+ return smbls
+
+ def __load_nss(self):
+ def ns_filter( smbl ):
+ tags = ( msdia.SymTagFunction
+ , msdia.SymTagBlock
+ , msdia.SymTagData
+ , msdia.SymTagAnnotation
+ , msdia.SymTagPublicSymbol
+ , msdia.SymTagUDT
+ , msdia.SymTagEnum
+ , msdia.SymTagFunctionType
+ , msdia.SymTagPointerType
+ , msdia.SymTagArrayType
+ , msdia.SymTagBaseType
+ , msdia.SymTagTypedef
+ , msdia.SymTagBaseClass
+ , msdia.SymTagFriend
+ , msdia.SymTagFunctionArgType
+ , msdia.SymTagUsingNamespace )
+ if smbl.symTag not in tags:
+ return False
+ elif not smbl.name:
+ return False
+ elif smbl.classParent:
+ if smbl.classParent.name:
+ return False
+ elif smbl.classParent.symTag == msdia.SymTagUDT:
+ return False
+ elif smbl.name.endswith( '__unnamed' ):
+ return False
+ return True
+
+ self.logger.debug( 'scanning symbols table' )
+
+ self.logger.debug( 'looking for scopes' )
+ names = set()
+ for index, smbl in enumerate( itertools.ifilter( ns_filter, self.symbols.itervalues() ) ):
+ if index and ( index % 10000 == 0 ):
+ self.logger.debug( '%d symbols scanned', index )
+ name_splitter = impl_details.get_name_splitter( smbl.name )
+ names.update( name_splitter.scope_names )
+ names = list( names )
+ names.sort()
+ self.logger.debug( 'looking for scopes - done' )
+
+ nss = {'': self.__global_ns}
+
+ self.logger.debug( 'building namespace objects' )
+ for ns_name in itertools.ifilterfalse( self.__find_udt, names ):
+ name_splitter = impl_details.get_name_splitter( ns_name )
+ if not name_splitter.scope_names:
+ parent_ns = self.global_ns
+ else:
+ parent_ns = nss[ name_splitter.scope_names[-1] ]
+ ns_decl = declarations.namespace_t( name_splitter.name )
+ parent_ns.adopt_declaration( ns_decl )
+ nss[ ns_name ] = ns_decl
+ self.logger.debug( 'building namespace objects - done' )
+
+ self.logger.debug( 'scanning symbols table - done' )
+ def read(self):
+ self.__load_nss()
+ #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 = enums.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 as_symbol( 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 [as_symbol( s ) for s in iter(found)]
+ #~ for s in iter(found):
+ #~ s =
+ #~ print s.name
+ #~ print impl_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 itertools.imap(as_symbol, dia_classes ):
+ name_splitter = impl_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 itertools.imap(as_symbol, found):
+ self.logger.debug( '\t\tinner UDT found - %s' % inner_dia_class.name )
+ inner_name_splitter = impl_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
+ , impl_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 = impl_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 itertools.imap(as_symbol, values):
+ 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 )
+ enum_smbls = parent_symbol.findChildren( SymTagEnum, None, 0 )
+ for enum_smbl in itertools.imap(as_symbol, enum_smbls ):
+ 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 __create_typedef( self, typedef_smbl ):
+ name_splitter = impl_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 )
+ typedef_smbls = parent_symbol.findChildren( SymTagTypedef, None, 0 )
+ for typedef_smbl in itertools.imap(as_symbol, typedef_smbls ):
+ 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 )
+ class_smbls = parent_symbol.findChildren( msdia.SymTagUDT, None, 0 )
+ for class_smbl in itertools.imap(as_symbol, class_smbls ):
+ 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_class( self, class_smbl ):
+ name_splitter = impl_details.get_name_splitter( class_smbl.name )
+ class_decl = declarations.class_t( name_splitter.name )
+ class_decl.class_type = impl_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()
+
+ #~ for dia_class in main_classes:
+ #~ name_splitter = impl_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' ) )
+
Modified: pygccxml_dev/unittests/pdb_tester.py
===================================================================
--- pygccxml_dev/unittests/pdb_tester.py 2008-03-12 21:11:19 UTC (rev 1279)
+++ pygccxml_dev/unittests/pdb_tester.py 2008-03-15 19:18:36 UTC (rev 1280)
@@ -9,16 +9,37 @@
def __init__(self, *args):
unittest.TestCase.__init__(self, *args)
- def test(self):
+ def __test_splitter_impl( self, name, expected_result ):
+ splitter = pdb.impl_details.full_name_splitter_t( name )
+ self.failUnless( len(splitter.scope_names) == len(expected_result) )
+ self.failUnless( splitter.scope_names == expected_result )
+
+ def __test_name_splitter(self):
+ name = "std::_Tree<std::_Tmap_traits<engine_objects::ouuid_t,engine_objects::sql_query::parameterized_query::sql_fragment_t,std::less<engine_objects::ouuid_t>,std::allocator<std::pair<engine_objects::ouuid_t const ,engine_objects::sql_query::parameterized_query::sql_fragment_t> >,0> >::const_iterator::operator->"
+ expected_result = [
+ 'std'
+ , 'std::_Tree<std::_Tmap_traits<engine_objects::ouuid_t,engine_objects::sql_query::parameterized_query::sql_fragment_t,std::less<engine_objects::ouuid_t>,std::allocator<std::pair<engine_objects::ouuid_t const ,engine_objects::sql_query::parameterized_query::sql_fragment_t> >,0> >', 'std::_Tree<std::_Tmap_traits<engine_objects::ouuid_t,engine_objects::sql_query::parameterized_query::sql_fragment_t,std::less<engine_objects::ouuid_t>,std::allocator<std::pair<engine_objects::ouuid_t const ,engine_objects::sql_query::parameterized_query::sql_fragment_t> >,0> >::const_iterator'
+ ]
+ self.__test_splitter_impl( name, expected_result )
+
+ name = 'boost::reference_wrapper<engine_objects::ops::pathable_t const >::operator engine_objects::ops::pathable_t const &'
+ expected_result = [
+ 'boost'
+ , 'boost::reference_wrapper<engine_objects::ops::pathable_t const >'
+ ]
+ self.__test_splitter_impl( name, expected_result )
+
+ def test_create_nss(self):
control_pdb = os.path.join( autoconfig.data_directory, r'xxx.pdb' )
- reader = pdb.reader_t( control_pdb )
+ reader = pdb.decl_loader_t( control_pdb )
+ print reader.symbols_table.name
reader.read()
f = file( 'decls.cpp', 'w+' )
- declarations.print_declarations( reader.global_ns, writer=f.write )
+ declarations.print_declarations( reader.global_ns )#, writer=f.write )
f.close()
def create_suite():
- suite = unittest.TestSuite()
+ suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
return suite
@@ -26,4 +47,4 @@
unittest.TextTestRunner(verbosity=2).run( create_suite() )
if __name__ == "__main__":
- run_suite()
\ No newline at end of file
+ run_suite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-12 21:11:13
|
Revision: 1279
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1279&view=rev
Author: roman_yakovenko
Date: 2008-03-12 14:11:19 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
adding new unit testers
Added Paths:
-----------
pygccxml_dev/unittests/bsc_tester.py
pygccxml_dev/unittests/data/xxx.bsc.bz2
pygccxml_dev/unittests/data/xxx.pdb.bz2
pygccxml_dev/unittests/pdb_tester.py
Added: pygccxml_dev/unittests/bsc_tester.py
===================================================================
--- pygccxml_dev/unittests/bsc_tester.py (rev 0)
+++ pygccxml_dev/unittests/bsc_tester.py 2008-03-12 21:11:19 UTC (rev 1279)
@@ -0,0 +1,31 @@
+import os
+import unittest
+import autoconfig
+
+from pygccxml.msvc import bsc
+
+class tester_t( unittest.TestCase ):
+ def __init__(self, *args):
+ unittest.TestCase.__init__(self, *args)
+
+ def test(self):
+ control_bsc = os.path.join( autoconfig.data_directory, r'xxx.bsc' )
+ reader = bsc.reader_t( control_bsc )
+ reader.print_stat()
+ print 'is_case_sensitive', reader.is_case_sensitive
+ reader.load_instances()
+ print 'done'
+ #reader.files
+ #reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
+
+
+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()
\ No newline at end of file
Added: pygccxml_dev/unittests/data/xxx.bsc.bz2
===================================================================
(Binary files differ)
Property changes on: pygccxml_dev/unittests/data/xxx.bsc.bz2
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: pygccxml_dev/unittests/data/xxx.pdb.bz2
===================================================================
(Binary files differ)
Property changes on: pygccxml_dev/unittests/data/xxx.pdb.bz2
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: pygccxml_dev/unittests/pdb_tester.py
===================================================================
--- pygccxml_dev/unittests/pdb_tester.py (rev 0)
+++ pygccxml_dev/unittests/pdb_tester.py 2008-03-12 21:11:19 UTC (rev 1279)
@@ -0,0 +1,29 @@
+import os
+import unittest
+import autoconfig
+
+from pygccxml.msvc import pdb
+from pygccxml import declarations
+
+class tester_t( unittest.TestCase ):
+ def __init__(self, *args):
+ unittest.TestCase.__init__(self, *args)
+
+ def test(self):
+ control_pdb = os.path.join( autoconfig.data_directory, 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()
+
+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()
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-12 21:03:35
|
Revision: 1278
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1278&view=rev
Author: roman_yakovenko
Date: 2008-03-12 14:03:41 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
massive refactoring - better package structure
Added Paths:
-----------
pygccxml_dev/pygccxml/msvc/__init__.py
pygccxml_dev/pygccxml/msvc/bsc/
pygccxml_dev/pygccxml/msvc/bsc/__init__.py
pygccxml_dev/pygccxml/msvc/bsc/c_wrapper.py
pygccxml_dev/pygccxml/msvc/config.py
pygccxml_dev/pygccxml/msvc/pdb/
pygccxml_dev/pygccxml/msvc/pdb/__init__.py
pygccxml_dev/pygccxml/msvc/pdb/enums.py
pygccxml_dev/pygccxml/msvc/pdb/impl_details.py
Removed Paths:
-------------
pygccxml_dev/pygccxml/msvc/bsc.py
pygccxml_dev/pygccxml/msvc/details.py
pygccxml_dev/pygccxml/msvc/msvc_details.py
pygccxml_dev/pygccxml/msvc/scanner.py
Added: pygccxml_dev/pygccxml/msvc/__init__.py
===================================================================
Added: pygccxml_dev/pygccxml/msvc/bsc/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/bsc/__init__.py (rev 0)
+++ pygccxml_dev/pygccxml/msvc/bsc/__init__.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -0,0 +1,279 @@
+import os
+import sys
+import logging
+
+from c_wrapper import *
+
+class definition_t(object):
+ #represents some other symbol
+ def __init__( self, def_id, bsc ):
+ self.__bsc = bsc
+ self.__def_id = def_id
+
+ @property
+ def def_id(self):
+ return self.__def_id
+
+ @utils.cached
+ def location( self ):
+ module = STRING()
+ line = LINE()
+ if not BSCIdefInfo( self.__bsc, self.def_id, byref( module ), byref( line ) ):
+ raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__def_id ) )
+ return (module, line)
+
+ @utils.cached
+ def file_name(self):
+ return self.location[0].value
+
+ @utils.cached
+ def line(self):
+ return self.location[1].value
+
+ def __str__( self ):
+ return self.file_name + ': %d' % self.line + ' name: %s' % self.as_instance.name
+
+ @utils.cached
+ def as_instance(self):
+ return self.__bsc.create_instance( BSCIinstFrIdef( self.__bsc, self.def_id) )
+
+class instance_t(object):
+ #represents some symbol
+ def __init__( self, inst_id, bsc ):
+ self.__bsc = bsc
+ self.__inst_id = inst_id
+
+ @property
+ def inst_id(self):
+ return self.__inst_id
+
+ @utils.cached
+ def name_type_attribute_mangled_name( self ):
+ name = STRING()
+ typ = TYP()
+ attribute = ATR()
+ if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ):
+ raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) )
+ undecorated_name = BSCFormatDname( self.__bsc, name )
+ return undecorated_name, typ, attribute, name.value
+
+
+ @utils.cached
+ def mangled_name(self):
+ return self.name_type_attribute_mangled_name[3]
+
+ @utils.cached
+ def name(self):
+ return self.name_type_attribute_mangled_name[0]
+
+ @utils.cached
+ def type(self):
+ return self.name_type_attribute_mangled_name[1].value
+
+ @utils.cached
+ def attribute(self):
+ return self.name_type_attribute_mangled_name[2].value
+
+ def __str__( self ):
+ tmp = []
+ if enums.TYPES.has_value( self.type ):
+ tmp.append( 'type( "%s" )' % enums.TYPES.name_of( self.type ) )
+ if enums.ATTRIBUTES.has_value( self.attribute ):
+ tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) )
+ tmp.append( 'name( "%s" )' % self.name )
+ tmp.append( 'mangled name( "%s" )' % self.mangled_name )
+ return ', '.join( tmp )
+
+
+ @utils.cached
+ def definitions( self ):
+ definitions_len = ULONG(0)
+ definitions_ids = pointer( IDEF() )
+
+ if not BSCGetDefArray( self.__bsc, self.inst_id, byref( definitions_ids ), byref( definitions_len ) ):
+ raise RuntimeError( "Unable to call BSCGetDefArray" )
+
+ definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc )
+ , range( definitions_len.value ) )
+
+ BSCDisposeArray( self.__bsc, definitions_ids )
+ return definitions
+
+ @utils.cached
+ def members( self ):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetMembersArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetMembersArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+ @utils.cached
+ def used_symbols(self):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetUsesArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetUsesArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+ @utils.cached
+ def base_classes(self):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetBaseArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetBaseArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+ @utils.cached
+ def derived_classes(self):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetDervArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetDervArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+class module_t(object):
+ #represents file
+ def __init__( self, mod_id, bsc ):
+ self.__bsc = bsc
+ self.__mod_id = mod_id
+
+ @property
+ def mod_id( self ):
+ return self.__mod_id
+
+ @utils.cached
+ def path( self ):
+ name = STRING()
+ BSCImodInfo(self.__bsc, self.__mod_id, byref(name))
+ return name.value
+
+ @utils.cached
+ def instances( self ):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetModuleContents" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+class reader_t( object ):
+ def __init__( self, bsc_file ):
+ self.logger = utils.loggers.pdb_reader
+ self.logger.setLevel(logging.INFO)
+
+ self.__bsc_file = bsc_file
+ self.__bsc = pointer( Bsc() )
+ if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ):
+ raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file )
+
+ self.__instances_cache = {} #inst id : instance_t
+ self.__bsc.create_instance = lambda inst_id: self.__create_instance( inst_id )
+
+ def __create_instance( self, inst_id ):
+ try:
+ return self.__instances_cache[ inst_id ]
+ except KeyError:
+ inst = instance_t( inst_id, self.__bsc )
+ self.__instances_cache[ inst_id ] = inst
+ return inst
+
+ def load_instances( self ):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to load all globals symbols" )
+
+ for i in range( instances_len.value ):
+ self.__create_instance( instances_ids[i] )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+
+ @utils.cached
+ def is_case_sensitive( self ):
+ return bool( BSCFCaseSensitive( self.__bsc ) )
+
+ @utils.cached
+ def files(self):
+ module_ids = pointer( IMOD() )
+ module_len = ULONG()
+ bs = BSC_STAT()
+
+ if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_len) ):
+ raise RuntimeError( "Unable to load all modules" )
+
+ modules = map( lambda i: module_t( module_ids[i], self.__bsc )
+ , range( module_len.value ) )
+
+ BSCDisposeArray( self.__bsc, module_ids )
+
+ return modules
+
+ def print_stat( self ):
+ stat = BSC_STAT()
+ BSCGetStatistics( self.__bsc, byref( stat ) )
+ for f, t in stat._fields_:
+ print '%s: %s' % ( f, str( getattr( stat, f) ) )
+
+ def print_classes(self, file_name=None):
+ for m in self.files:
+ if file_name and m.path != file_name:
+ continue
+ print 'File: ', m.path
+ if m.instances:
+ print '\tInstances:'
+ for inst in m.instances:
+ print '\t\t', str(inst)
+ if inst.definitions:
+ print '\t\t\tDefinitions:'
+ for definition in inst.definitions:
+ print '\t\t\t\t', str( definition )
+ if inst.members:
+ print '\t\t\tMembers:'
+ for member in inst.members:
+ print '\t\t\t\t', str( member )
+ if inst.used_symbols:
+ print '\t\t\tUsed symbols:'
+ for used_symbol in inst.used_symbols:
+ print '\t\t\t\t', str( used_symbol )
+ if inst.base_classes:
+ print '\t\t\tBase classes:'
+ for base_class in inst.base_classes:
+ print '\t\t\t\t', str( base_class )
+ if inst.derived_classes:
+ print '\t\t\tDerived classes:'
+ for derived_class in inst.derived_classes:
+ print '\t\t\t\t', str( derived_class )
+
+ def __del__( self ):
+ if self.__bsc:
+ BSCClose( self.__bsc )
Added: pygccxml_dev/pygccxml/msvc/bsc/c_wrapper.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/bsc/c_wrapper.py (rev 0)
+++ pygccxml_dev/pygccxml/msvc/bsc/c_wrapper.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -0,0 +1,284 @@
+import os
+import sys
+import ctypes
+import logging
+
+from ctypes import *
+from ctypes.wintypes import ULONG
+from ctypes.wintypes import DWORD
+from ctypes.wintypes import BOOL
+from ctypes.wintypes import BYTE
+from ctypes.wintypes import WORD
+from ctypes.wintypes import UINT
+
+from .. import config as msvc_cfg#
+from ... import utils #import utils from pygccxml package
+
+STRING = c_char_p
+_libraries = {}
+_libraries['msvcr70.dll'] = CDLL(msvc_cfg.msvcr_path, mode=RTLD_GLOBAL)
+_libraries['msbsc70.dll'] = CDLL(msvc_cfg.msbsc_path, mode=RTLD_GLOBAL)
+
+
+qyMac = 9
+refreshAllOp = 4
+qyDervOf = 7
+delOp = 1
+qyImpMembers = 8
+changeOp = 2
+qyRefs = 4
+qyCalls = 2
+changeIinstOp = 3
+qyContains = 1
+qyCalledBy = 3
+noOp = 5
+qyBaseOf = 6
+qyNil = 0
+addOp = 0
+qyDefs = 5
+PULONG = POINTER(ULONG)
+USHORT = c_ushort
+PUSHORT = POINTER(USHORT)
+UCHAR = c_ubyte
+PUCHAR = POINTER(UCHAR)
+PSZ = STRING
+FLOAT = c_float
+PFLOAT = POINTER(FLOAT)
+PBOOL = POINTER(BOOL)
+LPBOOL = POINTER(BOOL)
+PBYTE = POINTER(BYTE)
+LPBYTE = POINTER(BYTE)
+PINT = POINTER(c_int)
+LPINT = POINTER(c_int)
+PWORD = POINTER(WORD)
+LPWORD = POINTER(WORD)
+LPLONG = POINTER(c_long)
+PDWORD = POINTER(DWORD)
+LPDWORD = POINTER(DWORD)
+LPVOID = c_void_p
+LPCVOID = c_void_p
+INT = c_int
+PUINT = POINTER(c_uint)
+ULONG_PTR = POINTER(ULONG)
+NI = ULONG
+IINST = ULONG
+IREF = ULONG
+IDEF = ULONG
+IMOD = USHORT
+LINE = USHORT
+TYP = BYTE
+ATR = USHORT
+ATR32 = ULONG
+MBF = ULONG
+SZ = STRING
+SZ_CONST = STRING
+
+class Bsc(Structure):
+ pass
+
+# values for enumeration 'OPERATION'
+OPERATION = c_int # enum
+class IinstInfo(Structure):
+ pass
+IinstInfo._fields_ = [
+ ('m_iinst', IINST),
+ ('m_szName', SZ_CONST),
+ ('m_ni', NI),
+]
+class BSC_STAT(Structure):
+ pass
+BSC_STAT._fields_ = [
+ ('cDef', ULONG),
+ ('cRef', ULONG),
+ ('cInst', ULONG),
+ ('cMod', ULONG),
+ ('cUseLink', ULONG),
+ ('cBaseLink', ULONG),
+]
+class NiQ(Structure):
+ pass
+NiQ._fields_ = [
+ ('m_iinstOld', IINST),
+ ('m_iInfoNew', IinstInfo),
+ ('m_op', OPERATION),
+ ('m_typ', TYP),
+]
+pfnNotifyChange = CFUNCTYPE(BOOL, POINTER(NiQ), ULONG, ULONG_PTR)
+
+# values for enumeration '_qy_'
+_qy_ = c_int # enum
+QY = _qy_
+Bsc._fields_ = [
+]
+BSCOpen = _libraries['msbsc70.dll'].BSCOpen
+BSCOpen.restype = BOOL
+BSCOpen.argtypes = [SZ_CONST, POINTER(POINTER(Bsc))]
+BSCClose = _libraries['msbsc70.dll'].BSCClose
+BSCClose.restype = BOOL
+BSCClose.argtypes = [POINTER(Bsc)]
+BSCIinstInfo = _libraries['msbsc70.dll'].BSCIinstInfo
+BSCIinstInfo.restype = BOOL
+BSCIinstInfo.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR)]
+BSCIrefInfo = _libraries['msbsc70.dll'].BSCIrefInfo
+BSCIrefInfo.restype = BOOL
+BSCIrefInfo.argtypes = [POINTER(Bsc), IREF, POINTER(SZ), POINTER(LINE)]
+BSCIdefInfo = _libraries['msbsc70.dll'].BSCIdefInfo
+BSCIdefInfo.restype = BOOL
+BSCIdefInfo.argtypes = [POINTER(Bsc), IDEF, POINTER(SZ), POINTER(LINE)]
+BSCImodInfo = _libraries['msbsc70.dll'].BSCImodInfo
+BSCImodInfo.restype = BOOL
+BSCImodInfo.argtypes = [POINTER(Bsc), IMOD, POINTER(SZ)]
+BSCSzFrTyp = _libraries['msbsc70.dll'].BSCSzFrTyp
+BSCSzFrTyp.restype = SZ
+BSCSzFrTyp.argtypes = [POINTER(Bsc), TYP]
+BSCSzFrAtr = _libraries['msbsc70.dll'].BSCSzFrAtr
+BSCSzFrAtr.restype = SZ
+BSCSzFrAtr.argtypes = [POINTER(Bsc), ATR]
+BSCGetIinstByvalue = _libraries['msbsc70.dll'].BSCGetIinstByvalue
+BSCGetIinstByvalue.restype = BOOL
+BSCGetIinstByvalue.argtypes = [POINTER(Bsc), SZ, TYP, ATR, POINTER(IINST)]
+BSCGetOverloadArray = _libraries['msbsc70.dll'].BSCGetOverloadArray
+BSCGetOverloadArray.restype = BOOL
+BSCGetOverloadArray.argtypes = [POINTER(Bsc), SZ, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetUsedByArray = _libraries['msbsc70.dll'].BSCGetUsedByArray
+BSCGetUsedByArray.restype = BOOL
+BSCGetUsedByArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetUsesArray = _libraries['msbsc70.dll'].BSCGetUsesArray
+BSCGetUsesArray.restype = BOOL
+BSCGetUsesArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetBaseArray = _libraries['msbsc70.dll'].BSCGetBaseArray
+BSCGetBaseArray.restype = BOOL
+BSCGetBaseArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetDervArray = _libraries['msbsc70.dll'].BSCGetDervArray
+BSCGetDervArray.restype = BOOL
+BSCGetDervArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetMembersArray = _libraries['msbsc70.dll'].BSCGetMembersArray
+BSCGetMembersArray.restype = BOOL
+BSCGetMembersArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetDefArray = _libraries['msbsc70.dll'].BSCGetDefArray
+BSCGetDefArray.restype = BOOL
+BSCGetDefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
+BSCGetRefArray = _libraries['msbsc70.dll'].BSCGetRefArray
+BSCGetRefArray.restype = BOOL
+BSCGetRefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
+BSCGetModuleContents = _libraries['msbsc70.dll'].BSCGetModuleContents
+BSCGetModuleContents.restype = BOOL
+BSCGetModuleContents.argtypes = [POINTER(Bsc), IMOD, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetModuleByName = _libraries['msbsc70.dll'].BSCGetModuleByName
+BSCGetModuleByName.restype = BOOL
+BSCGetModuleByName.argtypes = [POINTER(Bsc), SZ, POINTER(IMOD)]
+BSCGetAllModulesArray = _libraries['msbsc70.dll'].BSCGetAllModulesArray
+BSCGetAllModulesArray.restype = BOOL
+BSCGetAllModulesArray.argtypes = [POINTER(Bsc), POINTER(POINTER(IMOD)), POINTER(ULONG)]
+BSCDisposeArray = _libraries['msbsc70.dll'].BSCDisposeArray
+BSCDisposeArray.restype = None
+BSCDisposeArray.argtypes = [POINTER(Bsc), c_void_p]
+BSCFormatDname = _libraries['msbsc70.dll'].BSCFormatDname
+BSCFormatDname.restype = SZ
+BSCFormatDname.argtypes = [POINTER(Bsc), SZ]
+BSCFInstFilter = _libraries['msbsc70.dll'].BSCFInstFilter
+BSCFInstFilter.restype = BOOL
+BSCFInstFilter.argtypes = [POINTER(Bsc), IINST, MBF]
+BSCIinstFrIref = _libraries['msbsc70.dll'].BSCIinstFrIref
+BSCIinstFrIref.restype = IINST
+BSCIinstFrIref.argtypes = [POINTER(Bsc), IREF]
+BSCIinstFrIdef = _libraries['msbsc70.dll'].BSCIinstFrIdef
+BSCIinstFrIdef.restype = IINST
+BSCIinstFrIdef.argtypes = [POINTER(Bsc), IDEF]
+BSCIinstContextIref = _libraries['msbsc70.dll'].BSCIinstContextIref
+BSCIinstContextIref.restype = IINST
+BSCIinstContextIref.argtypes = [POINTER(Bsc), IREF]
+BSCGetStatistics = _libraries['msbsc70.dll'].BSCGetStatistics
+BSCGetStatistics.restype = BOOL
+BSCGetStatistics.argtypes = [POINTER(Bsc), POINTER(BSC_STAT)]
+BSCGetModuleStatistics = _libraries['msbsc70.dll'].BSCGetModuleStatistics
+BSCGetModuleStatistics.restype = BOOL
+BSCGetModuleStatistics.argtypes = [POINTER(Bsc), IMOD, POINTER(BSC_STAT)]
+BSCFCaseSensitive = _libraries['msbsc70.dll'].BSCFCaseSensitive
+BSCFCaseSensitive.restype = BOOL
+BSCFCaseSensitive.argtypes = [POINTER(Bsc)]
+BSCSetCaseSensitivity = _libraries['msbsc70.dll'].BSCSetCaseSensitivity
+BSCSetCaseSensitivity.restype = BOOL
+BSCSetCaseSensitivity.argtypes = [POINTER(Bsc), BOOL]
+BSCGetAllGlobalsArray = _libraries['msbsc70.dll'].BSCGetAllGlobalsArray
+BSCGetAllGlobalsArray.restype = BOOL
+BSCGetAllGlobalsArray.argtypes = [POINTER(Bsc), MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCSzFrAtr2 = _libraries['msbsc70.dll'].BSCSzFrAtr2
+BSCSzFrAtr2.restype = SZ
+BSCSzFrAtr2.argtypes = [POINTER(Bsc), ATR32]
+BSCIinstInfo2 = _libraries['msbsc70.dll'].BSCIinstInfo2
+BSCIinstInfo2.restype = BOOL
+BSCIinstInfo2.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR32)]
+BSCGetIinstByvalue2 = _libraries['msbsc70.dll'].BSCGetIinstByvalue2
+BSCGetIinstByvalue2.restype = BOOL
+BSCGetIinstByvalue2.argtypes = [POINTER(Bsc), SZ, TYP, ATR32, POINTER(IINST)]
+OpenBSCQuery = _libraries['msbsc70.dll'].OpenBSCQuery
+OpenBSCQuery.restype = BOOL
+OpenBSCQuery.argtypes = [POINTER(Bsc)]
+CloseBSCQuery = _libraries['msbsc70.dll'].CloseBSCQuery
+CloseBSCQuery.restype = BOOL
+CloseBSCQuery.argtypes = []
+BOB = ULONG
+InitBSCQuery = _libraries['msbsc70.dll'].InitBSCQuery
+InitBSCQuery.restype = BOOL
+InitBSCQuery.argtypes = [QY, BOB]
+BobNext = _libraries['msbsc70.dll'].BobNext
+BobNext.restype = BOB
+BobNext.argtypes = []
+BobFrName = _libraries['msbsc70.dll'].BobFrName
+BobFrName.restype = BOB
+BobFrName.argtypes = [SZ]
+LszNameFrBob = _libraries['msbsc70.dll'].LszNameFrBob
+LszNameFrBob.restype = SZ
+LszNameFrBob.argtypes = [BOB]
+CLS = USHORT
+
+class enums:
+ class MBF(utils.enum):
+ NIL = 0x000
+ VARS = 0x001
+ FUNCS = 0x002
+ MACROS = 0x004
+ TYPES = 0x008
+ CLASS = 0x010
+ INCL = 0x020
+ MSGMAP = 0x040
+ DIALOGID = 0x080
+ LIBRARY = 0x100
+ IMPORT = 0x200
+ TEMPLATE = 0x400
+ NAMESPACE = 0x800
+ ALL = 0xFFF
+
+ class TYPES(utils.enum):
+ FUNCTION = 0x01
+ LABEL = 0x02
+ PARAMETER = 0x03
+ VARIABLE = 0x04
+ CONSTANT = 0x05
+ MACRO = 0x06
+ TYPEDEF = 0x07
+ STRUCNAM = 0x08
+ ENUMNAM = 0x09
+ ENUMMEM = 0x0A
+ UNIONNAM = 0x0B
+ SEGMENT = 0x0C
+ GROUP = 0x0D
+ PROGRAM = 0x0E
+ CLASSNAM = 0x0F
+ MEMFUNC = 0x10
+ MEMVAR = 0x11
+
+ class ATTRIBUTES(utils.enum):
+ LOCAL = 0x001
+ STATIC = 0x002
+ SHARED = 0x004
+ NEAR = 0x008
+ COMMON = 0x010
+ DECL_ONLY = 0x020
+ PUBLIC = 0x040
+ NAMED = 0x080
+ MODULE = 0x100
+ VIRTUAL = 0x200
+ PRIVATE = 0x400
+ PROTECT = 0x800
Deleted: pygccxml_dev/pygccxml/msvc/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/bsc.py 2008-03-12 11:59:29 UTC (rev 1277)
+++ pygccxml_dev/pygccxml/msvc/bsc.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -1,568 +0,0 @@
-import os
-import sys
-import ctypes
-import logging
-import msvc_details
-from ctypes import *
-from ctypes.wintypes import ULONG
-from ctypes.wintypes import DWORD
-from ctypes.wintypes import BOOL
-from ctypes.wintypes import BYTE
-from ctypes.wintypes import WORD
-from ctypes.wintypes import UINT
-
-sys.path.append( r'../..' )
-
-from pygccxml import utils
-from pygccxml import declarations
-
-
-STRING = c_char_p
-_libraries = {}
-_libraries['msvcr70.dll'] = CDLL(msvc_details.msvcr_path, mode=RTLD_GLOBAL)
-_libraries['msbsc70.dll'] = CDLL(msvc_details.msbsc_path, mode=RTLD_GLOBAL)
-
-
-qyMac = 9
-refreshAllOp = 4
-qyDervOf = 7
-delOp = 1
-qyImpMembers = 8
-changeOp = 2
-qyRefs = 4
-qyCalls = 2
-changeIinstOp = 3
-qyContains = 1
-qyCalledBy = 3
-noOp = 5
-qyBaseOf = 6
-qyNil = 0
-addOp = 0
-qyDefs = 5
-PULONG = POINTER(ULONG)
-USHORT = c_ushort
-PUSHORT = POINTER(USHORT)
-UCHAR = c_ubyte
-PUCHAR = POINTER(UCHAR)
-PSZ = STRING
-FLOAT = c_float
-PFLOAT = POINTER(FLOAT)
-PBOOL = POINTER(BOOL)
-LPBOOL = POINTER(BOOL)
-PBYTE = POINTER(BYTE)
-LPBYTE = POINTER(BYTE)
-PINT = POINTER(c_int)
-LPINT = POINTER(c_int)
-PWORD = POINTER(WORD)
-LPWORD = POINTER(WORD)
-LPLONG = POINTER(c_long)
-PDWORD = POINTER(DWORD)
-LPDWORD = POINTER(DWORD)
-LPVOID = c_void_p
-LPCVOID = c_void_p
-INT = c_int
-PUINT = POINTER(c_uint)
-ULONG_PTR = POINTER(ULONG)
-NI = ULONG
-IINST = ULONG
-IREF = ULONG
-IDEF = ULONG
-IMOD = USHORT
-LINE = USHORT
-TYP = BYTE
-ATR = USHORT
-ATR32 = ULONG
-MBF = ULONG
-SZ = STRING
-SZ_CONST = STRING
-
-class Bsc(Structure):
- pass
-
-# values for enumeration 'OPERATION'
-OPERATION = c_int # enum
-class IinstInfo(Structure):
- pass
-IinstInfo._fields_ = [
- ('m_iinst', IINST),
- ('m_szName', SZ_CONST),
- ('m_ni', NI),
-]
-class BSC_STAT(Structure):
- pass
-BSC_STAT._fields_ = [
- ('cDef', ULONG),
- ('cRef', ULONG),
- ('cInst', ULONG),
- ('cMod', ULONG),
- ('cUseLink', ULONG),
- ('cBaseLink', ULONG),
-]
-class NiQ(Structure):
- pass
-NiQ._fields_ = [
- ('m_iinstOld', IINST),
- ('m_iInfoNew', IinstInfo),
- ('m_op', OPERATION),
- ('m_typ', TYP),
-]
-pfnNotifyChange = CFUNCTYPE(BOOL, POINTER(NiQ), ULONG, ULONG_PTR)
-
-# values for enumeration '_qy_'
-_qy_ = c_int # enum
-QY = _qy_
-Bsc._fields_ = [
-]
-BSCOpen = _libraries['msbsc70.dll'].BSCOpen
-BSCOpen.restype = BOOL
-BSCOpen.argtypes = [SZ_CONST, POINTER(POINTER(Bsc))]
-BSCClose = _libraries['msbsc70.dll'].BSCClose
-BSCClose.restype = BOOL
-BSCClose.argtypes = [POINTER(Bsc)]
-BSCIinstInfo = _libraries['msbsc70.dll'].BSCIinstInfo
-BSCIinstInfo.restype = BOOL
-BSCIinstInfo.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR)]
-BSCIrefInfo = _libraries['msbsc70.dll'].BSCIrefInfo
-BSCIrefInfo.restype = BOOL
-BSCIrefInfo.argtypes = [POINTER(Bsc), IREF, POINTER(SZ), POINTER(LINE)]
-BSCIdefInfo = _libraries['msbsc70.dll'].BSCIdefInfo
-BSCIdefInfo.restype = BOOL
-BSCIdefInfo.argtypes = [POINTER(Bsc), IDEF, POINTER(SZ), POINTER(LINE)]
-BSCImodInfo = _libraries['msbsc70.dll'].BSCImodInfo
-BSCImodInfo.restype = BOOL
-BSCImodInfo.argtypes = [POINTER(Bsc), IMOD, POINTER(SZ)]
-BSCSzFrTyp = _libraries['msbsc70.dll'].BSCSzFrTyp
-BSCSzFrTyp.restype = SZ
-BSCSzFrTyp.argtypes = [POINTER(Bsc), TYP]
-BSCSzFrAtr = _libraries['msbsc70.dll'].BSCSzFrAtr
-BSCSzFrAtr.restype = SZ
-BSCSzFrAtr.argtypes = [POINTER(Bsc), ATR]
-BSCGetIinstByvalue = _libraries['msbsc70.dll'].BSCGetIinstByvalue
-BSCGetIinstByvalue.restype = BOOL
-BSCGetIinstByvalue.argtypes = [POINTER(Bsc), SZ, TYP, ATR, POINTER(IINST)]
-BSCGetOverloadArray = _libraries['msbsc70.dll'].BSCGetOverloadArray
-BSCGetOverloadArray.restype = BOOL
-BSCGetOverloadArray.argtypes = [POINTER(Bsc), SZ, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetUsedByArray = _libraries['msbsc70.dll'].BSCGetUsedByArray
-BSCGetUsedByArray.restype = BOOL
-BSCGetUsedByArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetUsesArray = _libraries['msbsc70.dll'].BSCGetUsesArray
-BSCGetUsesArray.restype = BOOL
-BSCGetUsesArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetBaseArray = _libraries['msbsc70.dll'].BSCGetBaseArray
-BSCGetBaseArray.restype = BOOL
-BSCGetBaseArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetDervArray = _libraries['msbsc70.dll'].BSCGetDervArray
-BSCGetDervArray.restype = BOOL
-BSCGetDervArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetMembersArray = _libraries['msbsc70.dll'].BSCGetMembersArray
-BSCGetMembersArray.restype = BOOL
-BSCGetMembersArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetDefArray = _libraries['msbsc70.dll'].BSCGetDefArray
-BSCGetDefArray.restype = BOOL
-BSCGetDefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
-BSCGetRefArray = _libraries['msbsc70.dll'].BSCGetRefArray
-BSCGetRefArray.restype = BOOL
-BSCGetRefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
-BSCGetModuleContents = _libraries['msbsc70.dll'].BSCGetModuleContents
-BSCGetModuleContents.restype = BOOL
-BSCGetModuleContents.argtypes = [POINTER(Bsc), IMOD, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCGetModuleByName = _libraries['msbsc70.dll'].BSCGetModuleByName
-BSCGetModuleByName.restype = BOOL
-BSCGetModuleByName.argtypes = [POINTER(Bsc), SZ, POINTER(IMOD)]
-BSCGetAllModulesArray = _libraries['msbsc70.dll'].BSCGetAllModulesArray
-BSCGetAllModulesArray.restype = BOOL
-BSCGetAllModulesArray.argtypes = [POINTER(Bsc), POINTER(POINTER(IMOD)), POINTER(ULONG)]
-BSCDisposeArray = _libraries['msbsc70.dll'].BSCDisposeArray
-BSCDisposeArray.restype = None
-BSCDisposeArray.argtypes = [POINTER(Bsc), c_void_p]
-BSCFormatDname = _libraries['msbsc70.dll'].BSCFormatDname
-BSCFormatDname.restype = SZ
-BSCFormatDname.argtypes = [POINTER(Bsc), SZ]
-BSCFInstFilter = _libraries['msbsc70.dll'].BSCFInstFilter
-BSCFInstFilter.restype = BOOL
-BSCFInstFilter.argtypes = [POINTER(Bsc), IINST, MBF]
-BSCIinstFrIref = _libraries['msbsc70.dll'].BSCIinstFrIref
-BSCIinstFrIref.restype = IINST
-BSCIinstFrIref.argtypes = [POINTER(Bsc), IREF]
-BSCIinstFrIdef = _libraries['msbsc70.dll'].BSCIinstFrIdef
-BSCIinstFrIdef.restype = IINST
-BSCIinstFrIdef.argtypes = [POINTER(Bsc), IDEF]
-BSCIinstContextIref = _libraries['msbsc70.dll'].BSCIinstContextIref
-BSCIinstContextIref.restype = IINST
-BSCIinstContextIref.argtypes = [POINTER(Bsc), IREF]
-BSCGetStatistics = _libraries['msbsc70.dll'].BSCGetStatistics
-BSCGetStatistics.restype = BOOL
-BSCGetStatistics.argtypes = [POINTER(Bsc), POINTER(BSC_STAT)]
-BSCGetModuleStatistics = _libraries['msbsc70.dll'].BSCGetModuleStatistics
-BSCGetModuleStatistics.restype = BOOL
-BSCGetModuleStatistics.argtypes = [POINTER(Bsc), IMOD, POINTER(BSC_STAT)]
-BSCFCaseSensitive = _libraries['msbsc70.dll'].BSCFCaseSensitive
-BSCFCaseSensitive.restype = BOOL
-BSCFCaseSensitive.argtypes = [POINTER(Bsc)]
-BSCSetCaseSensitivity = _libraries['msbsc70.dll'].BSCSetCaseSensitivity
-BSCSetCaseSensitivity.restype = BOOL
-BSCSetCaseSensitivity.argtypes = [POINTER(Bsc), BOOL]
-BSCGetAllGlobalsArray = _libraries['msbsc70.dll'].BSCGetAllGlobalsArray
-BSCGetAllGlobalsArray.restype = BOOL
-BSCGetAllGlobalsArray.argtypes = [POINTER(Bsc), MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
-BSCSzFrAtr2 = _libraries['msbsc70.dll'].BSCSzFrAtr2
-BSCSzFrAtr2.restype = SZ
-BSCSzFrAtr2.argtypes = [POINTER(Bsc), ATR32]
-BSCIinstInfo2 = _libraries['msbsc70.dll'].BSCIinstInfo2
-BSCIinstInfo2.restype = BOOL
-BSCIinstInfo2.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR32)]
-BSCGetIinstByvalue2 = _libraries['msbsc70.dll'].BSCGetIinstByvalue2
-BSCGetIinstByvalue2.restype = BOOL
-BSCGetIinstByvalue2.argtypes = [POINTER(Bsc), SZ, TYP, ATR32, POINTER(IINST)]
-OpenBSCQuery = _libraries['msbsc70.dll'].OpenBSCQuery
-OpenBSCQuery.restype = BOOL
-OpenBSCQuery.argtypes = [POINTER(Bsc)]
-CloseBSCQuery = _libraries['msbsc70.dll'].CloseBSCQuery
-CloseBSCQuery.restype = BOOL
-CloseBSCQuery.argtypes = []
-BOB = ULONG
-InitBSCQuery = _libraries['msbsc70.dll'].InitBSCQuery
-InitBSCQuery.restype = BOOL
-InitBSCQuery.argtypes = [QY, BOB]
-BobNext = _libraries['msbsc70.dll'].BobNext
-BobNext.restype = BOB
-BobNext.argtypes = []
-BobFrName = _libraries['msbsc70.dll'].BobFrName
-BobFrName.restype = BOB
-BobFrName.argtypes = [SZ]
-LszNameFrBob = _libraries['msbsc70.dll'].LszNameFrBob
-LszNameFrBob.restype = SZ
-LszNameFrBob.argtypes = [BOB]
-CLS = USHORT
-
-class enums:
- class MBF(utils.enum):
- NIL = 0x000
- VARS = 0x001
- FUNCS = 0x002
- MACROS = 0x004
- TYPES = 0x008
- CLASS = 0x010
- INCL = 0x020
- MSGMAP = 0x040
- DIALOGID = 0x080
- LIBRARY = 0x100
- IMPORT = 0x200
- TEMPLATE = 0x400
- NAMESPACE = 0x800
- ALL = 0xFFF
-
- class TYPES(utils.enum):
- FUNCTION = 0x01
- LABEL = 0x02
- PARAMETER = 0x03
- VARIABLE = 0x04
- CONSTANT = 0x05
- MACRO = 0x06
- TYPEDEF = 0x07
- STRUCNAM = 0x08
- ENUMNAM = 0x09
- ENUMMEM = 0x0A
- UNIONNAM = 0x0B
- SEGMENT = 0x0C
- GROUP = 0x0D
- PROGRAM = 0x0E
- CLASSNAM = 0x0F
- MEMFUNC = 0x10
- MEMVAR = 0x11
-
- class ATTRIBUTES(utils.enum):
- LOCAL = 0x001
- STATIC = 0x002
- SHARED = 0x004
- NEAR = 0x008
- COMMON = 0x010
- DECL_ONLY = 0x020
- PUBLIC = 0x040
- NAMED = 0x080
- MODULE = 0x100
- VIRTUAL = 0x200
- PRIVATE = 0x400
- PROTECT = 0x800
-
-class definition_t(object):
- #represents some other symbol
- def __init__( self, def_id, bsc ):
- self.__bsc = bsc
- self.__def_id = def_id
-
- @property
- def def_id(self):
- return self.__def_id
-
- @utils.cached
- def location( self ):
- module = STRING()
- line = LINE()
- if not BSCIdefInfo( self.__bsc, self.def_id, byref( module ), byref( line ) ):
- raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__def_id ) )
- return (module, line)
-
- @utils.cached
- def file_name(self):
- return self.location[0].value
-
- @utils.cached
- def line(self):
- return self.location[1].value
-
- def __str__( self ):
- return self.file_name + ': %d' % self.line + ' name: %s' % self.as_instance.name
-
- @utils.cached
- def as_instance(self):
- return self.__bsc.create_instance( BSCIinstFrIdef( self.__bsc, self.def_id) )
-
-class instance_t(object):
- #represents some symbol
- def __init__( self, inst_id, bsc ):
- self.__bsc = bsc
- self.__inst_id = inst_id
-
- @property
- def inst_id(self):
- return self.__inst_id
-
- @utils.cached
- def name_type_attribute_mangled_name( self ):
- name = STRING()
- typ = TYP()
- attribute = ATR()
- if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ):
- raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) )
- undecorated_name = BSCFormatDname( self.__bsc, name )
- return undecorated_name, typ, attribute, name.value
-
-
- @utils.cached
- def mangled_name(self):
- return self.name_type_attribute_mangled_name[3]
-
- @utils.cached
- def name(self):
- return self.name_type_attribute_mangled_name[0]
-
- @utils.cached
- def type(self):
- return self.name_type_attribute_mangled_name[1].value
-
- @utils.cached
- def attribute(self):
- return self.name_type_attribute_mangled_name[2].value
-
- def __str__( self ):
- tmp = []
- if enums.TYPES.has_value( self.type ):
- tmp.append( 'type( "%s" )' % enums.TYPES.name_of( self.type ) )
- if enums.ATTRIBUTES.has_value( self.attribute ):
- tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) )
- tmp.append( 'name( "%s" )' % self.name )
- tmp.append( 'mangled name( "%s" )' % self.mangled_name )
- return ', '.join( tmp )
-
-
- @utils.cached
- def definitions( self ):
- definitions_len = ULONG(0)
- definitions_ids = pointer( IDEF() )
-
- if not BSCGetDefArray( self.__bsc, self.inst_id, byref( definitions_ids ), byref( definitions_len ) ):
- raise RuntimeError( "Unable to call BSCGetDefArray" )
-
- definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc )
- , range( definitions_len.value ) )
-
- BSCDisposeArray( self.__bsc, definitions_ids )
- return definitions
-
- @utils.cached
- def members( self ):
- instances_len = ULONG(0)
- instances_ids = pointer( IINST() )
-
- if not BSCGetMembersArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
- raise RuntimeError( "Unable to call BSCGetMembersArray" )
-
- instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
- , range( instances_len.value ) )
-
- BSCDisposeArray( self.__bsc, instances_ids )
- return instances
-
- @utils.cached
- def used_symbols(self):
- instances_len = ULONG(0)
- instances_ids = pointer( IINST() )
-
- if not BSCGetUsesArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
- raise RuntimeError( "Unable to call BSCGetUsesArray" )
-
- instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
- , range( instances_len.value ) )
-
- BSCDisposeArray( self.__bsc, instances_ids )
- return instances
-
- @utils.cached
- def base_classes(self):
- instances_len = ULONG(0)
- instances_ids = pointer( IINST() )
-
- if not BSCGetBaseArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
- raise RuntimeError( "Unable to call BSCGetBaseArray" )
-
- instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
- , range( instances_len.value ) )
-
- BSCDisposeArray( self.__bsc, instances_ids )
- return instances
-
- @utils.cached
- def derived_classes(self):
- instances_len = ULONG(0)
- instances_ids = pointer( IINST() )
-
- if not BSCGetDervArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
- raise RuntimeError( "Unable to call BSCGetDervArray" )
-
- instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
- , range( instances_len.value ) )
-
- BSCDisposeArray( self.__bsc, instances_ids )
- return instances
-
-class module_t(object):
- #represents file
- def __init__( self, mod_id, bsc ):
- self.__bsc = bsc
- self.__mod_id = mod_id
-
- @property
- def mod_id( self ):
- return self.__mod_id
-
- @utils.cached
- def path( self ):
- name = STRING()
- BSCImodInfo(self.__bsc, self.__mod_id, byref(name))
- return name.value
-
- @utils.cached
- def instances( self ):
- instances_len = ULONG(0)
- instances_ids = pointer( IINST() )
-
- if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
- raise RuntimeError( "Unable to call BSCGetModuleContents" )
-
- instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
- , range( instances_len.value ) )
-
- BSCDisposeArray( self.__bsc, instances_ids )
- return instances
-
-class bsc_reader_t( object ):
- def __init__( self, bsc_file ):
- self.logger = utils.loggers.pdb_reader
- self.logger.setLevel(logging.INFO)
-
- self.__bsc_file = bsc_file
- self.__bsc = pointer( Bsc() )
- if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ):
- raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file )
-
- self.__instances_cache = {} #inst id : instance_t
- self.__bsc.create_instance = lambda inst_id: self.__create_instance( inst_id )
-
- def __create_instance( self, inst_id ):
- try:
- return self.__instances_cache[ inst_id ]
- except KeyError:
- inst = instance_t( inst_id, self.__bsc )
- self.__instances_cache[ inst_id ] = inst
- return inst
-
- def query_all_instances( self ):
- instances_len = ULONG(0)
- instances = pointer( IINST() )
-
- if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.ALL, byref( instances ), byref( instances_len ) ):
- raise RuntimeError( "Unable to load all globals symbols" )
- for i in range( instances_len.value ):
- self.__instances.append( instances[i] )
- BSCDisposeArray( self.__bsc, instances )
-
- @utils.cached
- def is_case_sensitive( self ):
- return bool( BSCFCaseSensitive( self.__bsc ) )
-
- @utils.cached
- def files(self):
- module_ids = pointer( IMOD() )
- module_len = ULONG()
- bs = BSC_STAT()
-
- if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_len) ):
- raise RuntimeError( "Unable to load all modules" )
-
- modules = map( lambda i: module_t( module_ids[i], self.__bsc )
- , range( module_len.value ) )
-
- BSCDisposeArray( self.__bsc, module_ids )
-
- return modules
-
- def print_stat( self ):
- stat = BSC_STAT()
- BSCGetStatistics( self.__bsc, byref( stat ) )
- for f, t in stat._fields_:
- print '%s: %s' % ( f, str( getattr( stat, f) ) )
-
- def print_classes(self, file_name=None):
- for m in self.files:
- if file_name and m.path != file_name:
- continue
- print 'File: ', m.path
- if m.instances:
- print '\tInstances:'
- for inst in m.instances:
- print '\t\t', str(inst)
- if inst.definitions:
- print '\t\t\tDefinitions:'
- for definition in inst.definitions:
- print '\t\t\t\t', str( definition )
- if inst.members:
- print '\t\t\tMembers:'
- for member in inst.members:
- print '\t\t\t\t', str( member )
- if inst.used_symbols:
- print '\t\t\tUsed symbols:'
- for used_symbol in inst.used_symbols:
- print '\t\t\t\t', str( used_symbol )
- if inst.base_classes:
- print '\t\t\tBase classes:'
- for base_class in inst.base_classes:
- print '\t\t\t\t', str( base_class )
- if inst.derived_classes:
- print '\t\t\tDerived classes:'
- for derived_class in inst.derived_classes:
- print '\t\t\t\t', str( derived_class )
-
- def __del__( self ):
- if self.__bsc:
- BSCClose( self.__bsc )
-
-if __name__ == '__main__':
- control_bsc = r'xxx.bsc'
- reader = bsc_reader_t( control_bsc )
- reader.print_stat()
- print 'is_case_sensitive', reader.is_case_sensitive
- #~ reader.query_all_instances()
- #reader.files
- reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
Added: pygccxml_dev/pygccxml/msvc/config.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/config.py (rev 0)
+++ pygccxml_dev/pygccxml/msvc/config.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -0,0 +1,62 @@
+import os
+import sys
+import comtypes
+import comtypes.client
+import _winreg as win_registry
+from distutils import msvccompiler
+
+class binaries_searcher_t:
+
+ def get_msbsc_path( self ):
+ relative_path = os.path.dirname( sys.modules[__name__].__file__)
+ absolute_path = os.path.abspath (relative_path)
+ return os.path.join( absolute_path, 'msbsc70.dll' )
+
+ def get_msvcr_path( self ):
+ relative_path = os.path.dirname( sys.modules[__name__].__file__)
+ absolute_path = os.path.abspath (relative_path)
+ return os.path.join( absolute_path, 'msvcr70.dll' )
+
+ def get_msdia_path( self ):
+ vss_installed = self.__get_installed_vs_dirs()
+ msdia_dlls = self.__get_msdia_dll_paths( vss_installed )
+ if 1 == len(msdia_dlls):
+ return msdia_dlls[0]
+ else:
+ #TODO find the highest version and use it.
+ pass
+
+ def __get_msdia_dll_paths( self, vss_installed ):
+ msdia_dlls = []
+ for vs in vss_installed:
+ debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' )
+ files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' )
+ , os.listdir( debug_dir ) )
+ if not files:
+ continue
+ msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ])
+ if not msdia_dlls:
+ raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' )
+ return msdia_dlls
+
+ def __get_installed_vs_dirs( self ):
+ vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7'
+ values = self.read_values( win_registry.HKEY_LOCAL_MACHINE, vs_reg_path )
+ return [ values.values()[0] ]
+
+ def read_keys(self, base, key):
+ return msvccompiler.read_keys(base, key)
+
+ def read_values(self, base, key):
+ return msvccompiler.read_values(base, key)
+
+bs = binaries_searcher_t()
+
+msdia_path = bs.get_msdia_path()
+print 'msdia path: ', msdia_path
+
+msbsc_path = bs.get_msbsc_path()
+print 'msbsc path: ', msbsc_path
+
+msvcr_path = bs.get_msvcr_path()
+print 'msvcr path: ', msvcr_path
Deleted: pygccxml_dev/pygccxml/msvc/details.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/details.py 2008-03-12 11:59:29 UTC (rev 1277)
+++ pygccxml_dev/pygccxml/msvc/details.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -1,77 +0,0 @@
-from msvc_details import msdia
-from pygccxml import declarations
-
-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
-
-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
- 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
-
-__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 )
- 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/msvc/msvc_details.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/msvc_details.py 2008-03-12 11:59:29 UTC (rev 1277)
+++ pygccxml_dev/pygccxml/msvc/msvc_details.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -1,98 +0,0 @@
-import os
-import sys
-import comtypes
-import comtypes.client
-import _winreg as win_registry
-from distutils import msvccompiler
-
-
-class binaries_searcher_t:
-
- def get_msbsc_path( self ):
- relative_path = os.path.dirname( sys.modules[__name__].__file__)
- absolute_path = os.path.abspath (relative_path)
- return os.path.join( absolute_path, 'msbsc70.dll' )
-
- def get_msvcr_path( self ):
- relative_path = os.path.dirname( sys.modules[__name__].__file__)
- absolute_path = os.path.abspath (relative_path)
- return os.path.join( absolute_path, 'msvcr70.dll' )
-
- def get_msdia_path( self ):
- vss_installed = self.__get_installed_vs_dirs()
- msdia_dlls = self.__get_msdia_dll_paths( vss_installed )
- if 1 == len(msdia_dlls):
- return msdia_dlls[0]
- else:
- #TODO find the highest version and use it.
- pass
-
- def __get_msdia_dll_paths( self, vss_installed ):
- msdia_dlls = []
- for vs in vss_installed:
- debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' )
- files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' )
- , os.listdir( debug_dir ) )
- if not files:
- continue
- msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ])
- if not msdia_dlls:
- raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' )
- return msdia_dlls
-
- def __get_installed_vs_dirs( self ):
- vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7'
- values = self.read_values( win_registry.HKEY_LOCAL_MACHINE, vs_reg_path )
- return [ values.values()[0] ]
-
- def read_keys(self, base, key):
- return msvccompiler.read_keys(base, key)
-
- def read_values(self, base, key):
- return msvccompiler.read_values(base, key)
-
-bs = binaries_searcher_t()
-
-msdia_path = bs.get_msdia_path()
-print 'msdia path: ', msdia_path
-
-msbsc_path = bs.get_msbsc_path()
-print 'msbsc path: ', msbsc_path
-
-msvcr_path = bs.get_msvcr_path()
-print 'msvcr path: ', msvcr_path
-
-comtypes_client_gen_dir = comtypes.client.gen_dir
-try:
- comtypes.client.gen_dir = None
- msdia = comtypes.client.GetModule( msdia_path )
-finally:
- comtypes.client.gen_dir = comtypes_client_gen_dir
-
-#Adding code, that was not generated for some reason.
-
-class UdtKind:
- UdtStruct, UdtClass, UdtUnion = (0, 1, 2)
-
-class CV_access_e:
- CV_private, CV_protected, CV_public = (1, 2, 3)
-
-msdia.UdtKind = UdtKind
-msdia.CV_access_e = CV_access_e
-
-class NameSearchOptions:
- nsNone = 0
- nsfCaseSensitive = 0x1
- nsfCaseInsensitive = 0x2
- nsfFNameExt = 0x4
- nsfRegularExpression = 0x8
- nsfUndecoratedName = 0x10
-
- # For backward compabibility:
- nsCaseSensitive = nsfCaseSensitive
- nsCaseInsensitive = nsfCaseInsensitive
- nsFNameExt = nsfFNameExt
- nsRegularExpression = nsfRegularExpression | nsfCaseSensitive
- nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive
-
-msdia.NameSearchOptions = NameSearchOptions
Added: pygccxml_dev/pygccxml/msvc/pdb/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/__init__.py (rev 0)
+++ pygccxml_dev/pygccxml/msvc/pdb/__init__.py 2008-03-12 21:03:41 UTC (rev 1278)
@@ -0,0 +1,284 @@
+import os
+import sys
+import ctypes
+import pprint
+import logging
+import comtypes
+import comtypes.client
+
+from . import impl_details
+
+from ... import utils
+from ... import declarations
+from .. import config as msvc_cfg
+
+comtypes_client_gen_dir = comtypes.client.gen_dir
+try:
+ comtypes.client.gen_dir = None
+ msdia = comtypes.client.GetModule( msvc_cfg.msdia_path )
+finally:
+ comtypes.client.gen_dir = comtypes_client_gen_dir
+
+
+
+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 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.__enums = {}
+ self.__classes = {}
+ self.__typedefs = {}
+ 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 impl_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 = impl_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 = impl_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
+ , impl_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 = impl_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)
+ 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 __create_typedef( self, typedef_smbl ):
+ name_splitter = impl_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 )
+ ...
[truncated message content] |
|
From: <rom...@us...> - 2008-03-12 11:59:25
|
Revision: 1277
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1277&view=rev
Author: roman_yakovenko
Date: 2008-03-12 04:59:29 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
rename directory to better reflect the content
Added Paths:
-----------
pygccxml_dev/pygccxml/msvc/
Removed Paths:
-------------
pygccxml_dev/pygccxml/pdb_reader/
Copied: pygccxml_dev/pygccxml/msvc (from rev 1276, pygccxml_dev/pygccxml/pdb_reader)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-12 11:20:19
|
Revision: 1276
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1276&view=rev
Author: roman_yakovenko
Date: 2008-03-12 04:16:53 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-11 19:05:57 UTC (rev 1275)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-12 11:16:53 UTC (rev 1276)
@@ -330,26 +330,31 @@
return self.__inst_id
@utils.cached
- def name_type_attribute( self ):
+ def name_type_attribute_mangled_name( self ):
name = STRING()
typ = TYP()
attribute = ATR()
if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ):
raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) )
- name = BSCFormatDname( self.__bsc, name )
- return name, typ, attribute
+ undecorated_name = BSCFormatDname( self.__bsc, name )
+ return undecorated_name, typ, attribute, name.value
+
+
+ @utils.cached
+ def mangled_name(self):
+ return self.name_type_attribute_mangled_name[3]
@utils.cached
def name(self):
- return self.name_type_attribute[0]
+ return self.name_type_attribute_mangled_name[0]
@utils.cached
def type(self):
- return self.name_type_attribute[1].value
+ return self.name_type_attribute_mangled_name[1].value
@utils.cached
def attribute(self):
- return self.name_type_attribute[2].value
+ return self.name_type_attribute_mangled_name[2].value
def __str__( self ):
tmp = []
@@ -358,6 +363,7 @@
if enums.ATTRIBUTES.has_value( self.attribute ):
tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) )
tmp.append( 'name( "%s" )' % self.name )
+ tmp.append( 'mangled name( "%s" )' % self.mangled_name )
return ', '.join( tmp )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-11 19:05:55
|
Revision: 1275
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1275&view=rev
Author: roman_yakovenko
Date: 2008-03-11 12:05:57 -0700 (Tue, 11 Mar 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-10 20:42:05 UTC (rev 1274)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-11 19:05:57 UTC (rev 1275)
@@ -559,4 +559,4 @@
print 'is_case_sensitive', reader.is_case_sensitive
#~ reader.query_all_instances()
#reader.files
- reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
\ No newline at end of file
+ reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-10 20:42:03
|
Revision: 1274
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1274&view=rev
Author: roman_yakovenko
Date: 2008-03-10 13:42:05 -0700 (Mon, 10 Mar 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-05 21:52:25 UTC (rev 1273)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-10 20:42:05 UTC (rev 1274)
@@ -288,10 +288,9 @@
class definition_t(object):
#represents some other symbol
- def __init__( self, def_id, bsc, logger ):
+ def __init__( self, def_id, bsc ):
self.__bsc = bsc
self.__def_id = def_id
- self.logger = logger
@property
def def_id(self):
@@ -301,11 +300,8 @@
def location( self ):
module = STRING()
line = LINE()
- self.logger.debug( 'call BSCIdefInfo( %s ) function', str(self.__def_id) )
if not BSCIdefInfo( self.__bsc, self.def_id, byref( module ), byref( line ) ):
- self.logger.debug( 'call BSCIdefInfo( %s ) function - failure', str(self.__def_id) )
raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__def_id ) )
- self.logger.debug( 'call BSCIdefInfo( %s ) function - success', str(self.__def_id) )
return (module, line)
@utils.cached
@@ -321,14 +317,13 @@
@utils.cached
def as_instance(self):
- return instance_t( BSCIinstFrIdef( self.__bsc, self.def_id), self.__bsc, self.logger )
+ return self.__bsc.create_instance( BSCIinstFrIdef( self.__bsc, self.def_id) )
class instance_t(object):
#represents some symbol
- def __init__( self, inst_id, bsc, logger ):
+ def __init__( self, inst_id, bsc ):
self.__bsc = bsc
self.__inst_id = inst_id
- self.logger = logger
@property
def inst_id(self):
@@ -339,11 +334,8 @@
name = STRING()
typ = TYP()
attribute = ATR()
- self.logger.debug( 'call BSCIinstInfo( %s ) function', str(self.__inst_id) )
if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ):
- self.logger.debug( 'call BSCIinstInfo( %s ) function - failure', str(self.__inst_id) )
raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) )
- self.logger.debug( 'call BSCIinstInfo( %s ) function - success', str(self.__inst_id) )
name = BSCFormatDname( self.__bsc, name )
return name, typ, attribute
@@ -365,23 +357,19 @@
tmp.append( 'type( "%s" )' % enums.TYPES.name_of( self.type ) )
if enums.ATTRIBUTES.has_value( self.attribute ):
tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) )
- tmp.append( 'name( "%s" )' % self.name )
+ tmp.append( 'name( "%s" )' % self.name )
return ', '.join( tmp )
+
@utils.cached
def definitions( self ):
- self.logger.debug( 'load definitions for instance "%s"', self.name )
-
definitions_len = ULONG(0)
definitions_ids = pointer( IDEF() )
- self.logger.debug( 'call BSCGetDefArray function' )
if not BSCGetDefArray( self.__bsc, self.inst_id, byref( definitions_ids ), byref( definitions_len ) ):
- self.logger.debug( 'call BSCGetDefArray function - failure' )
raise RuntimeError( "Unable to call BSCGetDefArray" )
- self.logger.debug( 'load definitions for instance "%s" - done', self.name )
- definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc, self.logger )
+ definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc )
, range( definitions_len.value ) )
BSCDisposeArray( self.__bsc, definitions_ids )
@@ -389,30 +377,65 @@
@utils.cached
def members( self ):
- self.logger.debug( 'load members for instance "%s"', self.name )
-
instances_len = ULONG(0)
instances_ids = pointer( IINST() )
- self.logger.debug( 'call BSCGetMembersArray function' )
if not BSCGetMembersArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
- self.logger.debug( 'call BSCGetMembersArray function - failure' )
raise RuntimeError( "Unable to call BSCGetMembersArray" )
- self.logger.debug( 'load members for instance "%s" - done', self.name )
- instances = map( lambda i: instance_t( instances_ids[i], self.__bsc, self.logger )
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
, range( instances_len.value ) )
BSCDisposeArray( self.__bsc, instances_ids )
return instances
+ @utils.cached
+ def used_symbols(self):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+ if not BSCGetUsesArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetUsesArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+ @utils.cached
+ def base_classes(self):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetBaseArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetBaseArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+ @utils.cached
+ def derived_classes(self):
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ if not BSCGetDervArray( self.__bsc, self.inst_id, byref( instances_ids ), byref( instances_len ) ):
+ raise RuntimeError( "Unable to call BSCGetDervArray" )
+
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
class module_t(object):
#represents file
- def __init__( self, mod_id, bsc, logger ):
+ def __init__( self, mod_id, bsc ):
self.__bsc = bsc
self.__mod_id = mod_id
- self.logger = logger
@property
def mod_id( self ):
@@ -426,18 +449,13 @@
@utils.cached
def instances( self ):
- self.logger.debug( 'load instances for file "%s"', self.path )
-
instances_len = ULONG(0)
instances_ids = pointer( IINST() )
- self.logger.debug( 'call BSCGetModuleContents function' )
if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
- self.logger.debug( 'call BSCGetModuleContents function - failure' )
raise RuntimeError( "Unable to call BSCGetModuleContents" )
- self.logger.debug( 'load instances for file "%s" - done', self.path )
- instances = map( lambda i: instance_t( instances_ids[i], self.__bsc, self.logger )
+ instances = map( lambda i: self.__bsc.create_instance( instances_ids[i] )
, range( instances_len.value ) )
BSCDisposeArray( self.__bsc, instances_ids )
@@ -450,22 +468,26 @@
self.__bsc_file = bsc_file
self.__bsc = pointer( Bsc() )
- self.logger.debug( 'openning bsc file "%s"', self.__bsc_file )
if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ):
- self.logger.debug( 'unable to open bsc file "%s"', self.__bsc_file )
raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file )
- self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file )
+ self.__instances_cache = {} #inst id : instance_t
+ self.__bsc.create_instance = lambda inst_id: self.__create_instance( inst_id )
+
+ def __create_instance( self, inst_id ):
+ try:
+ return self.__instances_cache[ inst_id ]
+ except KeyError:
+ inst = instance_t( inst_id, self.__bsc )
+ self.__instances_cache[ inst_id ] = inst
+ return inst
+
def query_all_instances( self ):
instances_len = ULONG(0)
instances = pointer( IINST() )
- self.logger.debug( 'call BSCGetAllGlobalsArray function' )
if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.ALL, byref( instances ), byref( instances_len ) ):
- self.logger.debug( 'call BSCGetAllGlobalsArray function - failure' )
raise RuntimeError( "Unable to load all globals symbols" )
- self.logger.debug( 'call BSCGetAllGlobalsArray function - success' )
- self.logger.debug( 'instances_len: %d', instances_len.value )
for i in range( instances_len.value ):
self.__instances.append( instances[i] )
BSCDisposeArray( self.__bsc, instances )
@@ -480,13 +502,10 @@
module_len = ULONG()
bs = BSC_STAT()
- self.logger.debug( 'call BSCGetAllModulesArray function' )
if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_len) ):
- self.logger.debug( 'call BSCGetAllModulesArray function - failure' )
raise RuntimeError( "Unable to load all modules" )
- self.logger.debug( 'call BSCGetAllModulesArray function - success' )
- modules = map( lambda i: module_t( module_ids[i], self.__bsc, self.logger )
+ modules = map( lambda i: module_t( module_ids[i], self.__bsc )
, range( module_len.value ) )
BSCDisposeArray( self.__bsc, module_ids )
@@ -504,15 +523,30 @@
if file_name and m.path != file_name:
continue
print 'File: ', m.path
- print '\tInstances:'
- for inst in m.instances:
- print '\t\t', str(inst)
- print '\t\t\tDefinitions:'
- for definition in inst.definitions:
- print '\t\t\t\t', str( definition )
- print '\t\t\tMembers:'
- for member in inst.members:
- print '\t\t\t\t', str( member )
+ if m.instances:
+ print '\tInstances:'
+ for inst in m.instances:
+ print '\t\t', str(inst)
+ if inst.definitions:
+ print '\t\t\tDefinitions:'
+ for definition in inst.definitions:
+ print '\t\t\t\t', str( definition )
+ if inst.members:
+ print '\t\t\tMembers:'
+ for member in inst.members:
+ print '\t\t\t\t', str( member )
+ if inst.used_symbols:
+ print '\t\t\tUsed symbols:'
+ for used_symbol in inst.used_symbols:
+ print '\t\t\t\t', str( used_symbol )
+ if inst.base_classes:
+ print '\t\t\tBase classes:'
+ for base_class in inst.base_classes:
+ print '\t\t\t\t', str( base_class )
+ if inst.derived_classes:
+ print '\t\t\tDerived classes:'
+ for derived_class in inst.derived_classes:
+ print '\t\t\t\t', str( derived_class )
def __del__( self ):
if self.__bsc:
@@ -525,4 +559,4 @@
print 'is_case_sensitive', reader.is_case_sensitive
#~ reader.query_all_instances()
#reader.files
- reader.print_classes( r'c:\dev\produce_pdb\produce_pdb.cpp')
\ No newline at end of file
+ reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-05 21:56:04
|
Revision: 1273
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1273&view=rev
Author: roman_yakovenko
Date: 2008-03-05 13:52:25 -0800 (Wed, 05 Mar 2008)
Log Message:
-----------
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-05 21:29:40 UTC (rev 1272)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-05 21:52:25 UTC (rev 1273)
@@ -317,9 +317,12 @@
return self.location[1].value
def __str__( self ):
- return self.file_name + ': %d' % self.line
+ return self.file_name + ': %d' % self.line + ' name: %s' % self.as_instance.name
+
+ @utils.cached
+ def as_instance(self):
+ return instance_t( BSCIinstFrIdef( self.__bsc, self.def_id), self.__bsc, self.logger )
-
class instance_t(object):
#represents some symbol
def __init__( self, inst_id, bsc, logger ):
@@ -383,7 +386,27 @@
BSCDisposeArray( self.__bsc, definitions_ids )
return definitions
+
+ @utils.cached
+ def members( self ):
+ self.logger.debug( 'load members for instance "%s"', self.name )
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ self.logger.debug( 'call BSCGetMembersArray function' )
+ if not BSCGetMembersArray( self.__bsc, self.inst_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
+ self.logger.debug( 'call BSCGetMembersArray function - failure' )
+ raise RuntimeError( "Unable to call BSCGetMembersArray" )
+ self.logger.debug( 'load members for instance "%s" - done', self.name )
+
+ instances = map( lambda i: instance_t( instances_ids[i], self.__bsc, self.logger )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
+
class module_t(object):
#represents file
def __init__( self, mod_id, bsc, logger ):
@@ -476,13 +499,20 @@
for f, t in stat._fields_:
print '%s: %s' % ( f, str( getattr( stat, f) ) )
- def print_classes(self):
+ def print_classes(self, file_name=None):
for m in self.files:
- print m.path
+ if file_name and m.path != file_name:
+ continue
+ print 'File: ', m.path
+ print '\tInstances:'
for inst in m.instances:
- print '\t', str(inst)
+ print '\t\t', str(inst)
+ print '\t\t\tDefinitions:'
for definition in inst.definitions:
- print '\t\t', str( definition )
+ print '\t\t\t\t', str( definition )
+ print '\t\t\tMembers:'
+ for member in inst.members:
+ print '\t\t\t\t', str( member )
def __del__( self ):
if self.__bsc:
@@ -495,5 +525,4 @@
print 'is_case_sensitive', reader.is_case_sensitive
#~ reader.query_all_instances()
#reader.files
- reader.print_classes()
-
+ reader.print_classes( r'c:\dev\produce_pdb\produce_pdb.cpp')
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-05 21:29:36
|
Revision: 1272
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1272&view=rev
Author: roman_yakovenko
Date: 2008-03-05 13:29:40 -0800 (Wed, 05 Mar 2008)
Log Message:
-----------
adding bsc support
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
pygccxml_dev/pygccxml/utils/__init__.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-04 10:33:07 UTC (rev 1271)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-05 21:29:40 UTC (rev 1272)
@@ -236,42 +236,90 @@
LszNameFrBob.argtypes = [BOB]
CLS = USHORT
-class enums:
- class MBF:
- Nil = (0x000, 'Nil')
- Vars = (0x001, 'Vars')
- Funcs = (0x002, 'Funcs')
- Macros = (0x004, 'Macros')
- Types = (0x008, 'Types')
- Class = (0x010, 'Class')
- Incl = (0x020, 'Incl')
- MsgMap = (0x040, 'MsgMap')
- DialogID = (0x080, 'DialogID')
- Library = (0x100, 'Library')
- Import = (0x200, 'Import')
- Template = (0x400, 'Template')
- Namespace = (0x800, 'Namespace')
- All = (0xFFF, 'All')
+class enums:
+ class MBF(utils.enum):
+ NIL = 0x000
+ VARS = 0x001
+ FUNCS = 0x002
+ MACROS = 0x004
+ TYPES = 0x008
+ CLASS = 0x010
+ INCL = 0x020
+ MSGMAP = 0x040
+ DIALOGID = 0x080
+ LIBRARY = 0x100
+ IMPORT = 0x200
+ TEMPLATE = 0x400
+ NAMESPACE = 0x800
+ ALL = 0xFFF
+
+ class TYPES(utils.enum):
+ FUNCTION = 0x01
+ LABEL = 0x02
+ PARAMETER = 0x03
+ VARIABLE = 0x04
+ CONSTANT = 0x05
+ MACRO = 0x06
+ TYPEDEF = 0x07
+ STRUCNAM = 0x08
+ ENUMNAM = 0x09
+ ENUMMEM = 0x0A
+ UNIONNAM = 0x0B
+ SEGMENT = 0x0C
+ GROUP = 0x0D
+ PROGRAM = 0x0E
+ CLASSNAM = 0x0F
+ MEMFUNC = 0x10
+ MEMVAR = 0x11
+
+ class ATTRIBUTES(utils.enum):
+ LOCAL = 0x001
+ STATIC = 0x002
+ SHARED = 0x004
+ NEAR = 0x008
+ COMMON = 0x010
+ DECL_ONLY = 0x020
+ PUBLIC = 0x040
+ NAMED = 0x080
+ MODULE = 0x100
+ VIRTUAL = 0x200
+ PRIVATE = 0x400
+ PROTECT = 0x800
+
+class definition_t(object):
+ #represents some other symbol
+ def __init__( self, def_id, bsc, logger ):
+ self.__bsc = bsc
+ self.__def_id = def_id
+ self.logger = logger
+
+ @property
+ def def_id(self):
+ return self.__def_id
- class TYP:
- FUNCTION = (0x01, 'Function')
- LABEL = (0x02, 'Label')
- PARAMETER = (0x03, 'Parameter')
- VARIABLE = (0x04, 'Variable')
- CONSTANT = (0x05, 'Const')
- MACRO = (0x06, 'Macro')
- TYPEDEF = (0x07, 'Typedef')
- STRUCNAM = (0x08, 'Struct')
- ENUMNAM = (0x09, 'Enum')
- ENUMMEM = (0x0A, 'Enum value')
- UNIONNAM = (0x0B, 'Union')
- SEGMENT = (0x0C, 'Segment')
- GROUP = (0x0D, 'Group')
- PROGRAM = (0x0E, 'Program')
- CLASSNAM = (0x0F, 'Class')
- MEMFUNC = (0x10, 'Mem Function')
- MEMVAR = (0x11, 'Mem Variable')
+ @utils.cached
+ def location( self ):
+ module = STRING()
+ line = LINE()
+ self.logger.debug( 'call BSCIdefInfo( %s ) function', str(self.__def_id) )
+ if not BSCIdefInfo( self.__bsc, self.def_id, byref( module ), byref( line ) ):
+ self.logger.debug( 'call BSCIdefInfo( %s ) function - failure', str(self.__def_id) )
+ raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__def_id ) )
+ self.logger.debug( 'call BSCIdefInfo( %s ) function - success', str(self.__def_id) )
+ return (module, line)
+
+ @utils.cached
+ def file_name(self):
+ return self.location[0].value
+ @utils.cached
+ def line(self):
+ return self.location[1].value
+
+ def __str__( self ):
+ return self.file_name + ': %d' % self.line
+
+
class instance_t(object):
#represents some symbol
def __init__( self, inst_id, bsc, logger ):
@@ -308,10 +356,34 @@
def attribute(self):
return self.name_type_attribute[2].value
- def __str__( self ):
- return 'type( "%s" ), attribute( "%s" ), name( "%s" )' \
- % ( TYP_ENUM.names[ self.type], str( self.attribute ), self.name )
+ def __str__( self ):
+ tmp = []
+ if enums.TYPES.has_value( self.type ):
+ tmp.append( 'type( "%s" )' % enums.TYPES.name_of( self.type ) )
+ if enums.ATTRIBUTES.has_value( self.attribute ):
+ tmp.append( 'attribute( "%s" )' % enums.ATTRIBUTES.name_of( self.attribute ) )
+ tmp.append( 'name( "%s" )' % self.name )
+ return ', '.join( tmp )
+
+ @utils.cached
+ def definitions( self ):
+ self.logger.debug( 'load definitions for instance "%s"', self.name )
+ definitions_len = ULONG(0)
+ definitions_ids = pointer( IDEF() )
+
+ self.logger.debug( 'call BSCGetDefArray function' )
+ if not BSCGetDefArray( self.__bsc, self.inst_id, byref( definitions_ids ), byref( definitions_len ) ):
+ self.logger.debug( 'call BSCGetDefArray function - failure' )
+ raise RuntimeError( "Unable to call BSCGetDefArray" )
+ self.logger.debug( 'load definitions for instance "%s" - done', self.name )
+
+ definitions = map( lambda i: definition_t( definitions_ids[i], self.__bsc, self.logger )
+ , range( definitions_len.value ) )
+
+ BSCDisposeArray( self.__bsc, definitions_ids )
+ return definitions
+
class module_t(object):
#represents file
def __init__( self, mod_id, bsc, logger ):
@@ -327,7 +399,7 @@
def path( self ):
name = STRING()
BSCImodInfo(self.__bsc, self.__mod_id, byref(name))
- return name
+ return name.value
@utils.cached
def instances( self ):
@@ -337,7 +409,7 @@
instances_ids = pointer( IINST() )
self.logger.debug( 'call BSCGetModuleContents function' )
- if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.All[0], byref( instances_ids ), byref( instances_len ) ):
+ if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.ALL, byref( instances_ids ), byref( instances_len ) ):
self.logger.debug( 'call BSCGetModuleContents function - failure' )
raise RuntimeError( "Unable to call BSCGetModuleContents" )
self.logger.debug( 'load instances for file "%s" - done', self.path )
@@ -366,7 +438,7 @@
instances = pointer( IINST() )
self.logger.debug( 'call BSCGetAllGlobalsArray function' )
- if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.All[0], byref( instances ), byref( instances_len ) ):
+ if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.ALL, byref( instances ), byref( instances_len ) ):
self.logger.debug( 'call BSCGetAllGlobalsArray function - failure' )
raise RuntimeError( "Unable to load all globals symbols" )
self.logger.debug( 'call BSCGetAllGlobalsArray function - success' )
@@ -376,6 +448,10 @@
BSCDisposeArray( self.__bsc, instances )
@utils.cached
+ def is_case_sensitive( self ):
+ return bool( BSCFCaseSensitive( self.__bsc ) )
+
+ @utils.cached
def files(self):
module_ids = pointer( IMOD() )
module_len = ULONG()
@@ -405,14 +481,18 @@
print m.path
for inst in m.instances:
print '\t', str(inst)
+ for definition in inst.definitions:
+ print '\t\t', str( definition )
def __del__( self ):
- BSCClose( self.__bsc )
+ if self.__bsc:
+ BSCClose( self.__bsc )
if __name__ == '__main__':
control_bsc = r'xxx.bsc'
reader = bsc_reader_t( control_bsc )
reader.print_stat()
+ print 'is_case_sensitive', reader.is_case_sensitive
#~ reader.query_all_instances()
#reader.files
reader.print_classes()
Modified: pygccxml_dev/pygccxml/utils/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/utils/__init__.py 2008-03-04 10:33:07 UTC (rev 1271)
+++ pygccxml_dev/pygccxml/utils/__init__.py 2008-03-05 21:29:40 UTC (rev 1272)
@@ -125,3 +125,30 @@
attr = getattr(cls, name)
if isinstance(attr, cached):
delattr(self, name)
+
+class enum( object ):
+ """Usage example:
+ class fruits(enum):
+ apple = 0
+ orange = 1
+
+ fruits.has_value( 1 )
+ fruits.name_of( 1 )
+ """
+
+ @classmethod
+ def has_value( cls, enum_numeric_value ):
+ for name, value in cls.__dict__.iteritems():
+ if enum_numeric_value == value:
+ return True
+ else:
+ return False
+
+ @classmethod
+ def name_of( cls, enum_numeric_value ):
+ for name, value in cls.__dict__.iteritems():
+ if enum_numeric_value == value:
+ return name
+ else:
+ raise RuntimeError( 'Unable to find name for value(%d) in enumeration "%s"'
+ % ( enum_numeric_value, cls.__name__ ) )
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-04 10:33:01
|
Revision: 1271
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1271&view=rev
Author: roman_yakovenko
Date: 2008-03-04 02:33:07 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
refactoring of bsc module
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
pygccxml_dev/pygccxml/utils/__init__.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-03 20:21:22 UTC (rev 1270)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-03-04 10:33:07 UTC (rev 1271)
@@ -236,22 +236,118 @@
LszNameFrBob.argtypes = [BOB]
CLS = USHORT
-class MBF:
- mbfNil = 0x000
- mbfVars = 0x001
- mbfFuncs = 0x002
- mbfMacros = 0x004
- mbfTypes = 0x008
- mbfClass = 0x010
- mbfIncl = 0x020
- mbfMsgMap = 0x040
- mbfDialogID = 0x080
- mbfLibrary = 0x100
- mbfImport = 0x200
- mbfTemplate = 0x400
- mbfNamespace = 0x800
- mbfAll = 0xFFF
+class enums:
+ class MBF:
+ Nil = (0x000, 'Nil')
+ Vars = (0x001, 'Vars')
+ Funcs = (0x002, 'Funcs')
+ Macros = (0x004, 'Macros')
+ Types = (0x008, 'Types')
+ Class = (0x010, 'Class')
+ Incl = (0x020, 'Incl')
+ MsgMap = (0x040, 'MsgMap')
+ DialogID = (0x080, 'DialogID')
+ Library = (0x100, 'Library')
+ Import = (0x200, 'Import')
+ Template = (0x400, 'Template')
+ Namespace = (0x800, 'Namespace')
+ All = (0xFFF, 'All')
+
+ class TYP:
+ FUNCTION = (0x01, 'Function')
+ LABEL = (0x02, 'Label')
+ PARAMETER = (0x03, 'Parameter')
+ VARIABLE = (0x04, 'Variable')
+ CONSTANT = (0x05, 'Const')
+ MACRO = (0x06, 'Macro')
+ TYPEDEF = (0x07, 'Typedef')
+ STRUCNAM = (0x08, 'Struct')
+ ENUMNAM = (0x09, 'Enum')
+ ENUMMEM = (0x0A, 'Enum value')
+ UNIONNAM = (0x0B, 'Union')
+ SEGMENT = (0x0C, 'Segment')
+ GROUP = (0x0D, 'Group')
+ PROGRAM = (0x0E, 'Program')
+ CLASSNAM = (0x0F, 'Class')
+ MEMFUNC = (0x10, 'Mem Function')
+ MEMVAR = (0x11, 'Mem Variable')
+class instance_t(object):
+ #represents some symbol
+ def __init__( self, inst_id, bsc, logger ):
+ self.__bsc = bsc
+ self.__inst_id = inst_id
+ self.logger = logger
+
+ @property
+ def inst_id(self):
+ return self.__inst_id
+
+ @utils.cached
+ def name_type_attribute( self ):
+ name = STRING()
+ typ = TYP()
+ attribute = ATR()
+ self.logger.debug( 'call BSCIinstInfo( %s ) function', str(self.__inst_id) )
+ if not BSCIinstInfo( self.__bsc, self.inst_id, byref( name ), byref( typ ), byref( attribute ) ):
+ self.logger.debug( 'call BSCIinstInfo( %s ) function - failure', str(self.__inst_id) )
+ raise RuntimeError( "Unable to load information about instance(%s)" % str( self.__inst_id ) )
+ self.logger.debug( 'call BSCIinstInfo( %s ) function - success', str(self.__inst_id) )
+ name = BSCFormatDname( self.__bsc, name )
+ return name, typ, attribute
+
+ @utils.cached
+ def name(self):
+ return self.name_type_attribute[0]
+
+ @utils.cached
+ def type(self):
+ return self.name_type_attribute[1].value
+
+ @utils.cached
+ def attribute(self):
+ return self.name_type_attribute[2].value
+
+ def __str__( self ):
+ return 'type( "%s" ), attribute( "%s" ), name( "%s" )' \
+ % ( TYP_ENUM.names[ self.type], str( self.attribute ), self.name )
+
+class module_t(object):
+ #represents file
+ def __init__( self, mod_id, bsc, logger ):
+ self.__bsc = bsc
+ self.__mod_id = mod_id
+ self.logger = logger
+
+ @property
+ def mod_id( self ):
+ return self.__mod_id
+
+ @utils.cached
+ def path( self ):
+ name = STRING()
+ BSCImodInfo(self.__bsc, self.__mod_id, byref(name))
+ return name
+
+ @utils.cached
+ def instances( self ):
+ self.logger.debug( 'load instances for file "%s"', self.path )
+
+ instances_len = ULONG(0)
+ instances_ids = pointer( IINST() )
+
+ self.logger.debug( 'call BSCGetModuleContents function' )
+ if not BSCGetModuleContents( self.__bsc, self.mod_id, enums.MBF.All[0], byref( instances_ids ), byref( instances_len ) ):
+ self.logger.debug( 'call BSCGetModuleContents function - failure' )
+ raise RuntimeError( "Unable to call BSCGetModuleContents" )
+ self.logger.debug( 'load instances for file "%s" - done', self.path )
+
+ instances = map( lambda i: instance_t( instances_ids[i], self.__bsc, self.logger )
+ , range( instances_len.value ) )
+
+ BSCDisposeArray( self.__bsc, instances_ids )
+ return instances
+
class bsc_reader_t( object ):
def __init__( self, bsc_file ):
self.logger = utils.loggers.pdb_reader
@@ -263,19 +359,14 @@
if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ):
self.logger.debug( 'unable to open bsc file "%s"', self.__bsc_file )
raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file )
- self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file )
+ self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file )
- self.__instances = []
-
- self.__files = self.__load_files()
- self.__file_instances = self.__load_files_instances( self.__files )
-
def query_all_instances( self ):
instances_len = ULONG(0)
instances = pointer( IINST() )
self.logger.debug( 'call BSCGetAllGlobalsArray function' )
- if not BSCGetAllGlobalsArray( self.__bsc, MBF.mbfAll, byref( instances ), byref( instances_len ) ):
+ if not BSCGetAllGlobalsArray( self.__bsc, enums.MBF.All[0], byref( instances ), byref( instances_len ) ):
self.logger.debug( 'call BSCGetAllGlobalsArray function - failure' )
raise RuntimeError( "Unable to load all globals symbols" )
self.logger.debug( 'call BSCGetAllGlobalsArray function - success' )
@@ -284,32 +375,24 @@
self.__instances.append( instances[i] )
BSCDisposeArray( self.__bsc, instances )
- @property
- def files( self ):
- return self.__files.keys()
-
- def __load_files(self):
+ @utils.cached
+ def files(self):
module_ids = pointer( IMOD() )
- module_ids_len = ULONG()
+ module_len = ULONG()
bs = BSC_STAT()
+
self.logger.debug( 'call BSCGetAllModulesArray function' )
-
- if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_ids_len) ):
+ if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_len) ):
self.logger.debug( 'call BSCGetAllModulesArray function - failure' )
raise RuntimeError( "Unable to load all modules" )
self.logger.debug( 'call BSCGetAllModulesArray function - success' )
- modules = [ module_ids[i] for i in range( module_ids_len.value ) ]
+
+ modules = map( lambda i: module_t( module_ids[i], self.__bsc, self.logger )
+ , range( module_len.value ) )
- files = {}
-
- for m in modules:
- name = STRING()
- BSCImodInfo(self.__bsc, m, byref(name))
- files[ name.value ] = m
-
BSCDisposeArray( self.__bsc, module_ids )
- return files
+ return modules
def print_stat( self ):
stat = BSC_STAT()
@@ -317,39 +400,14 @@
for f, t in stat._fields_:
print '%s: %s' % ( f, str( getattr( stat, f) ) )
- def __load_files_instances( self, files ):
- file_instances = {}
- for fname, file_id in files.iteritems():
- self.logger.debug( 'load instances for file "%s"', fname )
-
- instances_len = ULONG(0)
- instances = pointer( IINST() )
-
- self.logger.debug( 'call BSCGetModuleContents function' )
- if not BSCGetModuleContents( self.__bsc, file_id, MBF.mbfClass, byref( instances ), byref( instances_len ) ):
- self.logger.debug( 'call BSCGetModuleContents function - failure' )
- raise RuntimeError( "Unable to call BSCGetModuleContents" )
- file_instances[ fname ] = [ instances[i] for i in range( instances_len.value ) ]
-
- self.logger.debug( 'load instances for file "%s" - done', fname )
- return file_instances
+ def print_classes(self):
+ for m in self.files:
+ print m.path
+ for inst in m.instances:
+ print '\t', str(inst)
def __del__( self ):
BSCClose( self.__bsc )
-
- def print_classes( self ):
- for fname, instances in self.__file_instances.iteritems():
- print 'file: ', fname
- for inst in instances:
- name = STRING()
- typ = TYP()
- attribute = ATR()
- BSCIinstInfo( self.__bsc, inst, byref( name ), byref( typ ), byref( attribute ) )
- name = BSCFormatDname( self.__bsc, name )
- print '\tname: ', name
- print '\ttype: ', typ
- print '\tattribute: ', attribute
-
if __name__ == '__main__':
control_bsc = r'xxx.bsc'
Modified: pygccxml_dev/pygccxml/utils/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/utils/__init__.py 2008-03-03 20:21:22 UTC (rev 1270)
+++ pygccxml_dev/pygccxml/utils/__init__.py 2008-03-04 10:33:07 UTC (rev 1271)
@@ -99,3 +99,29 @@
else:
raise RuntimeError( "Unknown architecture" )
+
+#The following code is cut-and-paste from this post:
+#http://groups.google.com/group/comp.lang.python/browse_thread/thread/5b71896c06bd0f76/
+#Thanks to Michele Simionato, for it
+class cached(property):
+ 'Convert a method into a cached attribute'
+ def __init__(self, method):
+ private = '_' + method.__name__
+ def fget(s):
+ try:
+ return getattr(s, private)
+ except AttributeError:
+ value = method(s)
+ setattr(s, private, value)
+ return value
+ def fdel(s):
+ del s.__dict__[private]
+ super(cached, self).__init__(fget, fdel=fdel)
+
+ @staticmethod
+ def reset(self):
+ cls = self.__class__
+ for name in dir(cls):
+ attr = getattr(cls, name)
+ if isinstance(attr, cached):
+ delattr(self, name)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-03 20:21:17
|
Revision: 1270
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1270&view=rev
Author: roman_yakovenko
Date: 2008-03-03 12:21:22 -0800 (Mon, 03 Mar 2008)
Log Message:
-----------
adding one more use case - private inheritance
Modified Paths:
--------------
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
Modified: pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-03-02 19:13:11 UTC (rev 1269)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-03-03 20:21:22 UTC (rev 1270)
@@ -82,6 +82,11 @@
virtual int do_smth() {};
};
+class ZZ : private YY{
+public:
+ void do_nothing() {}
+};
+
}
#endif//__final_classes_to_be_exported_hpp__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-02 19:13:04
|
Revision: 1269
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1269&view=rev
Author: roman_yakovenko
Date: 2008-03-02 11:13:11 -0800 (Sun, 02 Mar 2008)
Log Message:
-----------
pure virtual functions should be generated in class-wrapper, even if they are excluded or could not be exposed, otherwise the generated code will not compile
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-03-01 19:48:27 UTC (rev 1268)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-03-02 19:13:11 UTC (rev 1269)
@@ -430,8 +430,8 @@
all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
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' ))
+ & ( 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
@@ -444,8 +444,6 @@
if base.access == ACCESS_TYPES.PRIVATE:
continue
base_cls = base.related_class
- #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 ) )
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 ) )
@@ -479,7 +477,8 @@
break
else:
not_reimplemented_funcs.add( f )
- functions = filter( lambda f: not f.ignore and f.exportable
+ functions = filter( lambda f: ( False == f.ignore and True == f.exportable )
+ or all_pure_virtual( f )
, list( not_reimplemented_funcs ) )
functions.sort( cmp=lambda f1, f2: cmp( ( f1.name, f1.location.as_tuple() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-03-01 19:48:26
|
Revision: 1268
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1268&view=rev
Author: roman_yakovenko
Date: 2008-03-01 11:48:27 -0800 (Sat, 01 Mar 2008)
Log Message:
-----------
adding new test case
Modified Paths:
--------------
pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp
pyplusplus_dev/unittests/override_bug_tester.py
pyplusplus_dev/unittests/particle_universe_generate_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-27 19:57:49 UTC (rev 1267)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-03-01 19:48:27 UTC (rev 1268)
@@ -72,6 +72,16 @@
virtual void do_smth(int& i, int& j) const { i = j = 'b' ;}
};
+class XX
+{
+ virtual void do_smth(int& i, int& j) const = 0;
+};
+
+class YY : public XX{
+ public:
+ virtual int do_smth() {};
+};
+
}
#endif//__final_classes_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py 2008-02-27 19:57:49 UTC (rev 1267)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-03-01 19:48:27 UTC (rev 1268)
@@ -25,7 +25,8 @@
do_smth.add_transformation( FT.output(0), alias='do_smth_a' )
do_smth = mb.mem_fun( '::override_bug::BB::do_smth' )
do_smth.add_transformation( FT.output(0), FT.output(1), alias='do_smth_b' )
-
+ mb.class_( 'XX' ).mem_fun( 'do_smth' ).exclude()
+
def run_tests(self, module):
class C( module.B ):
def __init__( self ):
Modified: pyplusplus_dev/unittests/particle_universe_generate_tester.py
===================================================================
--- pyplusplus_dev/unittests/particle_universe_generate_tester.py 2008-02-27 19:57:49 UTC (rev 1267)
+++ pyplusplus_dev/unittests/particle_universe_generate_tester.py 2008-03-01 19:48:27 UTC (rev 1268)
@@ -33,6 +33,7 @@
mb.global_ns.exclude()
mb.namespace('ParticleUniverse').include()
mb.namespace('Ogre').include()
+ mb.namespace('Ogre').classes().already_exposed = True
target_dir = os.path.join( autoconfig.build_directory, 'particle_universe' )
#~ if os.path.exists( target_dir ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-27 19:58:01
|
Revision: 1267
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1267&view=rev
Author: roman_yakovenko
Date: 2008-02-27 11:57:49 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
adding new test case
Added Paths:
-----------
pyplusplus_dev/unittests/data/particleuniverse.xml.bz2
pyplusplus_dev/unittests/particle_universe_generate_tester.py
Added: pyplusplus_dev/unittests/data/particleuniverse.xml.bz2
===================================================================
(Binary files differ)
Property changes on: pyplusplus_dev/unittests/data/particleuniverse.xml.bz2
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: pyplusplus_dev/unittests/particle_universe_generate_tester.py
===================================================================
--- pyplusplus_dev/unittests/particle_universe_generate_tester.py (rev 0)
+++ pyplusplus_dev/unittests/particle_universe_generate_tester.py 2008-02-27 19:57:49 UTC (rev 1267)
@@ -0,0 +1,57 @@
+# 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 shutil
+import logging
+import unittest
+import autoconfig
+from pygccxml import parser
+from pygccxml import declarations
+from pyplusplus import messages
+from pyplusplus import code_creators
+from pyplusplus import module_creator
+from pyplusplus import module_builder
+from pyplusplus import utils as pypp_utils
+from pyplusplus import function_transformers as ft
+
+class ogre_generate_tester_t(unittest.TestCase):
+ def test(self):
+ module_builder.set_logger_level( logging.CRITICAL )
+ messages.disable( *messages.all_warning_msgs )
+
+ xml_file = parser.create_gccxml_fc( os.path.join( autoconfig.data_directory, 'particleuniverse.xml' ) )
+
+ mb = module_builder.module_builder_t(
+ [ xml_file ]
+ , gccxml_path=autoconfig.gccxml.executable
+ , indexing_suite_version=2)
+
+ mb.global_ns.exclude()
+ mb.namespace('ParticleUniverse').include()
+ mb.namespace('Ogre').include()
+
+ target_dir = os.path.join( autoconfig.build_directory, 'particle_universe' )
+ #~ if os.path.exists( target_dir ):
+ #~ shutil.rmtree( target_dir )
+ #~ os.mkdir( target_dir )
+ psp = mb.class_( '::ParticleUniverse::ParticleScriptParser' )
+ declarations.print_declarations( psp )
+ mb.build_code_creator( 'PU' )
+ mb.split_module( target_dir )
+
+
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(ogre_generate_tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ 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-27 19:20:54
|
Revision: 1266
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1266&view=rev
Author: roman_yakovenko
Date: 2008-02-27 11:20:58 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
updating to the latest ogre version
Modified Paths:
--------------
pygccxml_dev/unittests/data/ogre1.4.xml.bz2
Modified: pygccxml_dev/unittests/data/ogre1.4.xml.bz2
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-27 17:47:20
|
Revision: 1265
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1265&view=rev
Author: roman_yakovenko
Date: 2008-02-27 09:47:24 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
adding bsc support
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-02-27 14:12:56 UTC (rev 1264)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-02-27 17:47:24 UTC (rev 1265)
@@ -255,7 +255,7 @@
class bsc_reader_t( object ):
def __init__( self, bsc_file ):
self.logger = utils.loggers.pdb_reader
- self.logger.setLevel(logging.DEBUG)
+ self.logger.setLevel(logging.INFO)
self.__bsc_file = bsc_file
self.__bsc = pointer( Bsc() )
@@ -266,7 +266,10 @@
self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file )
self.__instances = []
-
+
+ self.__files = self.__load_files()
+ self.__file_instances = self.__load_files_instances( self.__files )
+
def query_all_instances( self ):
instances_len = ULONG(0)
instances = pointer( IINST() )
@@ -278,26 +281,81 @@
self.logger.debug( 'call BSCGetAllGlobalsArray function - success' )
self.logger.debug( 'instances_len: %d', instances_len.value )
for i in range( instances_len.value ):
- print i
- self.__instances.append( i )
+ self.__instances.append( instances[i] )
+ BSCDisposeArray( self.__bsc, instances )
+
+ @property
+ def files( self ):
+ return self.__files.keys()
+
+ def __load_files(self):
+ module_ids = pointer( IMOD() )
+ module_ids_len = ULONG()
+ bs = BSC_STAT()
+ self.logger.debug( 'call BSCGetAllModulesArray function' )
+ if not BSCGetAllModulesArray( self.__bsc, module_ids, byref(module_ids_len) ):
+ self.logger.debug( 'call BSCGetAllModulesArray function - failure' )
+ raise RuntimeError( "Unable to load all modules" )
+ self.logger.debug( 'call BSCGetAllModulesArray function - success' )
+ modules = [ module_ids[i] for i in range( module_ids_len.value ) ]
+
+ files = {}
+
+ for m in modules:
+ name = STRING()
+ BSCImodInfo(self.__bsc, m, byref(name))
+ files[ name.value ] = m
+
+ BSCDisposeArray( self.__bsc, module_ids )
+
+ return files
+
def print_stat( self ):
stat = BSC_STAT()
BSCGetStatistics( self.__bsc, byref( stat ) )
for f, t in stat._fields_:
print '%s: %s' % ( f, str( getattr( stat, f) ) )
+ def __load_files_instances( self, files ):
+ file_instances = {}
+ for fname, file_id in files.iteritems():
+ self.logger.debug( 'load instances for file "%s"', fname )
+
+ instances_len = ULONG(0)
+ instances = pointer( IINST() )
+
+ self.logger.debug( 'call BSCGetModuleContents function' )
+ if not BSCGetModuleContents( self.__bsc, file_id, MBF.mbfClass, byref( instances ), byref( instances_len ) ):
+ self.logger.debug( 'call BSCGetModuleContents function - failure' )
+ raise RuntimeError( "Unable to call BSCGetModuleContents" )
+ file_instances[ fname ] = [ instances[i] for i in range( instances_len.value ) ]
+
+ self.logger.debug( 'load instances for file "%s" - done', fname )
+ return file_instances
+
def __del__( self ):
BSCClose( self.__bsc )
+
+ def print_classes( self ):
+ for fname, instances in self.__file_instances.iteritems():
+ print 'file: ', fname
+ for inst in instances:
+ name = STRING()
+ typ = TYP()
+ attribute = ATR()
+ BSCIinstInfo( self.__bsc, inst, byref( name ), byref( typ ), byref( attribute ) )
+ name = BSCFormatDname( self.__bsc, name )
+ print '\tname: ', name
+ print '\ttype: ', typ
+ print '\tattribute: ', attribute
+
-
-
-
if __name__ == '__main__':
- #for i in range( 1000 ):
control_bsc = r'xxx.bsc'
reader = bsc_reader_t( control_bsc )
reader.print_stat()
- reader.query_all_instances()
+ #~ reader.query_all_instances()
+ #reader.files
+ reader.print_classes()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-27 14:12:53
|
Revision: 1264
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1264&view=rev
Author: roman_yakovenko
Date: 2008-02-27 06:12:56 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
adding bsc support
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
pygccxml_dev/pygccxml/pdb_reader/msvc_details.py
Modified: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-02-26 20:38:16 UTC (rev 1263)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-02-27 14:12:56 UTC (rev 1264)
@@ -1,10 +1,303 @@
import os
import sys
import ctypes
+import logging
import msvc_details
+from ctypes import *
+from ctypes.wintypes import ULONG
+from ctypes.wintypes import DWORD
+from ctypes.wintypes import BOOL
+from ctypes.wintypes import BYTE
+from ctypes.wintypes import WORD
+from ctypes.wintypes import UINT
-bsc = ctypes.cdll.LoadLibrary( msvc_details.msbsc_path )
+sys.path.append( r'../..' )
-class bsc_t( object ):
- def __init__( self, bsc_file_path ):
- self.__bsc_file = bsc_file_path
\ No newline at end of file
+from pygccxml import utils
+from pygccxml import declarations
+
+
+STRING = c_char_p
+_libraries = {}
+_libraries['msvcr70.dll'] = CDLL(msvc_details.msvcr_path, mode=RTLD_GLOBAL)
+_libraries['msbsc70.dll'] = CDLL(msvc_details.msbsc_path, mode=RTLD_GLOBAL)
+
+
+qyMac = 9
+refreshAllOp = 4
+qyDervOf = 7
+delOp = 1
+qyImpMembers = 8
+changeOp = 2
+qyRefs = 4
+qyCalls = 2
+changeIinstOp = 3
+qyContains = 1
+qyCalledBy = 3
+noOp = 5
+qyBaseOf = 6
+qyNil = 0
+addOp = 0
+qyDefs = 5
+PULONG = POINTER(ULONG)
+USHORT = c_ushort
+PUSHORT = POINTER(USHORT)
+UCHAR = c_ubyte
+PUCHAR = POINTER(UCHAR)
+PSZ = STRING
+FLOAT = c_float
+PFLOAT = POINTER(FLOAT)
+PBOOL = POINTER(BOOL)
+LPBOOL = POINTER(BOOL)
+PBYTE = POINTER(BYTE)
+LPBYTE = POINTER(BYTE)
+PINT = POINTER(c_int)
+LPINT = POINTER(c_int)
+PWORD = POINTER(WORD)
+LPWORD = POINTER(WORD)
+LPLONG = POINTER(c_long)
+PDWORD = POINTER(DWORD)
+LPDWORD = POINTER(DWORD)
+LPVOID = c_void_p
+LPCVOID = c_void_p
+INT = c_int
+PUINT = POINTER(c_uint)
+ULONG_PTR = POINTER(ULONG)
+NI = ULONG
+IINST = ULONG
+IREF = ULONG
+IDEF = ULONG
+IMOD = USHORT
+LINE = USHORT
+TYP = BYTE
+ATR = USHORT
+ATR32 = ULONG
+MBF = ULONG
+SZ = STRING
+SZ_CONST = STRING
+
+class Bsc(Structure):
+ pass
+
+# values for enumeration 'OPERATION'
+OPERATION = c_int # enum
+class IinstInfo(Structure):
+ pass
+IinstInfo._fields_ = [
+ ('m_iinst', IINST),
+ ('m_szName', SZ_CONST),
+ ('m_ni', NI),
+]
+class BSC_STAT(Structure):
+ pass
+BSC_STAT._fields_ = [
+ ('cDef', ULONG),
+ ('cRef', ULONG),
+ ('cInst', ULONG),
+ ('cMod', ULONG),
+ ('cUseLink', ULONG),
+ ('cBaseLink', ULONG),
+]
+class NiQ(Structure):
+ pass
+NiQ._fields_ = [
+ ('m_iinstOld', IINST),
+ ('m_iInfoNew', IinstInfo),
+ ('m_op', OPERATION),
+ ('m_typ', TYP),
+]
+pfnNotifyChange = CFUNCTYPE(BOOL, POINTER(NiQ), ULONG, ULONG_PTR)
+
+# values for enumeration '_qy_'
+_qy_ = c_int # enum
+QY = _qy_
+Bsc._fields_ = [
+]
+BSCOpen = _libraries['msbsc70.dll'].BSCOpen
+BSCOpen.restype = BOOL
+BSCOpen.argtypes = [SZ_CONST, POINTER(POINTER(Bsc))]
+BSCClose = _libraries['msbsc70.dll'].BSCClose
+BSCClose.restype = BOOL
+BSCClose.argtypes = [POINTER(Bsc)]
+BSCIinstInfo = _libraries['msbsc70.dll'].BSCIinstInfo
+BSCIinstInfo.restype = BOOL
+BSCIinstInfo.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR)]
+BSCIrefInfo = _libraries['msbsc70.dll'].BSCIrefInfo
+BSCIrefInfo.restype = BOOL
+BSCIrefInfo.argtypes = [POINTER(Bsc), IREF, POINTER(SZ), POINTER(LINE)]
+BSCIdefInfo = _libraries['msbsc70.dll'].BSCIdefInfo
+BSCIdefInfo.restype = BOOL
+BSCIdefInfo.argtypes = [POINTER(Bsc), IDEF, POINTER(SZ), POINTER(LINE)]
+BSCImodInfo = _libraries['msbsc70.dll'].BSCImodInfo
+BSCImodInfo.restype = BOOL
+BSCImodInfo.argtypes = [POINTER(Bsc), IMOD, POINTER(SZ)]
+BSCSzFrTyp = _libraries['msbsc70.dll'].BSCSzFrTyp
+BSCSzFrTyp.restype = SZ
+BSCSzFrTyp.argtypes = [POINTER(Bsc), TYP]
+BSCSzFrAtr = _libraries['msbsc70.dll'].BSCSzFrAtr
+BSCSzFrAtr.restype = SZ
+BSCSzFrAtr.argtypes = [POINTER(Bsc), ATR]
+BSCGetIinstByvalue = _libraries['msbsc70.dll'].BSCGetIinstByvalue
+BSCGetIinstByvalue.restype = BOOL
+BSCGetIinstByvalue.argtypes = [POINTER(Bsc), SZ, TYP, ATR, POINTER(IINST)]
+BSCGetOverloadArray = _libraries['msbsc70.dll'].BSCGetOverloadArray
+BSCGetOverloadArray.restype = BOOL
+BSCGetOverloadArray.argtypes = [POINTER(Bsc), SZ, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetUsedByArray = _libraries['msbsc70.dll'].BSCGetUsedByArray
+BSCGetUsedByArray.restype = BOOL
+BSCGetUsedByArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetUsesArray = _libraries['msbsc70.dll'].BSCGetUsesArray
+BSCGetUsesArray.restype = BOOL
+BSCGetUsesArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetBaseArray = _libraries['msbsc70.dll'].BSCGetBaseArray
+BSCGetBaseArray.restype = BOOL
+BSCGetBaseArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetDervArray = _libraries['msbsc70.dll'].BSCGetDervArray
+BSCGetDervArray.restype = BOOL
+BSCGetDervArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetMembersArray = _libraries['msbsc70.dll'].BSCGetMembersArray
+BSCGetMembersArray.restype = BOOL
+BSCGetMembersArray.argtypes = [POINTER(Bsc), IINST, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetDefArray = _libraries['msbsc70.dll'].BSCGetDefArray
+BSCGetDefArray.restype = BOOL
+BSCGetDefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
+BSCGetRefArray = _libraries['msbsc70.dll'].BSCGetRefArray
+BSCGetRefArray.restype = BOOL
+BSCGetRefArray.argtypes = [POINTER(Bsc), IINST, POINTER(POINTER(IREF)), POINTER(ULONG)]
+BSCGetModuleContents = _libraries['msbsc70.dll'].BSCGetModuleContents
+BSCGetModuleContents.restype = BOOL
+BSCGetModuleContents.argtypes = [POINTER(Bsc), IMOD, MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCGetModuleByName = _libraries['msbsc70.dll'].BSCGetModuleByName
+BSCGetModuleByName.restype = BOOL
+BSCGetModuleByName.argtypes = [POINTER(Bsc), SZ, POINTER(IMOD)]
+BSCGetAllModulesArray = _libraries['msbsc70.dll'].BSCGetAllModulesArray
+BSCGetAllModulesArray.restype = BOOL
+BSCGetAllModulesArray.argtypes = [POINTER(Bsc), POINTER(POINTER(IMOD)), POINTER(ULONG)]
+BSCDisposeArray = _libraries['msbsc70.dll'].BSCDisposeArray
+BSCDisposeArray.restype = None
+BSCDisposeArray.argtypes = [POINTER(Bsc), c_void_p]
+BSCFormatDname = _libraries['msbsc70.dll'].BSCFormatDname
+BSCFormatDname.restype = SZ
+BSCFormatDname.argtypes = [POINTER(Bsc), SZ]
+BSCFInstFilter = _libraries['msbsc70.dll'].BSCFInstFilter
+BSCFInstFilter.restype = BOOL
+BSCFInstFilter.argtypes = [POINTER(Bsc), IINST, MBF]
+BSCIinstFrIref = _libraries['msbsc70.dll'].BSCIinstFrIref
+BSCIinstFrIref.restype = IINST
+BSCIinstFrIref.argtypes = [POINTER(Bsc), IREF]
+BSCIinstFrIdef = _libraries['msbsc70.dll'].BSCIinstFrIdef
+BSCIinstFrIdef.restype = IINST
+BSCIinstFrIdef.argtypes = [POINTER(Bsc), IDEF]
+BSCIinstContextIref = _libraries['msbsc70.dll'].BSCIinstContextIref
+BSCIinstContextIref.restype = IINST
+BSCIinstContextIref.argtypes = [POINTER(Bsc), IREF]
+BSCGetStatistics = _libraries['msbsc70.dll'].BSCGetStatistics
+BSCGetStatistics.restype = BOOL
+BSCGetStatistics.argtypes = [POINTER(Bsc), POINTER(BSC_STAT)]
+BSCGetModuleStatistics = _libraries['msbsc70.dll'].BSCGetModuleStatistics
+BSCGetModuleStatistics.restype = BOOL
+BSCGetModuleStatistics.argtypes = [POINTER(Bsc), IMOD, POINTER(BSC_STAT)]
+BSCFCaseSensitive = _libraries['msbsc70.dll'].BSCFCaseSensitive
+BSCFCaseSensitive.restype = BOOL
+BSCFCaseSensitive.argtypes = [POINTER(Bsc)]
+BSCSetCaseSensitivity = _libraries['msbsc70.dll'].BSCSetCaseSensitivity
+BSCSetCaseSensitivity.restype = BOOL
+BSCSetCaseSensitivity.argtypes = [POINTER(Bsc), BOOL]
+BSCGetAllGlobalsArray = _libraries['msbsc70.dll'].BSCGetAllGlobalsArray
+BSCGetAllGlobalsArray.restype = BOOL
+BSCGetAllGlobalsArray.argtypes = [POINTER(Bsc), MBF, POINTER(POINTER(IINST)), POINTER(ULONG)]
+BSCSzFrAtr2 = _libraries['msbsc70.dll'].BSCSzFrAtr2
+BSCSzFrAtr2.restype = SZ
+BSCSzFrAtr2.argtypes = [POINTER(Bsc), ATR32]
+BSCIinstInfo2 = _libraries['msbsc70.dll'].BSCIinstInfo2
+BSCIinstInfo2.restype = BOOL
+BSCIinstInfo2.argtypes = [POINTER(Bsc), IINST, POINTER(SZ), POINTER(TYP), POINTER(ATR32)]
+BSCGetIinstByvalue2 = _libraries['msbsc70.dll'].BSCGetIinstByvalue2
+BSCGetIinstByvalue2.restype = BOOL
+BSCGetIinstByvalue2.argtypes = [POINTER(Bsc), SZ, TYP, ATR32, POINTER(IINST)]
+OpenBSCQuery = _libraries['msbsc70.dll'].OpenBSCQuery
+OpenBSCQuery.restype = BOOL
+OpenBSCQuery.argtypes = [POINTER(Bsc)]
+CloseBSCQuery = _libraries['msbsc70.dll'].CloseBSCQuery
+CloseBSCQuery.restype = BOOL
+CloseBSCQuery.argtypes = []
+BOB = ULONG
+InitBSCQuery = _libraries['msbsc70.dll'].InitBSCQuery
+InitBSCQuery.restype = BOOL
+InitBSCQuery.argtypes = [QY, BOB]
+BobNext = _libraries['msbsc70.dll'].BobNext
+BobNext.restype = BOB
+BobNext.argtypes = []
+BobFrName = _libraries['msbsc70.dll'].BobFrName
+BobFrName.restype = BOB
+BobFrName.argtypes = [SZ]
+LszNameFrBob = _libraries['msbsc70.dll'].LszNameFrBob
+LszNameFrBob.restype = SZ
+LszNameFrBob.argtypes = [BOB]
+CLS = USHORT
+
+class MBF:
+ mbfNil = 0x000
+ mbfVars = 0x001
+ mbfFuncs = 0x002
+ mbfMacros = 0x004
+ mbfTypes = 0x008
+ mbfClass = 0x010
+ mbfIncl = 0x020
+ mbfMsgMap = 0x040
+ mbfDialogID = 0x080
+ mbfLibrary = 0x100
+ mbfImport = 0x200
+ mbfTemplate = 0x400
+ mbfNamespace = 0x800
+ mbfAll = 0xFFF
+
+class bsc_reader_t( object ):
+ def __init__( self, bsc_file ):
+ self.logger = utils.loggers.pdb_reader
+ self.logger.setLevel(logging.DEBUG)
+
+ self.__bsc_file = bsc_file
+ self.__bsc = pointer( Bsc() )
+ self.logger.debug( 'openning bsc file "%s"', self.__bsc_file )
+ if not BSCOpen( self.__bsc_file, byref( self.__bsc ) ):
+ self.logger.debug( 'unable to open bsc file "%s"', self.__bsc_file )
+ raise RuntimeError( "Unable to open bsc file '%s'" % self.__bsc_file )
+ self.logger.debug( 'openning bsc file "%s" - done', self.__bsc_file )
+
+ self.__instances = []
+
+ def query_all_instances( self ):
+ instances_len = ULONG(0)
+ instances = pointer( IINST() )
+
+ self.logger.debug( 'call BSCGetAllGlobalsArray function' )
+ if not BSCGetAllGlobalsArray( self.__bsc, MBF.mbfAll, byref( instances ), byref( instances_len ) ):
+ self.logger.debug( 'call BSCGetAllGlobalsArray function - failure' )
+ raise RuntimeError( "Unable to load all globals symbols" )
+ self.logger.debug( 'call BSCGetAllGlobalsArray function - success' )
+ self.logger.debug( 'instances_len: %d', instances_len.value )
+ for i in range( instances_len.value ):
+ print i
+ self.__instances.append( i )
+
+ def print_stat( self ):
+ stat = BSC_STAT()
+ BSCGetStatistics( self.__bsc, byref( stat ) )
+ for f, t in stat._fields_:
+ print '%s: %s' % ( f, str( getattr( stat, f) ) )
+
+ def __del__( self ):
+ BSCClose( self.__bsc )
+
+
+
+
+if __name__ == '__main__':
+ #for i in range( 1000 ):
+ control_bsc = r'xxx.bsc'
+ reader = bsc_reader_t( control_bsc )
+ reader.print_stat()
+ reader.query_all_instances()
+
+
Modified: pygccxml_dev/pygccxml/pdb_reader/msvc_details.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/msvc_details.py 2008-02-26 20:38:16 UTC (rev 1263)
+++ pygccxml_dev/pygccxml/pdb_reader/msvc_details.py 2008-02-27 14:12:56 UTC (rev 1264)
@@ -12,6 +12,11 @@
relative_path = os.path.dirname( sys.modules[__name__].__file__)
absolute_path = os.path.abspath (relative_path)
return os.path.join( absolute_path, 'msbsc70.dll' )
+
+ def get_msvcr_path( self ):
+ relative_path = os.path.dirname( sys.modules[__name__].__file__)
+ absolute_path = os.path.abspath (relative_path)
+ return os.path.join( absolute_path, 'msvcr70.dll' )
def get_msdia_path( self ):
vss_installed = self.__get_installed_vs_dirs()
@@ -54,6 +59,9 @@
msbsc_path = bs.get_msbsc_path()
print 'msbsc path: ', msbsc_path
+msvcr_path = bs.get_msvcr_path()
+print 'msvcr path: ', msvcr_path
+
comtypes_client_gen_dir = comtypes.client.gen_dir
try:
comtypes.client.gen_dir = None
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-26 20:38:14
|
Revision: 1263
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1263&view=rev
Author: roman_yakovenko
Date: 2008-02-26 12:38:16 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
adding bsc support
Modified Paths:
--------------
pygccxml_dev/pygccxml/pdb_reader/details.py
pygccxml_dev/pygccxml/pdb_reader/scanner.py
pygccxml_dev/pygccxml/utils/__init__.py
Added Paths:
-----------
pygccxml_dev/pygccxml/pdb_reader/bsc.py
pygccxml_dev/pygccxml/pdb_reader/msvc_details.py
Removed Paths:
-------------
pygccxml_dev/pygccxml/pdb_reader/msdia_details.py
Added: pygccxml_dev/pygccxml/pdb_reader/bsc.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/bsc.py (rev 0)
+++ pygccxml_dev/pygccxml/pdb_reader/bsc.py 2008-02-26 20:38:16 UTC (rev 1263)
@@ -0,0 +1,10 @@
+import os
+import sys
+import ctypes
+import msvc_details
+
+bsc = ctypes.cdll.LoadLibrary( msvc_details.msbsc_path )
+
+class bsc_t( object ):
+ def __init__( self, bsc_file_path ):
+ self.__bsc_file = bsc_file_path
\ No newline at end of file
Modified: pygccxml_dev/pygccxml/pdb_reader/details.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/details.py 2008-02-25 20:47:57 UTC (rev 1262)
+++ pygccxml_dev/pygccxml/pdb_reader/details.py 2008-02-26 20:38:16 UTC (rev 1263)
@@ -1,4 +1,4 @@
-from msdia_details import msdia
+from msvc_details import msdia
from pygccxml import declarations
def guess_class_type( udt_kind ):
Deleted: pygccxml_dev/pygccxml/pdb_reader/msdia_details.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/msdia_details.py 2008-02-25 20:47:57 UTC (rev 1262)
+++ pygccxml_dev/pygccxml/pdb_reader/msdia_details.py 2008-02-26 20:38:16 UTC (rev 1263)
@@ -1,80 +0,0 @@
-import os
-import comtypes
-import comtypes.client
-import _winreg as win_registry
-from distutils import msvccompiler
-
-class msdia_searcher_t:
- def __init__( self ):
- self.root_reg_key = win_registry.HKEY_LOCAL_MACHINE
-
- def find_path( self ):
- vss_installed = self.__get_installed_vs_dirs()
- msdia_dlls = self.__get_msdia_dll_paths( vss_installed )
- if 1 == len(msdia_dlls):
- return msdia_dlls[0]
- else:
- #TODO find the highest version and use it.
- pass
-
- def __get_msdia_dll_paths( self, vss_installed ):
- msdia_dlls = []
- for vs in vss_installed:
- debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' )
- files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' )
- , os.listdir( debug_dir ) )
- if not files:
- continue
- msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ])
- if not msdia_dlls:
- raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' )
- return msdia_dlls
-
- def __get_installed_vs_dirs( self ):
- vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7'
- values = self.read_values( self.root_reg_key, vs_reg_path )
- return [ values.values()[0] ]
-
- def read_keys(self, base, key):
- return msvccompiler.read_keys(base, key)
-
- def read_values(self, base, key):
- return msvccompiler.read_values(base, key)
-
-msdia_path = msdia_searcher_t().find_path()
-print msdia_path
-
-comtypes_client_gen_dir = comtypes.client.gen_dir
-try:
- comtypes.client.gen_dir = None
- msdia = comtypes.client.GetModule( msdia_path )
-finally:
- comtypes.client.gen_dir = comtypes_client_gen_dir
-
-#Adding code, that was not generated for some reason.
-
-class UdtKind:
- UdtStruct, UdtClass, UdtUnion = (0, 1, 2)
-
-class CV_access_e:
- CV_private, CV_protected, CV_public = (1, 2, 3)
-
-msdia.UdtKind = UdtKind
-msdia.CV_access_e = CV_access_e
-
-class NameSearchOptions:
- nsNone = 0
- nsfCaseSensitive = 0x1
- nsfCaseInsensitive = 0x2
- nsfFNameExt = 0x4
- nsfRegularExpression = 0x8
- nsfUndecoratedName = 0x10
-
- # For backward compabibility:
- nsCaseSensitive = nsfCaseSensitive
- nsCaseInsensitive = nsfCaseInsensitive
- nsFNameExt = nsfFNameExt
- nsRegularExpression = nsfRegularExpression | nsfCaseSensitive
- nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive
-
-msdia.NameSearchOptions = NameSearchOptions
Copied: pygccxml_dev/pygccxml/pdb_reader/msvc_details.py (from rev 1262, pygccxml_dev/pygccxml/pdb_reader/msdia_details.py)
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/msvc_details.py (rev 0)
+++ pygccxml_dev/pygccxml/pdb_reader/msvc_details.py 2008-02-26 20:38:16 UTC (rev 1263)
@@ -0,0 +1,90 @@
+import os
+import sys
+import comtypes
+import comtypes.client
+import _winreg as win_registry
+from distutils import msvccompiler
+
+
+class binaries_searcher_t:
+
+ def get_msbsc_path( self ):
+ relative_path = os.path.dirname( sys.modules[__name__].__file__)
+ absolute_path = os.path.abspath (relative_path)
+ return os.path.join( absolute_path, 'msbsc70.dll' )
+
+ def get_msdia_path( self ):
+ vss_installed = self.__get_installed_vs_dirs()
+ msdia_dlls = self.__get_msdia_dll_paths( vss_installed )
+ if 1 == len(msdia_dlls):
+ return msdia_dlls[0]
+ else:
+ #TODO find the highest version and use it.
+ pass
+
+ def __get_msdia_dll_paths( self, vss_installed ):
+ msdia_dlls = []
+ for vs in vss_installed:
+ debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' )
+ files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' )
+ , os.listdir( debug_dir ) )
+ if not files:
+ continue
+ msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ])
+ if not msdia_dlls:
+ raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' )
+ return msdia_dlls
+
+ def __get_installed_vs_dirs( self ):
+ vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7'
+ values = self.read_values( win_registry.HKEY_LOCAL_MACHINE, vs_reg_path )
+ return [ values.values()[0] ]
+
+ def read_keys(self, base, key):
+ return msvccompiler.read_keys(base, key)
+
+ def read_values(self, base, key):
+ return msvccompiler.read_values(base, key)
+
+bs = binaries_searcher_t()
+
+msdia_path = bs.get_msdia_path()
+print 'msdia path: ', msdia_path
+
+msbsc_path = bs.get_msbsc_path()
+print 'msbsc path: ', msbsc_path
+
+comtypes_client_gen_dir = comtypes.client.gen_dir
+try:
+ comtypes.client.gen_dir = None
+ msdia = comtypes.client.GetModule( msdia_path )
+finally:
+ comtypes.client.gen_dir = comtypes_client_gen_dir
+
+#Adding code, that was not generated for some reason.
+
+class UdtKind:
+ UdtStruct, UdtClass, UdtUnion = (0, 1, 2)
+
+class CV_access_e:
+ CV_private, CV_protected, CV_public = (1, 2, 3)
+
+msdia.UdtKind = UdtKind
+msdia.CV_access_e = CV_access_e
+
+class NameSearchOptions:
+ nsNone = 0
+ nsfCaseSensitive = 0x1
+ nsfCaseInsensitive = 0x2
+ nsfFNameExt = 0x4
+ nsfRegularExpression = 0x8
+ nsfUndecoratedName = 0x10
+
+ # For backward compabibility:
+ nsCaseSensitive = nsfCaseSensitive
+ nsCaseInsensitive = nsfCaseInsensitive
+ nsFNameExt = nsfFNameExt
+ nsRegularExpression = nsfRegularExpression | nsfCaseSensitive
+ nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive
+
+msdia.NameSearchOptions = NameSearchOptions
Modified: pygccxml_dev/pygccxml/pdb_reader/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-25 20:47:57 UTC (rev 1262)
+++ pygccxml_dev/pygccxml/pdb_reader/scanner.py 2008-02-26 20:38:16 UTC (rev 1263)
@@ -5,7 +5,7 @@
import logging
import comtypes
import comtypes.client
-from msdia_details import msdia
+from msvc_details import msdia
sys.path.append( r'../..' )
#sys.path.append( r'C:\dev\language-binding\pygccxml_dev' )
Modified: pygccxml_dev/pygccxml/utils/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/utils/__init__.py 2008-02-25 20:47:57 UTC (rev 1262)
+++ pygccxml_dev/pygccxml/utils/__init__.py 2008-02-26 20:38:16 UTC (rev 1263)
@@ -17,7 +17,8 @@
"""implementation details"""
logger = logging.getLogger(name)
handler = logging.StreamHandler()
- handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) )
+ #handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) )
+ handler.setFormatter( logging.Formatter( '%(levelname)s %(message)s' ) )
logger.addHandler(handler)
logger.setLevel(logging.INFO)
return logger
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-25 20:47:51
|
Revision: 1262
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1262&view=rev
Author: roman_yakovenko
Date: 2008-02-25 12:47:57 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
update unit 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-25 20:40:52 UTC (rev 1261)
+++ pyplusplus_dev/unittests/data/override_bug_to_be_exported.hpp 2008-02-25 20:47:57 UTC (rev 1262)
@@ -60,16 +60,16 @@
}
-class AA
+struct AA
{
public:
virtual void do_smth(int& i) const { i = 'a' ;}
virtual ~AA(){}
};
-class BB: public AA
+struct BB: public AA
{
- virtual void do_smth(int& i) const { i = 'b' ;}
+ virtual void do_smth(int& i, int& j) const { i = j = 'b' ;}
};
}
Modified: pyplusplus_dev/unittests/override_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/override_bug_tester.py 2008-02-25 20:40:52 UTC (rev 1261)
+++ pyplusplus_dev/unittests/override_bug_tester.py 2008-02-25 20:47:57 UTC (rev 1262)
@@ -21,8 +21,10 @@
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) )
+ do_smth = mb.mem_fun( '::override_bug::AA::do_smth' )
+ do_smth.add_transformation( FT.output(0), alias='do_smth_a' )
+ do_smth = mb.mem_fun( '::override_bug::BB::do_smth' )
+ do_smth.add_transformation( FT.output(0), FT.output(1), alias='do_smth_b' )
def run_tests(self, module):
class C( module.B ):
@@ -42,6 +44,11 @@
self.failUnless( 22223 == module.eval( Derived4() ) )
+ bb = module.BB()
+ print dir( bb )
+ x = bb.do_smth_b()
+ self.failUnless( x[0] == x[1] == ord( 'b' ) )
+
# 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-25 20:40:47
|
Revision: 1261
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1261&view=rev
Author: roman_yakovenko
Date: 2008-02-25 12:40:52 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
improve algorithm, which decides when function should be exposed with the signature
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2008-02-25 07:32:55 UTC (rev 1260)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2008-02-25 20:40:52 UTC (rev 1261)
@@ -69,6 +69,9 @@
break
if self._create_with_signature:
break
+ if not self._create_with_signature:
+ self._create_with_signature \
+ = bool( self.parent.calldefs( self.name, recursive=False, allow_empty=True ) )
return self._create_with_signature
def _set_create_with_signature(self, create_with_signature):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-02-25 07:32:51
|
Revision: 1260
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1260&view=rev
Author: roman_yakovenko
Date: 2008-02-24 23:32:55 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
fixing docs
Modified Paths:
--------------
pygccxml_dev/docs/history/history.rest
Modified: pygccxml_dev/docs/history/history.rest
===================================================================
--- pygccxml_dev/docs/history/history.rest 2008-02-25 07:25:27 UTC (rev 1259)
+++ pygccxml_dev/docs/history/history.rest 2008-02-25 07:32:55 UTC (rev 1260)
@@ -29,9 +29,11 @@
-----------
1. Support for ellipsis was added.
+
Warning: this feature introduce backward compatibility problem!
-
+
Description:
+
.. code-block:: C++
void do_smth( int, ... )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|