Граф коммитов

203 Коммитов

Автор SHA1 Сообщение Дата
David Machaj 2aed347fb7
GitHub Actions workflow cannot build arm32 after updating Windows SDK (#1454)
arm32 is not supported anymore by Windows. There has not been a native arm32 OS since before Win11. The wow32 backcompat on arm64 devices to run arm32 programs was removed with Win11 24H2. Most notably, the ability to build arm32 with newer SDKs and toolsets has seemingly been removed. This is now breaking the CI build.

The easiest fix is to simply remove arm32 support.
2024-11-18 16:52:31 -08:00
David Machaj febda5dfa1
Try to fix the disabled/failing nuget test build step (#1451)
These failures were pointed out yesterday when the CLA policy was stuck. They are not blocking but have seemingly been failing for a long time and the failure is suppressed.

The issue seems to be that some of these test projects reference an old NuGet package while also referencing the props/targets that are about to go into the new NuGet package. Double-including essentially the same files twice is what caused the build breaks in these projects.

Some projects also had build breaks that seem to be related to a very old Windows SDK minimum version. I increased the floor to 10.0.18362.0 (early 2019; almost 6 years ago) and that fixed the remaining breaks. The random packages.config that downloaded random builds of cppwinrt from 2019 or 2020 have been deleted too.

This set of changes aims to fix the build breaks and un-suppress this failure. It now builds locally on my device but I'll need an official PR build to ensure that the GitHub Actions flow is also passing.
2024-11-15 16:12:21 -08:00
David Machaj b82340f3fc
Bug: Projected winrt::consume_ methods will nullptr crash if the underlying QueryInterface call fails (#1442)
# Why is this change being made?
The generated projection code for interfaces that the metadata declares as required for a runtimeclass assume that QueryInterface never fails. Assuming the metadata is correct in the first place, this is a valid assumption for inproc calls.

However, for cross-process calls the QI can fail even if the metadata is correct and the class really does implement all of the required interfaces. It can fail with E_ACCESSDENIED and a variety of other RPC error codes.

When this happens there is a nullptr crash in the generated consume method. This can be very painful to debug because the HRESULT is lost by the time it crashes.

# Briefly summarize what changed
This set of changes fixes the crash by detecting the QueryInterface error and throwing an exception when that occurs during one of these required casts. The try_as method was changed to capture COM error context when the QI fails. The code gen surrounding WINRT_IMPL_STUB was changed to save the result into a temporary variable and then pass it to a new check_cast_result method. check_cast_result is marked noinline so that the binary size impact of throwing exceptions is limited to a single function instead of inlining into high-volume generated code.

If the cast succeeded then nothing happens. If the cast failed, returning null, then the stored COM exception is retrieved. Assuming it is available the HRESULT is pulled out of it and it is thrown. This then propagates like any other exception. Callers are free to try and catch it or let it go uncaught and crash. Now they have the choice.

I also added a new file of test code that exercises this code path. The test_component IDL declares a runtimeclass that implements IStringable. And then the implementation fails to implement IStringable. When ToString is called on this object it hits the failure path. The cppwinrt code gen will not allow this to happen so I had to directly use winrt::implements.

# How was this change tested?
Besides the new test cases I also wrote a little console app that crashes this way. I built and ran it using the latest stable cppwinrt as well as my private new one. As expected the debugger blame is far more useful with these changes.
2024-10-30 09:54:35 -07:00
Josh Soref 881b5614b8
Spelling (#1412) 2024-04-06 07:17:18 -05:00
Dan Legg 6dccf9ef88
Pipeline changes to build, publish, and test (#1400)
Co-authored-by: Dan Legg <dalegg@microsoft.com>
2024-03-28 18:06:25 -07:00
Kenny Kerr 2bfcd7524a
Fail gracefully when error reporting is suppressed (#1386) 2024-01-16 13:00:38 -06:00
David Machaj 5ef408f8b0
User/dmachaj/slim source location (#1379)
* First draft of slim_source_location

* Fix build breaks from first impl

* Fix failing test case
2023-12-22 11:47:37 -08:00
Raymond Chen fc587f31f9
Allow delegates to be created with weak reference + lambda (#1372)
We have found that a very common pattern for event handlers is
to capture a weak reference into a lambda, and in the event handler,
try to upgrade the weak reference to a strong one, and if so, do some work:

```cpp
widget.Closed([weak = get_weak(), data](auto&& sender, auto&& args)
{
    if (auto strongThis = weak.get())
    {
        strongThis->do_all_the_things(data);
    }
});
```

This commit extends the existing delegate constructors to permit a
`winrt::weak_ref` + lambda (or `std::weak_ptr` + lambda), which
simplifies the above to

```cpp
widget.Closed({ get_weak(), [this, data](auto&& sender, auto&& args)
{
    do_all_the_things(data);
} });
```

## Implementation notes

A lambda and pointer to member function are hard to distinguish
in a template parameter list. In theory, we could use SFINAE or
partial specialization, but a simpler solution is to distinguish
the two inside the body of the constructor, via
`std::is_member_function_pointer_v`.

The `com_ptr` and `shared_ptr` variants of the test were
unified, since I found myself editing two nearly identical tests.

Fixes #1371

Co-authored-by: Jon Wiswall <jonwis@microsoft.com>
2023-11-25 23:18:59 -08:00
Jon Wiswall 912aa47ff4
Update GitHub action LLVM version to 17.0.5 (#1373)
* Maybe update tools version

* LLVM & Clang v17.0.5 now support source_location properly
2023-11-25 21:48:38 -08:00
Raymond Chen bf4459b25a
Allow resume_agile to be stored in a variable (#1358)
`resume_agile` exposes the ability to save the `await_adapter`
in a variable. This was not possible without `resume_agile` because
the `await_adapter` had previously been available only via
`operator co_await`, which means that it is created only in
response to an immediate attempt to `co_await` it, so we knew
that it would be consumed before its argument (possibly a temporary)
was destructed.

`resume_agile` returns the `await_adapter`, and we expect people
to await it immediately, but it's possible that they decide to
save it in a variable and await it later. In that case, we have
to record the `Async` as a value instead of a reference. We forward
the `resume_agile` argument into the `Async` so that it moves
if given an rvalue reference, or copies if given an lvalue reference.
This ensure that the common case where somebody does
`co_await resume_agile(DoSomething())`, we do not incur any additional
AddRefs or Releases.

Now that it's possible to `co_await` the `await_adapter` twice,
we have to worry about `await_suspend` being called twice. It had
previously assumed that `suspending` was true (since that's how it
was constructed), but that is no longer valid in the `resume_agile`
case if somebody tries to await the `resume_agile` twice. So we have
to force it to `true`. (Now, the second await will fail with
"illegal delegate assignment", but our failure to set `suspending`
to `true` led to double-resumption, which is super-bad.)
2023-09-14 16:19:23 -07:00
Raymond Chen fac72c82b0
Add `resume_agile` to allow coroutine to resume in any apartment (#1356) 2023-09-12 13:25:16 -05:00
Jon Wiswall 691f6f8c9d
Support for std::span for winrt::array_view and winrt::com_array (#1343)
* Implicit conversion between std::span and winrt::array_view

* Add testing and additional ctad for spans

* PR FB - yes, yes it does!

* PR FB

---------

Co-authored-by: Jaiganésh Kumaran <jaiganesh.kumaran@outlook.com>
Co-authored-by: Jon Wiswall <jonwis@ntdev.microsoft.com>
Co-authored-by: Kenny Kerr <kenny@kennykerr.ca>
2023-08-28 10:24:04 -07:00
Kenny Kerr de6ca88bd6
Remove old Windows 7 support code (#1348) 2023-08-28 08:35:09 -05:00
Jon Wiswall 9b453cfc51
Enable faster dev cycle in Visual Studio (#1340)
* Enable faster dev cycle in Visual Studio

* Oops, remove one more run

* Fix linux build temporarily - see also #1341

---------

Co-authored-by: Jon Wiswall <jonwis@ntdev.microsoft.com>
2023-08-17 15:51:08 -07:00
Charles Milette 0958cf3a4d
Hide protected and overridable members from public projections (#1319) 2023-07-11 21:38:42 -05:00
Charles Milette 953d65cc85
Register event handlers with `shared_ptr` and `weak_ptr` (#1330) 2023-07-10 17:16:10 -05:00
Charles Milette 297454ee28
Allow classic COM interfaces with get_self (#1314)
* Allow classic COM interfaces with get_self

Fixes #1312

* Fix mingw builds

---------

Co-authored-by: Kenny Kerr <kenny@kennykerr.ca>
2023-06-27 09:40:35 -07:00
David Machaj d3bb275464
Fix source location test failure resulting from newer compiler (#1326) 2023-06-22 12:39:33 -05:00
Kenny Kerr 65581a379f
Add `capture` support for unconventional result types (#1301) 2023-04-29 14:53:13 -05:00
Raymond Chen 6162c9d05d
Fix flakey clock and line-number tests (#1294) 2023-03-31 22:17:20 -05:00
Ryan Shepherd 737adea24a
Compliance and test cleanup (#1291)
* Compliance and test cleanup

* Leave CFG off for debug builds
2023-03-27 18:34:35 -07:00
Johan Laanstra f3c730994e
Expose configuring /nomidl. (#1290)
* Expose configuring /nomidl.

* Add test project and fix comments.
2023-03-24 11:32:14 -07:00
Dustin L. Howett 72b30cc0f1
Add a clang-specific impl->projection conversion operator (#1274) 2023-02-23 15:38:07 -06:00
Jaiganésh Kumaran abcdc75e00
Add `to_hstring` overload for `IStringable` (#1271) 2023-02-20 09:38:23 -06:00
Raymond Chen 4e674c7ebf
Fix unreliable clock epoch tests (#1277) 2023-02-17 16:19:54 -06:00
Raymond Chen 419c33a903
Reduce stack consumption if unable to switch to `apartment_context` (#1276) 2023-02-16 12:53:02 -06:00
Raymond Chen 4363e5c37a
Stack usage reduction in apartment switching, and lifetime fixes (#1272) 2023-02-08 12:04:42 -06:00
alvinhochun e38b0801a8
Enable cpp20/custom_error for incoming LLVM 16 (#1265)
Tested with a recent llvm-mingw build very close to LLVM 16 rc1.
2023-01-30 07:42:59 -06:00
David Machaj 6ff78e4974
Add a mechanism to suppress `std::source_location` (#1260) 2023-01-09 16:52:54 -06:00
alvinhochun 983f659840
Cleaning up some warnings for Clang and GCC (#1255) 2023-01-09 08:57:33 -06:00
alvinhochun 44572ed0f1
Try to fix random failure of the clock test (#1251) 2022-12-19 19:59:35 -06:00
Charles Milette 8ac2b798c7
Fix cancellation propagation by moving responsability to awaiter (#1246) 2022-12-19 08:45:09 -06:00
Kenny Kerr 69f9d8ca18
Improve error reporting for clock test (#1248) 2022-12-15 19:31:38 -06:00
alvinhochun 3343c7cb78
Make compatible with GCC (#1245) 2022-12-13 11:32:15 -06:00
alvinhochun 4a5acf6445
Add Linux native build (#1239) 2022-12-06 11:13:30 -06:00
alvinhochun 80236cdf55
Fix llvm-mingw tests with LLVM trunk (#1235) 2022-11-23 20:10:21 -06:00
alvinhochun 37bd17f2a8
Fix null pointer dereference in weak_ref::get() (#1232) 2022-11-21 11:57:55 -06:00
alvinhochun e96613d88b
Fix multi_threaded_map/_vector tests on Clang (#1230) 2022-11-21 10:26:55 -06:00
Charles Milette 96bfd1631e
Fix formatting base types such as integers (#1231) 2022-11-21 10:26:06 -06:00
alvinhochun 921f62f1fa
Enable more tests on llvm-mingw and some fixes (#1229) 2022-11-18 09:32:09 -06:00
Charles Milette 104b0b9a27
Efficient way to format directly to hstring (#1207) 2022-11-12 09:32:51 -06:00
Charles Milette fb9ef7b919
Remove low-level coroutine suspension notifications (#1228) 2022-11-11 13:00:51 -06:00
alvinhochun 5ca626adae
Add CMake build and a limited subset of tests for llvm-mingw (#1216) 2022-11-09 10:26:19 -06:00
alvinhochun b79565c8fc
Harden `disconnected.cpp` test (#1226) 2022-11-08 11:04:20 -06:00
alvinhochun 526d72ad6f
Fix invoke call on Clang (possibly a compiler bug) (#1225) 2022-11-07 07:55:46 -06:00
Jaiganésh Kumaran 6ce4fa91bb
C++ Streams support for hstring and IStringable (#1221) 2022-11-01 09:53:33 -05:00
Jaiganésh Kumaran 3deb508335
`check_bool<T>` now returns `T` (#1205) 2022-10-24 11:48:43 -05:00
alvinhochun 1b4e0099cc
CI: Build ARM64 cppwinrt and tests (not run) (#1211) 2022-10-20 10:42:42 -05:00
alvinhochun 5390dc86d4
Add CI test with LLVM 15 clang-cl (#1203) 2022-10-18 13:58:43 -05:00
alvinhochun d3aa5db099
Improve CI jobs split (#1210) 2022-10-18 08:28:35 -05:00