dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

xmlgen: Incorrect codegen with more complex type structures #267

Open zeenix opened 2 years ago

zeenix commented 2 years ago

In GitLab by @PolyMeilex on Mar 31, 2022, 12:20

Hi, I have a method like this one:

    <method name="GetAbcd">
      <arg type="u" name="a" direction="out" />
      <arg type="a((ssss)a(siiddada{sv})a{sv})" name="b" direction="out" />
      <arg type="a(iiduba(ssss)a{sv})" name="c" direction="out" />
      <arg type="a{sv}" name="d" direction="out" />
    </method>

After piping it into xmlgen I get this type as return value:

     (
        u32,
        Vec<(String, String, String, String)>,
        Vec<(
            i32,
            i32,
            f64,
            u32,
            bool,
            Vec<(String, String, String, String)>,
        )>,
        std::collections::HashMap<String, zbus::zvariant::OwnedValue>,
    )

There is several fields missing in this definition, here is the same type manually written by me to match what xml defines:

(
    u32,
    Vec<(
        (String, String, String, String),
        Vec<(
            String,
            i32,
            i32,
            f64,
            f64,
            Vec<f64>,
            HashMap<String, zbus::zvariant::OwnedValue>,
        )>,
        HashMap<String, zbus::zvariant::OwnedValue>,
    )>,
    Vec<(
        i32,
        i32,
        f64,
        u32,
        bool,
        Vec<(String, String, String, String)>,
        HashMap<String, zbus::zvariant::OwnedValue>,
    )>,
    HashMap<String, zbus::zvariant::OwnedValue>,
)
zeenix commented 2 years ago

Thanks for reporting this. Wonder what happens. :thinking:

zeenix commented 2 years ago

In GitLab by @TTWNO on Jul 23, 2022, 20:52

I've had a similar problems with the Collection.xml file from AT-SPI.

XML Source:

<?xml version="1.0" encoding="UTF-8"?>
<node name="/node">
<interface name="org.a11y.atspi.Collection">
  <method name="GetMatches">
    <arg direction="in" name="rule" type="(aiia{ss}iaiiasib)"/>
    <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiMatchRule"/>
    <arg direction="in" name="sortby" type="u"/>
    <arg direction="in" name="count" type="i"/>
    <arg direction="in" name="traverse" type="b"/>
    <arg direction="out" type="a(so)"/>
    <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiReferenceSet"/>
  </method>
</interface>
</node>

Generated code:


#[dbus_proxy(interface = "org.a11y.atspi.Collection")]
trait Collection {
    /// GetMatches method
    fn get_matches(
        &self,
        rule: &(&[i32], i32, std::collections::HashMap<&str, &str>),
        sortby: u32,
        count: i32,
        traverse: bool,
    ) -> zbus::Result<Vec<(String, zbus::zvariant::OwnedObjectPath)>>;
}

I was able to set my methods up manually, but yes, @PolyMeilex , it's not just you.