[Sketch] Support for __stdcall members#194
Open
OskiKervinen-MF wants to merge 22 commits intoeranpeer:masterfrom
Open
[Sketch] Support for __stdcall members#194OskiKervinen-MF wants to merge 22 commits intoeranpeer:masterfrom
OskiKervinen-MF wants to merge 22 commits intoeranpeer:masterfrom
Conversation
To have a baseline.
Fails to compile in 32-bit mode.
Added a front stub method that uses remove_func_cv to remove const and volatile, so the actual logic layer only needs one copy of each case.
I used a macro to avoid copy pasting the thousand methods multiple times.
I didn't realize such a thing existed.
The changes had lost the T vs C relationship. This should make it work again. The code before this branch was giving a T member pointer to UniqueMethodMockContext constructor, which accepted a C method pointer, so I presume it is safe to cast from one to the other.
They worked, because __thiscall and __cdecl are the default when they are used at all, but it's better to be explicit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When compiling 32-bit executables, the Visual Studio compiler (MSVC) uses the calling convention
___thiscallfor member functions. Since FakeIt says nothing about calling conventions, this is what it works with.Unfortunately COM interfaces use the
__stdcallconvention, so FakeIt cannot be used to mock COM interfaces, because all the mock templates use the default convention. (There is no such problem in x64, because both COM and normal objects use__cdecl.)This MR creates support for varying calling conventions, primarily focusing on my need: supporting mocking of COM interfaces.
The thing is, 32-bit is not hugely relevant in this day and age, so I cannot justify spending the time to polish this large a change to a state where it would be actually merge-worthy. The most glaring omission here is that I probably didn't add quite enough ifdefs here to make this even compile on compilers other than MSVC. I'm creating this MR more as a way to publish this sketch to the people in need of this, in #71 and #78, than with the actual belief that this would be good enough to be merged.
That being said, if the maintainer does see some fairly short path to making this a thing they would actually want in the codebase, I may get around to addressing feedback some day. I'm just explicitly unmaking the promise to do so; and acknowledging that in this day and age supporting 32-bit COM objects may not be worth the extra complexity.