Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
c26f9695
Commit
c26f9695
authored
Mar 12, 2014
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the gmock generator work with the 'override' keyword. Also pull in gtest 680.
parent
b6a34886
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
ast.py
scripts/generator/cpp/ast.py
+4
-1
gmock_class.py
scripts/generator/cpp/gmock_class.py
+2
-1
gmock_class_test.py
scripts/generator/cpp/gmock_class_test.py
+11
-0
No files found.
scripts/generator/cpp/ast.py
View file @
c26f9695
...
@@ -70,6 +70,7 @@ FUNCTION_DTOR = 0x10
...
@@ -70,6 +70,7 @@ FUNCTION_DTOR = 0x10
FUNCTION_ATTRIBUTE
=
0x20
FUNCTION_ATTRIBUTE
=
0x20
FUNCTION_UNKNOWN_ANNOTATION
=
0x40
FUNCTION_UNKNOWN_ANNOTATION
=
0x40
FUNCTION_THROW
=
0x80
FUNCTION_THROW
=
0x80
FUNCTION_OVERRIDE
=
0x100
"""
"""
These are currently unused. Should really handle these properly at some point.
These are currently unused. Should really handle these properly at some point.
...
@@ -1027,6 +1028,8 @@ class AstBuilder(object):
...
@@ -1027,6 +1028,8 @@ class AstBuilder(object):
# Consume everything between the (parens).
# Consume everything between the (parens).
unused_tokens
=
list
(
self
.
_GetMatchingChar
(
'('
,
')'
))
unused_tokens
=
list
(
self
.
_GetMatchingChar
(
'('
,
')'
))
token
=
self
.
_GetNextToken
()
token
=
self
.
_GetNextToken
()
elif
modifier_token
.
name
==
'override'
:
modifiers
|=
FUNCTION_OVERRIDE
elif
modifier_token
.
name
==
modifier_token
.
name
.
upper
():
elif
modifier_token
.
name
==
modifier_token
.
name
.
upper
():
# HACK(nnorwitz): assume that all upper-case names
# HACK(nnorwitz): assume that all upper-case names
# are some macro we aren't expanding.
# are some macro we aren't expanding.
...
@@ -1285,7 +1288,7 @@ class AstBuilder(object):
...
@@ -1285,7 +1288,7 @@ class AstBuilder(object):
if
token2
.
token_type
==
tokenize
.
SYNTAX
and
token2
.
name
==
'~'
:
if
token2
.
token_type
==
tokenize
.
SYNTAX
and
token2
.
name
==
'~'
:
return
self
.
GetMethod
(
FUNCTION_VIRTUAL
+
FUNCTION_DTOR
,
None
)
return
self
.
GetMethod
(
FUNCTION_VIRTUAL
+
FUNCTION_DTOR
,
None
)
assert
token
.
token_type
==
tokenize
.
NAME
or
token
.
name
==
'::'
,
token
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
)
return_type_and_name
.
insert
(
0
,
token
)
if
token2
is
not
token
:
if
token2
is
not
token
:
return_type_and_name
.
insert
(
1
,
token2
)
return_type_and_name
.
insert
(
1
,
token2
)
...
...
scripts/generator/cpp/gmock_class.py
View file @
c26f9695
...
@@ -49,7 +49,8 @@ _INDENT = 2
...
@@ -49,7 +49,8 @@ _INDENT = 2
def
_GenerateMethods
(
output_lines
,
source
,
class_node
):
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
ctor_or_dtor
=
ast
.
FUNCTION_CTOR
|
ast
.
FUNCTION_DTOR
indent
=
' '
*
_INDENT
indent
=
' '
*
_INDENT
...
...
scripts/generator/cpp/gmock_class_test.py
View file @
c26f9695
...
@@ -65,6 +65,17 @@ class Foo {
...
@@ -65,6 +65,17 @@ class Foo {
'MOCK_METHOD0(Bar,
\n
int());'
,
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
self
.
GenerateMethodSource
(
source
))
def
testSimpleOverrideMethod
(
self
):
source
=
"""
class Foo {
public:
int Bar() override;
};
"""
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
def
testSimpleConstMethod
(
self
):
def
testSimpleConstMethod
(
self
):
source
=
"""
source
=
"""
class Foo {
class Foo {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment