Skip to content
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

Port code generator from C# to Rust #50

Open
Boddlnagg opened this issue Dec 27, 2017 · 10 comments
Open

Port code generator from C# to Rust #50

Boddlnagg opened this issue Dec 27, 2017 · 10 comments
Assignees

Comments

@Boddlnagg
Copy link
Collaborator

Boddlnagg commented Dec 27, 2017

This would allow us to run code generation as part of build.rs (also see #21), and get rid of the C#/.NET dependency.

Blocked on having a suitable replacement for Mono.Cecil written in Rust, for reading the IL metadata.

Update: The easiest approach is probably to port https://github.com/Microsoft/xlang/tree/master/src/library/impl/meta_reader (modern C++, MIT licensed) to Rust (as an external crate).

@CarePackage17
Copy link

Have you seen this project?
https://github.com/paavohuhtala/clri

Maybe some parts could be reused (and even if not, there are some links to useful info).

@Boddlnagg
Copy link
Collaborator Author

Maybe we can make use of the metadata reader implemented as part of https://github.com/Microsoft/xlang (https://github.com/Microsoft/xlang/tree/master/src/library/impl/meta_reader), which is written in modern C++ and could probably be ported to Rust easier than something like Mono.Cecil.

@CarePackage17
Copy link

Thanks for the link, that project seems really interesting. It's essentially an open source implementation of the Windows Runtime.

Also, it seems to contain the cppwinrt compiler/code generator itself as described in the wiki.
So, if we were able to port those bits to Rust we'd have auto-generated language projections for any WinRT/xlang component in the future.

@Boddlnagg
Copy link
Collaborator Author

Yes, the project was announced only yesterday on the author's blog (same author as cppwinrt): https://kennykerr.ca/2018/10/10/xlang/

@CarePackage17
Copy link

Wait, really? That's pretty fucking awesome!

I'm excited.

@Boddlnagg
Copy link
Collaborator Author

We probably can also hide much of the generated code behind procedural macros now that they are stable (though that arguably means that someone who wants to understand what actually happens in the generated code needs to drill through yet another layer of magic – but I guess that procedural macros can't get worse than the declarative macros we have now).

@Boddlnagg
Copy link
Collaborator Author

I'm working on a Rust port of xlang's meta_reader (https://github.com/Microsoft/xlang/tree/master/src/library/impl/meta_reader), but have nothing to show yet.

@Boddlnagg
Copy link
Collaborator Author

A first (incomplete) version of a CLI metadata reader in Rust is now available: https://github.com/Boddlnagg/climeta

@Mart-Bogdan
Copy link

I'd suggest to nog go down the road of proc macros. Having generated code commited into vcs spreads up compilation, and it allows IDE code completion. IDEs aren't good with proc macros.

@Boddlnagg
Copy link
Collaborator Author

@Mart-Bogdan That is tracked in issue #68. I agree that there are tradeoffs and it's definitely not yet clear whether a proc macro would be a good idea, but I think we should experiment with it.

This issue, however, is about implementing the code generator in Rust, which is a necessary precondition for #68, but has value on its own.

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

No branches or pull requests

3 participants