[pygccxml-commit] SF.net SVN: pygccxml: [1323] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-06-02 21:19:01
|
Revision: 1323
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1323&view=rev
Author: roman_yakovenko
Date: 2008-06-02 14:19:07 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
small set of improvements
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/core_overloads_1.hpp
pygccxml_dev/unittests/data/core_overloads_2.hpp
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
pygccxml_dev/unittests/parser_test_case.py
pygccxml_dev/unittests/pdb_tester.py
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -274,6 +274,8 @@
msdia.SymTagAnnotation
, msdia.SymTagPublicSymbol
, msdia.SymTagBlock
+ , msdia.SymTagFuncDebugStart
+ , msdia.SymTagFuncDebugEnd
)
for smbl_id, smbl in self.symbols.iteritems():
if smbl.symTag in useless_tags \
@@ -367,9 +369,10 @@
if not isinstance( decl, declarations.typedef_t ):
decl.byte_size = smbl.length
decl.byte_offset = smbl.offset
- decl.mangled = iif( smbl.name, smbl.name, '' )
+ decl.mangled = iif( smbl.get_undecoratedNameEx(0), smbl.name, '' )
decl.demangled = iif( smbl.uname, smbl.uname, '' )
decl.is_artificial = bool( smbl.compilerGenerated )
+ decl.location = declarations.location_t( smbl.lexicalParent.sourceFileName )
def __load_classes( self ):
@@ -504,7 +507,8 @@
is_function = lambda smbl: smbl.symTag == msdia.SymTagFunction
for functions_count, function_smbl in enumerate( itertools.ifilter( is_function, self.symbols.itervalues() ) ):
function_decl = self.__create_calldef(function_smbl)
- self.__update_decls_tree( function_decl )
+ if function_decl:
+ self.__update_decls_tree( function_decl )
self.logger.info( 'building function objects(%d) - done', functions_count )
def __guess_operator_type( self, smbl, operator_type ):
@@ -540,21 +544,31 @@
calldef_type = self.create_type( smbl.type ) #what does happen with constructor?
decl = None
if isinstance( calldef_type, declarations.member_function_type_t ):
+ could_be_static = False
+ could_be_const = False
if smbl.uname.startswith( '~' ):
decl = declarations.destructor_t()
if not decl: #may be operator
decl = self.__guess_operator_type(smbl, calldef_type)
+ could_be_static = True
+ could_be_const = True
if not decl: #may be constructor
decl = self.__guess_constructor( smbl, calldef_type )
if not decl:
decl = declarations.member_function_t()
+ could_be_static = True
+ could_be_const = True
if smbl.virtual:
decl.virtuality = iif( smbl.pure
, declarations.VIRTUALITY_TYPES.PURE_VIRTUAL
, declarations.VIRTUALITY_TYPES.VIRTUAL )
+ decl.has_const = bool( could_be_const and smbl.constType )
+ decl.has_static = bool( could_be_static and smbl.isStatic )
else:
decl = self.__guess_operator_type(smbl, calldef_type)
if not decl:
+ if 'instantiate::`dynamic initializer for' in smbl.uname:
+ return #in this case we deal with initializer of some global variable
decl = declarations.free_function_t()
decl.name = smbl.uname
decl.arguments = map( lambda t: declarations.argument_t( type=t )
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/autoconfig.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -41,27 +41,23 @@
pygccxml.declarations.class_t.USE_DEMANGLED_AS_NAME = True
class cxx_parsers_cfg:
- gccxml = pygccxml.parser.gccxml_configuration_t( gccxml_path=gccxml_path
- , working_directory=data_directory
- , define_symbols=[ gccxml_version ]
- , compiler=compiler )
-
+ gccxml = None
+ if os.path.exists( os.path.join( gccxml_path, 'gccxml' ) ) \
+ or os.path.exists( os.path.join( gccxml_path, 'gccxml.exe' ) ):
+ gccxml = pygccxml.parser.gccxml_configuration_t( gccxml_path=gccxml_path
+ , working_directory=data_directory
+ , define_symbols=[ gccxml_version ]
+ , compiler=compiler )
pdb_loader = None
+ if sys.platform == 'win32':
+ from pygccxml.msvc import pdb
+ pdb_file = os.path.join( data_directory, 'msvc_build', 'Debug', 'msvc_build.pdb' )
+ pdb_loader = pdb.decl_loader_t( pdb_file )
+ pdb_loader.read()
- @staticmethod
- def get_pdb_loader():
- if not cxx_parsers_cfg.pdb_loader and sys.platform == 'win32':
- from pygccxml.msvc import pdb
- pdb_file = os.path.join( data_directory, 'msvc_build', 'Debug', 'msvc_build.pdb' )
- cxx_parsers_cfg.pdb_loader = pdb.decl_loader_t( pdb_file )
- cxx_parsers_cfg.pdb_loader.read()
- return cxx_parsers_cfg.pdb_loader
-
-
def get_pdb_global_ns():
- return cxx_parsers_cfg.get_pdb_loader().global_ns
+ return cxx_parsers_cfg.pdb_loader.global_ns
-
#~ try:
#~ import pydsc
#~ pydsc.include( r'D:\pygccxml_sources\sources\pygccxml_dev' )
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/core_tester.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -256,6 +256,8 @@
if self.global_ns.compiler != compilers.MSVC_PDB_9:
self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
+ sf = self.glo
+ members_pointers_t
def test_member_variable_type(self):
if self.global_ns.compiler == compilers.MSVC_PDB_9:
return
@@ -379,13 +381,13 @@
def create_suite():
suite = unittest.TestSuite()
- #~ suite.addTest( unittest.makeSuite(core_all_at_once_t))
- #~ suite.addTest( unittest.makeSuite(core_all_at_once_no_opt_t))
- #~ suite.addTest( unittest.makeSuite(core_file_by_file_t))
- #~ suite.addTest( unittest.makeSuite(core_file_by_file_no_opt_t))
- if sys.platform == 'win32':
+ if autoconfig.cxx_parsers_cfg.gccxml:
+ suite.addTest( unittest.makeSuite(core_all_at_once_t))
+ suite.addTest( unittest.makeSuite(core_all_at_once_no_opt_t))
+ suite.addTest( unittest.makeSuite(core_file_by_file_t))
+ suite.addTest( unittest.makeSuite(core_file_by_file_no_opt_t))
+ if autoconfig.cxx_parsers_cfg.pdb_loader:
suite.addTest( unittest.makeSuite(pdb_based_core_tester_t))
-
return suite
def run_suite():
Modified: pygccxml_dev/unittests/data/core_overloads_1.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_overloads_1.hpp 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/core_overloads_1.hpp 2008-06-02 21:19:07 UTC (rev 1323)
@@ -6,10 +6,12 @@
#ifndef __core_overloads_1_hpp__
#define __core_overloads_1_hpp__
+#include <string>
+
namespace core{ namespace overloads{
-void do_nothing( int );
-void do_nothing( double );
+void do_nothing( std::string );
+void do_nothing( std::wstring );
} }
Modified: pygccxml_dev/unittests/data/core_overloads_2.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_overloads_2.hpp 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/core_overloads_2.hpp 2008-06-02 21:19:07 UTC (rev 1323)
@@ -5,11 +5,12 @@
#ifndef __core_overloads_2_hpp__
#define __core_overloads_2_hpp__
-
+#include <string>
+#include <set>
namespace core{ namespace overloads{
-void do_nothing( bool );
-void do_nothing( float );
+void do_nothing( std::set< std::string > );
+void do_nothing( std::set< std::wstring > );
} }
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-06-02 21:19:07 UTC (rev 1323)
@@ -44,6 +44,16 @@
#include "vector_traits.hpp"
#include "core_types.hpp"
+
+namespace core{ namespace overloads{
+
+void do_nothing( std::string d){ std::cout << d; }
+void do_nothing( std::wstring d){ std::wcout << d; }
+void do_nothing( std::set< std::string > d ){ std::set< std::string >::size_type t = d.size(); }
+void do_nothing( std::set< std::wstring > d ){ std::set< std::wstring >::size_type t = d.size(); }
+
+} }
+
namespace declarations{ namespace variables{
int static_var = 0;
@@ -56,8 +66,12 @@
sizeof(core::types::exception );
}
+void use_core_overloads(){
+ namespace co = core::overloads;
+}
void use_core_types(){
+ use_core_overloads();
core::types::members_pointers_t mem_ptrs;
core::types::typedef_const_int typedef_const_int_ = 0;
core::types::typedef_pointer_int typedef_pointer_int_ = 0;
Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-06-02 21:19:07 UTC (rev 1323)
@@ -41,6 +41,7 @@
/>
<Tool
Name="VCCLCompilerTool"
+ AdditionalOptions="/Iu /n "
Optimization="0"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="..\"
@@ -85,6 +86,7 @@
/>
<Tool
Name="VCBscMakeTool"
+ AdditionalOptions="/Iu /n "
/>
<Tool
Name="VCFxCopTool"
Modified: pygccxml_dev/unittests/parser_test_case.py
===================================================================
--- pygccxml_dev/unittests/parser_test_case.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/parser_test_case.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -14,15 +14,17 @@
from pygccxml.declarations import *
class parser_test_case_t( unittest.TestCase ):
-
+
CXX_PARSER_CFG = None
-
+
def __init__(self, *args):
unittest.TestCase.__init__(self, *args)
if self.CXX_PARSER_CFG:
self.config = self.CXX_PARSER_CFG.clone()
+ elif autoconfig.cxx_parsers_cfg.gccxml:
+ self.config = autoconfig.cxx_parsers_cfg.gccxml.clone()
else:
- self.config = autoconfig.cxx_parsers_cfg.gccxml.clone()
+ pass
def _test_type_composition( self, type, expected_compound, expected_base ):
self.failUnless( isinstance( type, expected_compound)
Modified: pygccxml_dev/unittests/pdb_tester.py
===================================================================
--- pygccxml_dev/unittests/pdb_tester.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/pdb_tester.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -38,11 +38,8 @@
reader = pdb.decl_loader_t( self.pdb_file )
print reader.symbols_table.name
reader.read()
- x = []
- declarations.print_declarations( reader.global_ns, writer=x.append )
- x = filter( None, map( lambda l: l.rstrip(), x ) )
f = file( 'decls.cpp', 'w+' )
- f.write( os.linesep.join( x ) )
+ declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
f.close()
f = file( 'symbols.txt', 'w+')
@@ -76,7 +73,19 @@
#~ print undecorated
self.failUnless( msvc_utils.undecorate_name( decorated ) == undecorated )
+ #todo: move to GUI
+ def test_pdbs( self ):
+ for f in filter( lambda f: f.endswith( 'pdb' ), os.listdir( r'E:\pdbs' ) ):
+ try:
+ reader = pdb.decl_loader_t( f )
+ reader.read()
+ f = file( d + '.txt', 'w+' )
+ declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
+ f.close()
+ except Exception, error:
+ print 'unable to load pdb file ', f, ' Error: ', str(error)
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|