@@ -193,7 +193,9 @@ def is_method_namestack(stack):
193
193
elif "{" in stack and stack .index ("{" ) < stack .index ("(" ):
194
194
r = False # struct that looks like a method/class
195
195
elif "(" in stack and ")" in stack :
196
- if "{" in stack and "}" in stack :
196
+ if stack [- 1 ] == ":" :
197
+ r = True
198
+ elif "{" in stack and "}" in stack :
197
199
r = True
198
200
elif stack [- 1 ] == ";" :
199
201
if is_function_pointer_stack (stack ):
@@ -994,22 +996,6 @@ def __init__(self, nameStack, curClass, methinfo, curTemplate, doxygen, location
994
996
self .update (methinfo )
995
997
set_location_info (self , location )
996
998
997
- # Filter out initializer lists used in constructors
998
- try :
999
- paren_depth_counter = 0
1000
- for i in range (0 , len (nameStack )):
1001
- elm = nameStack [i ]
1002
- if elm == "(" :
1003
- paren_depth_counter += 1
1004
- if elm == ")" :
1005
- paren_depth_counter -= 1
1006
- if paren_depth_counter == 0 and nameStack [i + 1 ] == ":" :
1007
- debug_print ("Stripping out initializer list" )
1008
- nameStack = nameStack [: i + 1 ]
1009
- break
1010
- except :
1011
- pass
1012
-
1013
999
paramsStack = self ._params_helper1 (nameStack )
1014
1000
1015
1001
debug_print ("curTemplate: %s" , curTemplate )
@@ -2018,6 +2004,10 @@ def parse_method_type(self, stack):
2018
2004
self .braceHandled = True
2019
2005
elif stack [- 1 ] == ";" :
2020
2006
info ["defined" ] = False
2007
+ elif stack [- 1 ] == ":" :
2008
+ info ["defined" ] = True
2009
+ self ._discard_ctor_initializer ()
2010
+ self .braceHandled = True
2021
2011
else :
2022
2012
assert 0
2023
2013
@@ -2806,6 +2796,12 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
2806
2796
self .nameStack = []
2807
2797
self .stack = []
2808
2798
self .stmtTokens = []
2799
+ elif is_method_namestack (self .stack ):
2800
+ debug_print ("trace" )
2801
+ self ._evaluate_method_stack ()
2802
+ self .nameStack = []
2803
+ self .stack = []
2804
+ self .stmtTokens = []
2809
2805
else :
2810
2806
self .nameStack .append (tok .value )
2811
2807
@@ -2923,7 +2919,7 @@ def _parse_error(self, tokens, expected):
2923
2919
def _next_token_must_be (self , * tokenTypes ):
2924
2920
tok = self .lex .token ()
2925
2921
if tok .type not in tokenTypes :
2926
- raise self ._parse_error ((tok ,), " or " .join (tokenTypes ))
2922
+ raise self ._parse_error ((tok ,), "' or ' " .join (tokenTypes ))
2927
2923
return tok
2928
2924
2929
2925
_end_balanced_tokens = {">" , "}" , "]" , ")" , "DBL_RBRACKET" }
@@ -2983,6 +2979,59 @@ def _discard_contents(self, start_type, end_type):
2983
2979
if level == 0 :
2984
2980
break
2985
2981
2982
+ def _discard_ctor_initializer (self ):
2983
+ """
2984
+ ctor_initializer: ":" mem_initializer_list
2985
+
2986
+ mem_initializer_list: mem_initializer ["..."]
2987
+ | mem_initializer "," mem_initializer_list ["..."]
2988
+
2989
+ mem_initializer: mem_initializer_id "(" [expression_list] ")"
2990
+ | mem_initializer_id braced_init_list
2991
+
2992
+ mem_initializer_id: class_or_decltype
2993
+ | IDENTIFIER
2994
+ """
2995
+ debug_print ("discarding ctor intializer" )
2996
+ # all of this is discarded.. the challenge is to determine
2997
+ # when the initializer ends and the function starts
2998
+ while True :
2999
+ tok = self .lex .token ()
3000
+ if tok .type == "DBL_COLON" :
3001
+ tok = self .lex .token ()
3002
+
3003
+ if tok .type == "decltype" :
3004
+ tok = self ._next_token_must_be ("(" )
3005
+ self ._consume_balanced_tokens (tok )
3006
+ tok = self .lex .token ()
3007
+
3008
+ # each initializer is either foo() or foo{}, so look for that
3009
+ while True :
3010
+ if tok .type not in ("{" , "(" ):
3011
+ tok = self .lex .token ()
3012
+ continue
3013
+
3014
+ if tok .type == "{" :
3015
+ self ._discard_contents ("{" , "}" )
3016
+ elif tok .type == "(" :
3017
+ self ._discard_contents ("(" , ")" )
3018
+
3019
+ tok = self .lex .token ()
3020
+ break
3021
+
3022
+ # at the end
3023
+ if tok .type == "ELLIPSIS" :
3024
+ tok = self .lex .token ()
3025
+
3026
+ if tok .type == "," :
3027
+ continue
3028
+ elif tok .type == "{" :
3029
+ # reached the function
3030
+ self ._discard_contents ("{" , "}" )
3031
+ return
3032
+ else :
3033
+ raise self ._parse_error ((tok ,), ",' or '{" )
3034
+
2986
3035
def _evaluate_stack (self , token = None ):
2987
3036
"""Evaluates the current name stack"""
2988
3037
@@ -3133,7 +3182,7 @@ def _evaluate_stack(self, token=None):
3133
3182
self .nameStackHistory [self .braceDepth ] = (nameStackCopy , self .curClass )
3134
3183
except :
3135
3184
self .nameStackHistory .append ((nameStackCopy , self .curClass ))
3136
-
3185
+
3137
3186
# its a little confusing to have some if/else above return and others not, and then clearning the nameStack down here
3138
3187
self .nameStack = []
3139
3188
self .lex .doxygenCommentCache = ""
0 commit comments