-
Notifications
You must be signed in to change notification settings - Fork 20
Add support for arbitrary method specifiers #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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_EXT
macro which was in thedetail
namespace but seemingly used by users without variadic macro support. Those codes will stop to compile.Fix is a literal replacement to
MOCK_METHOD
so 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_OVERLOAD
as described in the issue but quickly found that it is just another optional parameter ofMOCK_METHOD
so no new macro is required.MOCK_METHOD_EXT
is now used to easily add specifiers. In the issue I thought about naming itMOCK_METHOD_MOD
or similar but settled withEXT
which to me sounds better.It allows using specifiers as easily as regular usage with the
MOCK_METHOD
macro, i.e. without using a signature and/or identifier by default but as options.To reduce boilerplate future work could maybe automatically add
override
to each generated method and/or automatically derivenoexcept
for "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.