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
67c377d3
Commit
67c377d3
authored
Jul 19, 2015
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Callback-related generated actions to a custom/ file.
parent
d86a723e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
57 deletions
+55
-57
gmock-generated-actions.h
include/gmock/gmock-generated-actions.h
+0
-0
gmock-generated-actions.h.pump
include/gmock/gmock-generated-actions.h.pump
+35
-55
callback-actions.h
include/gmock/internal/custom/callback-actions.h
+8
-0
callback-actions.h.pump
include/gmock/internal/custom/callback-actions.h.pump
+10
-0
gmock_doctor.py
scripts/gmock_doctor.py
+2
-2
No files found.
include/gmock/gmock-generated-actions.h
View file @
67c377d3
This diff is collapsed.
Click to expand it.
include/gmock/gmock-generated-actions.h.pump
View file @
67c377d3
...
...
@@ -80,60 +80,6 @@ class InvokeHelper<R, ::testing::tuple<$as> > {
]]
// CallableHelper has static methods for invoking "callables",
// i.e. function pointers and functors. It uses overloading to
// provide a uniform interface for invoking different kinds of
// callables. In particular, you can use:
//
// CallableHelper<R>::Call(callable, a1, a2, ..., an)
//
// to invoke an n-ary callable, where R is its return type. If an
// argument, say a2, needs to be passed by reference, you should write
// ByRef(a2) instead of a2 in the above expression.
template
<
typename
R
>
class
CallableHelper
{
public
:
// Calls a nullary callable.
template
<
typename
Function
>
static
R
Call
(
Function
function
)
{
return
function
();
}
// Calls a unary callable.
// We deliberately pass a1 by value instead of const reference here
// in case it is a C-string literal. If we had declared the
// parameter as 'const A1& a1' and write Call(function, "Hi"), the
// compiler would've thought A1 is 'char[3]', which causes trouble
// when you need to copy a value of type A1. By declaring the
// parameter as 'A1 a1', the compiler will correctly infer that A1
// is 'const char*' when it sees Call(function, "Hi").
//
// Since this function is defined inline, the compiler can get rid
// of the copying of the arguments. Therefore the performance won't
// be hurt.
template
<
typename
Function
,
typename
A1
>
static
R
Call
(
Function
function
,
A1
a1
)
{
return
function
(
a1
);
}
$
range
i
2.
.
n
$
for
i
[[
$
var
arity
=
[[
$
if
i
==
2
[[
binary
]]
$
elif
i
==
3
[[
ternary
]]
$
else
[[
$
i
-
ary
]]]]
// Calls a $arity callable.
$
range
j
1.
.
i
$
var
typename_As
=
[[
$
for
j
,
[[
typename
A
$
j
]]]]
$
var
Aas
=
[[
$
for
j
,
[[
A
$
j
a
$
j
]]]]
$
var
as
=
[[
$
for
j
,
[[
a
$
j
]]]]
$
var
typename_Ts
=
[[
$
for
j
,
[[
typename
T
$
j
]]]]
$
var
Ts
=
[[
$
for
j
,
[[
T
$
j
]]]]
template
<
typename
Function
,
$
typename_As
>
static
R
Call
(
Function
function
,
$
Aas
)
{
return
function
(
$
as
);
}
]]
};
// class CallableHelper
// An INTERNAL macro for extracting the type of a tuple field. It's
// subject to change without notice - DO NOT USE IN USER CODE!
#define GMOCK_FIELD_(Tuple, N) \
...
...
@@ -734,6 +680,7 @@ $$ // show up in the generated code.
namespace
testing
{
// The ACTION*() macros trigger warning C4100 (unreferenced formal
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
// the macro definition, as the warnings are generated when the macro
...
...
@@ -774,6 +721,32 @@ namespace testing {
// InvokeArgument action from temporary values and have it performed
// later.
namespace
internal
{
namespace
invoke_argument
{
// Appears in InvokeArgumentAdl's argument list to help avoid
// accidental calls to user functions of the same name.
struct
AdlTag
{};
// InvokeArgumentAdl - a helper for InvokeArgument.
// The basic overloads are provided here for generic functors.
// Overloads for other custom-callables are provided in the
// internal/custom/callback-actions.h header.
$
range
i
0.
.
n
$
for
i
[[
$
range
j
1.
.
i
template
<
typename
R
,
typename
F
[[
$
for
j
[[,
typename
A
$
j
]]]]
>
R
InvokeArgumentAdl
(
AdlTag
,
F
f
[[
$
for
j
[[,
A
$
j
a
$
j
]]]])
{
return
f
([[
$
for
j
,
[[
a
$
j
]]]]);
}
]]
}
// namespace invoke_argument
}
// namespace internal
$
range
i
0.
.
n
$
for
i
[[
$
range
j
0.
.
i
-
1
...
...
@@ -781,7 +754,9 @@ $range j 0..i-1
ACTION_TEMPLATE
(
InvokeArgument
,
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
AND_
$
i
[[]]
_VALUE_PARAMS
(
$
for
j
,
[[
p
$
j
]]))
{
return
internal
::
CallableHelper
<
return_type
>::
Call
(
using
internal
::
invoke_argument
::
InvokeArgumentAdl
;
return
InvokeArgumentAdl
<
return_type
>
(
internal
::
invoke_argument
::
AdlTag
(),
::
testing
::
get
<
k
>
(
args
)
$
for
j
[[,
p
$
j
]]);
}
...
...
@@ -811,4 +786,9 @@ ACTION_TEMPLATE(ReturnNew,
}
// namespace testing
// Include any custom callback actions added by the local installation.
// We must include this header at the end to make sure it can use the
// declarations from this file.
#include "gmock/internal/custom/callback-actions.h"
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
include/gmock/internal/custom/callback-actions.h
0 → 100644
View file @
67c377d3
// This file was GENERATED by command:
// pump.py callback-actions.h.pump
// DO NOT EDIT BY HAND!!!
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_ACTIONS_H_
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_ACTIONS_H_
include/gmock/internal/custom/callback-actions.h.pump
0 → 100644
View file @
67c377d3
$$
-*-
mode
:
c
++
;
-*-
$$
This
is
a
Pump
source
file
(
http
:
//go/pump). Please use Pump to convert
$$
it
to
callback
-
actions
.
h
.
$$
$
var
max_callback_arity
=
5
$$
}}
This
meta
comment
fixes
auto
-
indentation
in
editors
.
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_ACTIONS_H_
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_ACTIONS_H_
scripts/gmock_doctor.py
View file @
67c377d3
...
...
@@ -308,7 +308,7 @@ def _OverloadedFunctionActionDiagnoser(msg):
clang_regex
=
(
_CLANG_FILE_LINE_RE
+
r'error: no matching '
r'function for call to \'Invoke\'\r?\n'
r'(.*\n)*?'
r'.*\b
gmock-\w+
-actions\.h:\d+:\d+:\s+'
r'.*\b
callback
-actions\.h:\d+:\d+:\s+'
r'note: candidate template ignored:\s+'
r'couldn\'t infer template argument \'FunctionImpl\''
)
diagnosis
=
"""
...
...
@@ -334,7 +334,7 @@ def _OverloadedMethodActionDiagnoser(msg):
clang_regex
=
(
_CLANG_FILE_LINE_RE
+
r'error: no matching function '
r'for call to \'Invoke\'\r?\n'
r'(.*\n)*?'
r'.*\b
gmock-\w+
-actions\.h:\d+:\d+: '
r'.*\b
callback
-actions\.h:\d+:\d+: '
r'note: candidate function template not viable: '
r'requires .*, but 2 (arguments )?were provided'
)
diagnosis
=
"""
...
...
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