[pygccxml-commit] SF.net SVN: pygccxml: [766] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-11-30 10:34:04
|
Revision: 766 http://svn.sourceforge.net/pygccxml/?rev=766&view=rev Author: roman_yakovenko Date: 2006-11-30 02:33:59 -0800 (Thu, 30 Nov 2006) Log Message: ----------- adding new functionality: declarations will report declarations and types they depend on Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/declaration.py pygccxml_dev/pygccxml/declarations/enumeration.py pygccxml_dev/pygccxml/declarations/namespace.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/declarations/typedef.py pygccxml_dev/pygccxml/declarations/variable.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/pygccxml/declarations/dependencies.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-11-30 10:33:59 UTC (rev 766) @@ -6,7 +6,7 @@ """ contains classes that describe different C++ declarations """ - +from dependencies import dependency_info_t from declaration import location_t from declaration import declaration_t from scopedef import scopedef_t Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2006-11-30 10:33:59 UTC (rev 766) @@ -21,6 +21,7 @@ import algorithm import declaration import type_traits +import dependencies import call_invocation class VIRTUALITY_TYPES: @@ -270,6 +271,17 @@ demangled_name = property( _get_demangled_name , doc="returns function demangled name. It can help you to deal with function template instantiations") + def i_depend_on_them( self ): + report_dependency = lambda x: dependencies.dependency_info_t( self, x ) + answer = [] + map( lambda arg: answer.append( report_dependency( arg.type ) ) + , self.arguments ) + if self.return_type: + answer.append( report_dependency( self.return_type ) ) + map( lambda exception: answer.append( report_dependency( exception ) ) + , self.exceptions ) + return answer + #Second level in hierarchy of calldef class member_calldef_t( calldef_t ): """base class for "callable" declarations that defined within C++ class or struct""" Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2006-11-30 10:33:59 UTC (rev 766) @@ -15,6 +15,7 @@ import scopedef import algorithm import declaration +import dependencies class ACCESS_TYPES: """class that defines "access" constants""" @@ -83,7 +84,10 @@ def _get__cmp__items(self): """implementation details""" return [] - + + def i_depend_on_them( self ): + return [] + class class_t( scopedef.scopedef_t ): """describes class definition""" @@ -330,3 +334,24 @@ else: return member.cache.access_type + def __find_out_member_dependencies( self, access_type ): + members = self.get_members( access_type ) + answer = [] + map( lambda mem: answer.extend( mem.i_depend_on_them() ), members ) + member_ids = set( map( lambda m: id( m ), members ) ) + for dependency in answer: + if id( dependency.declaration ) in member_ids: + dependency.access_type = access_type + return answer + + def i_depend_on_them( self ): + report_dependency = lambda *args: dependencies.dependency_info_t( self, *args ) + answer = [] + + map( lambda base: answer.append( report_dependency( base.related_class, base.access_type ) ) + , self.bases ) + + map( lambda access_type: answer.extend( self.__find_out_member_dependencies( access_type ) ) + , ACCESS_TYPES.ALL ) + + return answer Modified: pygccxml_dev/pygccxml/declarations/declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/declaration.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/declaration.py 2006-11-30 10:33:59 UTC (rev 766) @@ -244,3 +244,8 @@ reference to instance of L{algorithms_cache.algorithms_cache_t} class. """ return self._cache + + def i_depend_on_them( self ): + #this method should return list of all types, declarations it depends on + print self + raise NotImplementedError() Added: pygccxml_dev/pygccxml/declarations/dependencies.py =================================================================== --- pygccxml_dev/pygccxml/declarations/dependencies.py (rev 0) +++ pygccxml_dev/pygccxml/declarations/dependencies.py 2006-11-30 10:33:59 UTC (rev 766) @@ -0,0 +1,34 @@ +# 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) + +""" +""" + +class dependency_info_t( object ): + def __init__( self, declaration, depend_on_it, access_type=None ): + object.__init__( self ) + self._declaration = declaration + self._depend_on_it = depend_on_it + self._access_type = access_type + + @property + def declaration( self ): + return self._declaration + #short name + decl = declaration + + @property + def depend_on_it( self ): + return self._depend_on_it + + def _get_access_type( self ): + return self._access_type + def _set_access_type( self, access_type ): + self._access_type = access_type + access_type = property( _get_access_type, _set_access_type ) + + def __str__( self ): + return 'declaration "%s" depends( %s ) on "%s" ' \ + % ( self.declaration, self.access_type, self.depend_on_it ) Modified: pygccxml_dev/pygccxml/declarations/enumeration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/enumeration.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/enumeration.py 2006-11-30 10:33:59 UTC (rev 766) @@ -113,3 +113,6 @@ for val, num in self._values: x[val] = num return x + + def i_depend_on_them( self ): + return [] Modified: pygccxml_dev/pygccxml/declarations/namespace.py =================================================================== --- pygccxml_dev/pygccxml/declarations/namespace.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/namespace.py 2006-11-30 10:33:59 UTC (rev 766) @@ -135,3 +135,7 @@ , recursive=recursive , allow_empty=allow_empty) + def i_depend_on_them( self ): + answer = [] + map( lambda decl: answer.extend( decl.i_depend_on_them() ), self.declarations ) + return answer Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2006-11-30 10:33:59 UTC (rev 766) @@ -625,6 +625,3 @@ - - - Modified: pygccxml_dev/pygccxml/declarations/typedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/typedef.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/typedef.py 2006-11-30 10:33:59 UTC (rev 766) @@ -8,6 +8,7 @@ """ import declaration +import dependencies class typedef_t( declaration.declaration_t ): """describes C++ typedef declaration""" @@ -32,3 +33,6 @@ self._type = type type = property( _get_type, _set_type , doc="reference to the original L{type<type_t>}" ) + + def i_depend_on_them( self ): + return [ dependencies.dependency_info_t( self, self.type ) ] Modified: pygccxml_dev/pygccxml/declarations/variable.py =================================================================== --- pygccxml_dev/pygccxml/declarations/variable.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/pygccxml/declarations/variable.py 2006-11-30 10:33:59 UTC (rev 766) @@ -8,6 +8,7 @@ """ import declaration +import dependencies import class_declaration class variable_t( declaration.declaration_t ): @@ -68,3 +69,5 @@ raise RuntimeError( "access_type functionality only available on member variables and not on global variables" ) return self.parent.find_out_member_access_type( self ) + def i_depend_on_them( self ): + return [ dependencies.dependency_info_t( self, self.type ) ] Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-11-29 20:10:52 UTC (rev 765) +++ pygccxml_dev/unittests/test_all.py 2006-11-30 10:33:59 UTC (rev 766) @@ -39,6 +39,7 @@ import declarations_cache_tester import has_binary_operator_traits_tester import algorithms_cache_tester +import dependencies_tester def create_suite(): testers = [ @@ -77,6 +78,7 @@ , declarations_cache_tester , has_binary_operator_traits_tester , algorithms_cache_tester + , dependencies_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |