-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sketch] Support for __stdcall members #194
Open
OskiKervinen-MF
wants to merge
22
commits into
eranpeer:master
Choose a base branch
from
OskiKervinen-MF:topic/support-stdcall
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Sketch] Support for __stdcall members #194
OskiKervinen-MF
wants to merge
22
commits into
eranpeer:master
from
OskiKervinen-MF:topic/support-stdcall
Conversation
This file contains 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
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.
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
___thiscall
for member functions. Since FakeIt says nothing about calling conventions, this is what it works with.Unfortunately COM interfaces use the
__stdcall
convention, 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.