-
Notifications
You must be signed in to change notification settings - Fork 3
Implement the generator #1
Comments
How are we going to read, and process the GIR files? We should probable focus on using an XML library which is easy to use rather than blazing fast because GIR files aren't going to be processed that often (only at compile-time.) As I understand the situation there are no existing bindings to XML parsers for Rust, and we'd have to write our own. Luckily, there is https://github.com/crabtw/rust-bindgen which could help out a bit. I don't have any preference towards any XML libraries in particular so I'd appreciate some input. Alternatively, we could write the binding generator in a different language from Rust. This seems like a bad idea to me though because deciding on a proper language would be difficult. There has been some work towards dynamically loadable compiler plugins but it is still very preliminary. I think the best idea would be to have a program which generates the bindings. |
My idea is to take the Python generator from gobject-introspection and modify or extend it to generate Rust. |
@mzabaluev Right, that'd be a sensible approach. |
So I chatted on Gnome's IRC channel for introspection, and apparently the typelib libraries don't expose enough information to create static bindings. I think we'll have to parse the GIR files ourselves like Vala does. |
I wonder if an xslt sheet could be used to transform the gir into something usable. |
Yes, the files under fauxgen are meant to test out the eventually generated bindings. I have mixed experience with XSLT; it's good for basic transformations, but the trouble begins when your needs exceed the standard feature set. The output is not XML, which tends to make XSLT rules cumbersome. |
I've been spending a while trying to write bindings to libxml2 for Rust, and it's been very painful so far. I've already had experience generating Rust code from Python to create asset data (see http://gitorious.org/p-x/p-x/trees/master/pX-x_assets), and it has been quite fun, and elegant so far. I would support the use of Python to write the generator. |
What information is missing from Typelib libraries? Looking at it a bit, it seems that information about whether integers are "system-sized" or a fixed number of bits may be elided, as well as information about aliases. Are these critical omissions, or is there something else fundamental which isn't wrapped? Could we submit patches upstream that would make the typelib libraries sufficient for generating static bindings? In my mind, it's nonsense to have a library for working with GIR data but also require half of the users of the data to roll their own alternative. |
I have started a code generator in Python in the codegen branch. The modules |
We need a GIR-to-Rust code generator to automate most of the dirty work.
The text was updated successfully, but these errors were encountered: