diff options
Diffstat (limited to 'scripts/generator')
| -rwxr-xr-x | scripts/generator/cpp/ast.py | 8 | ||||
| -rwxr-xr-x | scripts/generator/cpp/gmock_class_test.py | 16 | 
2 files changed, 23 insertions, 1 deletions
diff --git a/scripts/generator/cpp/ast.py b/scripts/generator/cpp/ast.py index 47dc9a07..6f61f877 100755 --- a/scripts/generator/cpp/ast.py +++ b/scripts/generator/cpp/ast.py @@ -1483,7 +1483,13 @@ class AstBuilder(object):              assert class_token.token_type == tokenize.SYNTAX, class_token              token = class_token          else: -            self._AddBackToken(class_token) +            # Skip any macro (e.g. storage class specifiers) after the +            # 'class' keyword. +            next_token = self._GetNextToken() +            if next_token.token_type == tokenize.NAME: +                self._AddBackToken(next_token) +            else: +                self._AddBackTokens([class_token, next_token])              name_tokens, token = self.GetName()              class_name = ''.join([t.name for t in name_tokens])          bases = None diff --git a/scripts/generator/cpp/gmock_class_test.py b/scripts/generator/cpp/gmock_class_test.py index 607d5cf7..494720cd 100755 --- a/scripts/generator/cpp/gmock_class_test.py +++ b/scripts/generator/cpp/gmock_class_test.py @@ -193,6 +193,22 @@ void());      self.assertEqualIgnoreLeadingWhitespace(          expected, self.GenerateMocks(source)) +  def testClassWithStorageSpecifierMacro(self): +    source = """ +class STORAGE_SPECIFIER Test { + public: +  virtual void Foo(); +}; +""" +    expected = """\ +class MockTest : public Test { +public: +MOCK_METHOD0(Foo, +void()); +}; +""" +    self.assertEqualIgnoreLeadingWhitespace( +        expected, self.GenerateMocks(source))  if __name__ == '__main__':    unittest.main()  | 
