Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add capture support for unconventional result types#1301

Merged
kennykerr merged 4 commits intomastermicrosoft/cppwinrt:masterfrom
capture_decaymicrosoft/cppwinrt:capture_decayCopy head branch name to clipboard
Apr 29, 2023
Merged

Add capture support for unconventional result types#1301
kennykerr merged 4 commits intomastermicrosoft/cppwinrt:masterfrom
capture_decaymicrosoft/cppwinrt:capture_decayCopy head branch name to clipboard

Conversation

@kennykerr
Copy link
Collaborator

Fixes: #1299

jonwis
jonwis previously approved these changes Apr 28, 2023
strings/base_com_ptr.h Show resolved Hide resolved
test/old_tests/UnitTests/capture.cpp Outdated Show resolved Hide resolved
@kennykerr kennykerr merged commit 65581a3 into master Apr 29, 2023
@kennykerr kennykerr deleted the capture_decay branch April 29, 2023 19:53
@oldnewthing
Copy link
Member

oldnewthing commented Apr 30, 2023

I was originally worried that this might be too permissive. There are some methods that take a REFIID followed by something that isn't the matched output pointer. However, they are exceedingly rare, and the only one that does it at the end of the parameter list that I could find (mind you, I gave up halfway through the D's) is IDebugProperty::EnumMembers, so I concluded that the very low risk wasn't worth the extra protection.

Unit test needs to include the forwarder pattern:

com_ptr<ICapture> f = capture<ICapture>([&](auto riid, auto ppv) { return CreateCapture2(10, riid, ppv); });

This pattern is used to accommodate methods that don't put the riid/ppv as the last two parameters.

HRESULT WeirdMethod(REFIID riid, char const* interloper, IUnknown** result, int straggler);

e.capture<IUnknown>(WeirdMethod, [](auto interloper, auto straggler, auto riid, auto result) { return WeirdMethod(riid, interloper, result, straggler); }, "interloper", 10);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: winrt::capture needs detector for "REFIID, IUnknown**" methods

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.