File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 81
81
from algorithm import make_flatten
82
82
from algorithm import apply_visitor
83
83
from algorithm import declaration_path
84
+ from algorithm import get_named_parent
84
85
from algorithm import find_declaration
85
86
from algorithm import match_declaration_t
86
87
from algorithm import find_all_declarations
Original file line number Diff line number Diff line change @@ -70,9 +70,27 @@ def partial_declaration_path( decl ):
70
70
else :
71
71
return decl .cache .partial_declaration_path
72
72
73
+ def get_named_parent ( decl ):
74
+ """
75
+ returns a reference to a named parent declaration
76
+
77
+ @param decl: the child declaration
78
+ @type decl: L{declaration_t}
79
+
80
+ @return: reference to L{declaration_t} or None if not found
81
+ """
82
+ if not decl :
83
+ return None
84
+
85
+ parent = decl .parent
86
+ while parent and ( not parent .name or parent .name == '::' ):
87
+ parent = parent .parent
88
+ return parent
89
+
90
+
73
91
def full_name_from_declaration_path ( dpath ):
74
92
##Here I have lack of knowledge:
75
- ##TODO: "What is the full name of declaration declared in unnamed namespace?"
93
+ ##TODO: "What is the full name of declaration declared in unnamed namespace?"
76
94
result = filter ( None , dpath )
77
95
result = result [0 ] + '::' .join ( result [1 :] )
78
96
return result
@@ -98,7 +116,7 @@ def full_name( decl, with_defaults=True ):
98
116
decl .cache .full_partial_name \
99
117
= full_name_from_declaration_path ( partial_declaration_path ( decl ) )
100
118
return decl .cache .full_partial_name
101
-
119
+
102
120
def make_flatten ( decl_or_decls ):
103
121
"""
104
122
converts tree representation of declarations to flatten one.
You can’t perform that action at this time.
0 commit comments