[pygccxml-commit] SF.net SVN: pygccxml: [1316] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2008-04-30 21:01:46
|
Revision: 1316 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1316&view=rev Author: roman_yakovenko Date: 2008-04-30 14:01:30 -0700 (Wed, 30 Apr 2008) Log Message: ----------- adding support for function types Modified Paths: -------------- pygccxml_dev/pygccxml/msvc/pdb/loader.py pygccxml_dev/unittests/core_tester.py pygccxml_dev/unittests/data/msvc_build/all.cpp pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py =================================================================== --- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-28 15:22:30 UTC (rev 1315) +++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-30 21:01:30 UTC (rev 1316) @@ -267,9 +267,14 @@ def __clear_symbols(self): self.logger.info( 'clearing symbols' ) to_be_deleted = [] + useless_tags = ( + msdia.SymTagAnnotation + , msdia.SymTagPublicSymbol + , msdia.SymTagBlock + ) for smbl_id, smbl in self.symbols.iteritems(): - if ( smbl.symTag == msdia.SymTagData and not self.__is_my_var( smbl ) ) \ - or smbl.symTag in ( msdia.SymTagAnnotation, msdia.SymTagPublicSymbol ): + if smbl.symTag in useless_tags \ + or ( smbl.symTag == msdia.SymTagData and not self.__is_my_var( smbl ) ): to_be_deleted.append( smbl_id ) map( lambda smbl_id: self.symbols.pop( smbl_id ), to_be_deleted ) @@ -301,7 +306,7 @@ def read(self): - #self.__clear_symbols() + self.__clear_symbols() self.__load_nss() self.__load_classes() self.__load_base_classes() @@ -482,14 +487,28 @@ def __create_typedef( self, smbl ): self.logger.debug( 'creating typedef "%s"', smbl.uname ) name_splitter = impl_details.get_name_splitter( smbl.uname ) - #~ if name_splitter.name == 'typedef_pointer_int': - #~ pdb.set_trace() decl = declarations.typedef_t( name_splitter.name , self.create_type( smbl.type ) ) self.__update_decl( decl, smbl ) self.logger.debug( 'creating typedef "%s" - done', smbl.uname ) return decl + def __create_function_type( self, smbl ): + return_type = self.create_type( smbl.type ) + args_smbls = smbl.findChildren( msdia.SymTagFunctionArgType, None, 0 ) + args_types = map( self.create_type, itertools.imap(as_symbol, args_smbls) ) + if smbl.objectPointerType: + try: + class_ = self.create_type( smbl.objectPointerType ) + class_ = declarations.base_type( class_ ) + pdb.set_trace() + return declarations.member_function_type_t( class_, return_type, args_types ) + except: + self.logger.warning( 'unable to find out the type of the object pointer for a class method.' ) + return declarations.unknown_t() + else: + return declarations.free_function_type_t( return_type, args_types ) + def create_type( self, smbl ): #http://msdn2.microsoft.com/en-us/library/s3f49ktz(VS.80).aspx if smbl.symIndexId in self.__types_cache: @@ -568,6 +587,10 @@ my_type = declarations.declarated_t( decl ) else: my_type = declarations.unknown_t() + elif msdia.SymTagFunctionArgType == smbl.symTag: + my_type = self.create_type( smbl.type ) + elif msdia.SymTagFunctionType == smbl.symTag: + my_type = self.__create_function_type( smbl ) else: my_type = declarations.unknown_t() try: @@ -575,7 +598,12 @@ except AttributeError: pass if smbl.constType: - my_type = declarations.const_t( my_type ) + if isinstance( my_type, declarations.member_function_type_t ): + my_type.has_const = True + else: + if not isinstance( my_type, declarations.const_t ): + my_type = declarations.const_t( my_type ) if smbl.volatileType: - my_type = declarations.volatile_t( my_type ) + if not isinstance( my_type, declarations.volatile_t ): + my_type = declarations.volatile_t( my_type ) return my_type Modified: pygccxml_dev/unittests/core_tester.py =================================================================== --- pygccxml_dev/unittests/core_tester.py 2008-04-28 15:22:30 UTC (rev 1315) +++ pygccxml_dev/unittests/core_tester.py 2008-04-30 21:01:30 UTC (rev 1316) @@ -243,7 +243,6 @@ , "member function type class should be '%s' instead of '%s'" \ % ( members_pointers.decl_string, function_type.class_inst.decl_string ) ) - self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." ) self.failUnless( isinstance( function_type.return_type, int_t ) , "return function type of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \ %( 'int_t', function_type.return_type.__class__.__name__ ) ) @@ -254,6 +253,8 @@ , "first argument of function of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \ %( 'double_t', function_type.arguments_types[0].__class__.__name__ ) ) + self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." ) + def test_member_variable_type(self): mv = self.global_ns.decl( decl_type=typedef_t, name='member_variable_ptr_t') self._test_type_composition( mv.type, pointer_t, member_variable_type_t ) Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp =================================================================== --- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-28 15:22:30 UTC (rev 1315) +++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-30 21:01:30 UTC (rev 1316) @@ -1,3 +1,4 @@ +#include <string> #include "abstract_classes.hpp" #include "attributes.hpp" #include "bit_fields.hpp" @@ -87,6 +88,11 @@ core::types::member_variable_ptr_t member_variable_ptr_ = 0; core::types::typedef_EFavoriteDrinks typedef_EFavoriteDrinks_; + std::wstring hello_world; + + core::types::function_ptr function_ptr_ = 0; + core::types::member_function_ptr_t member_function_ptr_ = 0; + } void use_core_ns_join_3(){ Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj =================================================================== --- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-28 15:22:30 UTC (rev 1315) +++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-30 21:01:30 UTC (rev 1316) @@ -22,6 +22,7 @@ IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" CharacterSet="1" + WholeProgramOptimization="0" > <Tool Name="VCPreBuildEventTool" @@ -69,6 +70,7 @@ GenerateDebugInformation="true" GenerateMapFile="true" MapExports="true" + Profile="true" /> <Tool Name="VCALinkTool" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |