|
72 | 72 | } \ |
73 | 73 | MOCK_METHOD_HELPER(void(), identifier) |
74 | 74 |
|
75 | | -/// MOCK_METHOD( [calling convention] name, arity[, signature[, identifier]] ) |
76 | | -/// generates both const and non-const methods |
| 75 | +/// MOCK_METHOD( [calling convention] name, arity[, signature[, identifier, [, specifiers]]] ) |
| 76 | +/// generates both const and non-const methods by default, but can be changed by passing a specifier tuple. |
77 | 77 | /// The 'signature' can be omitted if it can be uniquely identified from the base class |
78 | 78 | /// if 'identifier' is omitted it will default to 'name' |
79 | | -#define MOCK_METHOD(M, ...) \ |
80 | | - MOCK_METHOD_EXT(M, \ |
81 | | - BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \ |
82 | | - BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
83 | | - BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
84 | | - (const, )) |
| 79 | +/// 'specifiers' is a potentially empty, tuple of method specifiers, e.g. (&, &&) or (const override) |
| 80 | +#define MOCK_METHOD(M, ...) \ |
| 81 | + MOCK_METHOD_EXT_I(M, \ |
| 82 | + BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \ |
| 83 | + BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
| 84 | + BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
| 85 | + BOOST_PP_VARIADIC_ELEM(3, __VA_ARGS__, (const, ), (const, ), (const, ), )) |
85 | 86 | /// MOCK_CONST_METHOD( [calling convention] name, arity[, signature[, identifier]] ) |
86 | 87 | /// generates only the const version of the method |
87 | 88 | /// The 'signature' can be omitted if it can be uniquely identified from the base class |
88 | 89 | /// if 'identifier' is omitted it will default to 'name' |
89 | | -#define MOCK_CONST_METHOD(M, ...) \ |
90 | | - MOCK_METHOD_EXT(M, \ |
91 | | - BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \ |
92 | | - BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
93 | | - BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
94 | | - (const)) |
| 90 | +#define MOCK_CONST_METHOD(M, ...) \ |
| 91 | + MOCK_METHOD_EXT_I(M, \ |
| 92 | + BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \ |
| 93 | + BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
| 94 | + BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
| 95 | + (const)) |
95 | 96 | /// MOCK_NON_CONST_METHOD( [calling convention] name, arity[, signature[, identifier]] ) |
96 | 97 | /// generates only the non-const version of the method |
97 | 98 | /// The 'signature' can be omitted if it can be uniquely identified from the base class |
98 | 99 | /// if 'identifier' is omitted it will default to 'name' |
99 | | -#define MOCK_NON_CONST_METHOD(M, ...) \ |
100 | | - MOCK_METHOD_EXT(M, \ |
101 | | - BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \ |
102 | | - BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
103 | | - BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
104 | | - ()) |
| 100 | +#define MOCK_NON_CONST_METHOD(M, ...) \ |
| 101 | + MOCK_METHOD_EXT_I(M, \ |
| 102 | + BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \ |
| 103 | + BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
| 104 | + BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
| 105 | + ()) |
| 106 | + |
| 107 | +/// MOCK_METHOD_EXT( [calling convention] name, arity, qualifiers [, signature, [identifier]] ) |
| 108 | +#define MOCK_METHOD_EXT(M, arity, ...) \ |
| 109 | + MOCK_METHOD_EXT_I(M, \ |
| 110 | + arity, \ |
| 111 | + BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \ |
| 112 | + BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ), \ |
| 113 | + BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, )) |
105 | 114 |
|
106 | 115 | /// MOCK_FUNCTION( [calling convention] name, arity, signature[, identifier] ) |
107 | 116 | /// if 'identifier' is omitted it will default to 'name' |
|
0 commit comments