Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions googlemock/scripts/generator/cpp/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def AddType(templated_types):
elif token.name == '&':
reference = True
elif token.name == '[':
pointer = True
pointer = True
elif token.name == ']':
pass
else:
Expand Down Expand Up @@ -576,7 +576,7 @@ def DeclarationToParts(self, parts, needs_name_removed):
elif p.name not in ('*', '&', '>'):
# Ensure that names have a space between them.
if (type_name and type_name[-1].token_type == tokenize.NAME and
p.token_type == tokenize.NAME):
p.token_type == tokenize.NAME):
type_name.append(tokenize.Token(tokenize.SYNTAX, ' ', 0, 0))
type_name.append(p)
else:
Expand Down Expand Up @@ -652,7 +652,7 @@ def CreateReturnType(self, return_type_seq):
start = return_type_seq[0].start
end = return_type_seq[-1].end
_, name, templated_types, modifiers, default, other_tokens = \
self.DeclarationToParts(return_type_seq, False)
self.DeclarationToParts(return_type_seq, False)
names = [n.name for n in other_tokens]
reference = '&' in names
pointer = '*' in names
Expand Down Expand Up @@ -816,7 +816,7 @@ def _GenerateOne(self, token):
# self.in_class can contain A::Name, but the dtor will only
# be Name. Make sure to compare against the right value.
if (token.token_type == tokenize.NAME and
token.name == self.in_class_name_only):
token.name == self.in_class_name_only):
return self._GetMethod([token], FUNCTION_DTOR, None, True)
# TODO(nnorwitz): handle a lot more syntax.
elif token.token_type == tokenize.PREPROCESSOR:
Expand Down Expand Up @@ -929,7 +929,10 @@ def GetScope(self):
def _GetNextToken(self):
if self.token_queue:
return self.token_queue.pop()
return next(self.tokens)
try:
return next(self.tokens)
except StopIteration:
return

def _AddBackToken(self, token):
if token.whence == tokenize.WHENCE_STREAM:
Expand Down Expand Up @@ -1129,7 +1132,7 @@ def _GetMethod(self, return_type_and_name, modifiers, templated_types,
# Looks like we got a method, not a function.
if len(return_type) > 2 and return_type[-1].name == '::':
return_type, in_class = \
self._GetReturnTypeAndClassName(return_type)
self._GetReturnTypeAndClassName(return_type)
return Method(indices.start, indices.end, name.name, in_class,
return_type, parameters, modifiers, templated_types,
body, self.namespace_stack)
Expand Down Expand Up @@ -1374,7 +1377,7 @@ def handle_delete(self):
def handle_typedef(self):
token = self._GetNextToken()
if (token.token_type == tokenize.NAME and
keywords.IsKeyword(token.name)):
keywords.IsKeyword(token.name)):
# Token must be struct/enum/union/class.
method = getattr(self, 'handle_' + token.name)
self._handling_typedef = True
Expand All @@ -1397,7 +1400,7 @@ def handle_typedef(self):
if name.name == ')':
# HACK(nnorwitz): Handle pointers to functions "properly".
if (len(tokens) >= 4 and
tokens[1].name == '(' and tokens[2].name == '*'):
tokens[1].name == '(' and tokens[2].name == '*'):
tokens.append(name)
name = tokens[3]
elif name.name == ']':
Expand Down
Loading