aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorkosak <kosak@google.com>2014-03-12 23:27:35 +0000
committerkosak <kosak@google.com>2014-03-12 23:27:35 +0000
commitc26f969579d62444ae7d422b37e0037ceca97a7a (patch)
tree191ed20102b39f6405a803e2c670ff6b115950e6 /scripts
parentb6a348862b3ef745ae4c43117b67c7c6f877cd7e (diff)
downloadgoogletest-c26f969579d62444ae7d422b37e0037ceca97a7a.tar.gz
googletest-c26f969579d62444ae7d422b37e0037ceca97a7a.tar.bz2
googletest-c26f969579d62444ae7d422b37e0037ceca97a7a.zip
Make the gmock generator work with the 'override' keyword. Also pull in gtest 680.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generator/cpp/ast.py5
-rwxr-xr-xscripts/generator/cpp/gmock_class.py3
-rwxr-xr-xscripts/generator/cpp/gmock_class_test.py11
3 files changed, 17 insertions, 2 deletions
diff --git a/scripts/generator/cpp/ast.py b/scripts/generator/cpp/ast.py
index bb8226d7..38866717 100755
--- a/scripts/generator/cpp/ast.py
+++ b/scripts/generator/cpp/ast.py
@@ -70,6 +70,7 @@ FUNCTION_DTOR = 0x10
FUNCTION_ATTRIBUTE = 0x20
FUNCTION_UNKNOWN_ANNOTATION = 0x40
FUNCTION_THROW = 0x80
+FUNCTION_OVERRIDE = 0x100
"""
These are currently unused. Should really handle these properly at some point.
@@ -1027,6 +1028,8 @@ class AstBuilder(object):
# Consume everything between the (parens).
unused_tokens = list(self._GetMatchingChar('(', ')'))
token = self._GetNextToken()
+ elif modifier_token.name == 'override':
+ modifiers |= FUNCTION_OVERRIDE
elif modifier_token.name == modifier_token.name.upper():
# HACK(nnorwitz): assume that all upper-case names
# are some macro we aren't expanding.
@@ -1285,7 +1288,7 @@ class AstBuilder(object):
if token2.token_type == tokenize.SYNTAX and token2.name == '~':
return self.GetMethod(FUNCTION_VIRTUAL + FUNCTION_DTOR, None)
assert token.token_type == tokenize.NAME or token.name == '::', token
- return_type_and_name = self._GetTokensUpTo(tokenize.SYNTAX, '(')
+ return_type_and_name = self._GetTokensUpTo(tokenize.SYNTAX, '(') # )
return_type_and_name.insert(0, token)
if token2 is not token:
return_type_and_name.insert(1, token2)
diff --git a/scripts/generator/cpp/gmock_class.py b/scripts/generator/cpp/gmock_class.py
index 3c8a877d..443accf0 100755
--- a/scripts/generator/cpp/gmock_class.py
+++ b/scripts/generator/cpp/gmock_class.py
@@ -49,7 +49,8 @@ _INDENT = 2
def _GenerateMethods(output_lines, source, class_node):
- function_type = ast.FUNCTION_VIRTUAL | ast.FUNCTION_PURE_VIRTUAL
+ function_type = (ast.FUNCTION_VIRTUAL | ast.FUNCTION_PURE_VIRTUAL |
+ ast.FUNCTION_OVERRIDE)
ctor_or_dtor = ast.FUNCTION_CTOR | ast.FUNCTION_DTOR
indent = ' ' * _INDENT
diff --git a/scripts/generator/cpp/gmock_class_test.py b/scripts/generator/cpp/gmock_class_test.py
index 07d59571..361dad7f 100755
--- a/scripts/generator/cpp/gmock_class_test.py
+++ b/scripts/generator/cpp/gmock_class_test.py
@@ -65,6 +65,17 @@ class Foo {
'MOCK_METHOD0(Bar,\nint());',
self.GenerateMethodSource(source))
+ def testSimpleOverrideMethod(self):
+ source = """
+class Foo {
+ public:
+ int Bar() override;
+};
+"""
+ self.assertEqualIgnoreLeadingWhitespace(
+ 'MOCK_METHOD0(Bar,\nint());',
+ self.GenerateMethodSource(source))
+
def testSimpleConstMethod(self):
source = """
class Foo {