From 2bb9086214fd8aefa64a88cc42e3dc1edbe8d958 Mon Sep 17 00:00:00 2001 From: ml-physec <206103694+ml-physec@users.noreply.github.com> Date: Fri, 4 Jul 2025 16:32:37 +0200 Subject: [PATCH] Unset argument detail before calling callback --- lib/cmock_generator_plugin_callback.rb | 3 ++- test/unit/cmock_generator_plugin_callback_test.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/cmock_generator_plugin_callback.rb b/lib/cmock_generator_plugin_callback.rb index eaee329e..eddda92b 100644 --- a/lib/cmock_generator_plugin_callback.rb +++ b/lib/cmock_generator_plugin_callback.rb @@ -43,7 +43,8 @@ def generate_call(function) end def mock_implementation(function) - " if (Mock.#{function[:name]}_CallbackFunctionPointer != NULL)\n {\n" + + " if (Mock.#{function[:name]}_CallbackFunctionPointer != NULL)\n {\n" \ + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n" + if function[:return][:void?] " #{generate_call(function)};\n }\n" else diff --git a/test/unit/cmock_generator_plugin_callback_test.rb b/test/unit/cmock_generator_plugin_callback_test.rb index 109555b1..44cc868c 100644 --- a/test/unit/cmock_generator_plugin_callback_test.rb +++ b/test/unit/cmock_generator_plugin_callback_test.rb @@ -96,6 +96,7 @@ function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:void]} expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n", " {\n", + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n", " Mock.Apple_CallbackFunctionPointer(Mock.Apple_CallbackCalls++);\n", " }\n" ].join @@ -107,6 +108,7 @@ function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:void]} expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n", " {\n", + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n", " Mock.Apple_CallbackFunctionPointer();\n", " }\n" ].join @@ -119,6 +121,7 @@ function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:int]} expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n", " {\n", + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n", " cmock_call_instance->ReturnVal = Mock.Apple_CallbackFunctionPointer(Mock.Apple_CallbackCalls++);\n", " }\n" ].join @@ -134,6 +137,7 @@ :return=> test_return[:void]} expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n", " {\n", + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n", " Mock.Apple_CallbackFunctionPointer(steak, flag, Mock.Apple_CallbackCalls++);\n", " }\n" ].join @@ -149,6 +153,7 @@ :return=> test_return[:void]} expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n", " {\n", + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n", " Mock.Apple_CallbackFunctionPointer(steak, flag);\n", " }\n" ].join @@ -165,6 +170,7 @@ :return => test_return[:int]} expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n", " {\n", + " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n", " cmock_call_instance->ReturnVal = Mock.Apple_CallbackFunctionPointer(steak, flag, Mock.Apple_CallbackCalls++);\n", " }\n" ].join