It didn't add direct comparisons only for pointer arguments, but
also other types of arguments like structs, which can't be compared
with '==' and cause a compiler error instead.
To reproduce, just enable the :array plugin in
system/test_interactions/expect_and_return_custom_types.yml:
In function ‘foo’:
error: invalid operands to binary != (have ‘EXAMPLE_STRUCT_T’ {aka
‘struct _EXAMPLE_STRUCT_T’} and ‘EXAMPLE_STRUCT_T’ {aka ‘struct
_EXAMPLE_STRUCT_T’})
59 | if (cmock_call_instance->Expected_a != a) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~
This reverts commit 4df532afcc.
- If inlines are included, we don't do anything since they are
disguised already as normal functions
- If inlines are NOT included, we remove anything that has inline in
it
- We set the defaults but the user is free to add his own.
This will overwrite our defaults but they will be added to the
documentation as reference for the user
- Just looking for static|inline in the gsub is a bit too aggressive.
Instead, look for the "static inline" and parse it:
- Everything before the match should just be copied, we don't want
to touch anything but the inline functions.
- Remove the implementation of the inline function (this is enclosed
in square brackets) and replace it with ";" to complete the
transformation to normal/non-inline function.
- Copy everything after the inline function implementation
Repeat the above step until we can't find "static inline" anymore
- To remove the inline implementation,
we count the number of square-bracket 'levels' in the inline function
and remove every pair. This ensures that constructs like:
inline void func(void) {
if (...) {
//NOP
}
else
{
//NOP
}
}
will not end up leaving the 'else' keyword unremoved:
inline void func(void);
else
If we count the number of levels, we don't end up in this scenario
since we remove 3 'pairs', the if-one, the else-one and finally the
main body.
- This way, @normalized_source will always be defined, which it should
because we are referencing it a few lines down, thanks to
@mvandervoord for the suggestion
- This prevents changing the original mock file that is generated,
it thinks it includes the 'original' header file that is being
mocked,
but if we place our newly generated header file in the same
directory as the mock_<header_file>.h, it will include our newly
generated header file.
- normalize_source() will convert the header-to-mock.
It will look for the inline function definitions and transform them
into function declarations for non-inline functions.