Skip to content

Commit

Permalink
Added callback_kind to use * or ^ or other for callback types.
Browse files Browse the repository at this point in the history
  • Loading branch information
informatimago committed May 25, 2023
1 parent 68012c8 commit 3c981ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/cmock_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion lib/cmock_generator_plugin_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3c981ce

Please sign in to comment.