contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

[Question] Plans to use the new cppwinrt project? #28

Open pingzing opened 7 years ago

pingzing commented 7 years ago

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.

Boddlnagg commented 7 years ago

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!

pingzing commented 7 years ago

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!

Boddlnagg commented 7 years ago

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!

Boddlnagg commented 7 years ago

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

Boddlnagg commented 6 years ago

Another interesting video from CppCon 2017: https://www.youtube.com/watch?v=7TdpWB_vRZM

ZHOUYue67 commented 5 years ago

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