gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
230 stars 102 forks source link

Types' names that start with a number in input gir file produce invalid code #1443

Open AbuShawarib opened 1 year ago

AbuShawarib commented 1 year ago

If you use a gir file that start some of its elements' names by a number, like network-manager's gir file:

...

<bitfield name="80211ApFlags"
              glib:type-name="NM80211ApFlags"
              glib:get-type="nm_802_11_ap_flags_get_type"
              c:type="NM80211ApFlags">

...

<enumeration name="80211Mode"
                 glib:type-name="NM80211Mode"
                 glib:get-type="nm_802_11_mode_get_type"
                 c:type="NM80211Mode">

...

This crate will produce invalid rust code:

...

impl fmt::Display for 80211ApFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

...

pub enum 80211Mode {
    #[doc(alias = "NM_802_11_MODE_UNKNOWN")]
    Unknown,
    #[doc(alias = "NM_802_11_MODE_ADHOC")]
    Adhoc,

...