Closed contextfree closed 8 years ago
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?
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.
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).
Can this be closed now that we basically have a "mid-level" API (as high-level as possible, but still currently unsafe)?
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.
Tentatively decided to write this in F# (there doesn't seem to be much benefit to bootstrapping a tool like this in Rust)