- 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.
- treat_externs only has effect on "extern", not "inline" anymore
- when treat_inline = :include, we remove the "inline" so that the inline functions become 'normal' functions
- they are handled as as usual and will be mocked
- Add tests to check inline functions are not deleted when treat_inline=:include (and thus mocked)
IgnoreMode was used only for the ExpectAnyArgs plugin, and the
semantics of it were backwards:
- IgnoreMode = CMOCK_ARG_NONE means to ignore all arguments
- IgnoreMode = CMOCK_ARG_ALL means to verify all arguments
ExpectAnyArgsBool should make the purpose and semantics of this
field clearer.
Additionally, ExpectAnyArgs doesn't use FinalReturn for anything.
The generated _Expect() functions called UNITY_CLR_DETAILS, which was
unnecessary because they did not call UNITY_SET_DETAIL.
The generated _Verify() functions called UNITY_SET_DETAIL but never
called UNITY_CLR_DETAILS to clean up after themselves.
StubWithCallback can currently be configured to run the callback
function either before or after argument+ordering checks, based on
:callback_after_arg_check. Currently, however, you can't use both
behaviors in the same test suite; you have to pick one.
This change makes both behaviors available under two new names:
- IgnoreWithCallback, as if :callback_after_arg_check = false
- CheckWithCallback, as if :callback_after_arg_check = true
StubWithCallback simply becomes an alias (#define) for either
IgnoreWithCallback or CheckWithCallback, depending on config.
create_mock_destroy_function() in cmock_generator.rb already clears
the entire mock to 0 (using memset) before call the plugin's
mock_destroy() function. So mock_destroy() in the callback plugin
is doing work that was already done.