Add support for arbitrary method specifiers#127
Add support for arbitrary method specifiers#127Flamefire wants to merge 9 commits intomat007:mainfrom
Conversation
004c6a6 to
0c7d64a
Compare
|
@Flamefire this looks pretty good! |
|
Ok, and it passes for GCC/Clang on CI now. This also needs a documentation update. Is http://turtle.sourceforge.net autogenerated or anyhow updated from the repo? |
I think it’s uploaded manually by me after each release. |
The AppVeyor App was never installer on this repo, I’ve fixed that. |
f3dc305 to
7a7e3cd
Compare
Some compilers support detection of an empty variadic macro element in which case `BOOST_PP_VARIADIC_SIZE` returns "0" so `BOOST_PP_OVERLOAD` calls the `macro_0` overload. An empty variadic element should be considered as a single empty value. So add that overload with this in mind.
7a7e3cd to
59d5312
Compare
53ee4c0 to
2156789
Compare
As requested in #48 this adds support for passing method specifiers.
This is a breaking change for the
MOCK_METHOD_EXTmacro which was in thedetailnamespace but seemingly used by users without variadic macro support. Those codes will stop to compile.Fix is a literal replacement to
MOCK_METHODso I didn't keep the compatibility in favor of a better interface.The test case shows the intended usage nicely, so I copy it here:
This shows the current usage and how it can be extended to add any number of specifier combinations.
It is likely that when using specifiers a custom identifier/name is required. I experimented with a
MOCK_METHOD_OVERLOADas described in the issue but quickly found that it is just another optional parameter ofMOCK_METHODso no new macro is required.MOCK_METHOD_EXTis now used to easily add specifiers. In the issue I thought about naming itMOCK_METHOD_MODor similar but settled withEXTwhich to me sounds better.It allows using specifiers as easily as regular usage with the
MOCK_METHODmacro, i.e. without using a signature and/or identifier by default but as options.To reduce boilerplate future work could maybe automatically add
overrideto each generated method and/or automatically derivenoexceptfor "easy" cases.Any opinions on the current design so far? @mat007 @sebkraemer
Note on the implementation: Empty tuple elements are required to support the case of no specifiers, i.e. non-const etc. This allows e.g.
MOCK_METHOD_EXT(m, 0, (, const, &, &&,), void())to generate all 4 variants in one go. However MSVC has the warning C4003 when passing an empty argument to a function expecting a parameter and BOOST_PP does that during tuple unpacking to remove one item at a time. Hence the need for a custom FOR_EACH loop implementation.