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

Autogenerate "low-level projection" from metadata #1

Closed
contextfree opened this issue May 9, 2016 · 5 comments
Closed

Autogenerate "low-level projection" from metadata #1

contextfree opened this issue May 9, 2016 · 5 comments
Assignees
Milestone

Comments

@contextfree
Copy link
Owner

Tentatively decided to write this in F# (there doesn't seem to be much benefit to bootstrapping a tool like this in Rust)

@contextfree contextfree self-assigned this May 9, 2016
@contextfree contextfree added this to the low-level milestone May 9, 2016
@Boddlnagg
Copy link
Collaborator

For reading the metadata, use either Mono.Cecil or System.Reflection.Metadata. The latter is newer, and slightly more low-level and lightweight, but probably sufficient if we don't need an in-memory-representation of everything and instead just go through the types and write them out as Rust code one-by-one.
I agree that writing a metadata reader in Rust is not a priority, though it would be nice to have.
I don't have much experience with F#, but this tool will probably be quite small anyway, so I don't really care.
Furthermore, maybe a templating system might be helpful?

@Boddlnagg
Copy link
Collaborator

I started implementing the generator in C# using Mono.Cecil in my branch. The C# code is more like a proof-of-concept in terms of coding style, and I wouldn't object to a rewrite in F#. I'm just not really familiar with F#.

Running the codegen for the whole of C:\Windows\System32\WinMetadata results in a 40k+ line file which fails to compile due to some seemingly unrelated macro errors. Running on Windows.Foundation.winmd only works just fine, so further investigation is needed.

@Boddlnagg
Copy link
Collaborator

The problem was the keyword box appearing as a parameter name in one of the definitions. This is replaced by box_ now, and the whole of WinMetadata can now be generated, currently resulting in 43707 generated lines of Rust code (ca 5 MB) and a 194 MB (debug) libwinrt.rlib (after a few minutes of compilation).

@Boddlnagg
Copy link
Collaborator

Can this be closed now that we basically have a "mid-level" API (as high-level as possible, but still currently unsafe)?

@contextfree
Copy link
Owner Author

great! sorry I haven't really been contributing. i have been reading the code though & am amazed by what you've done, I didn't bother uploading any of the stuff I had because your implementations were so much better. I still hope to contribute in the future.

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

2 participants