Skip to content

Commit d1b6f51

Browse files
author
roman_yakovenko
committed
improve dependencies_manager.py class algorithm
1 parent 21fa480 commit d1b6f51

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

pygccxml/declarations/calldef.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ def _get_demangled_name( self ):
310310
, doc="returns function demangled name. It can help you to deal with function template instantiations")
311311

312312
def i_depend_on_them( self, recursive=True ):
313-
report_dependency = lambda x: dependencies.dependency_info_t( self, x )
313+
report_dependency = lambda *args, **keywd: dependencies.dependency_info_t( self, *args, **keywd )
314314
answer = []
315+
if self.return_type:
316+
answer.append( report_dependency( self.return_type, hint="return type" ) )
315317
map( lambda arg: answer.append( report_dependency( arg.type ) )
316318
, self.arguments )
317-
if self.return_type:
318-
answer.append( report_dependency( self.return_type ) )
319-
map( lambda exception: answer.append( report_dependency( exception ) )
319+
map( lambda exception: answer.append( report_dependency( exception, hint="exception" ) )
320320
, self.exceptions )
321321
return answer
322322

pygccxml/declarations/class_declaration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,10 @@ def __find_out_member_dependencies( self, access_type ):
457457

458458
def i_depend_on_them( self, recursive=True ):
459459
report_dependency = lambda *args: dependencies.dependency_info_t( self, *args )
460+
460461
answer = []
461462

462-
map( lambda base: answer.append( report_dependency( base.related_class, base.access_type ) )
463+
map( lambda base: answer.append( report_dependency( base.related_class, base.access_type, "base class" ) )
463464
, self.bases )
464465

465466
if recursive:

pygccxml/declarations/dependencies.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import cpptypes
1111

1212
class dependency_info_t( object ):
13-
def __init__( self, declaration, depend_on_it, access_type=None ):
13+
def __init__( self, declaration, depend_on_it, access_type=None, hint=None ):
1414
object.__init__( self )
1515
#prevent recursive import
1616
import class_declaration
1717
assert isinstance( depend_on_it, ( class_declaration.class_t, cpptypes.type_t ) )
1818
self._declaration = declaration
1919
self._depend_on_it = depend_on_it
2020
self._access_type = access_type
21+
self._hint = hint
2122

2223
@property
2324
def declaration( self ):
@@ -39,6 +40,12 @@ def __str__( self ):
3940
return 'declaration "%s" depends( %s ) on "%s" ' \
4041
% ( self.declaration, self.access_type, self.depend_on_it )
4142

43+
@property
44+
def hint(self):
45+
"""the declaration, that report dependency can put some additional inforamtion
46+
about dependency. It can be used later"""
47+
return self._hint
48+
4249
def find_out_depend_on_declaration( self ):
4350
"""if declaration depends on other declaration and not on some type
4451
this function will return reference to it. Otherwise None will be returned

0 commit comments

Comments
 (0)