From 3c981ce02c136302c790c4056c37958ef88c780c Mon Sep 17 00:00:00 2001 From: "Pascal J. Bourguignon" Date: Thu, 25 May 2023 11:46:35 +0200 Subject: [PATCH] Added callback_kind to use * or ^ or other for callback types. --- lib/cmock_config.rb | 1 + lib/cmock_generator_plugin_callback.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cmock_config.rb b/lib/cmock_config.rb index 7c5891be..aec5a8e0 100644 --- a/lib/cmock_config.rb +++ b/lib/cmock_config.rb @@ -35,6 +35,7 @@ class CMockConfig :treat_inlines => :exclude, # the options being :include or :exclude :callback_include_count => true, :callback_after_arg_check => false, + :callback_kind => "*", :includes => nil, :includes_h_pre_orig_header => nil, :includes_h_post_orig_header => nil, diff --git a/lib/cmock_generator_plugin_callback.rb b/lib/cmock_generator_plugin_callback.rb index 6ba8e9bd..781155c5 100644 --- a/lib/cmock_generator_plugin_callback.rb +++ b/lib/cmock_generator_plugin_callback.rb @@ -27,10 +27,11 @@ def instance_structure(function) def mock_function_declarations(function) func_name = function[:name] return_type = function[:return][:type] + kind = @config.callback_kind.nil? ? '*' : @config.callback_kind action = @config.callback_after_arg_check ? 'AddCallback' : 'Stub' style = (@include_count ? 1 : 0) | (function[:args].empty? ? 0 : 2) styles = ['void', 'int cmock_num_calls', function[:args_string], "#{function[:args_string]}, int cmock_num_calls"] - "typedef #{return_type} (* CMOCK_#{func_name}_CALLBACK)(#{styles[style]});\n" \ + "typedef #{return_type} (#{kind} CMOCK_#{func_name}_CALLBACK)(#{styles[style]});\n" \ "void #{func_name}_AddCallback(CMOCK_#{func_name}_CALLBACK Callback);\n" \ "void #{func_name}_Stub(CMOCK_#{func_name}_CALLBACK Callback);\n" \ "#define #{func_name}_StubWithCallback #{func_name}_#{action}\n"