trompeloeil icon indicating copy to clipboard operation
trompeloeil copied to clipboard

Allow specifying STDMETHODCALLTYPE to Mock methods

Open cesenaLA opened this issue 1 year ago • 2 comments

Adds new IMPLEMENT_STDMETHOD_MOCKn and MAKE_STDMETHOD_MOCKn to allow to mock COM interfaces declared using STDMETHOD(name) i.e. virtual HRESULT __stdcall name (...). As .idl/.tlb do not support cvref-qualified methods, so there's no need for all the permutations of STDMETHODCALLTYPE vs const/volatile/rvalue/etc.

The new macros are implemented by extending TROMPELOEIL_MAKE_MOCK_ to take a calling convention and placing it in the correct location allowed by the microsoft compiler. This also means that the new macros only work on Windows.

It also add tests and documentation for the new macros.

Closes #329

cesenaLA avatar May 20 '24 14:05 cesenaLA

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.09%. Comparing base (8f36c45) to head (fd94c04). Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
- Coverage   99.10%   99.09%   -0.01%     
==========================================
  Files          12       12              
  Lines        1001      996       -5     
  Branches       21        0      -21     
==========================================
- Hits          992      987       -5     
  Misses          9        9              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 21 '24 11:05 codecov[bot]

I'm a bit confused by this. It solves a much more specific problem than the issue you originally opened. Is there a reason for limiting the support to only ´STDMETHOD`?

The change is good, BTW. Very good! Especially the docs and the extended test suite.

rollbear avatar Jun 30 '24 07:06 rollbear

Yes, the scope of the PR was reduced to only handle STDMETHOD, use when implementing COM interfaces on windows (which is our use case) based on the comment from @puetzk https://github.com/rollbear/trompeloeil/issues/329#issuecomment-2036157088

cesenaLA avatar Jul 09 '24 15:07 cesenaLA