winrt-rust
winrt-rust copied to clipboard
[Question] Plans to use the new cppwinrt project?
Looks like Microsoft just released a new repo that contains Vanilla C++ projections for WinRT: https://github.com/Microsoft/cppwinrt (and the associated blog post)
Would using this be easier than generating the necessary metadata from the DLLs themselves? Mostly asking as a curious party.
If by "using this" you mean "wrapping these C++ headers" from Rust (or generating the Rust wrappers from C++ headers instead of from the winmd files), that's probably not easier, because interfacing with C++ from Rust is not (yet) as easy as interfacing with C. Furthermore, they use co_await
for asynchronous calls, which I think is only available in Microsoft's C++ compiler at the moment.
However, this also looks like it's also autogenerated (who would write code like this by hand?) and we might be able to get some inspiration how they solved certain things (especially since they say it's more efficient than using C# or C++/CX). Maybe they will even open-source the tools to generate these headers at some point. By the way, C(++) headers for WinRT (without C++/CX) already existed previously (available via the Windows SDK), and winrt-rust
has already drawn some inspiration from there.
Anyway, thanks for pointing this new project out to us!
Ah, I wasn't aware that C++-from-Rust was notably trickier than C-from-Rust (though I guess I should have been). Anyway, thanks for satisfying my curiosity, and happy to at least give you a source of inspiration!
I have now looked at this again, and especially the information on https://moderncpp.com/ and https://kennykerr.ca/ (the author's blog) is very helpful and inspiring indeed!
There are also some talks from CppCon 2016 about this: https://www.youtube.com/watch?v=lm4IwfiJ3EU and https://www.youtube.com/watch?v=v0SjumbIips
Another interesting video from CppCon 2017: https://www.youtube.com/watch?v=7TdpWB_vRZM
Now C++/WinRT compiler is open source with a project called xlang. https://kennykerr.ca/2019/01/25/getting-started-with-xlang-and-cppwinrt/ https://github.com/Microsoft/xlang